Re: relative path from one node to another (XSLT 2.0
> First thing I did was to give the document (root) node an id attribute terminological quibble: the document note (Xpath2 terminology) or root not (XPath 1 terminoligy) is / the notional top of the document, not the top level element (so it doesn't take an attribute). //*[@id=$from-id] That's a bit expensive (and you do it twice) if your file has a dtd and these are ID attributes you could use id($from-id) or if not you could set up an equivalent key and do the same thing. id($from-id)/ancestor::*[(name()='section' or name()='document') You could write that as id($from-id)/ancestor::*[self::section or self::document][@display='page'] or even, since this is xpath2 id($from-id)/(ancestor::*section|ancestor::document)[@display='page'] although I would guess this causes the system to do more node re-ordering (or perhaps it just get re-written back to the self:: form anyway) You are generating long paths going up to the top and down again however once you have the two sets of attribute nodes then you could use the xpath2 except operator to prune the nodes that are in both sets s so you only need to go up as far as the first ancestor that is shared between from-id and to-id. David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format