Ticker

6/recent/ticker-posts

How To Add CDATA Section in XML using ESQL

CDATA - CDATA is a property which we can use to transport any type of data lets say XML which is not formatted properly ie.

C Data tells XML parser not to parse the XML (data) inside these tags , A CDATA section starts with "<![CDATA[" and ends with "]]>" in Message broker or IIB we can achieve this using below code


DECLARE requestBlob BLOB ASBITSTREAM(outRef,OutputRoot.Properties.Encoding,OutputRoot.Properties.CodedCharSetId);
        DECLARE requestChar CHAR CAST(requestBlob AS CHARACTER CCSID OutputRoot.Properties.CodedCharSetId);
        DELETE FIELD OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.ser:serviceCall.xsd:requestBody.xsd:request;
        SET OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.ser:serviceCall.xsd:requestBody.(XMLNSC.CDataField)xsd:request = requestChar;


The output of above ESQL will be like below

<NS3:requestBody xmlns:NS3="example.com">
                    <NS3:request>
                        <![CDATA[<RequestXml><TxnRefNo>12342233</TxnRefNo><other data></RequestXml>]]></NS3:request>
                </NS3:requestBody>


By looking at above example you can format your ESQL, hope this help you, do let me know in comment if any further queries in the comment section below. Enjoy.


Post a Comment

2 Comments

  1. This comment has been removed by a blog administrator.

    ReplyDelete