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

RE: relative path from one node to another (XSLT 2.0

Subject: RE: relative path from one node to another (XSLT 2.0 solution)
From: "Ross, Douglas" <DRoss@xxxxxxxxxx>
Date: Fri, 20 May 2005 13:06:49 -0400
xsl up one node
Richard,

Did you just say RegEx is easy?! You are much smarter than you give
yourself credit for. :) Xpath started to make a lot more sense to me
when I implemented a simple XPath engine in ECMA Script for finding
nodes in HTML clients. I finally understand axis, determinates and the
current context node. Even with this understanding, I still find a lot
of this stuff is magic! By the way, my new moto is "XML is all!"

Douglas Ross
Developer, HTML UI Framework
Kronos
www.kronos.com

-----Original Message-----
From: Richard Lewis [mailto:richardlewis@xxxxxxxxxxxxxx]
Sent: Friday, May 20, 2005 12:33 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  relative path from one node to another (XSLT 2.0
solution)


On Fri, 20 May 2005 12:02:18 +0100, "David Carlisle" <davidc@xxxxxxxxx>
said:
>
>   //*[@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.
>
Oh, yes. I haven't got a DTD (yet). I was going to change the code I
posted to include the id() function so y'all didn't think I was stupid;
but then I forgot. So, evidently, I *am* stupid. Oh, well...

>   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']
>
Right. This works (just goes to show how little I really understand
XPath!)

> 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)
>
Hmm, yes that was a bit weird.
>
> 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.
>
Yes, thats right. I think I did say I was doing it like that; but not
because I thought that was a good way of doing it - just an easy way.
Yet again, my ignorance of XPath comes through: I never knew there were
intersect and except operators! (I wonder if XPath ignorance is
widespread or whether its just me? Is XPath difficult? I get on with C
all right and regular expressions are easy, but I often seem to get
stuck with XPath. Does anyone else feel like this?.....)

Cheers for your comments!

Richard

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.