Subject: [xsl] RE: Counting preceding elemets of similar node, but in different branch From: "Karlmarx Rajangam" <karlmarx.rajangam@xxxxxxxxxxxxxxxxxx> Date: Wed, 23 Jul 2008 09:16:12 -0400 |
I have requirement to display certain id's in a sequential numbering order. My xml is something like [and pls ignore any spell / case mistakes] <root> <something> <assessQ> <header/> <Block> <blockID>xxxx</blockID> <questions> <QUESTION ID="1" /> <QUESTION ID="2" /> <QUESTION ID="3"/> </questions> </Block> </assessQ> <assessQ> <header/> <Block> <blockID>yyy</blockID> <questions> <QUESTION ID="1" /> <QUESTION ID="2" /> </questions> </Block> </assessQ> </something> </root> And in my xslt (Ver 1), I have something like <xsl:apply-templates select="something/assessQ/Block/questions"/> [I think I cannot change this due to various other elements] And what I am do is something like 1= 1 2= 2 3= 3 4= 1 5= 2 and so on.... so, i tried to use position, <xsl:template match="QUESTION"> <xsl:value-of select="position()"/> = <xsl:value-of select="@ID"/><br/> </xsl:template> but I released the mistake after seeing the result, 3=3 is being followed by again by 1=1, ... instead of 4=1. So, i think i must use preceding-sibling and/or some other logic to calculate how many <QUESTION/> elements are there before it. Pls can you suggest the best way to handle this? Hope there might be some solution? Thanks, karl
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] FO Table widths - table-l, Tony Graham | Thread | Re: [xsl] RE: Counting preceding el, David Carlisle |
Re: [xsl] Whitespace Copied in Elem, Andrew Welch | Date | Re: [xsl] RE: Counting preceding el, David Carlisle |
Month |