Reputation: 135
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';
Upvotes: 1
Views: 2121
Reputation: 2422
You have probably worked this out already, but you cannot use field type constants like XML.Element with the XMLNSC parser. You must always use constants prefixed with 'XMLNSC'.
In case it helps, you can make your code more compact by initialising the variables as part of the DECLARE statement:
DECLARE seorno CHARACTER FIELDVALUE(InputRoot.XMLNSC.ROOT.(XMLNSC.Field)SEORNO);
Upvotes: 1
Reputation: 135
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';
Upvotes: 1