<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- This XSL transformation generates the page index for the web technology pages. It also processes section and subsection headings and inserts separators between sections. --> <!-- should be Latin1 or ISO-8859-1, but 1&1 can't do these --> <xsl:output method="xml" omit-xml-declaration = "yes" encoding="utf-8" indent="yes" /> <!-- Main template --> <xsl:template match="/page"> <!-- Make the index --> <xsl:call-template name="do-index"/> <!-- Output the body --> <xsl:apply-templates select="section"/> </xsl:template> <!-- Generate the index from the section and subsect elements --> <xsl:template name="do-index"> <div id="index"> <h2>Page index</h2> <ul> <xsl:for-each select="section"> <li> <xsl:if test="position()=last()"> <xsl:attribute name="class">last</xsl:attribute> </xsl:if> <a href="#{@ref}" title="jump to "{@title}""><xsl:value-of select="@title"/></a> <xsl:if test="subsect"> <ul> <xsl:for-each select="subsect"> <li><a href="#{@ref}" title="jump to "{@title}""><xsl:value-of select="@title"/></a></li> </xsl:for-each> </ul> </xsl:if> </li> </xsl:for-each> </ul> </div> </xsl:template> <!-- Deal with sections --> <xsl:template match="section"> <!-- Make title with anchor --> <h2><a id="{@ref}" name="{@ref}"><xsl:value-of select="@title"/></a></h2> <!-- Copy all elements but process subsections --> <xsl:for-each select="*"> <xsl:choose> <xsl:when test="self::subsect"> <xsl:apply-templates select="."/> </xsl:when> <xsl:otherwise> <xsl:copy-of select="."/> </xsl:otherwise> </xsl:choose> </xsl:for-each> <!-- Add separator --> <xsl:if test="position()!=last()"> <div class="break"> </div> </xsl:if> </xsl:template> <!-- Deal with subsections --> <xsl:template match="subsect"> <!-- Add title to subsections --> <h3><a id="{@ref}" name="{@ref}"><xsl:value-of select="@title"/></a></h3> <!-- Copy contents --> <xsl:copy-of select="*"/> </xsl:template> </xsl:stylesheet>