Input xml:
<Parent>
<Child attr="thing">stuff</Child>
</Parent>
xslt:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="Child">
<newChild chars="{..}" />
</xsl:template>
</xsl:stylesheet>
Desired otuput:
<newChild chars="<Child attr="thing">stuff</Child>" />
Note that the value of the 'chars' attribute is just the escaped version of the 'Child' tag.
Problem: how do I get the currently matched element in to the attribute? I though that ..
would normally do it, but seems not to when talking about attributes, I just get some random xml entities followed by the value of the Child tag e.g. <newChild chars="
 stuff
"/>
. I'm expecting there might need to be some escaping stuff to make it valid.
Any suggestions appreciated.
(and before everyone asks why I'd want to do something like this, I'm constrained by the api of the application I'm connecting to)