[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] XSL:Number, value attribute


Subject: RE: [xsl] XSL:Number, value attribute
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 27 Jun 2003 09:47:46 +0100

Using the "value" attribute of xsl:number gives you access to the number
formatting functionality of xsl:number without the node-counting
functionality. For example

<xsl:number value="7" format="i"/>

gives you "vii", regardless of where the context node is in the source
tree. This means that value can't be used with multi-level numbering (at
least in XSLT 1.0 - in 2.0 the value attribute can be a sequence of
numbers).

If position() is giving you 2 rather than 1, that's probably because the
current iteration (for-each or apply-templates) is processing whitespace
text nodes as well as elements.

Often explicit node counting, e.g. count(preceding-sibling::item) is
easier to control than xsl:number. Though position() is generally the
most efficient of the three techniques, it depends on the processing
sequence of the nodes, not only on their absolute position in the source
tree.

Michael Kay





> I'm using Xalan v2.5.1 on JDK 1.3.1 and running into some 
> problems using 
> xsl:number.
> 
> I can successfully number nodes in a hierarchical fashion using 
> level=multiple and format="1.a.i" However, I need to start 
> numbering my 
> nodes from a seed, e.g 3,4,5 instead of 1,2,3. So I thought I 
> could specify 
> value="position()+{$seed}" but whenever I specify the value 
> attribute, the 
> formatting is lost and the multiple level numbering is lost.
> 
> Furthermore, nodes end up getting numbered 2,4,6 instead of 
> 1,2,3 with 
> value="position()". I tried specifying the count attribute to 
> fix this but I 
> had no luck.
> 
> Is the value attribute of xsl:number supported at all?
> 
> I would be grateful for any ideas,
> 
> Chris
> 
> _________________________________________________________________
> Tired of 56k? Get a FREE BT Broadband connection 
> http://www.msn.co.uk/specials/btbroadband
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


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



Current Thread
Keywords