cancel
Showing results for 
Search instead for 
Did you mean: 

adding <?xml version="1.0" encoding="UTF-8"?> in the middle of output payload in xslt

former_member214909
Participant
0 Kudos

/DoHello All,

I am working on XSLT Mapping where we are configuring the MQ Header in xslt mapping.

after removing MQ header detail by MQ from output file we need to add XML version tag for further processing but xslt is not allowing to add any related tag in the middle of the file so can anyone please suggest how to achieve this.

My code :

<?xml version="1.0"?>

<!-- $Id: XMLStatementSingle_MQHeader.xsl 7799 2015-06-26 13:52:36Z NEOMORE\erktaa $ -->

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

<xsl:output method="xml" encoding="ISO-8859-1"/>

<xsl:param name="MessageId"/>

<xsl:template match="/">

  <xsl:text disable-output-escaping="yes">&lt;</xsl:text>!DOCTYPE MessageHeader<xsl:text disable-output-escaping="yes">&gt;</xsl:text>

  <xsl:text>&#xa;</xsl:text>

            <MessageHeader>

                       <xsl:text>&#xa;</xsl:text>

                                 <File>

                                         <xsl:value-of select="concat('abc', '.xml')"/>

                                     </File>

                       <xsl:text>&#xa;</xsl:text>

            </MessageHeader>

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

  <xsl:processing-instruction name="xml-stylesheet">

   <xsl:text>type="text/xsl" href="abc.xsl"</xsl:text>

  </xsl:processing-instruction>

</xsl:template>


I want to add   <?xml version="1.0" encoding="UTF-8"?> after <MessageHeader> tag so that we will get the same in output xml but XSLT is not allowing to this tag by any way so can some one please help me how can we achieve this.

Required output :

<?xml version="1.0" encoding="ISO-8859-1"?>

<MessageHeader>

<FIle>abc.xml</File>

<MessageHeader>

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

<?xml-stylesheet type="text/xsl" href="abc.xsl"?>

<Document>

...................

.....................

</Document>

Thanks in advance.

Anant

Accepted Solutions (0)

Answers (1)

Answers (1)

stefan_grube
Active Contributor
0 Kudos

You cannot create invalid XML with XSLT. So there is no way to achieve this. The only possible way to create invalid XML or any other type of output is usig Java mapping.