【发布时间】:2021-01-05 03:40:32
【问题描述】:
我想复制一个 xml 并用一个变量替换内部文本。 这是我创建的 xslt
<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>
上面的xslt是为了转化下面的XML
<?xml version="1.0" encoding="utf-8"?><ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings"><InstrumentationKey>TestData</InstrumentationKey></ApplicationInsights>
我收到了错误,即 xsl:text 中不允许
【问题讨论】: