cancel
Showing results for 
Search instead for 
Did you mean: 

Need to remove XML version header on XML Document

Former Member
0 Kudos

Hello Everybody,

I am generating an XML file using an FTP adapter and in the generated XML we are having first line as

<XML vesrion ... >, is there any way to remove this line from XML document?

Please provide your inputs as soon as possible.

thanks,

Vijay Kumar T.

Accepted Solutions (1)

Accepted Solutions (1)

stefan_grube
Active Contributor
0 Kudos

Use this xslt:

<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:copy-of select="." /> 
  </xsl:template>
  </xsl:stylesheet>

Former Member
0 Kudos

Hi Stefan,

Thanks for your solution it resolved my issue.

Thanks,

Vijay Kumar T.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Open your Message Type in Integration Repository and from field 'XML Namespace', just delete it from there. Thta's it.

Regards,

Sarvesh

Former Member
0 Kudos

Hi Sarvesh,

I am using External definition XSD for my purpose and i am importing the XSD by removing the header line but then also it is coming as first line while creating External definition. Please provide me any other thoughts.

Thanks,

Vijay Kumar T.

Former Member
0 Kudos

If it is possible to use Data Type instead of XSD then you can remove the namespace from corresponding Message Type in which you will use this Data Type.

Regards,

Sarvesh

Former Member
0 Kudos

Hi Sarvesh,

Even we are able to delete the XML namespace from XSD itself but the problem is with the first line which specifies XML version, i need to remove that line in generanted XML file.

Thanks,

Vijay Kumar T.

Former Member
0 Kudos

Hi,

As Kulwant said is correct use XSLT mapping. take the help of this blog..

Regards,

Sarvesh

VijayKonam
Active Contributor
0 Kudos

I do not know your requirement but, and XML file file without XML tag header is invalid as per w3c standards.

VJ

Former Member
0 Kudos

Hi,

Yes, i know, but you can open XML file with out that header line and it is client requirement not to have that heade line for them to process on their side.

Thanks,

Vijay Kumar T.

Former Member
0 Kudos

Hello Vijay,

It is possible using XSLT mapping. We had simliar requirement.I have done that.

1. Convert you input XML data in String. Below is the code to do that

<a:ReceiveXml>

<xml>

<xsl:text disable-output-escaping="yes"><![CDATA[<![CDATA[]]></xsl:text>

<xsl:copy-of select="VendorLink"/>

<xsl:text disable-output-escaping="yes"><![CDATA[]]]]></xsl:text>

<xsl:text disable-output-escaping="yes"><![CDATA[>]]></xsl:text>

</xml>

</a:ReceiveXml>

2. Use Replace function of mapping to rempove XML declaration.

3. Convert String to XML data again usiong XSLT mapping.

<?xml version='1.0'?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:tns="your namespace">

<xsl:template match="/">

<xsl:for-each select="//tns:xml">

<xsl:value-of select="." disable-output-escaping="yes"/>

</xsl:for-each>

</xsl:template>

</xsl:stylesheet>

You can find it on the SDN more about to convert XML to string and back to XML

Thanks

-Kulwant

Edited by: Kulwant Bhatia on Nov 12, 2008 4:06 PM

Former Member
0 Kudos

Hi Kulwant,

thanks for your inputs,

i have used XSLT mapping to convert the XML file ( after graphical mapping ) to string, below is the code that i used

<?xml version='1.0' ?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">

<name>

<xsl:text disable-output-escaping="yes"><![CDATA[<![CDATA[]]></xsl:text>

<xsl:copy-of select="/"/>

<xsl:text disable-output-escaping="yes"><![CDATA[]]]]></xsl:text>

<xsl:text disable-output-escaping="yes"><![CDATA[>]]></xsl:text>

</name>

</xsl:template>

</xsl:stylesheet>

with this above i am able to get entire xml document in one string but i am not able to see xml vesrion header line at all, it is having remaining data except first line.

Please suggest us.

Thanks,

Vijay Kumar T.