函数functx:remove-attributes会自动向节点添加一个空@xmlns,我想防止这种行为。 示例 xml:
<mei meiversion="3.0.0" xmlns="http://www.music-encoding.org/ns/mei">
<note accid.ges="f" doxml.id="d28e18935" dur="8" oct="4" pname="e" tstamp="1.75" xml:id="note_112296"/>
</mei>
XSLT 摘录:
<xsl:copy-of select="functx:remove-attributes(., $attributes2remove)" />
当前(错误(XML 输出:
<note accid.ges="f" doxml.id="d28e18935" dur="8" oct="4" pname="e" tstamp="1.75" xml:id="note_112296" xmlns=""/>
在函数体中,我认为您想使用xsl:copy
而不是xsl:element
:
<xsl:function name="functx:remove-attributes" as="element()"
xmlns:functx="http://www.functx.com">
<xsl:param name="elements" as="element()*"/>
<xsl:param name="names" as="xs:string*"/>
<xsl:for-each select="$elements">
<xsl:copy>
<xsl:sequence
select="(@*[not(functx:name-test(name(),$names))],
node())"/>
</xsl:copy>
</xsl:for-each>
</xsl:function>
https://xsltfiddle.liberty-development.net/ejivJrP