Subject: RE: [xsl] XPath Question From: "Lars Huttar" <lars_huttar@xxxxxxx> Date: Wed, 31 Dec 2003 17:04:47 -0600 |
> >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. which is the right answer for this data, but in general this expression will not always give the value Kyle asked for. Instead it tells the number of br nodes that have ANY preceding siblings that are tab nodes. An expression that does what Kyle asked would be count(parent::p/br[preceding-sibling::*[1][self::tab]]) Lars XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] XPath Question, Ryan Graham | Thread | [xsl] XSL-List Guidelines, B Tommie Usdin |
RE: [xsl] randlist followed by rand, G. Ken Holman | Date | [xsl] XSL-List Guidelines, B Tommie Usdin |
Month |