CSTUG

Stylesheet

<xsl:stylesheet version="2.0" exclude-result-prefixes="c">

<!-- This stylesheet gets the value of the root nodes based on the link to the index document. It is assumed that this small stylesheet will be imported into other stylesheets. The stylesheet can correctly handle the case that you process the index document. Your stylesheet can thus test whether local-name(/descendant::element()) is what you expect. If not, you can try to process the document the name of which is returned from this stylesheet, e.g. document($toclist). However, this may cause stack overflow. it is always better to process the correct document in the first place. Notice that the table-of-contents file is not read, its URL is only stored. The user can read it if she really needs it. Other documents are always used, therefore they are stored as node sets. -->
<xsl:variable name="indexhref" select="document(/descendant::element()/@indexhref)"/> <xsl:variable name="url-base"> <xsl:choose> <xsl:when test="/descendant::element()/@indexhref"> <xsl:value-of select="$indexhref/c:index/@base"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="/c:index/@base"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="url-acronyms"> <xsl:choose> <xsl:when test="/descendant::element()/@indexhref"> <xsl:value-of select="$indexhref/c:index/@acronyms"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="/c:index/@acronyms"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="url-authors"> <xsl:choose> <xsl:when test="/descendant::element()/@indexhref"> <xsl:value-of select="$indexhref/c:index/@authors"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="/c:index/@authors"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="url-keywords"> <xsl:choose> <xsl:when test="/descendant::element()/@indexhref"> <xsl:value-of select="$indexhref/c:index/@keywords"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="/c:index/@keywords"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="url-toc"> <xsl:choose> <xsl:when test="/descendant::element()/@indexhref"> <xsl:value-of select="$indexhref/c:index/@toc"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="/c:index/@toc"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="acronymlist" select="document(concat($url-base,$url-acronyms), $indexhref)"/> <xsl:variable name="authorlist" select="document(concat($url-base,$url-authors), $indexhref)"/> <xsl:variable name="keywordlist" select="document(concat($url-base,$url-keywords), $indexhref)"/> <xsl:variable name="toclist" select="concat($url-base,$url-toc)"/> </xsl:stylesheet>

index2.xsl