Author |
Message
|
eai_guy |
Posted: Mon Feb 08, 2010 11:31 pm Post subject: Not Able to Add element to XML Message |
|
|
Voyager
Joined: 18 Oct 2007 Posts: 90
|
Hi,
I m trying to add an XML element to an XML message which is received via a MQInput Node. The Flow is MQInput->Compute->MQOutput.
My sample input message which I m using to test the flow is as below
<?xml version="1.0" encoding="UTF-8"?>
<TenantOrgMsg xmlns="http://xyz.abc.com/TenantOrigMsgSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xyz.abc.com//TenantOrigMsgSchema TenantOrgMsg.xsd ">
<L1Element1>L1Element1</L1Element1>
<L1Element2 L1attr="121">
<L2Element1>L2Element1</L2Element1>
</L1Element2>
</TenantOrgMsg>
So I need to add an element called Error to this XML message when it comes to the compute node and my xml should look like
<?xml version="1.0" encoding="UTF-8"?>
<TenantOrgMsg xmlns="http://xyz.abc.com/TenantOrigMsgSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xyz.abc.com//TenantOrigMsgSchema TenantOrgMsg.xsd ">
<L1Element1>L1Element1</L1Element1>
<L1Element2 L1attr="121">
<L2Element1>L2Element1</L2Element1>
</L1Element2>
</TenantOrgMsg>
<Error>
<RetryCount>1</RetryCount>
</Error>
My ESQL in compute is as below
CALL CopyEntireMessage();
CREATE FIELD OutputRoot.XMLNSC.Error;
CREATE FIRSTCHILD OF OutputRoot.XMLNSC.Error TYPE NameValue NAME 'RetryCount' VALUE '1'
I have also tried creating field using Identity and so on....
By doing above I m able to see message being formed correctly under xmlnsc. But when the message goes onto MQOutput node it throws below in exception list
Any expert thoughts on this one. I tried searching on the forum and tried to make necessary changes but no luck
ParserException
File:CHARACTER:/build/S610_P/src/MTI/MTIforBroker/GenXmlParser4/ImbXMLNSCParser.cpp
Line:INTEGER:737
Function:CHARACTER:ImbXMLNSCParser::refreshBitStreamFromElementsCommon
Type:CHARACTER:ComIbmMQInputNode
Name:CHARACTER:RetryLogicPOCMsgFlow#FCMComposite_1_3
Label:CHARACTER:RetryLogicPOCMsgFlow.MQInput
Catalog:CHARACTER:BIPv610
Severity:INTEGER:3
Number:INTEGER:5010
Text:CHARACTER:XML Writing Errors have occurred
ParserException
File:CHARACTER:/build/S610_P/src/MTI/MTIforBroker/GenXmlParser4/ImbXMLNSCWriter.cpp
Line:INTEGER:880
Function:CHARACTER:ImbXMLNSCWriter::writeMisc
Type:CHARACTER:
Name:CHARACTER:
Label:CHARACTER:
Catalog:CHARACTER:BIPv610
Severity:INTEGER:3
Number:INTEGER:5016
Text:CHARACTER:Unexpected XML type at this point in document.
Insert
Type:INTEGER:5
Text:CHARACTER:Error
Insert
Type:INTEGER:5
Text:CHARACTER:folderType
ParserException
File:CHARACTER:/build/S610_P/src/MTI/MTIforBroker/GenXmlParser4/ImbXMLNSCParser.cpp
Line:INTEGER:737
Function:CHARACTER:ImbXMLNSCParser::refreshBitStreamFromElementsCommon
Type:CHARACTER:ComIbmMQInputNode
Name:CHARACTER:RetryLogicPOCMsgFlow#FCMComposite_1_3
Label:CHARACTER:RetryLogicPOCMsgFlow.MQInput
Catalog:CHARACTER:BIPv610
Severity:INTEGER:3
Number:INTEGER:5010
Text:CHARACTER:XML Writing Errors have occurred
ParserException
File:CHARACTER:/build/S610_P/src/MTI/MTIforBroker/GenXmlParser4/ImbXMLNSCWriter.cpp
Line:INTEGER:880
Function:CHARACTER:ImbXMLNSCWriter::writeMisc
Type:CHARACTER:
Name:CHARACTER:
Label:CHARACTER:
Catalog:CHARACTER:BIPv610
Severity:INTEGER:3
Number:INTEGER:5016
Text:CHARACTER:Unexpected XML type at this point in document.
Insert
Type:INTEGER:5
Text:CHARACTER:Error
Insert
Type:INTEGER:5
Text:CHARACTER:folderType |
|
Back to top |
|
 |
Gaya3 |
Posted: Mon Feb 08, 2010 11:45 pm Post subject: |
|
|
 Jedi
Joined: 12 Sep 2006 Posts: 2493 Location: Boston, US
|
XML has to comply its own rules and regulations.
XML should have only one header..and you are trying to create 2 different headers in it.
you are not supposed to create 2 root header to the same XML message that is the reason you are getting the Exception _________________ Regards
Gayathri
-----------------------------------------------
Do Something Before you Die |
|
Back to top |
|
 |
smdavies99 |
Posted: Tue Feb 09, 2010 1:06 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
If you put errors & code inside "code" tags, it really hels us read your posts.
What's wrong with using something like this?
Code: |
CREATE FIELD OutputRoot.XMLNSC.Error;
SET OutputRoot.XMLNSC.Error.RetryCount = 1;
|
_________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
Gaya3 |
Posted: Tue Feb 09, 2010 1:32 am Post subject: |
|
|
 Jedi
Joined: 12 Sep 2006 Posts: 2493 Location: Boston, US
|
smdavies99 wrote: |
If you put errors & code inside "code" tags, it really hels us read your posts.
What's wrong with using something like this?
Code: |
CREATE FIELD OutputRoot.XMLNSC.Error;
SET OutputRoot.XMLNSC.Error.RetryCount = 1;
|
|
but my question here it is how come an XML contains 2 root header elements. _________________ Regards
Gayathri
-----------------------------------------------
Do Something Before you Die |
|
Back to top |
|
 |
eai_guy |
Posted: Tue Feb 09, 2010 6:23 am Post subject: |
|
|
Voyager
Joined: 18 Oct 2007 Posts: 90
|
Hi,
You are right there can be one root/header element. Now I m trying to add an element inside the root , that is inside TenantOrgMsg by using below ESQLs
ESQL1 - This is creates an element "TenantOrgMsg" outside TenantOrgMsg root
Code: |
CREATE FIELD OutputRoot.XMLNS.TenantOrgMsg.Root IDENTITY (XML.ParserRoot)TenantOrgMsg;
CREATE LASTCHILD OF OutputRoot.XMLNS.TenantOrgMsg.Root
IDENTITY (XML.Element)ErrorCode VALUE 'Element 1 Value';
|
ESQL2 - This is creates an element "TenantOrgMsg" outside TenantOrgMsg root
Code: |
CREATE FIELD OutputRoot.XMLNS.TenantOrgMsg.ErrorCode TYPE NameValue VALUE 'This is my TestCase' ;
|
Both these approaches makes the XML fail at output node because its not a valid/ Well formed xml.
Can anyone guide me to add an element to incoming XML message for which element names are not known and new element has to be added inside root. I have tried creating lastchild, field , nextsibling and so on to get this new element in root ; in this example root is TenantOrgMsg |
|
Back to top |
|
 |
smdavies99 |
Posted: Tue Feb 09, 2010 6:36 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Your first post used the XMLNSC doman. Your last one uses the XMLNS domain. Which is it?
Put a trace node after the Compute node and post the trace of ${Root} here. That will help us.
Don't use the debugger! _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
eai_guy |
Posted: Tue Feb 09, 2010 6:38 am Post subject: |
|
|
Voyager
Joined: 18 Oct 2007 Posts: 90
|
I just changed it to xmlns, Will try to put a trace node |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Tue Feb 09, 2010 6:58 am Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
eai_guy wrote: |
I just changed it to xmlns |
Why? XMLNSC should be your domain of choice unless you have a very good reason for not using it.
I've noticed that you have namespaces on your original message but I cant see evidence of this in your ESQL when referencing the elements. I suspect this is the cause of your issue.
As smdavies has suggested, a trace should be quite illuminating |
|
Back to top |
|
 |
Vitor |
Posted: Tue Feb 09, 2010 7:03 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
eai_guy wrote: |
Can anyone guide me to add an element to incoming XML message for which element names are not known and new element has to be added inside root. |
Read this which describes what you're trying to do. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Feb 09, 2010 7:03 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
eai_guy wrote: |
I just changed it to xmlns, Will try to put a trace node |
Don't do this. It won't help. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
kimbert |
Posted: Tue Feb 09, 2010 12:40 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
Both these approaches makes the XML fail at output node because its not a valid/ Well formed xml. |
I suggest that you:
a) go back to using XMLNSC.
b) take a user trace and carefully read what it says. If you still need help, post the full text of the error message from the user trace ( or you can get the full text of the error from Windows Event Viewer if you're on Windows ). |
|
Back to top |
|
 |
eai_guy |
Posted: Tue Feb 09, 2010 3:44 pm Post subject: |
|
|
Voyager
Joined: 18 Oct 2007 Posts: 90
|
Hi All,
Taking trace helped to nail down this problem.
Problem: There was an xmlnamespace for root element TenantOrgMsg.So whenever I tried to create a Field or child for TenantOrgMsg it created a new folder under xmlnsc. As full name had namespace:TenantOrgMsg
So now I need to go back and see how I get the namespace dynamically from input xml.
By doing this I will be able to generate a valid xml. Current code is working for xml without namespace.
Thanks everyone, |
|
Back to top |
|
 |
kimbert |
Posted: Tue Feb 09, 2010 4:07 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
So now I need to go back and see how I get the namespace dynamically from input xml. |
FIELDNAMESPACE is what you would need for that.
Most people know the namespace of the incoming message - is there a (good) reason why you don't? |
|
Back to top |
|
 |
eai_guy |
Posted: Tue Feb 09, 2010 4:14 pm Post subject: |
|
|
Voyager
Joined: 18 Oct 2007 Posts: 90
|
Thanks for that .......
Basically we are building a generic component for all our flows which will process all kinds of messages as a part of error handling.....
Regards, |
|
Back to top |
|
 |
Vitor |
Posted: Tue Feb 09, 2010 4:55 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
eai_guy wrote: |
Basically we are building a generic component for all our flows which will process all kinds of messages as a part of error handling..... |
Then rather using FIELDNAMESPACE (which would give you the value) you might want to consider using a wildcard to match all namespaces.
Just a suggestion; might not be relevant depending on exactly what you're doing. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|