Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xslt 如何不复制某些属性?_Xslt_Xpath - Fatal编程技术网

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>

我使用了较长的一个来替换属性的名称(“将
类型
更改为
”)。是否有一个版本的较短的,将完成同样的事情?