<?xml version="1.0"?>
<?xml-stylesheet href="/pool/xslt_ht.xslt" type="application/xml"?>
<xsl:stylesheet
  xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
  xmlns:d = "http://herbaer.de/xmlns/20051201/doc"
  xmlns:ht = "http://www.w3.org/1999/xhtml"
  xmlns = "http://www.w3.org/1999/xhtml"
  xmlns:sm = "http://www.sitemaps.org/schemas/sitemap/0.9"
  xmlns:im = "http://www.google.com/schemas/sitemap-image/1.1"
  xmlns:c = "http://www.google.com/codesearch/schemas/sitemap/1.0"
  xmlns:t = "http://herbaer.de/xmlns/20110907/terms"
  exclude-result-prefixes = "xsl d ht sm im c t"
  version = "1.0"
>

<d:info xmlns="http://herbaer.de/xmlns/20051201/doc">
  <title>sitemap_ht.xslt</title>
  <subtitle>XHTML-Darstellung einer Sitemap (Bilder)</subtitle>
  <date>2011-09-19</date>
  <author>
    <personname>
      <firstname>Herbert</firstname>
      <surname>Schiemann</surname>
    </personname>
    <email>h.schiemann@herbaer.de</email>
  </author>
</d:info>

<xsl:variable name="g_terms" select="document('')/xsl:stylesheet/t:terms"/>

<xsl:output method="xml" encoding="utf-8"/>

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

<d:para>
Der HTML-Rahmen
</d:para>
<xsl:template match="sm:urlset">
  <xsl:variable
    name = "title"
    select = "
      concat (
      'Sitemap ', substring-before (substring-after (sm:url[1]/sm:loc, 'http://'), '/') )
    "
  />
  <html>
    <head>
      <link href="style/shortcut_icon.png" rel="icon"/>
      <title><xsl:value-of select="$title"/></title>
      <xsl:element name="style">
        <xsl:attribute name="type">text/css</xsl:attribute>
        <xsl:text>
dd p { margin: 0pt; }
dt   { margin-top: 5pt; }
a[class~="inlimg"] {
    display: inline-block;
    width:  100px;
    height: 100px;
    background-position: center center;
    background-repeat: no-repeat;
}
        </xsl:text>
      </xsl:element>
    </head>
    <body>
      <h1><xsl:value-of select="$title"/></h1>
      <dl>
        <xsl:apply-templates select="sm:url"/>
      </dl>
    </body>
  </html>
</xsl:template>

<d:para>
Ein Dokument ohne Bild wird nicht angezeigt.
</d:para>
<xsl:template match="sm:url [not (im:image)]"/>

<d:para>
Eintrag zu einem Dokument
</d:para>
<xsl:template match="sm:url">
  <xsl:apply-templates select="sm:loc"/>
  <dd>
    <xsl:apply-templates select="sm:lastmod"/>
    <xsl:apply-templates select="sm:changefreq"/>
    <xsl:apply-templates select="sm:priority"/>
    <xsl:apply-templates select="c:codesearch/c:filetype"/>
    <div>
      <xsl:apply-templates select="im:image"/>
    </div>
  </dd>
</xsl:template>

<d:para>
Die URL mit einem Verweis
</d:para>
<xsl:template match="sm:loc">
  <dt><a href="{.}"><xsl:apply-templates/></a></dt>
</xsl:template>

<d:para>
Datum der letzten Änderung
</d:para>
<xsl:template match="sm:lastmod">
  <xsl:if test="string-length(.) &gt; 9">
    <p class="lastmod">
      <span class="legend">Zuletzt geändert:</span>
      <xsl:text> </xsl:text>
      <span class="lastmod">
        <xsl:value-of
          select = "
            concat (
            substring (., 9, 2), '.',
            substring (., 6, 2), '.',
            substring (., 1, 4) )
          "
        />
      </span>
    </p>
  </xsl:if>
</xsl:template>

<d:para>
Änderungshäufigkeit
</d:para>
<xsl:template match="sm:changefreq">
  <xsl:if test=". != 'yearly'">
    <xsl:variable name="f" select="."/>
    <p class="changefreq">
      <span class="legend">Änderungshäufigkeit:</span>
      <xsl:text> </xsl:text>
      <span class="changefreq">
        <xsl:value-of select="$g_terms/t:term [t:key = $f]/t:val"/>
      </span>
    </p>
  </xsl:if>
</xsl:template>

<d:para>
Priorität
</d:para>
<xsl:template match="sm:priority">
  <p class="priority">
    <span class="priority">Priorität:</span>
    <xsl:text> </xsl:text>
    <span class="priority"><xsl:apply-templates/></span>
  </p>
</xsl:template>

<d:para>
Dateityp: "Übersetzung" suchen
</d:para>
<xsl:template match="c:codesearch/c:filetype">
  <xsl:variable name="ft" select="."/>
  <xsl:apply-templates select="$g_terms/t:term [t:key = $ft]"/>
</xsl:template>

<d:para>
Übersetzter Dateityp
</d:para>
<xsl:template match="t:term">
  <p class="filetype">
    <span class="legend">Dateityp:</span>
    <xsl:text> </xsl:text>
    <span class="filetype"><xsl:apply-templates select="t:val"/></span>
  </p>
</xsl:template>

<d:para>
Ein Bild:
Mit Hintergrundbildern wird das Dokument wesentlich schneller angezeigt
als mit img-Elementen statt der Hintergrundbilder.
</d:para>
<xsl:template match="im:image">
  <a href="{im:loc}" class="inlimg">
    <xsl:attribute name="style">
      <xsl:value-of
        select = "
          concat (
          'background-image: url(',
          substring-before (im:loc, '/smallimg/'),
          '/thumbs/',
          substring-after (im:loc, '/smallimg/'),
          ');' )
        "
      />
    </xsl:attribute>
  </a>
  <xsl:text> </xsl:text>
</xsl:template>

<t:terms>
  <!-- Änderungshäufigkeit -->
  <t:term><t:key>always</t:key><t:val>immer</t:val></t:term>
  <t:term><t:key>hourly</t:key><t:val>stündlich</t:val></t:term>
  <t:term><t:key>daily</t:key><t:val>täglich</t:val></t:term>
  <t:term><t:key>weekly</t:key><t:val>wöchentlich</t:val></t:term>
  <t:term><t:key>monthly</t:key><t:val>monatlich</t:val></t:term>
  <t:term><t:key>yearly</t:key><t:val>jährlich</t:val></t:term>
  <t:term><t:key>never</t:key><t:val>nie</t:val></t:term>

  <!-- Dateityp (Quellcode) -->
  <t:term><t:key>css</t:key><t:val>CSS</t:val></t:term>
  <t:term><t:key>javascript</t:key><t:val>JavaScript</t:val></t:term>
  <t:term><t:key>perl</t:key><t:val>Perl</t:val></t:term>
  <t:term><t:key>shell</t:key><t:val>Shell</t:val></t:term>
  <t:term><t:key>xml</t:key><t:val>XML</t:val></t:term>
  <t:term><t:key>xslt</t:key><t:val>XSLT</t:val></t:term>
</t:terms>

</xsl:stylesheet>
