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

Re: Relative XPATH between 2 nodes

Subject: Re: Relative XPATH between 2 nodes
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 28 Jan 2005 15:42:24 GMT
xpath relative namespace
  That's not necessary the case.

'tis so:-)

 (except for the special cases of replacing self::*[1] and
ancestor::*[1] by . and ..)


  Here is the example
  Node A:
  /A/B[2]/C[text()='test']/text()
  Node B:
  /A/B/D[@a='123']/comment()
  The short cut doesn't follow xxx::*[n]

I wrote

> then I think in general for two element nodes, 

Just to save me writing out the full version, which I will now do:-)

neither of those are element nodes. if you want to include text and
comment nodes then just replace * by node() (and use a different number
for n)

If you need to include namespace and attribute nodes as a possibility for
the target then you  can use the above format to find the parent and add
oe more step namespace::abc or attribute::abc.

So you never need more than two steps.

So the general format for the shortest relative Xpath between two nodes
in the same document is is one of


.
..
xxx::node()[n]
yyy:zzz
../yyy:zzz
xxx::node()[n]/yyy:zzz


where

 xxx is one of a
  ancestor self preceding following descendant
 yyy is one of
   namespace attribute
 zzz is a QName (name of an attribute or namespace node)
and n is a positive integer


You could get a shorter path than that eg if there is only one foo child
you could use foo rather than descendant::foo[1] but you can not use
less steps I believe.

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
________________________________________________________________________

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.