Hello,
I'm trying to figure out how to count the preceding set of cousins of a
particular element, but am having trouble figuring out the proper method.
My XML goes something like so:
<div>
<p></p>
<block>
<p></p>
<p></p>
</block>
<p></p>
<p></p>
<block>
<p></p>
</block>
</div>
I'm trying to count all the preceding /block/p elements of the current
one, being sure to not count 'p' elements at different levels, etc.
My XSL looks something like this:
<xsl:template match="block" mode="main">
<xsl:apply-templates mode="grandchild" />
</xsl:template>
<xsl:template match="p" mode="grandchild">
<xsl:number format="1." level="multiple" value="count(preceding::p)
+ 1"/>
</xsl:template>
Unfortunately, the above counts all <p> elements in the whole tree, not
just cousins (but uncles, aunts, and even the neighbour's dog). I also
tried to make something work with preceding-siblings, but that obviously
only counts according to the current parent 'block', so the numbering
restarts for each new parent.
I even got a count of all immediate cousins, however that was just a total
count, not relative to the location of the current node (i.e. preceding).
In that case, I considered incorporating 'position()', but couldn't figure
out how to get that to accurately know where it was.
I hunted around online for a while, but could only find examples of
slightly different problems.
What's the best way of solving this problem?
Thanks in advance for any assistance,
Jordan
--~------------------------------------------------------------------
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>
--~--