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

Numbering in a hierarchy

Subject: Numbering in a hierarchy
From: "Lech Rzedzicki" <xchaotic@xxxxxxxxx>
Date: Thu, 3 Apr 2008 16:28:40 +0100
 Numbering in a hierarchy
Hi.

I'm currently reading a number of of excellent resources on numbering
(mostly archives from this list), but I'm still torn as to what's the
best (OK, easiest) way to approach to number my elements. I want to
put the numbering scheme in the elements' attributes recursively.

My sample input:

<top>
    <group>
        <item>test</item>
        <item>test</item>
        <item>test</item>
        <item>test</item>
    </group>
    <group>
        <item>test</item>
 <otheritem>test</otheritem>
        <item>test</item>
        <item>test</item>
        <item>test</item>
    </group>
</top>

My desired output:

<top>
    <group number="1">
        <item number="1-1">test</item>
        <item number="1-2">test</item>
        <item number="1-3">test</item>
        <item number="1-4">test</item>
    </group>
    <group number="2">
        <item number="2-1">test</item>
        <otheritem>test</otheritem>
        <item number="2-2">test</item>
        <item number="2-3">test</item>
        <!-- etc -->
    </group>
</top>

My initial approach was to simply use <xsl:number/>, is it too much
work or is it better to use saxon:assign for that?

Further notes: It doesn't need to be recursive, just two levels are
OK. Also other elements can be sometimes in between the nodes to be
counted as shown in example.

It seems my brain goes to sleep after 4pm and I need some pointers again.

Thanks in advance, Lech

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.