<?xml version="1.0" encoding="ISO-8859-1"?>


<!--
  author: Marcus Fritzsch
  date: 2006-05-06
  comment: second try on xsl
-->


<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">


<xsl:output method="xml"
  media-type="text/xhtml"
  omit-xml-declaration="no"
  version="1.0"
  encoding="ISO-8859-1"
  indent="yes"
  doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
  doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" />


<!--<xsl:strip-space elements="not(codebox)" />-->


<xsl:template match="/">
  <xsl:apply-templates />
</xsl:template>


<xsl:template match="document">
  <html lang='en' xml:lang='en'>

    <xsl:comment>
      This page was generated through XML and XSLT. _DO NOT EDIT_!
    </xsl:comment>

    <head>
      <link rel="stylesheet" href="style.css" type="text/css"/>
      <xsl:if test="@title">
        <title><xsl:value-of select="@title" /></title>
      </xsl:if>
    </head>

    <body>

    <div id="Info">
      <a href="/" title="http://fritschy.de">
        http://fritsch.de
      </a>
    </div>

    <div id="Header">
      <h1><xsl:value-of select="@title" /></h1>
    </div>

    <xsl:if test="@menu">
      <xsl:apply-templates select="document(@menu)" />
    </xsl:if>

    <div id="Content">
      <xsl:if test="article">
        <xsl:for-each select="article">
          <xsl:sort select="concat(substring(@date,1,4),substring(@date,6,2),substring(@date,9,2))" order="descending" format="number" />
          <div class="article">
    
            <div class="break" />
    
            <ul class="heading" id="entry-{@date}">
              <li class="date">
                <a class="entry-link" href="#entry-{@date}"
                   title="link to entry of {@date}">
                  <xsl:value-of select="@date" />
                </a>
              </li>
            </ul>
    
            <h2><xsl:value-of select="@title" /></h2>
  
            <xsl:apply-templates />
          </div>
        </xsl:for-each>
      </xsl:if>
  
      <xsl:if test="boxed-image | named-list">
        <div class="break" />
        <xsl:for-each select="named-list">
          <div class="section">
            <h2><xsl:value-of select="@title" /></h2>
            <table>
	      <xsl:for-each select="entry">
	        <tr id="{concat(translate(../@title,' /.+','----'),'-',translate(@name,' /.+','----'))}">
		  <td class="a"><xsl:value-of select="@name" /></td>
		  <td><xsl:apply-templates /></td>
		</tr>
	      </xsl:for-each>
            </table>
          </div>
        </xsl:for-each>

        <xsl:if test="boxed-image">
          <div class="image-container">
            <xsl:for-each select="boxed-image">
              <xsl:apply-templates select="." />
            </xsl:for-each>
            <div class="break" />
          </div>
        </xsl:if>
      </xsl:if>
    </div>

    <div class="break" />
    <!-- XXX this one overlaps with menu if not enough content available! -->
    <div id="Footer">
      (c) 2006 by <a href="about.html#fritschy-eMail"
        title="eMail">Marcus &apos;fritschy&apos; Fritzsch</a>
    </div>

    </body>
  </html>
</xsl:template>


<xsl:template match="p">
  <div class="paragraph">
    <xsl:apply-templates />
  </div>
</xsl:template>


<xsl:template match="boxed-image">
  <div class="boxed-image"
    style="float:{@float};width:{@width+10}px;">
    <a href="{@source}" title="image, {@source}">
      <img src="{@thumb}" alt=" img[{@source}] " />
    </a>
    <xsl:if test="caption">
      <div class="image-caption" style="width:{@width}px">
        <xsl:apply-templates select="caption" />
      </div>
    </xsl:if>
  </div>
</xsl:template>


<xsl:template match="caption">
  <xsl:apply-templates />
</xsl:template>


<xsl:template match="image">
  <div class="image" style="float:{@float};">
    <a href="{@source}" title="image, {@source}">
      <img src="{@thumb}" alt=" img[{@source}] " />
    </a>
  </div>
</xsl:template>


<xsl:template match="menu">
  <div id="SideMenu">
    <div id="Menu">
      <div class="command">$ ls -1p /</div>
      <ul>
        <xsl:for-each select="entry">
        <!--<xsl:sort select="name" />-->
          <li>
            <a href="{@target}" title="{@desc}">
              <xsl:value-of select="@name" />
            </a>
          </li>
        </xsl:for-each>
      </ul>
    </div>
  
    <div id="Logos">
      <div class="command">cat /dev/kmem</div>
      <ul>
        <xsl:for-each select="logo-entry">
          <li>
            <a href="{@target}" title="{@desc}">
            <img src="{@logo}" alt="{@desc}" />
            </a>
          </li>
        </xsl:for-each>
      </ul>
    </div>
  </div>
</xsl:template>


<xsl:template match="codebox">
  <div class="codebox">
    <xsl:if test="@caption">
      <div class="codecaption">
        <xsl:value-of select="@caption" />
      </div>
    </xsl:if>
    <xsl:apply-templates />
  </div>
</xsl:template>


<xsl:template match="link">
  <xsl:choose>

    <xsl:when test="@title">
      <a href="{@href}" title="{@title}">
        <xsl:call-template name="int-or-ext-link-img" /><xsl:apply-templates />
      </a>
    </xsl:when>

    <xsl:otherwise>
      <a href="{@href}" title="link to {@href}">
        <xsl:call-template name="int-or-ext-link-img" /><xsl:apply-templates />
      </a>
    </xsl:otherwise>

  </xsl:choose>
</xsl:template>


<xsl:template match="mailto">
  <xsl:choose>

    <xsl:when test="@subject">
      <a href="mailto:{@addr}?Subject={@subject}"
         title="write an eMail to {@addr} on '{@subject}'">
        <img class="link" src="gfx/mail-link.png" alt="[mail]" />
        <xsl:apply-templates />
      </a>
    </xsl:when>

    <xsl:otherwise>
      <a href="mailto:{@addr}" title="write an eMail to {@addr}">
        <img class="link" src="gfx/mail-link.png" alt="[mail]" />
        <xsl:apply-templates />
      </a>
    </xsl:otherwise>

  </xsl:choose>
</xsl:template>


<xsl:template name="int-or-ext-link-img">
  <xsl:choose>
 
    <xsl:when test="starts-with(@href,'http://') or starts-with(@href,'https://') or starts-with(@href,'ftp://')">
      <img class="link" src="gfx/ext-link.png" alt="[ext]" />
    </xsl:when>

    <xsl:otherwise>
      <img class="link" src="gfx/int-link.png" alt="[int]" />
    </xsl:otherwise>

  </xsl:choose>
</xsl:template>


<xsl:template match="list">
  <ul style="list-style-type:{@bullet};">
    <xsl:apply-templates /> <!-- just items -->
  </ul>
</xsl:template>


<xsl:template match="item">
  <li><xsl:apply-templates /></li>
</xsl:template>


<xsl:template match="table">
  <table cellpadding="0" cellspacing="0">
    <xsl:apply-templates /> <!-- just rows -->
  </table>
</xsl:template>


<xsl:template match="row">
  <tr><xsl:apply-templates /></tr>
</xsl:template>


<xsl:template match="cell">
  <td><xsl:apply-templates /></td>
</xsl:template>


<xsl:template match="mark">
  <span class="marked">
    <xsl:value-of select="." />
  </span>
</xsl:template>


<xsl:template match="note">
  <span class="note">
    <xsl:value-of select="." />
  </span>
</xsl:template>


<xsl:template match="break">
  <div class="break" />
</xsl:template>


</xsl:stylesheet>
