XSLT - 删除所有属性 [英] XSLT - remove all attributes

查看:36
本文介绍了XSLT - 删除所有属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很简单的问题.没有找到确切的答案.

Pretty straightforward question. Didn't find an answer to exactly this one.

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

Would like to see XSLT 1.0 without attribute axis, and others too if possible (I am using python's lxml lib which is not really catching up on that stuff).

推荐答案

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

Your solution should work without issue, but there's an even easier way - just use an identity template that doesn't include attributes:

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

这篇关于XSLT - 删除所有属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆