Author |
Message
|
abhivin |
Posted: Mon Jun 28, 2010 2:55 am Post subject: In MB how to traverse the next Child using ESQL |
|
|
Novice
Joined: 15 Jun 2010 Posts: 10
|
Hi,
I am trying to do the message conversion from XML-TDS. I am getting output for the first set of elements, whereas i am unable to get the second elements.
FYI pls find the below XML:
<employee>
<name>Sample</name>
<id>2384</id>
<dept>53456</dept>
</employee>
<company>
<cname>Joeton</name>
<cid>2384</id>
<cdept>53456</dept>
</company>
Here, i am able to get the output "Sample 2384 53456" whereas the 2nd element company value is not getting.
Pls give me the idea to how to access the element and achieve the scenario.
Thanks in Advance
Regards ,
Abhi |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Jun 28, 2010 3:11 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
We can't tell you how to do this until you tell us what you tried. |
|
Back to top |
|
 |
abhivin |
Posted: Mon Jun 28, 2010 3:28 am Post subject: |
|
|
Novice
Joined: 15 Jun 2010 Posts: 10
|
Thanks.
Below the snippet of the code i am using:
SET OutputRoot.MRM.Name = FIELDVALUE(InputRoot.XMLNSC.employee.name);
SET OutputRoot.MRM.ID = FIELDVALUE(InputRoot.XMLNSC.employee.id);
SET OutputRoot.MRM.Dept = FIELDVALUE(InputRoot.XMLNSC.employee.dept);
SET OutputRoot.MRM.CName = FIELDVALUE(InputRoot.XMLNSC.company.name);
SET OutputRoot.MRM.CID = FIELDVALUE(InputRoot.XMLNSC.company.id);
SET OutputRoot.MRM.CDept = FIELDVALUE(InputRoot.XMLNSC.company.dept);
Do let me know if you need more info reg. this.
Thanks,
Abhi |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Jun 28, 2010 3:37 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Why are you trying to access InputRoot.XMLNSC.company.id when the field is named "cid" in the XML? |
|
Back to top |
|
 |
abhivin |
Posted: Mon Jun 28, 2010 4:03 am Post subject: |
|
|
Novice
Joined: 15 Jun 2010 Posts: 10
|
Apologize for that, typo error.
I am try to accessing the below code only
SET OutputRoot.MRM.CName = FIELDVALUE(InputRoot.XMLNSC.company.cname);
SET OutputRoot.MRM.CID = FIELDVALUE(InputRoot.XMLNSC.company.cid);
SET OutputRoot.MRM.CDept = FIELDVALUE(InputRoot.XMLNSC.company.cdept);
Thanks,
Joice.V |
|
Back to top |
|
 |
sirsi |
Posted: Mon Jun 28, 2010 4:29 am Post subject: |
|
|
Disciple
Joined: 11 Mar 2005 Posts: 177
|
looks like out put message set is not defined properly...! can you define the structure of ur output msg set |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Jun 28, 2010 4:34 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Looking at your XML again, I'm confused.
It is not legal for an XML document to have more than one root.
So it is not legal for <employee> to be a sibling of <company> when neither of them have a common parent.
Take a user trace of your code.
Use the Trace node to output the ${Root}. Compare your code against the tree described in the Trace node output. Compare your expectations against what the usertrace says is being executed. |
|
Back to top |
|
 |
abhivin |
Posted: Mon Jun 28, 2010 4:43 am Post subject: |
|
|
Novice
Joined: 15 Jun 2010 Posts: 10
|
Thanks,
Yes defined properly.
I am unable to attach the screen shot of the message set.
Regards,
Joice.V
[/code] |
|
Back to top |
|
 |
sirsi |
Posted: Mon Jun 28, 2010 5:09 am Post subject: |
|
|
Disciple
Joined: 11 Mar 2005 Posts: 177
|
I believe he has provided part of xml, otherwise MB will throw an error...
can you take a trace, write it to a file and paste the contents here... |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Jun 28, 2010 6:42 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Also it looks like company is not valid... there can only be one xmlroot under XMLNSC. You have employee. Company looks like it is a sibling of employee but employee is your xmlroot... This xml document is not valid...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Jun 29, 2010 2:32 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
fjb_saper wrote: |
Also it looks like company is not valid... there can only be one xmlroot under XMLNSC. You have employee. Company looks like it is a sibling of employee but employee is your xmlroot... This xml document is not valid...  |
Well, of course, I've already *said* that. And been told "Oh, it must be that it was a partial XML".
But of course it can't be a partial XML because the ESQL path is trying to treat it as if it were a full XML.
So either the ESQL path is still not being reported correctly, or the XML is invalid. |
|
Back to top |
|
 |
sirsi |
Posted: Thu Jul 01, 2010 6:24 am Post subject: |
|
|
Disciple
Joined: 11 Mar 2005 Posts: 177
|
ahh, it has to do with esql... because the bad formed xml would have thrown the user an error!... |
|
Back to top |
|
 |
anek77 |
Posted: Thu Jul 01, 2010 10:47 pm Post subject: |
|
|
Newbie
Joined: 04 Jun 2010 Posts: 3
|
The sample XML does not look correct at all.
Start and end tags does not match!
<cname>Joeton</name>
<cid>2384</id>
<cdept>53456</dept>
And as mentioned twice before, dual root elements.
Parser parses the first <employee> correct, and you get your output.
When parser tries to parse <company>, you vill get XML Parsing Errors have occurred. This error does not stop the flow, it only causes the following lines to return null.
Code: |
SET OutputRoot.MRM.CName = FIELDVALUE(InputRoot.XMLNSC.company.cname);
SET OutputRoot.MRM.CID = FIELDVALUE(InputRoot.XMLNSC.company.cid);
SET OutputRoot.MRM.CDept = FIELDVALUE(InputRoot.XMLNSC.company.cdept); |
|
|
Back to top |
|
 |
sirsi |
Posted: Fri Jul 02, 2010 2:12 am Post subject: |
|
|
Disciple
Joined: 11 Mar 2005 Posts: 177
|
I have tested this before with dual root element and it fails in the input node and doesnt process further... anyway the user abhivin seems to have got this working, as he is not interested in this topic anymore... |
|
Back to top |
|
 |
abhivin |
Posted: Fri Jul 02, 2010 2:18 am Post subject: |
|
|
Novice
Joined: 15 Jun 2010 Posts: 10
|
Thanks for the response.
Apologise for the delay response.
I am trying to regenerate my XML, with proper root/child elements.
Will update you asap.
AbhiVin |
|
Back to top |
|
 |
|