What does self::* means in XPath

V

Vijay

Hi

Can anybody explain what self::* means in Xpath. I understand that
"self" means the context node itself and * means any node type. So I
thought self::* meant all the child nodes of context, but I some where
read that self::* mean ".", the context itself. Can somebody please
explain this.

Vijay
 
M

Martin Honnen

Vijay wrote:

Can anybody explain what self::* means in Xpath. I understand that
"self" means the context node itself and * means any node type. So I
thought self::* meant all the child nodes of context, but I some where
read that self::* mean ".", the context itself. Can somebody please
explain this.

self is a so called axis in XPath along you can select nodes:
<http://www.w3.org/TR/xpath#axes>
* is a node test, it is true for any node type of the principal node
type of an axis, for the self axis that is the element node type.
If you have
self::*
then that is a so called location step, selecting any node along the
axis self of the type element.
As the self axis contains only the context node by definition
self::*
will either select the context node itself if that is an element node or
an empty nodeset otherwise.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,999
Messages
2,570,246
Members
46,839
Latest member
MartinaBur

Latest Threads

Top