user3813234
user3813234

Reputation: 1682

why does this version of xslt 2.0 identity transform not work?

Why does this not also copy all the nodes in the document, like the xslt identity transform?

<xsl:template match="/">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>

Why does the template have to match @* | node() as well?

Upvotes: 0

Views: 128

Answers (1)

michael.hor257k
michael.hor257k

Reputation: 116993

The identity transform template works recursively. When it calls:

<xsl:apply-templates select="@* | node()"/>

it applies itself (unless another template with a higher priority exist) to the child attributes and nodes of the current node.

Your version matches and processes only the / root node. When it calls for templates to be applied to the children, the processor will look for templates that match these - and your template will not be among them.

Upvotes: 1

Related Questions