xsl-list
[Top] [All Lists]

[xsl] Getting a specific element count from a generic match

2006-04-07 09:34:10
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

--~------------------------------------------------------------------
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>
--~--