Need to remove <?xml version=“1.0” encoding=“utf-16”?> from the xml

前端 未结 4 1638
你的背包
你的背包 2021-01-01 11:31

Hi i am generating a xml by appying the xsl to a xml input. I need the output without this part \"\"

in

相关标签:
4条回答
  • 2021-01-01 11:58

    Use this XSLT to remove encoding=“UTF-8” from xml Document using XSLT.In Cdaata section You can add encoding as your will. Cheers:)

    <?xml version="1.0" encoding="UTF-8" ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="xml" omit-xml-declaration="yes"/>
        <xsl:template match="/">
            <xsl:text disable-output-escaping="yes"><![CDATA[<?xml version="1.0"?>]]></xsl:text>
            <xsl:copy-of select="node()"/>
        </xsl:template>
    </xsl:stylesheet>
    
    0 讨论(0)
  • 2021-01-01 12:03

    Try adding the omit-xml-declaration="yes" attribute to your xsl:output tag.

    It should then read like this:

    <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
    
    0 讨论(0)
  • 2021-01-01 12:03

    Put this in your xslt

    <xsl:output method="xml" omit-xml-declaration="yes"/>
    

    or

    at an extreme push

    <xsl:output method="text" />
    

    should solve the symptom...

    The last one could have significant consequences though depending on the processor.

    0 讨论(0)
  • 2021-01-01 12:07

    This complete transformation:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
     xmlns:JT="http://jerseytelecom.com/" exclude-result-prefixes="soap JT">
    <xsl:output omit-xml-declaration="yes" indent="yes"
         encoding="utf-8"/>
     <xsl:template match="/">
      <Entity>
       <xsl:value-of select=
       "soap:Envelope/soap:Body/JT:CreateResponse
                  /JT:CreateResult/JT:ISD_XMLGateway/JT:Entity"/>
      </Entity>
     </xsl:template>
    </xsl:stylesheet>
    

    when applied on the provided XML document:

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope
     xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
    <CreateResponse xmlns="http://jerseytelecom.com/">
        <CreateResult>
            <ISD_XMLGateway>
                <Entity>RIM_BPS</Entity>
             </ISD_XMLGateway>
        </CreateResult>
       </CreateResponse>
    </soap:Body>
    </soap:Envelope>
    

    produces the wanted, correct result:

    <Entity>RIM_BPS</Entity>
    
    0 讨论(0)
提交回复
热议问题