Expand | Collapse

◀ 11. Tables13. Indexing of terms ▶

12. Cross references

xsl:stylesheet id="stylesheet" exclude-result-prefixes="x2 lit xs" version="1.0" xml:lang="en"

xsl:key name="labels" match="xs:label" use="@href"

Making a cross reference
Getting the cross-reference label for a target

12.1. Making a cross reference

xs:xref is the element that the user may put into the source document to make a cross reference to another part of the document. It translates in the obvious way to a standard HTML link, and the link text is the cross-reference label.

xsl:template match="xs:xref"
        xsl:attribute name="href"
          xsl:call-template name="map-uri"
        xsl:call-template name="xref-label"

12.2. Getting the cross-reference label for a target

xref-label gets the cross-reference label (as XHTML2 markup) for the target element. It is called upon when processing xs:xref elements, but may also be used in other contexts.

The information is looked up in the site map, in particular, the xs:label element, defined above under the XSL key labels.

xsl:template name="xref-label"
      xsl:param name="href" select="@href"
      xsl:variable name="absolute-href"
        xsl:call-template name="absolute-uri"
          xsl:with-param name="href" select="$href"

        xsl:when test="count($site-map-doc)>0"
          xsl:for-each select="$site-map-doc"
              xsl:when test="key('labels', $absolute-href)/node()"
                xsl:apply-templates select="key('labels', $absolute-href)/node()"
                xsl:apply-templates select="document(@href)" mode="for-xref-label"
          xsl:apply-templates select="document(@href)" mode="for-xref-label"

Formatted using xhtml2to1 by Steve Cheng.