identity template and attribute node cannot be created



I am using the identity template in XSLT and normally it works quite well. For the current batch of files I am getting 'An attribute node (class) cannot be created after a child of the containing element'.


If I understand this error message correctly, it tells me that I am trying to add an attribute on one element, but that the "cursor" has moved to the child element... How do I prevent this?


This is the template:



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


After I posted this, I found one suggestion in another similar question. Which was something in the line of: Create a match on @* So I added this:



<xsl:template match="@*">
<!-- don't do a thing -->
</xsl:template>


And the error message is gone and everything works.


No comments:

Post a Comment