Subject: Re: [xsl] Restrict numbering to a sub tree From: Brandon Ibach <brandon.ibach@xxxxxxxxxxxxxxxxxxx> Date: Sat, 2 Apr 2011 01:10:53 -0400 |
All you really need is a pattern for what starts a sub tree. In your case, that's a "section" with no "section" ancestors. Count those to get the sub tree number and count *from* the last one of those for the figure number: <xsl:number level="any" count="section[not(ancestor::section)]"/> <xsl:number level="any" format=".1" from="section[not(ancestor::section)]"/> This works for XSLT 1.0 or XSLT 2.0. -Brandon :) On Sat, Apr 2, 2011 at 12:36 AM, Graeme Kidd <coolkidd3@xxxxxxxxxxx> wrote: > > > > > 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Restrict numbering to a sub t, Graeme Kidd | Thread | [xsl] Help with regex, Ginny Wagner |
[xsl] Restrict numbering to a sub t, Graeme Kidd | Date | [xsl] Help with regex, Ginny Wagner |
Month |