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

RE: selecting the nearest preceding sibling

Subject: RE: selecting the nearest preceding sibling
From: David Neary <David@xxxxxxxxx>
Date: Tue, 13 May 2003 15:40:42 +0200
RE:  selecting the nearest preceding sibling
De : Mukul [mailto:mukulw3@xxxxxxxxx]
> My XML file is below

[snip]

> I want to write **a XPATH expression which will select
> the nearest preceding sibling , which contains a
> particular element ( <a> in this example) ** . I do
> not want preceding sibling which do not contain the
> <a> tag (also the tag <a> should be nearest to the
> context node)
> 
> for e.g. if the context node is node 5 , the XPATH
> expression which will select node 3(because it
> contains element <a>) or for e.g. if the context node
> is node 2 , the XPATH expression will select node
> 1(because it contains element <a>)

OK - the node set of all the preceding siblings which 
fit the criterium is given by 

preceding-sibling::tag[a]

The nearest preceding sibling fitting the criterium is 
the last one in that nodeset (the nodes are always in 
document order)... that is, 

preceding-sibling::tag[a and last()]

Hope this works,

Cheers,
Dave.


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


Current Thread

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.