Is there any easy way of handling cross references?
I am looking to do a transform to create a legal document where each
paragraph is a numbered clause (handled by styles in the form
of 1, 2,
3, 3(i), 3(ii), 3(iii)(a), 3(iii)(b), etc) and need to include a
facility where one clause might contain a reference to another clause
and the number of clauses in between might vary.
Has anyone come across this problem before/found a solution?
Sure, this is done routinely in the stylesheets that generate the W3C
specifications, and almost certainly in DocBook as well.
Suppose the target of the cross-reference is a section with an id (declared
as an ID in the DTD)
<section id="bananas">...</section>
and the cross-reference takes the form
(see <xref section="bananas"/>)
Write a template to number the sections as:
<xsl:template match="section" mode="number">
<xsl:number level="multiple" count="book|chapter|section"
format="1(i)(a)"/>
</xsl:template>
Invoke this when processing the section:
<xsl:template match="section">
<xsl:apply-templates select="." mode="number"/>
<xsl:apply-templates/>
</xsl:template>
and also when processing the cross-reference:
<xsl:template match="xref">
<xsl:apply-templates select="id(@section)" mode="number"/>
</xsl:template>
Michael Kay