Xslt 如何不复制某些属性?
我需要从输入文档复制到输出文档的所有属性,只有一个除外 我的输入如下:Xslt 如何不复制某些属性?,xslt,xpath,Xslt,Xpath,我需要从输入文档复制到输出文档的所有属性,只有一个除外 我的输入如下: <mylink id="nextButton" type="next" href="javascript:;" /> <a id="nextButton" href="javascript:;" /> <a id="nextButton" type="next" href="javascript:;" /> 我需要这样的输出: <mylink id="nextButton"
<mylink id="nextButton" type="next" href="javascript:;" />
<a id="nextButton" href="javascript:;" />
<a id="nextButton" type="next" href="javascript:;" />
我需要这样的输出:
<mylink id="nextButton" type="next" href="javascript:;" />
<a id="nextButton" href="javascript:;" />
<a id="nextButton" type="next" href="javascript:;" />
我将所有属性按如下方式输出:
<mylink id="nextButton" type="next" href="javascript:;" />
<a id="nextButton" href="javascript:;" />
<a id="nextButton" type="next" href="javascript:;" />
但是我想忽略“type”属性。
我尝试了以下方法,但没有一种方法能满足我的需要:
<xsl:copy-of select="attribute::!type"/>
<xsl:copy-of select="attribute::!'type'"/>
<xsl:copy-of select="attribute::*[!type]"/>
<xsl:copy-of select="attribute::not(type)"/>
如何编写样式表以获得所需的输出?最短格式:
<xsl:template match="mylink">
<a><xsl:copy-of select="@*[name()!='type']"/></a>
</xsl:template>
长一点的(这是我想到的第一件事,我留作参考):
在XSLT 2.0中:
<xsl:template match="mylink">
<a><xsl:copy-of select="@* except @type"/></a>
</xsl:template>
我使用了较长的一个来替换属性的名称(“将
类型更改为类”)。是否有一个版本的较短的,将完成同样的事情?