Subject: Getting a specific element count from a generic match
From: "Spencer Tickner" <spencertickner@xxxxxxxxx>
Date: Fri, 7 Apr 2006 08:33:49 -0800
|
Hi eveyone,
Thanks in advance for the help. I have a generic match in my xsl that
references another xml lookup file (not the problem). I need to count
the number of preceeding-sibiling:: elements with the same name. The
problem is the template that it is matching on is generic (the
template must remain a generic * match. ).
XSL (Doesn't work - Expected node test in pattern error)
<xsl:template match="*" mode="lookup">
<!-- I know the line below is incorrect but I think it illustrates
what I'm trying to accomplish -->
<xsl:number count="preceding-sibling::*[name()]" format="(1)"/>
</xsl:template>
Sooo if I had a source document like
<foo>
<bar>Test</bar>
<bar>Test</bar>
<foo>
<sab>Test</sab>
<rab>Test</rab>
</foo>
</foo>
When the template matched bar[1] produces (1)
When the template matched bar[2] produces (2)
When the template matched foo/rab[1] produces (1)
And the pattern continues ...
Any thoughts,
Spence
|