1 回答

TA贡献1853条经验 获得超6个赞
您可以通过从 Python 调用以下 XSLT-1.0 模板来使用 XSLT 方法。它将身份模板与name()将元素的(完整)s转换为local-name()仅 s 的模板相结合。例如,这意味着所有<ns1:abc>元素都将转换<abc>为 。名称空间被省略。
但是,这有多大用处取决于您的用例。它减少了信息量,因此请小心处理。
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="node()|@*"> <!-- Identity template copies all nodes (except for elements, which are handled by the other template) -->
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>
<xsl:template match="*"> <!-- Removes all namespaces from all elements -->
<xsl:element name="{local-name()}">
<xsl:apply-templates select="node()|@*" />
</xsl:element>
</xsl:template>
</xsl:stylesheet>
将其与 XSLT-1.0(或更高版本)框架/处理器一起应用。
添加回答
举报