Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Hi i am generating a xml by appying the xsl to a xml input. I need the output without this part "<?xml version="1.0" encoding="utf-16"?>"

input--xml

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

my xsl

    <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" 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" xmlns:JT="http://jerseytelecom.com/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="JT">          <xsl:output method="xml" indent="yes"/>          <xsl:template match="/">            <xsl:element name="Entity">             <xsl:value-of select="soap:Envelope/soap:Body/JT:CreateResponse/JT:CreateResult/JT:ISD_XMLGateway/JT:Entity"/>               </xsl:element>             </xsl:template>             </xsl:stylesheet> 

Current output

   <?xml version="1.0" encoding="utf-16"?>     <Entity>RIM_BPS</Entity> 

Expected Output

    <Entity>RIM_BPS</Entity> 
like image 924
shaiksha Avatar asked Feb 10 '13 17:02

shaiksha


People also ask

Is <? XML required?

<? xml version="1.0" encoding="UTF-8"?>

What is omit XML declaration?

The optional omit-xml-declaration attribute dictates whether the XSLT processor should output an XML declaration. The default is no and an XML declaration is output. If yes, there is no output.

What is the XML declaration?

An XML declaration is a processing instruction that identifies a document as XML. DITA documents must begin with an XML declaration.

What is XML version and encoding?

XML Encoding is defined as the process of converting Unicode characters into binary format and in XML when the processor reads the document it mandatorily encodes the statement to the declared type of encodings, the character encodings are specified through the attribute 'encoding'.


1 Answers

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" /> 
like image 99
ChrisC Avatar answered Sep 20 '22 18:09

ChrisC