如何从输出xml中删除名称空间? [英] How to remove namespace from the output xml?

查看:66
本文介绍了如何从输出xml中删除名称空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的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>

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

I need to remove xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" from the xml output

推荐答案

要排除名称空间,则应以这种方式表示:-

To exclude a namespace then you should represent this way:-

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">

这篇关于如何从输出xml中删除名称空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆