Author |
Message
|
sapana |
Posted: Mon Mar 30, 2009 10:55 pm Post subject: Traverse XML message |
|
|
Apprentice
Joined: 16 Apr 2007 Posts: 33 Location: Pune
|
Hi,
I need to convert all the field data in the request message (XML) to upper case. I have the schema of input message, which is quite complex.
1] Which is the most efficient way (ease of development & performance wise) of implementing this: using esql or xpath?
2] What is the best practice to traverse the input message: based on schema or as unknown XML message. Note schema validation is not required.
3] Pointer to sample code that traverses unknown XML input message.
Thanks,
Sapana |
|
Back to top |
|
 |
Gaya3 |
Posted: Tue Mar 31, 2009 12:55 am Post subject: Re: Traverse XML message |
|
|
 Jedi
Joined: 12 Sep 2006 Posts: 2493 Location: Boston, US
|
sapana wrote: |
1] Which is the most efficient way (ease of development & performance wise) of implementing this: using esql or xpath?
|
use X Path if you know, and using JCN is also a good option.
sapana wrote: |
2] What is the best practice to traverse the input message: based on schema or as unknown XML message. Note schema validation is not required.
|
It is better to traverse through using Schema, use XMLNSC, instead of MRM
http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/index.jsp?topic=/com.ibm.etools.mft.doc/ad70530_.htm
Unknown XML is always risky..XML is standard,
sapana wrote: |
3] Pointer to sample code that traverses unknown XML input message.
|
Search this site, it will help you a lot _________________ Regards
Gayathri
-----------------------------------------------
Do Something Before you Die |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Tue Mar 31, 2009 1:52 am Post subject: Re: Traverse XML message |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
sapana wrote: |
Hi,
1] Which is the most efficient way (ease of development & performance wise) of implementing this: using esql or xpath?
2] What is the best practice to traverse the input message: based on schema or as unknown XML message. Note schema validation is not required.
3] Pointer to sample code that traverses unknown XML input message.
Sapana |
I'd have thought:
1] Using Recursion in ESQL with the keywords firstchild and nextsibling benig used quite alot. Id have thought this would be faster than XPATH.
2] Regardless of whether a schema exists or not, to visit every element, including optional ones recusrion is the best way to go here.
3] the keywords using in point 1 should help you form a solution here |
|
Back to top |
|
 |
Gaya3 |
Posted: Tue Mar 31, 2009 2:21 am Post subject: Re: Traverse XML message |
|
|
 Jedi
Joined: 12 Sep 2006 Posts: 2493 Location: Boston, US
|
WMBDEV1 wrote: |
sapana wrote: |
Hi,
1] Which is the most efficient way (ease of development & performance wise) of implementing this: using esql or xpath?
2] What is the best practice to traverse the input message: based on schema or as unknown XML message. Note schema validation is not required.
3] Pointer to sample code that traverses unknown XML input message.
Sapana |
I'd have thought:
1] Using Recursion in ESQL with the keywords firstchild and nextsibling benig used quite alot. Id have thought this would be faster than XPATH.
2] Regardless of whether a schema exists or not, to visit every element, including optional ones recusrion is the best way to go here.
3] the keywords using in point 1 should help you form a solution here |
The performance is a question here....
I dont agree with the Second point, for XML, the Schema is very important AFIK. _________________ Regards
Gayathri
-----------------------------------------------
Do Something Before you Die |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Tue Mar 31, 2009 2:29 am Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
Ok... The schema would be used for validation really, that doesnt seem to be the primary requirment in this scenario....
And you would have to code every element into your ESQL which may be difficult if "extendable" elements are allowed, ie elements not explicity declared in the schema. |
|
Back to top |
|
 |
Gaya3 |
Posted: Tue Mar 31, 2009 2:34 am Post subject: |
|
|
 Jedi
Joined: 12 Sep 2006 Posts: 2493 Location: Boston, US
|
But still suggest to use Java Compute Node or Java instead of ESQL, as its mentioned its a complex schema.
performance is better in JCN when it deals with Complex computations/logic _________________ Regards
Gayathri
-----------------------------------------------
Do Something Before you Die |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Mar 31, 2009 4:59 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
I don't agree that a schema is important or necessary in this case. A schema is only important or necessary when the fields must be validated.
The one area in which a schema could provide value is in protecting your code from trying to uppercase fields that hold numeric values. But your code should be smart enough not to do that anyway.
It's going to be a lot simpler to write ESQL code to recurse over the XMLNSC message tree, and it's going to perform just as well in this situation as Java. And it's not clear that Java performance is any better in complicated situations either. Performance on both should be similar in most cases, with Java being used either when programmers don't know ESQL very well or when something is only available through Java. |
|
Back to top |
|
 |
Gaya3 |
Posted: Tue Mar 31, 2009 5:15 am Post subject: |
|
|
 Jedi
Joined: 12 Sep 2006 Posts: 2493 Location: Boston, US
|
|
Back to top |
|
 |
mqjeff |
Posted: Tue Mar 31, 2009 5:52 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Nothing in that article disputes what I said. It shows that for like function, ESQL performs *better*. It says that Java *may* perform better when there is a lot of "business logic", but it doesn't provide anything to back it up.
And there's not a lot of business logic here. It's a straight forward loop over all the children in a tree, performing the same operation on each. |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Tue Mar 31, 2009 5:52 am Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
i'm confused... the table in the "Java Compute node performance" section clearly shows the Java being slower than the ESQL (with fewer messages processed per second especially on manipulation). It also says the scenario is mostly message navigation and parsing, not business logic which is what we have here.
Am I missing something? |
|
Back to top |
|
 |
sapana |
Posted: Tue Mar 31, 2009 11:56 pm Post subject: |
|
|
Apprentice
Joined: 16 Apr 2007 Posts: 33 Location: Pune
|
Hi,
Thanks for your replies. From all the inputs , it seems using recursion in ESQL best serves the purpose here (as we can also reuse this in other modules) .
I am thinking of extending the pre-order traversal method of binary tree for traversal. Request you to correct me if a simpler / efficient method can be applied.
Would post the code once done.
Thanks,
Sapana |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Wed Apr 01, 2009 12:50 am Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
Thats how I would do it (and have done so in the past, sorry I cant provide code though as I dont own it and no longer work for the company where I wrote it). |
|
Back to top |
|
 |
kimbert |
Posted: Wed Apr 01, 2009 1:01 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
If this is being done in ESQL, then ESQL recursion is definitely the way to go.
Personally, I try the XSLT node first. I suspect that I would end up writing a lot less code that way because XSLT is designed for this sort of thing. |
|
Back to top |
|
 |
Gaya3 |
Posted: Wed Apr 01, 2009 1:07 am Post subject: |
|
|
 Jedi
Joined: 12 Sep 2006 Posts: 2493 Location: Boston, US
|
One doubt Kimbert
if we are using XSLT node, then automatically the style sheet and Validation part will come in to this Picture right. _________________ Regards
Gayathri
-----------------------------------------------
Do Something Before you Die |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Wed Apr 01, 2009 1:25 am Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
XSLT does not have to provide any validation in this scenario and still a schema is not needed. The recursion method should be no more than about 20 lines of code. |
|
Back to top |
|
 |
|