As written, this template matches an element node, so the attribute tag
would need to be wrapped in an element, as you indicate.
The template was perfectly valid as it stood. The element that contains
the attribute in the result tree does not have to be generated by the
same template as generates the attribute.
<xsl:template match="/report/version[(_at_)id]">
<xsl:attribute name="id">bar</xsl:attribute>
</xsl:template>
<xsl:template match="/report/version/@id">
<xsl:attribute name="id">bar</xsl:attribute>
</xsl:template>
Both have the same status. If they are triggerd by an apply-templates in
a context such as
<foo>
<xsl:apply-templates select=",,,,,
Then they are OK, and add an id attribute to foo.
If they are triggered by a context such as
<foo>
some text
<xsl:apply-templates select=",,,,,
then they are an error as you can't add attribute after the text node
has been added.
David
________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--