Author |
Message
|
MiLi |
Posted: Fri Mar 03, 2006 12:10 am Post subject: Mapping multiple elements to array |
|
|
Acolyte
Joined: 07 Oct 2005 Posts: 51
|
Hi, I would like some input on how solve a specific mapping issue.
I have a incoming xml where the repeted elements is represented with different names:
<DEALS>
<LOAN_1>
<AMOUNT>1234</AMOUNT>
</LOAN_1>
<LOAN_2>
<AMOUNT>5678</AMOUNT>
</LOAN_2>
<RATE>123</RATE>
</DEALS>
The messages is up to 1mb so its a question about performance.
I dont know which elements that will be repeted like this and I dont know where in the xml, so I like to build a general mapping so all elements that ends with _ + "INTEGER" is mapped to an array with an attrubute like:
<DEALS>
<LOAN sequence="1">
<AMOUNT>1234</AMOUNT>
</LOAN>
<LOAN sequence="2">
<AMOUNT>5678</AMOUNT>
</LOAN>
<RATE>123</RATE>
</DEALS>
The current soution is reading the message as a String and the use String operations like REPLACE.
Any suggestions? _________________ IBM Certified System Administrator - WebSphere MQ V6.0
IBM Instructor - WebSphere MQ, WebSphere Message Broker |
|
Back to top |
|
 |
elvis_gn |
Posted: Fri Mar 03, 2006 12:25 am Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi MiLi,
I am assuming that you want to pick the entire complex type where the parent complex tag has a "_".
First take a reference of the main tag.
Use a while to Check if the reference is a complex type
[list=]If the complex tag has a "_"
[list=]save the complex reference into a Array
Move the reference to the next tag in the same hierarchy(use MOVE NEXTSIBLING)[/list]
[/list]
I hope you get the logic...you can always work on customizing it.
Regards. |
|
Back to top |
|
 |
elvis_gn |
Posted: Fri Mar 03, 2006 12:28 am Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi MiLi,
I am assuming that you want to pick the entire complex type where the parent complex tag has a "_".
First take a reference of the main tag.
Use a while to Check if the reference is a complex type
* If the complex tag has a "_"
* Save the complex reference into a Array
* Move the reference to the next tag in the same hierarchy(use MOVE NEXTSIBLING)
I hope you get the logic...you can always work on customizing it.
Regards. |
|
Back to top |
|
 |
MiLi |
Posted: Fri Mar 03, 2006 1:10 am Post subject: |
|
|
Acolyte
Joined: 07 Oct 2005 Posts: 51
|
Hi
This was the plan for a while, however:
The logic isnt so obviouse.
The element could look like: <Currencies_SwapSchedule_Loan_Payment_0 type="T">
So I must se if the is a _0 or maby _153 then I would like to cange the element name on output to <Currencies_SwapSchedule_Loan_Payment type="T" sequence="0">
1. could I copy the entire message and then loop through the OutputRoot and CHANGE the necessary element names?
2. Isnt this a very heavy operation: Take every element in the xml and do a name comparsion?
3. Any suggestion on how the logic could look like, example: Look for the last "_" and the se if the following substring is an integer? _________________ IBM Certified System Administrator - WebSphere MQ V6.0
IBM Instructor - WebSphere MQ, WebSphere Message Broker |
|
Back to top |
|
 |
elvis_gn |
Posted: Fri Mar 03, 2006 1:42 am Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi MiLi,
I guess the string method would have to suffice as you dont have any idea where the tags can occur in the message (though I feel this is a ***** design then).
Are there going to be other tags where you are not supposed to replace the integer ??
Is this the only operation that you need to do on this message ??
Regards. |
|
Back to top |
|
 |
MiLi |
Posted: Fri Mar 03, 2006 2:01 am Post subject: |
|
|
Acolyte
Joined: 07 Oct 2005 Posts: 51
|
As far as I can se, I can replace all element names that end with "_" + integer.
The other thing I'm doing with the message is adding a namespace, thats all.
And I agree, I cant believe what system could possibly generate this kind of xml. And thats not all. When it comes it got some extra "bonus" chars:
{ DATA 253 <DEAL>lbablalballa</DEAL> }
Nice.... _________________ IBM Certified System Administrator - WebSphere MQ V6.0
IBM Instructor - WebSphere MQ, WebSphere Message Broker |
|
Back to top |
|
 |
elvis_gn |
Posted: Fri Mar 03, 2006 2:06 am Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Quote: |
some extra "bonus" chars: |
U lucky girl
Even my salary does not get me a bonus
Best of luck.
Regards. |
|
Back to top |
|
 |
MiLi |
Posted: Fri Mar 03, 2006 4:31 am Post subject: |
|
|
Acolyte
Joined: 07 Oct 2005 Posts: 51
|
I'm gonna do some experiments for performance.
Still one big issue!
I gab a substring as CHARACTER.
Is there now any way to se if its a integer?
like, IF mySubString IS NUMERIC THEN......
ESQL doesnt support try catch so I cant try to cast it! _________________ IBM Certified System Administrator - WebSphere MQ V6.0
IBM Instructor - WebSphere MQ, WebSphere Message Broker |
|
Back to top |
|
 |
mgk |
Posted: Fri Mar 03, 2006 5:15 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
If you are using V6 then you can use the DEFAULT clause on the CAST to avoid an exception if the CAST fails... _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
MiLi |
Posted: Fri Mar 03, 2006 5:20 am Post subject: |
|
|
Acolyte
Joined: 07 Oct 2005 Posts: 51
|
If life could be easy....
I'm running WBIMB v 5 _________________ IBM Certified System Administrator - WebSphere MQ V6.0
IBM Instructor - WebSphere MQ, WebSphere Message Broker |
|
Back to top |
|
 |
|