Given this XML...
<?xml version="1.0" encoding="UTF-8"?>
<root>
<item>
<this>
<that>one</that>
</this>
</item>
<item>
<this>
<that>two</that>
</this>
</item>
<item>
<this>
<that>three</that>
</this>
</item>
</root>
I want to make copies of the items into a new format which looks like...
<new>
<parm x=">that<one>/that<"/>
<parm x=">that<two>/that<"/>
<parm x=">that<three>/that<"/>
</new>
The style sheet...
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xml" indent="yes"/>
<xsl:param name="feedKey"/>
<xsl:template match="/">
<new>
<xsl:apply-templates select="//item"/>
</new>
</xsl:template>
<xsl:template match="item">
<xsl:element name="param">
<xsl:attribute name="x"><xsl:copy-of select="node()"/></xsl:attribute>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
...produces...
<?xml version="1.0" encoding="UTF-8"?>
<new>
<param x="
 
one
 
 "/>
<param x="
 
two
 
 "/>
<param x="
 
three
 
 "/>
</new>
A simple change to the sheet to remove the attribute...
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xml" indent="yes"/>
<xsl:param name="feedKey"/>
<xsl:template match="/">
<new>
<xsl:apply-templates select="//item"/>
</new>
</xsl:template>
<xsl:template match="item">
<xsl:element name="param">
<xsl:copy-of select="node()"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
...produces...
<?xml version="1.0" encoding="UTF-8"?>
<new>
<param>
<this>
<that>one</that>
</this>
</param>
<param>
<this>
<that>two</that>
</this>
</param>
<param>
<this>
<that>three</that>
</this>
</param>
</new>
How can I convert "this" into attribute "x" with the white space stripped and the tags encoded?