我有以下情况。
<xsl:template match="/s0:NotChangableTemplate">
<ns0:Root>
<xsl:for-each select="s0:Element">
<xsl:variable name="var" select="ext:MyCustomFunction(string(s0:Input/text()))" />
<xsl:call-template name="MyTemplate">
<xsl:with-param name="param" select="string($var)" />
</xsl:call-template>
</xsl:for-each>
</ns0:Root>
</xsl:template>
<xsl:template name="MyTemplate">
<xsl:param name="param" />
<xsl:variable name="myVar">
<xsl:value-of select="$param" disable-output-escaping="yes" />
</xsl:variable>
<xsl:for-each select="msxsl:node-set($myVar)/s0:Value">
<xsl:copy-of select="self::node()" />
</xsl:for-each>
</xsl:template>
模板/s0:NotChangableTemplate
是生成的代码,我无法更改它。该函数MyCustomFunction
返回即以下XML 片段作为字符串。
<s0:Value>'74024042','66111050','74024046','66110042','32060090'</s0:Value>
<s0:Value>'66111040','53260042','17439060','66111048','74024040'</s0:Value>
<s0:Value>'66110040','66110048','66110044','74024044','53283040'</s0:Value>
<s0:Value>'66111044','66111042','66111046','74024036','66110046'</s0:Value>
<s0:Value>'18235','17439058','53283038','53260036','66111038'</s0:Value>
<s0:Value>'74024038'</s0:Value>
在MyTemplate
我想将它解析为一棵树并浏览它。在这个虚拟函数中,我只想将节点复制到输出 XML 中。但是s0:Value
找不到节点。
如果我在变量中设置片段修复它可以工作。
<xsl:template name="MyTemplate">
<xsl:variable name="myVar">
<s0:Value>'74024042','66111050','74024046','66110042','32060090'</s0:Value>
<s0:Value>'66111040','53260042','17439060','66111048','74024040'</s0:Value>
<s0:Value>'66110040','66110048','66110044','74024044','53283040'</s0:Value>
<s0:Value>'66111044','66111042','66111046','74024036','66110046'</s0:Value>
<s0:Value>'18235','17439058','53283038','53260036','66111038'</s0:Value>
<s0:Value>'74024038'</s0:Value>
</xsl:variable>
<xsl:for-each select="msxsl:node-set($myVar)/s0:Value">
<xsl:copy-of select="self::node()" />
</xsl:for-each>
</xsl:template>
我可以改变什么,MyTemplate
因为它也可以在带有修复变量值的示例中工作?
提前致谢。