I want to copy an xml and replace inner text with a variable. Here's the xslt I've created
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns2="http://schemas.microsoft.com/ApplicationInsights/2013/Settings" exclude-result-prefixes="ns2">
<xsl:param name="InstrumentationKey" />
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="ns2:InstrumentationKey">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:text>
<xsl:value-of select="$InstrumentationKey" />
</xsl:text>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
The above xslt is to transform the following XML
<?xml version="1.0" encoding="utf-8"?><ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings"><InstrumentationKey>TestData</InstrumentationKey></ApplicationInsights>
I'm getting back error that <xsl:value-of not allowed in xsl:text. Any idea how I can replace inner text with a variable?