Search code examples
ibm-integration-busextended-sql

Acces XMLNSC tag value in ESQL


I need to access some XML values and concatenate them as a file name for output document. The problem is that solution demands the message to be read in BLOB format so ESQL script must first translate the blob to CHARACTER/XMLNSC. See the code bellow. The ESQL code ends up with error when I run it in the message flow and resulting file is named just ".xml". I'm using IBM Integration Toolkit 12.

Code

        DECLARE CCSID INT InputRoot.Properties.CodedCharSetId;
        DECLARE encoding INT InputRoot.Properties.Encoding;
        DECLARE bitStream BLOB ASBITSTREAM(InputRoot.BLOB.BLOB, encoding, CCSID);

        CREATE LASTCHILD OF Environment.tempXML DOMAIN('XMLNSC') PARSE(bitStream, encoding, CCSID,'BLOB', 'XMLNSC');

        DECLARE seorno CHARACTER;
        DECLARE sejobn CHARACTER;
        SET seorno = FIELDVALUE(Environment.tempXML.ROOT.(XML.Element)SEORNO);
        SET sejobn = FIELDVALUE(Environment.tempXML.ROOT.(XML.Element)SEJOBN);
        SET OutputLocalEnvironment.Destination.File.Name = seorno || '-' || sejobn || '.xml';

Solution

  • I have just found an answer

    CREATE LASTCHILD OF InputRoot DOMAIN('XMLNSC') PARSE(InputRoot.BLOB.BLOB, InputRoot.Properties.Encoding, InputRoot.Properties.CodedCharSetId);
    
        DECLARE seorno CHARACTER;
        DECLARE sejobn CHARACTER;
    
        SET seorno = FIELDVALUE(InputRoot.XMLNSC.ROOT.(XMLNSC.Field)SEORNO);
        SET sejobn = FIELDVALUE(InputRoot.XMLNSC.ROOT.(XMLNSC.Field)SEJOBN);
        SET OutputLocalEnvironment.Destination.File.Name = seorno || '-' || sejobn || '.xml';