tags:

views:

55

answers:

2
+1  Q: 

what // in xslt?

what // in xslt? e.g. ($currentPage//node)

+2  A: 

That looks like it's part of XPath, which can be used within XSLT to search the tree for given nodes matching a path. It's a similar technology to CSS selectors.

The double slash does a descendant search at any depth.

For example:

elementa//elementb

would match any elementb element which is a descendent of an elementa element, even if there are other levels in between, eg:

<elementa>
  <someelement>
    <elementb>
    </elementb>
  </someelement>
</elementa>
thomasrutter
+1  A: 

what // in xslt? e.g. ($currentPage//node)

In XPath the abbreviation:

// is short for /descendant-or-self::node()/

The value of some attributes of xslt instructions (such as the select attribute) must be an XPath expression.

Therefore,

($currentPage//node)

stands for

($currentPage/descendant-or-self::node()/node)

This selects all elements named node that are children of nodes that are either contained in the variable $currentPage or are descendents of nodes that are contained in the variable $currentPage.

Do note that in the provided expression node() is a node-test (it selects all node types on the descendant-or-self:: axis, such as elements, text nodes, comments and processing-instructions.

On the other side, somePath/node is a shorthand for somePath/child::node and only selects elements named node that are children of the context node.

I strongly recommend not to use the name node for an element in order to avoid this confusion.

Dimitre Novatchev
@Dimitre - I'm nitpicking on what is otherwise a good answer, but the penultimate paragraph's incorrect. They won't be children of the context node, they'll be children of the nodes selected by 'somePath'
Alohci
@Alohci: Yes and the "context node" at any moment is the node, from which the next location-step is performed -- this means that `child::node` is determined in `somePath/child::node`, the context node is any node that is selected by `somePath`. So, both you and I are saying the same thing :)
Dimitre Novatchev