RE: [xsl] number + document

Subject: RE: [xsl] number + document
From: "Lars Huttar" <lars_huttar@xxxxxxx>
Date: Thu, 19 Jun 2003 14:37:47 -0500
Thank you for remembering to show us your input documents. :-)
That helps a lot.

As far as I can tell (looking at the spec and at the XSLT Programmer's
Reference), <xsl:number> only counts within a given document,
not across documents. (E.g. in the spec at 7.7 it says
"If no value attribute is specified, then the xsl:number element inserts a number based on the
position of the current node IN THE SOURCE TREE
[emphasis mine].")

If you have multiple documents, it's not clear how XSLT would know
what the document order of nodes in different documents should be.

Here's an idea that would work if you're sure that all documents have a
<chap1> as the only child of <docbody> (i.e. there are no <chap2> or
<chap3> children of <docbody> in any document).

Make the number for the <chap1> elements separately, using the position
of the current <chapmod> in the outer for-each loop.
  <xsl:number level="single" count="chapmod" format="A." />

Then use <xsl:number> to number the parts within the document
in the inner for-each loop:
  <xsl:number level="multiple" count="chap2|chap3" format="1.1"/>

Put the result of each of these in a variable and concatenate them together
in the inner loop.  The result: A, B, B.1, B.1.1, etc.


By the way,
> <xsl:for-each select="//doccontent/chapmod">
do you really want to search the whole document for these?
Instead of using // could you use
  select="/*/doccontent/chapmod"
?  It should be faster.

Lars



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread