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

Re: xsl:number question

Subject: Re: xsl:number question
From: "David Marston/CAM/Lotus" <David_Marston@xxxxxxxxx>
Date: Fri, 12 May 2000 13:11:32 -0400
xsl number value position
Perry Molendijk writes:
>The onscreen output (html) looks like this:
>One - 2
>Two - 4
>Three - 6
>Four - 8
>This could be a usefull feature but I want the numbers 1,2,3...

There are some rules-of-thumb about xsl:number which you can
apply here, if you have enough thumbs.

1. Use xsl:number to generate numbering for output, not for
   general counting. (Mnemonic: that's why it's in chapter 7
   of the XSLT spec.)

In the example you sent, you are only using xsl:number for
display, so you can drop all that stuff about putting the
number in a variable.

2. There are well-targeted counting options in xsl:number,
   so try to let it do the work for you.

In your example, you used "value=position()" and thus
over-rode its built-in ability to count only the form
nodes. As a corollary to the above,

2A. Start with just plain <xsl:number>, then tinker with
    count, level, from, position, and format, IN THAT
    ORDER, to get what you need. (All other attributes
    come later, to tweak the appearance.)

Yes, you could do "value=position() div 2" but that would
be highly dependent on the regularity of the structure
and the intervening whitespace. If "count=form" is what
you want, say so. Actually, that should be the default
for your example.

3. Ultimately, xsl:number is creating strings.
   (Mnemonic: it can generate "numbers" with more than
   one decimal point, or with other separators.)

If you need position data for other reasons not shown in
your example, use separate expressions with position()
or count(node-set) to perform numerical calculations.
I hope this gives you a fresh outlook on the task.
.................David Marston



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


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.