Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.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
Xml XSLT-删除所有属性_Xml_Xslt_Xslt 1.0 - Fatal编程技术网

Xml XSLT-删除所有属性

Xml XSLT-删除所有属性,xml,xslt,xslt-1.0,Xml,Xslt,Xslt 1.0,这个问题很简单。没有找到确切的答案 希望看到没有属性轴的XSLT1.0,如果可能的话,还有其他的(我使用的是python的lxml库,它并没有真正赶上这方面的东西)。我在写问题时自己解决了这个问题。因为我找不到,所以仍在张贴: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" indent

这个问题很简单。没有找到确切的答案


希望看到没有属性轴的XSLT1.0,如果可能的话,还有其他的(我使用的是python的lxml库,它并没有真正赶上这方面的东西)。

我在写问题时自己解决了这个问题。因为我找不到,所以仍在张贴:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output omit-xml-declaration="yes" indent="yes"/>
  <xsl:strip-space elements="*"/>

  <xsl:template match="node()|@*" name="identity">
    <xsl:copy>
      <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="@*"/>

</xsl:stylesheet>


等待其他答案/评论,以防不完美。

您的解决方案应该可以正常工作,但还有一种更简单的方法-只需使用不包含属性的标识模板:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output omit-xml-declaration="yes" indent="yes"/>
  <xsl:strip-space elements="*"/>

  <xsl:template match="node()">
    <xsl:copy>
      <xsl:apply-templates />
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>

酷!当你看到它的时候似乎很明显