xsl-list
[Top] [All Lists]

RE: XPath Question

2003-12-31 11:34:14

Given the following xml,

<p style="Normal" tabs="0.2 1.2 2.2">
      Once upon a time, there was a <b>dark</b> and <i>stormy</i> sea.
Nobody could be<br/>
      certain what lay beneath it's churning surface.<br/>
              <tab/>One<tab/>Green<tab/>Octopus<br/>
              <tab/>Two<tab/>Red<tab/>Sharks<br/>
      Or something far more sinister?
</p>

how do I say, from inside a br-match template:

"The number of br nodes, of the parent axis's p node, that have
immediately preceding siblings that are tab nodes"

I tried this, (and many other things besides) but it didn't work...

<xsl:variable name="rows"
select="count(parent::p/br::preceding-sibling::tab[1])"/>

This is not a valid Xpath statement. You need to use a predicate:

count(parent::p/br[preceding-sibling::tab[1]])

This will return the number "2" given your source XML.

HTH,
RG

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>