XPath child :: * vs child :: node ()

I am working with XSLT conversion, and I found an interesting question that I could not answer:

What is the difference between child::*andchild::node()

I want to create a condition in which I limit the number of children to 1, in this case:

<xsl:if test="parent[count(child::*) eq 1])"> 

vs

<xsl:if test="parent[count(child::node()) eq 1])"> 

Who cares?

+4
source share
2 answers

To understand the difference between child::*and child::node()in XPath, to understand not only the difference between tests *and node()node, but also the concept of the main node axis type ...

Primary node Type

: , node element; node, . (, node attribute attribute, .)

child , node element.

Node

, child::* child::node() ,

  • * node child context node, * node node (element ),
  • node() node node, node() node . , child. :
    • root: , node .
    • :
    • :
    • : , .
    • namespace: , .
    • :
    • :

, child::* node, child::node() , node.

+4

:: * child:: node().

:

  • *
  • node() node, node, node

So child::* child::node() , , node. node: , , (. ).

+2

Source: https://habr.com/ru/post/1685320/


All Articles