Reputation: 455
please forgive me my beginner question.
I have seen xsl templates like this quite a number of times now and I do not know what it actually does. can someone explain please? Thanks!
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
Upvotes: 0
Views: 44
Reputation: 167696
That template is the identity transformation template, it matches any node with the exception of document nodes and namespace nodes and does a shallow copy of the node and then processes its attribute and child nodes (as far as those exist).
The template is usually the starting point for transformations that want to change, delete and/or add certain nodes as you can override with e.g.
<xsl:template match="foo">
<bar>
<xsl:apply-templates select="@* | node()"/>
</bar>
</xsl:template>
to transform foo
elements to bar
elements, with e.g.
<xsl:template match="baz"/>
to remove baz
elements and with e.g.
<xsl:template match="foobar">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
<whatever>...</whatever>
</xsl:copy>
</xsl:template>
to add a whatever
element to foobar
elements.
Upvotes: 1