I have one XML where some raw values are present as nodeset. i want to make it as variable and use in further process. Please look into below stuff:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<element1>Some value in the element1</element1>
<element2 value="<sno>1</sno><name>Amrendra</name><mobile>0123456789</mobile>"></element2>
</root>
XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:variable name="element">
<root>
<xsl:value-of select="/root/element2/@value" disable-output-escaping="yes"/>
</root>
</xsl:variable>
<xsl:template match="/">
<root>
<applytemp>
<xsl:apply-templates select="$element/root/name"/>
</applytemp>
<copy-of>
<xsl:copy-of select="$element/root/name"/>
</copy-of>
<value-of>
<xsl:value-of select="$element/root/name"/>
</value-of>
</root>
</xsl:template>
</xsl:stylesheet>
CURRENT OUT:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<applytemp/>
<copy-of/>
<value-of/>
</root>
REQUIRED OUT:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<applytemp>Amrendra</applytemp>
<copy-of>Amrendra</copy-of>
<value-of>Amrendra</value-of>
</root>