Hi;
I think I've read the spec at least 5 times. And I have 4 books on XML/XPath
that I have gone through. But I still trip on stuff - and figure it's best to
ask and ask until I know I understand a point well. I appreciate everyone
explaining the why behind this.
As soon as you said the .. is the node containing the namespace I realized
why it's ../.. instead of .. - should have figured that out.
One thing that hit me while going through this, it seems that xpath
basically walks the tree node by node to determine if that node matches the
xpath. If it does, it adds that node to the node(s) to be returned and walks
on to the next one. (Obviously in implementation it does not walk nodes it
knows can't match.)
So it makes sense that you can use . in the xpath to represent the node you
are presently evaluating. But I hadn't really comprehended that before as a
SQL select has no similiar concept.
Anyways, thanks for the lesson - I think I understand this now and this is
definitely useful info.
--
thanks - dave
"Martin Honnen" wrote:
David Thielen wrote:
Ok, that makes sense. To make sure I understand this:
../../namespace::* is getting the grandparent of the node on (../../) and
then getting any nodes in that element that start with namespace:: - why not
../namespace::* - isn't that the parent?
It helps looking into the XPath spec which here
<http://www.w3.org/TR/xpath#namespace-nodes>
says about the namespace nodes:
"Each element has an associated set of namespace nodes, one for each
distinct namespace prefix that is in scope for the element (including
the xml prefix, which is implicitly declared by the XML Namespaces
Recommendation [XML Names]) and one for the default namespace if one is
in scope for the element. The element is the parent of each of these
namespace nodes"
thus if you have a predicate on
//namespace::*
then
..
gives you the element the namespace node belongs to and
../..
gives the parent node of that element so that the predicate
not(../../namespace::*=.)
compares the namespace node on one element with the namespace nodes
attached to the parent element.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/