> > However the following expressions
> >
> > /.
> > /self::node()
> >
> > refer (AFAIK) to the document node, not the first child node (the root
> > element). So the following expressions would return a blank string,
since
> > name() of a document is empty according to the XPath spec.
> >
> > name(/.) or name(/self::node())
>
> Ah, you're correct indeed.
>
> /node() should be the valid thing, (exactly as you presented
> yesterday), since the default axis for elements is child::,
> right?

Yes - though care should be taken with the node() syntax rather than *.
node() matches any type of node whereas * matches only elements.
This just bit me when I was doing some XPath testing as /node() would match
any comments or PIs in the document.

e.g. if you had this document

<!-- comment -->
<root>text</root>

then the path /node() would result in a node set of a Comment and an
Element. And so the following

name(/node())

would return a blank string (as node() has to use the first node in the node
set in document order, which is the Comment node). Whereas

name(/*)

would return "root" as the node set for /* does not include the Comment.

James



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


_______________________________________________
dom4j-dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to