xsl-list
[Top] [All Lists]

[xsl] Restrict numbering to a sub tree

2011-04-01 23:36:33




Hi 

I am using XSLT 2.0 and trying to number some elements
based on the current position within a sub tree as well as numbering which sub 
tree it's in.

For example I could have the following mark-up:<root>
    <section>
        <figure />
        <section>
            <figure />
            <figure />
            <section>
                <figure />
            </section>
        </section>
        <section>
            <figure />
        </section>
    </section>
    <section>
        <figure />
    </section>
    <section>
        <figure />
        <figure />
    </section>
</root> 

Which I am wanting to convert to this:<root>
    <section>
        <figure id="1.1" />
        <section>
            <figure id="1.2" />
            <figure id="1.3" />
            <section>
                <figure id="1.4" />
            </section>
        </section>
        <section>
            <figure id="1.5" />
        </section>
    </section>
    <section>
        <figure id="2.1" />
    </section>
    <section>
        <figure id="3.1" />
        <figure id="3.2" />
    </section>
</root> 

As you can see the first number shows which "section" sub tree it is in while 
the second number is used to show its current position within that sub tree 
which could include further sub "sections".

 

I can easily use xsl:number to count every figure within
the root i.e:

<xsl:number level="any"
count="figure"/>

 

What I am finding difficult is limiting that count to
within the scope of the sub tree, conversely the same is said for
getting the count on the current sub tree it's in.
Some help on this would be greatly appreciated.

Thanks






                                          
--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>