Re: [xsl] position

Subject: Re: [xsl] position
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Sat, 14 Feb 2004 14:36:04 -0500
At 2004-02-14 16:17 +0100, Thomas Rasmussen wrote:
I was about to suggest using <xsl:number> too, so I made a small example, but the first note is not treated as I would expect it to be?

This is interesting ...

The value is zero because at the point in time, according to XSLT 1.0 Section 7.7 the <note> element isn't being processed and there are no preceding notes, so there is nothing to count.

But section 7.7.1 states that integers being processed are greater than zero.

So, I'm guessing it is incumbent on the stylesheet writer never to be in the position of getting a zero value when using <xsl:number>. But it doesn't say that explicitly in the Recommendation.

Can anyone on the committee comment on this? Are users of <xsl:number> required to use it only in situations where a positive number is being returned?

My earlier response to the original poster would fix the issue without treading into this territory though:

At 2004-02-14 10:13 -0500, I wrote:
At 2004-02-14 15:54 +0100, m.vanrootseler@xxxxxxxxx wrote:
Thanks Ken, this works. I hadn't thought of using <xsl:number/>. The
output, though, starts with '0', so the first note is numbered '0' but I
solved this by putting the lot into a variable and upping it by 1.

:{)} That's the "programmer's approach" to solving the problem: throwing it in a variable and upping it by one. Many of my students come to class always trying to employ a programming approach.

May I instead suggest a hierarchical approach more consistent with XSLT:

  <xsl:if test="note">
    <xsl:for-each select="note">
      <xsl:number level="any"/>
      ...other note stuff...

At 2004-02-14 16:17 +0100, Thomas Rasmussen wrote:
sabloton will not parse the xsl complaining about "number is not positive"

I'm thinking that may be a bona fide report.

saxon does not number the first node, probably treating it as NAN
xalan numbers the first node 0
So the following only works in Xalan (and it is probably a hack)
<xsl:template match="w">
<xsl:text> </xsl:text>
<xsl:if test="note">
<xsl:variable name="tmp"><xsl:number count="note" format="1" level="any"/></xsl:variable>
style="vertical-align:super;font-size:7pt"><xsl:value-of select="$tmp+1"/></span>

What am I doing wrong?

Given your evidence, I'm assuming you've chosen to utilize <xsl:number> in a situation that returns a zero result.

Therefore, that leads me to conclude my suggestion about changing context is required in order to properly use <xsl:number>. I've made note of it for a future edition of my book.

........................ Ken

Public courses: upcoming world tour of hands-on XSL training events
Each week:    Monday-Wednesday: XSLT/XPath; Thursday-Friday: XSL-FO
Washington, DC: 2004-03-15            San Francisco, CA: 2004-03-22
Hong Kong: 2004-05-17    Germany: 2004-05-24    England: 2004-06-07
World-wide on-site corporate, government & user group XML training!

G. Ken Holman                  mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd. 
Box 266, Kars, Ontario CANADA K0A-2E0     +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness

XSL-List info and archive:

Current Thread