Expand | Collapse

◀ 12.2. Getting the cross-reference label for a target▲ 12. Cross references

12.3. Indexing cross references

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

  for-xref-label
  for-xref-label.empty
  auto-label

  for-site-map-label mode

12.3.1. The auto-label mode

Processing a target node with the auto-label mode causes information about its cross-reference labels to be output. This mode is used only during the creation of site maps.

It differs from the for-xref-label mode, to be described below, in that all the wrapper elements inside the xs namespace are output, whereas for-xref-label only gives the content of the cross-reference label.

The default implementation below simply calls on the for-xref-label mode to get at the actual content of label. In the wrapper element xs:label, the absolute URI of the target node is recorded.

xsl:template match="*[@id]" mode="auto-label"
      xsl:param name="base-uri"

      <hs:label>
        xsl:attribute name="href"
          xsl:call-template name="absolute-uri"
            xsl:with-param name="base" select="$base-uri"
            xsl:with-param name="href" select="concat('#', @id)"
          
        

        xsl:apply-templates select="." mode="for-site-map-label"
      </hs:label>
    

12.3.2. The for-xref-label mode

Processing a target node with the for-xref-label mode returns the XHTML1 markup for its cross-reference label.

For example, processing a section would typically result in the content of its h child element, possibly preceded by its chapter or section number.

xsl:template match="x2:section" mode="for-xref-label"
      xsl:apply-templates select="x2:h" mode="title-text"
    
xsl:template match="*|text()" mode="for-xref-label"
      xsl:textunknown label
    

12.3.3. for-site-map-label mode

xsl:template match="x2:section" mode="for-site-map-label"
        xsl:copy-of select="x2:h/node()"
      
xsl:template match="*|text()" mode="for-site-map-label"
      

Formatted using xhtml2to1 by Steve Cheng.