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[(_at_)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
________________________________________________________________________
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--