1 回答

TA貢獻(xiàn)1853條經(jīng)驗(yàn) 獲得超6個(gè)贊
您可以通過從 Python 調(diào)用以下 XSLT-1.0 模板來使用 XSLT 方法。它將身份模板與name()將元素的(完整)s轉(zhuǎn)換為local-name()僅 s 的模板相結(jié)合。例如,這意味著所有<ns1:abc>元素都將轉(zhuǎn)換<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(或更高版本)框架/處理器一起應(yīng)用。
添加回答
舉報(bào)