Re: [xsl] Stumped on XPath

Subject: Re: [xsl] Stumped on XPath
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 7 Feb 2006 22:04:20 GMT
The trick with doing cross references in XSLT is always generate the
reference text _at the referenced node_ not on the referencing node.
then you can easily get the same number in the reference and in the
referenced heading. (Often by just calling a named template or special
mode that just does the numbering.

So at the referencing element, first follow the link, then generate the

<xsl:stylesheet version="1.0"

<xsl:key name="r" match="refnote" use="@id"/>

<xsl:template match="doc">

<xsl:template match="sentence">
<xsl:template match="clause">
 <p class="clause"><xsl:apply-templates/></p>
<xsl:template match="strong">
<xsl:template match="appendix"/>
<xsl:template match="id">
<xsl:for-each select="key('r',@ref)">
 <xsl:text> (see Appendix </xsl:text>
 <xsl:number format="A"/>
 <xsl:text>) </xsl:text>


$ saxon refid.xml refid.xsl
      <meta http-equiv="Content-Type" content="text/html;

      <p>This is a sentence with a reference (see Appendix A)  as an
         inline element

      <p class="clause">This is a clause with inline elements <strong>
            and</strong> a reference  (see Appendix B)


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:

Current Thread