下面是我的xsl
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ms="http://www.test.com/schemas/test"
xmlns:ns="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="ms ns">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<XMLResponse>
<xsl:apply-templates select="ms:ProductRS/ms:Product"/>
</XMLResponse>
</xsl:template>
<-- some templates here -->
</xsl:stylesheet>
在输出中我得到如下所示
<?xml version="1.0" encoding="UTF-16"?>
<XMLResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Product>-----</Product>
</XMLResponse>
我需要从 xml 输出中删除 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
最佳答案
要排除一个命名空间,那么你应该这样表示:-
exclude-result-prefixes="ms ns xsi
"
基本上你的样式表是这样的:-
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ms="http://www.test.com/schemas/test"
xmlns:ns="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="ms ns xsi">
关于xml - 如何从输出 xml 中删除 namespace ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9352412/