2

很直接的问题。没有找到确切的答案。

希望看到没有属性轴的 XSLT 1.0,如果可能的话也希望看到其他的(我正在使用 python 的 lxml 库,它并没有真正赶上那些东西)。

4

2 回答 2

8

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

<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>
于 2013-04-03T19:09:14.560 回答
0

我在写问题时自己想通了。仍然发布它,因为我找不到它:

<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>

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

于 2013-04-03T18:28:56.697 回答