当我执行下面的xsl时,我得到一个截断的标签对而不是完整的标签(参见问题的最后)。用“xsl:value-of select”截断标签
原始代码:
<xsl:template match="node()\@*">
<xsl:copy>
<xsl:apply-templates select="node()\@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="CONFIG">
<xsl:choose>
<xsl:when test=" ../ID/.='2'">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:text>STANDARD</xsl:text>
</xsl:copy>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="NAME">
<xsl:choose>
<xsl:when test=" ../ID/.='2'">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:text>DEVELOPMENT</xsl:text>
</xsl:copy>
</xsl:when>
</xsl:choose>
</xsl:template>
修改后的代码:
<xsl:template match="node()\@*">
<xsl:copy>
<xsl:apply-templates select="node()\@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="CONFIG">
<xsl:choose>
<xsl:when test=" ../ID/.='2'">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:text>STD</xsl:text>
</xsl:copy>
<xsl:attribute name="KEY">
<xsl:value-of select='0'/>
<xsl:attribute>
<xsl:attribute name="NAME">
<xsl:value-of select="'DEVELOPMENT'"/>
<xsl:attribute>
</xsl:when>
</xsl:choose>
</xsl:template>
这样的想法,而不是仅仅将CONFIG “标准”,我也想给SET键。 而不是处理相同的“查询”两次,我把名称的设置了。
KEY设置正确;但我得到的截断 <NAME>
代替
<NAME>DEVELOPMENT</NAME>
我显然不是一个XML的家伙,只是在做一些维护。任何线索或建议表示赞赏。
什么是'node()\ @ *'? – Tomalak
我怀疑反斜杠是'|' –