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

Re: Numbering quandry

Subject: Re: Numbering quandry
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 12 Apr 2001 17:40:03 +0100
parent in xsl
Stephen:

It looks like you have the numbering of each node working okay, it's the numbering of the parent that's not working.

That's because when you say
        <xsl:text>Section </xsl:text>
        <xsl:value-of select="@title"/>
        <xsl:text> (</xsl:text>
        <xsl:number level="multiple" count="section" format="1.1.0"/>
        <xsl:text>, parent </xsl:text>
        <xsl:number level="multiple" count="section/section" format="1.1.0"/>
        <xsl:text>)</xsl:text>

that second <xsl:number ...> is still taking the current node matched by the template as its context node. The 'count' attribute identifies what nodes should be counted, but it doesn't change the fact that the number inserted is 'based on the position of the current node in the source tree' [XSLT 7.7].

So to count the parent, you have to change the current node to be the parent of the node your template has matched, for that invocation of the <xsl:number/> instruction. You can do this by wrapping it in a for-each like so:

        <xsl:text>Section </xsl:text>
        <xsl:value-of select="@title"/>
        <xsl:text> (</xsl:text>
        <xsl:number level="multiple" count="section" format="1.1.0"/>
        <xsl:text>, parent </xsl:text>
       <xsl:for-each select="..">
         <xsl:number level="multiple" count="section/section" format="1.1.0"/>
       </xsl:for-each>
        <xsl:text>)</xsl:text>

which will count the correct nodes ... then you'll have to adjust the 'count' attribute to count the correct nodes (I'll leave you to figure that out).

Good luck,
Wendell

At 08:37 PM 4/12/01, you wrote:
Hello all,

I have numbering difficulty. I'm trying to number sections hierarchically,
and also to include the number of their parent section, if they have any, or
their own number if they are a top-level section. This is what I have:
...


======================================================================
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
======================================================================


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.