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

Re: Fun with xsl:number and a key

Subject: Re: Fun with xsl:number and a key
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 14 Oct 2004 18:25:24 -0400
xsl number multiple
Hi Jay,

You're asking the right questions....

At 01:55 PM 10/14/2004, you wrote:
My question is this: Why does the following bit not generate a multi-level
number?
      <xsl:for-each select="key('refentries', .)">
        <xsl:number level="multiple"/>
      </xsl:for-each>

Personally, I speculate that the cause is the nature of the key, which
matches an attribute and then uses . If I understand correctly, this key
holds the text of the attribute, which ditches the context information.

No, it returns the node, in this case a @title attribute.


Why xsl:number is doing what it's doing, I can't exactly say without digging into the spec (http://www.w3.org/TR/xslt#number) and testing. My guess, however, is that you're running into a clash between how you're using level="multiple" and the default on the 'count' attribute (okay now I'm in the spec):

'When level="multiple", it constructs a list of all ancestors of the current node in document order followed by the element itself; ***it then selects from the list those nodes that match the count pattern***; it then maps each node in the list to one plus the number of preceding siblings of that node that match the count pattern. If the from attribute is specified, then the only ancestors that are searched are those that are descendants of the nearest ancestor that matches the from pattern. Preceding siblings has the same meaning here as with the preceding-sibling axis.'

Your count pattern being "@title" (it has defaulted to the name and node type of the current node), xsl:number does not count the chapter it's inside of. And since attributes have no preceding siblings, you always get 1.

One way to go would be to say <xsl:number level="multiple" count="chapter"/>, but even better would be to set up your key differently --

<xsl:key name="refentries" match="chapter" use="@title"/>

or even

<xsl:key name="refentries" match="*[@title]" use="@title"/>

since with either of these, you'd get the actual chapter, not its @title attribute, back from the key() function, and would be counting chapters not their @title attributes.

Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

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.