xsl:stylesheet id="stylesheet" exclude-result-prefixes="lit #default" version="1.0" xml:lang="en" xsl:output method="xml" xsl:include href="uri.xsl" xsl:include href="xsltsl-uri.xsl" xsl:include href="xref-index.xsl" xsl:include href="indexing.xsl" Default mode Auto-navigation mode Source-to-output URI mapping
The default mode is the first mode invoked when processing a XHTML2 document. It performs the following tasks
auto-label mode.
auto-nav mode.
x2:nl.
xsl:template match="/" <hs:site-map> <hs:title> xsl:copy-of select="x2:html/x2:head/x2:title/node()" </hs:title> xsl:apply-templates xsl:with-param name="base-uri" select="$doc-uri" </hs:site-map>
xsl:template match="/*" xsl:param name="base-uri" <hs:label href="{$base-uri}"> xsl:apply-templates select="/*" mode="for-site-map-label" </hs:label> <-- <xsl:apply-templates select="/*" mode="auto-label"> <xsl:with-param name="base-uri" select="$base-uri" /> </xsl:apply-templates> --> xsl:apply-templates select="//*[@id]" mode="auto-label" xsl:with-param name="base-uri" select="$base-uri" xsl:apply-templates select="/*" mode="index-term" xsl:with-param name="base-uri" select="$base-uri" xsl:apply-templates select="/" mode="auto-nav" xsl:with-param name="base-uri" select="$base-uri" xsl:apply-templates xsl:with-param name="base-uri" select="$base-uri"
xsl:template match="@*|text()"
xsl:template match="*" xsl:apply-templates
xsl:template match="x2:nl" xsl:apply-templates select="." mode="site-map-gen"
xsl:template match="node()" mode="site-map-gen"
xsl:template match="x2:nl" mode="site-map-gen" xsl:apply-templates mode="site-map-gen"
xsl:template match="x2:li" mode="site-map-gen" xsl:variable name="absolute-uri" xsl:call-template name="absolute-uri" xsl:with-param name="href" select="x2:a/@href" <hs:site-item href="{$absolute-uri}"> <hs:html-uri href="{$absolute-uri}"> xsl:attribute name="to" xsl:call-template name="html-uri" xsl:with-param name="href" select="$absolute-uri" </hs:html-uri> xsl:variable name="t" select="document(x2:a/@href, .)" xsl:if test="count($t)>0" xsl:apply-templates select="$t/*" xsl:with-param name="base-uri" select="$absolute-uri" xsl:apply-templates mode="site-map-gen" </hs:site-item>
html-uri implements the lower-level
part of the source-to-output
URI transformation.
This is the simplest implementation possible, which is renaming the xml file name extension to the html extension.
xsl:template name="html-uri" xsl:param name="href" select="@href" xsl:param name="suffix" select="'.xml'" xsl:param name="replacement" select="'.html'" xsl:choose xsl:when test="starts-with($href, '#')" xsl:value-of select="$href" xsl:when test="contains($href, '#') and contains($href, $suffix)" xsl:variable name="fragment" select="substring-after($href, '#')" xsl:variable name="doc-uri" select="substring-before($href, '#')" xsl:value-of select="concat(substring-before($doc-uri, $suffix), $replacement, '#', $fragment)" xsl:when test="contains($href, $suffix)" xsl:value-of select="concat(substring-before($href, $suffix), $replacement)" xsl:otherwise xsl:value-of select="$href"
Formatted using xhtml2to1 by Steve Cheng.