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
number:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="r" match="refnote" use="@id"/>
<xsl:template match="doc">
<html>
<head/>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="sentence">
<p><xsl:apply-templates/></p>
</xsl:template>
<xsl:template match="clause">
<p class="clause"><xsl:apply-templates/></p>
</xsl:template>
<xsl:template match="strong">
<strong><xsl:apply-templates/></strong>
</xsl:template>
<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>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
$ saxon refid.xml refid.xsl
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8">
</head>
<body>
<p>This is a sentence with a reference (see Appendix A) as an
inline element
</p>
<p class="clause">This is a clause with inline elements <strong>
and</strong> a reference (see Appendix B)
</p>
</body>
</html>
________________________________________________________________________
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:
http://www.star.net.uk
________________________________________________________________________
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--