[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Handling Cross References

Subject: RE: Handling Cross References
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Tue, 11 May 2004 13:57:17 +0100
number handling
> 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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.