簡體   English   中英

如何從輸出xml中刪除命名空間?

[英]How to remove namespace from the output 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>

在輸出中我得到如下

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM