Oxygen XML Editor
 
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Numbering in a hierarchy


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

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
 
© 2002-2008 SyncRO Soft Ltd. All rights reserved. | Sitemap | Privacy Policy
This website was created & generated with <oXygen/> XML Editor