Reputation: 1682
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
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