<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
<xsl:output method="html" encoding="utf-8" indent="yes" doctype-system="[URL unfurl="true"]http://www.w3.org/TR/html4/strict.dtd"[/URL] doctype-public="-//W3C//DTD HTML 4.01//EN"/>
<xsl:param name="datestring" />
<xsl:key name="libFirstChar" match="library"
use="translate(substring(normalize-space(translation/translations/entry/value[1]),1,1),
'abcdefghijklmnopqrstuvwxyzäöüéèàç',
'ABCDEFGHIJKLMNOPQRSTUVWXYZAOUEEAC')"/>
<xsl:template match="/">
<html lang="de">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Bibliotheken in swissbib</title>
<link href="libstyle.css" rel="stylesheet" />
</head>
<body>
<div class="full_wrapper">
<div class="title_wrapper">
<h1 class="title">Bibliotheken in <xsl:element name="a"><xsl:attribute name="href">..</xsl:attribute>swissbib
</xsl:element></h1>
<p>
<xsl:if test="$datestring != ''">
<xsl:value-of select="concat('Stand: ',$datestring)"/>
</xsl:if>
</p>
<p> <xsl:element name="a">
<xsl:attribute name="href">codelist.html</xsl:attribute>
nach Codes sortieren
</xsl:element>
</p>
</div>
<div class="list_wrapper">
<!-- iterate over the first node for each starting character -->
<xsl:for-each select="//library[generate-id(.)=generate-id(key('libFirstChar',
translate(substring(normalize-space(translation/translations/entry/value[1]),1,1),
'abcdefghijklmnopqrstuvwxyzäöüéèàç',
'ABCDEFGHIJKLMNOPQRSTUVWXYZAOUEEAC'))[1])]">
<xsl:sort select="translate(substring(normalize-space(translation/translations/entry/value[1]),1,1),
'abcdefghijklmnopqrstuvwxyzäöüéèàç',
'ABCDEFGHIJKLMNOPQRSTUVWXYZAOUEEAC')"/>
<!-- we are now in the context of a <library> node -->
<xsl:variable name="myFirstChar" select="translate(substring(normalize-space(translation/translations/entry/value[1]),1,1),
'abcdefghijklmnopqrstuvwxyzäöüéèàç',
'ABCDEFGHIJKLMNOPQRSTUVWXYZAOUEEAC')"/>
<!-- output the links -->
<xsl:call-template name="genLinks"/>
<xsl:element name="a"><xsl:attribute name="name"><xsl:value-of select="string($myFirstChar)"/></xsl:attribute></xsl:element>
<!-- Now iterate over all the <library> nodes that start with the same character sort value -->
<xsl:for-each select="key('libFirstChar',$myFirstChar)">
<!-- sort all the <library> nodes in this result set by their full <value> (we know they all start with the same first letter) -->
<xsl:sort select="translate(normalize-space(translation/translations/entry/value),
'abcdefghijklmnopqrstuvwxyzäöüéèàç',
'ABCDEFGHIJKLMNOPQRSTUVWXYZAOUEEAC')"/>
<xsl:call-template name="outputLibrary"/>
</xsl:for-each>
</xsl:for-each>
<xsl:call-template name="genLinks"/>
</div>
</div>
</body>
</html>
</xsl:template>
<xsl:template name="genLinks">
<span>
<!-- The for-each will iterate exactly once for each unique initial letter. -->
<xsl:for-each select="//library[generate-id(.)=generate-id(key('libFirstChar',
translate(substring(normalize-space(translation/translations/entry/value[1]),1,1),
'abcdefghijklmnopqrstuvwxyzäöüéèàç',
'ABCDEFGHIJKLMNOPQRSTUVWXYZAOUEEAC'))[1])]">
<xsl:sort select="translate(normalize-space(translation/translations/entry/value),
'abcdefghijklmnopqrstuvwxyzäöüéèàç',
'ABCDEFGHIJKLMNOPQRSTUVWXYZAOUEEAC')"/>
<xsl:variable name="myLinkChar" select="translate(substring(normalize-space(translation/translations/entry/value[1]),1,1),
'abcdefghijklmnopqrstuvwxyzäöüéèàç',
'ABCDEFGHIJKLMNOPQRSTUVWXYZAOUEEAC')"/>
<a><xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:value-of select="$myLinkChar"/></xsl:attribute>
<xsl:value-of select="$myLinkChar"/></a>
<xsl:if test="position()!=last()"><xsl:text>-</xsl:text></xsl:if>
</xsl:for-each>
</span>
</xsl:template>
<xsl:template name="outputLibrary">
<div class="library">
<span class="libname">
<xsl:value-of select="normalize-space(translation/translations/entry/value)"/>
</span>
<span class="rowtitle"><br /> </span>
<span class="address"><xsl:value-of select="translate(road,'"','')"/></span>
<span class="rowtitle">, </span>
<span class="rowvontent">
<xsl:value-of select="zipCode"/><xsl:text> </xsl:text><xsl:value-of select="town" />
</span>
<span class="rowtitle"><br /></span>
<span class="bibinfo">
<xsl:if test="normalize-space(addressURL) != ''">
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="normalize-space(addressURL)"/></xsl:attribute>
Bibliotheksinfo
<xsl:choose>
<xsl:when test="libraryIdentifierMatcher != ' '">
<xsl:value-of select="libraryIdentifierMatcher"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="name"/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:if>
</span>
<span class="rowtitle"><br /></span>
<span class="bibinfo">
<xsl:element name="a">
<xsl:choose>
<xsl:when test="libraryIdentifierMatcher != ' '">
<xsl:element name="a"><xsl:attribute name="href">[URL unfurl="true"]http://www.swissbib.ch/TouchPoint/start.do?Query=1805="<xsl:value-of[/URL] select="libraryIdentifierMatcher"/>"</xsl:attribute>
Bestand
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="a"><xsl:attribute name="href">[URL unfurl="true"]http://www.swissbib.ch/TouchPoint/start.do?Query=1805="<xsl:value-of[/URL] select="name"/>"</xsl:attribute>
Bestand
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</span>
</div>
</xsl:template>
</xsl:stylesheet>