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

Restrict numbering to a sub tree

Subject: Restrict numbering to a sub tree
From: Graeme Kidd <coolkidd3@xxxxxxxxxxx>
Date: Sat, 2 Apr 2011 05:36:12 +0100
 Restrict numbering to a sub tree
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

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.