Author |
Message
|
MB |
Posted: Mon Feb 27, 2006 9:00 pm Post subject: Create FirstChild |
|
|
Acolyte
Joined: 25 Jun 2004 Posts: 52
|
Hi,
We are facing some issues while parsing Input xml.
Our code is:
CREATE FIRSTCHILD OF OutputRoot.XML PARSE(InputRoot.XML, InputRoot.MQMD.Encoding, InputRoot.MQMD.CodedCharSetId);
SET Environment.type = InputRoot.XML.abc.type;
IF Environment.type = 'z' THEN
DECLARE ref1 REFERENCE TO OutputRoot.XML.XML.xyz;
DETACH ref1;
ATTACH ref1 TO OutputRoot.XML AS FIRSTCHILD;
SET OutputRoot.XML.XML = NULL;
The Input xml message is <?xml version="1.0" encoding="UTF-8"?><abc><family>udas</family><type>z</type><id>1613</id><id>123</id><routingInfo><name>display_type</name><value>a</value></routingInfo><publishTime>2003-04-17 14:55:44.208 PDT</publishTime><hospitalID></hospitalID><messageData><!DOCTYPE z SYSTEM "><xyz><id>1613</id><xyz1>April UDA</xyz1><module>ITEM</module><display_type>LV</display_type><data_type>ALPHA</data_type><data_length/><single_value_ind>N</single_value_ind></xyz></messageData></abc>
We can see error in Event Viewer as not well formed xml and Error detected whilst processing a message in node 'abc.MQOutput'.
Expected output is:
<xyz>
<id>1613</id>
<xyz1>April UDA</xyz1>
<module>ITEM</module>
<display_type>LV</display_type>
<data_type>ALPHA</data_type>
<data_length/>
<single_value_ind>N</single_value_ind>
</xyz>
Please let me know we are missing out on something.
Thanks
~mb. |
|
Back to top |
|
 |
elvis_gn |
Posted: Mon Feb 27, 2006 10:25 pm Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi MB,
You are getting the error after/In the compute node or when you try to output the message through the output node ??
How is thedebug working ?
I notice that you are creating a ref1 to OutputRoot.XML.XML.xyz.....
Does the OutputRoot.XML.XML.xyz exist ?
Regards. |
|
Back to top |
|
 |
dipankar |
Posted: Tue Feb 28, 2006 12:50 am Post subject: |
|
|
Disciple
Joined: 03 Feb 2005 Posts: 171
|
Hi MB,
Code: |
CREATE FIRSTCHILD OF OutputRoot.XML PARSE(InputRoot.XML, InputRoot.MQMD.Encoding, InputRoot.MQMD.CodedCharSetId); |
I think parse clause expects bit stream, not field reference. Please see the syntax. you are getting exception from the above code. First correct the above one.
Besides this, one more issue remains that Elvis has already told you. _________________ Regards |
|
Back to top |
|
 |
MB |
Posted: Tue Feb 28, 2006 1:40 am Post subject: |
|
|
Acolyte
Joined: 25 Jun 2004 Posts: 52
|
Thanks elvis, depankar for your replies.
I changed the CREATE FIRSTCHILD OF syntax and it seems to work.
As Elvis says I agree there is no reference to xyz. If we need to get a reference to that then how do we go about doing that. Kindly let me know
Thanks,
MB. |
|
Back to top |
|
 |
elvis_gn |
Posted: Tue Feb 28, 2006 1:44 am Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi MB,
Quote: |
If we need to get a reference to that then how do we go about doing that. Kindly let me know |
If the Reference is from your input message then reference the InputRoot.XML instead of OutputRoot.XML....
Regards.
Last edited by elvis_gn on Tue Feb 28, 2006 1:47 am; edited 1 time in total |
|
Back to top |
|
 |
dipankar |
Posted: Tue Feb 28, 2006 1:45 am Post subject: |
|
|
Disciple
Joined: 03 Feb 2005 Posts: 171
|
Hi MB,
Quote: |
I changed the CREATE FIRSTCHILD OF syntax and it seems to work. |
How could you understand your code is working?
Could you post your modified code here again? _________________ Regards |
|
Back to top |
|
 |
MB |
Posted: Tue Feb 28, 2006 2:18 am Post subject: |
|
|
Acolyte
Joined: 25 Jun 2004 Posts: 52
|
Hi All,
Thanks for the quick reply.
Here is my latest code:
CREATE PROCEDURE CopyEntireMessage()
BEGIN
DECLARE bodyBlob BLOB ASBITSTREAM(InputRoot.XML, InputRoot.MQMD.Encoding, InputRoot.MQMD.CodedCharSetId);
CREATE FIRSTCHILD OF OutputRoot.XML PARSE(bodyBlob, InputRoot.MQMD.Encoding, InputRoot.MQMD.CodedCharSetId);
DECLARE ref1 REFERENCE TO OutputRoot.XML.XML.abc.messageData;
DETACH ref1;
ATTACH ref1 TO OutputRoot.XML AS FIRSTCHILD;
SET OutputRoot.XML.XML = NULL;
END;
Input XML:
<?xml version="1.0" encoding="UTF-8"?>
<abc>
<family>udas</family>
<type>UDAHdrCre</type>
<id>1613</id>
<ribmessageID>........</ribmessageID>
<routingInfo>
<name>display_type</name>
<value>LV</value>
</routingInfo>
<publishTime>2003-04-17 14:55:44.208 PDT</publishTime>
<hospitalID></hospitalID>
<messageData><!DOCTYPE UDADesc SYSTEM "http://www.retek.com/dtd/rib/UDADesc.dtd">
<xyz>
<uda_id>1613</uda_id>
<uda_desc>April UDA</uda_desc>
<module>ITEM</module>
<display_type>LV</display_type>
<data_type>ALPHA</data_type>
<data_length/>
<single_value_ind>N</single_value_ind>
</xyz>
</messageData>
</abc>
Expected output:
<xyz>
<uda_id>1613</uda_id>
<uda_desc>April UDA</uda_desc>
<module>ITEM</module>
<display_type>LV</display_type>
<data_type>ALPHA</data_type>
<data_length/>
<single_value_ind>N</single_value_ind>
</xyz>
Basically I am trying to get handle to a XML within the messageData tag of the outer XML, by extracting the inner XML.
Please let me know your valuable inputs on this.
Thanks,
~mb. |
|
Back to top |
|
 |
elvis_gn |
Posted: Tue Feb 28, 2006 2:36 am Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi MB,
So where are you now, have you got it working ?
We cannot take you line by line on how to code, plz do try to play with the code, the level of satisfaction on learning by yourself is greater
Regards. |
|
Back to top |
|
 |
dipankar |
Posted: Tue Feb 28, 2006 2:40 am Post subject: |
|
|
Disciple
Joined: 03 Feb 2005 Posts: 171
|
Hi MB,
Elvis is absolutely correct.
However I am giving you some hints
First extract the contents of messageData as blob to a variable and then create the message body by create statement. See the create statement in ESQL guide _________________ Regards |
|
Back to top |
|
 |
MB |
Posted: Tue Feb 28, 2006 5:20 am Post subject: |
|
|
Acolyte
Joined: 25 Jun 2004 Posts: 52
|
Hi,
I have already tried extracting the data from messageData. The code bombs at:
DECLARE bodyBlob BLOB ASBITSTREAM(InoutRoot.XML.abc.messageData, InputRoot.MQMD.Encoding, InputRoot.MQMD.CodedCharSetId);
The XML Parser error seen in debugger is "An error has been reported by the BIPXML4C component.".
Regards,
~mb. |
|
Back to top |
|
 |
dipankar |
Posted: Tue Feb 28, 2006 8:25 pm Post subject: |
|
|
Disciple
Joined: 03 Feb 2005 Posts: 171
|
ASBITSTREAM does not return the data, returns the data with field.
Here ASBITSTREAM will return
<messageData>data</messageData> as blob. But you need only data by which you want to create a XML message.
So you simply use CAST(InputRoot.XML.abc.messageData AS BLOB CCSID InputRoot.MQMD.CodedCharSetId)
After that create message body with domain and parse clause like CREATE LASTCHILD of OutputRoot Domain 'XML' PARSE (whatever) _________________ Regards |
|
Back to top |
|
 |
narendrach |
Posted: Fri Mar 03, 2006 2:03 pm Post subject: |
|
|
Voyager
Joined: 29 Jun 2005 Posts: 78
|
try to use
DECLARE ref1 REFERENCE TO
OutputRoot.XML.XML.abc.messageData.(XML.AsisElementContent); _________________ Narendra CH |
|
Back to top |
|
 |
|