What does this do? <xsl:apply-templates select="."/> and <xsl:apply-templates select="*|@*"/>

xslt, xslt-2.0

Solution

Check out the Abbreviated Syntax section of XPath 2.0.

In the `<xsl:apply-templates select="."/>` example, `.` evaluates to the context item. In most cases, this is the same as the node currently being processed. So this example will select the context node.

In the `<xsl:apply-templates select="*|@*"/>` example, `*` will select all the child elements of the context node. `@*` will select all the attributes of the context node. `|` is the union operator. So this example will select all the child elements of the context node and also all the attributes of the context node.

`<xsl:apply-templates select="."/>` is frequently used to apply further processing to the context node.

`<xsl:apply-templates select="*|@*"/>` is frequently used to process all the child elements of the current node and its attributes. It’s often used when you’re done handling an element and want to hand off its child elements/attributes to any other templates that apply.

Problem

I am very new to XSL and I am confused about what the select inside the following pieces of code will select. ``` <xsl:apply-templates select="."/> <xsl:apply-templates select="*|@*"/> ``` Any ideas? Thanks

Original source