Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List of XSLT instructions/functions that change the context node?

Does anyone know of a list of XSLT instructions/functions that change the context node?

For example, instruction like for-each is one of them.

like image 396
Pacerier Avatar asked Aug 05 '11 08:08

Pacerier


People also ask

How many trees are involved in XSL transformation?

Thus, XSLT processors model an XML document as a tree that contains seven kinds of nodes: The root. Elements. Text.

What are nodes in XSLT?

XSLT considers an XML file to consist of a tree of nodes , in which each element, attribute, and string of text contained in an element is a node. Each attribute of an element is a child node of that element's node; each child element is also a child node of that element's node.

What is context node in XPath?

A context node is the node the XPath processor is currently looking at. The context node changes as the XPath processor evaluates a query. If you pass a document to the XPath processor, the root node is the initial context node.


2 Answers

The obvious XSLT 2.0 instructions that change the context are for-each, apply-templates, for-each-group, and analyze-string. But there's also, for example, xsl:sort and xsl:key.

In XPath, the operators / and [] change the context. There are no functions that change the context.

like image 75
Michael Kay Avatar answered Nov 01 '22 22:11

Michael Kay


There are only two things in XSLT 1.0 that change the context and neither of them are functions. These are:

<xsl:apply-templates select='some-test'/>

(which will lead to the selected nodes being processed, each one becoming the context node as it is processed)

and

<xsl:for-each select='some-test'/>

In XSLT 2.0, you also have

<xsl:for-each-group/>

(which sets the context node in slightly more complex way than xsl:apply-templates and xsl:for-each

like image 42
Nic Gibson Avatar answered Nov 01 '22 22:11

Nic Gibson