如何从输出 xml 中删除命名空间?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9352412/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to remove namespace from the output xml?
提问by user475464
Below is my xsl
下面是我的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>
In the output i getting like below
在输出中我得到如下
<?xml version="1.0" encoding="UTF-16"?>
<XMLResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Product>-----</Product>
</XMLResponse>
I need to remove xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"from the xml output
我需要xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"从 xml 输出中删除
回答by Siva Charan
To exclude a namespace then you should represent this way:-
要排除命名空间,则应以这种方式表示:-
exclude-result-prefixes="ms ns xsi"
exclude-result-prefixes="ms ns xsi”
Basically your stylesheet looks like this:-
基本上你的样式表是这样的:-
<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">

