2013-06-30 47 views
0

我想使用XSLT为我的xml删除特定的命名空间。通过XSLT删除特定的命名空间

例如

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<root xmlns="http://test.com" xmlns:ns2="http://test2.com"> 
    <ns2:element1>hello</ns2:element1> 
    <ns2:element2>hello</ns2:element2> 
</root> 

如何拿出来的XSLT删除http://test.com命名空间?

感谢

+1

您注意,删除名称空间声明会改变你的文件的语义?实际上,'root'位于'http:// test.com'命名空间中,因为这是该点的默认命名空间。当您删除'xmlns =“http://test.com”'时,'root'将不再位于该名称空间中,这将影响该元素的模式验证和XSLT名称匹配。 – Dabbler

回答

0

尝试像

<xsl:template match="ns2:*"> 
    <xsl:element name="local-name()"> 
     <xsl:copy-of select="*"> 
    </xsl:element> 
</xsl:template> 
+1

最好使用''。 – Tomalak