[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: XPath Question

Subject: RE: XPath Question
From: "Lars Huttar" <lars_huttar@xxxxxxx>
Date: Wed, 31 Dec 2003 17:04:47 -0600
br tab
> >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
  • XPath Question
    • Kyle Partridge - Wed, 31 Dec 2003 13:16:31 -0500 (EST)
      • <Possible follow-ups>
      • Ryan Graham - Wed, 31 Dec 2003 13:35:11 -0500 (EST)
        • Lars Huttar - Wed, 31 Dec 2003 18:05:31 -0500 (EST) <=

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.