如何从输出xml中删除命名空间?

use*_*464 15 xml xslt xpath namespaces xml-namespaces

下面是我的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>
Run Code Online (Sandbox Code Playgroud)

在输出中我得到如下

<?xml version="1.0" encoding="UTF-16"?>
<XMLResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Product>-----</Product>
</XMLResponse>
Run Code Online (Sandbox Code Playgroud)

我需要xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"从xml输出中删除

Siv*_*ran 44

要排除命名空间,您应该这样表达: -

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">
Run Code Online (Sandbox Code Playgroud)