Author |
Message
|
madi |
Posted: Fri Jan 27, 2006 1:23 pm Post subject: eSQL help |
|
|
 Chevalier
Joined: 17 Jan 2006 Posts: 475
|
Hi
I am trying to generate an XML from name -value pairs and am using the following code.
DECLARE C INTEGER CARDINALITY(InputRoot.XML.InfoPublish.Item.ItemData.ItemAttr[]);
SET C = C + 1;
DECLARE K INTEGER 1;
WHILE K < C DO
DECLARE cursor REFERENCE TO InputRoot.XML.Publish.Item.ItemData.ItemAttr[K];
SET OutputRoot.XML.Item.ItemData.{FIELDVALUE(cursor.(XML.attr)name)} = FIELDVALUE(cursor.AttrValue.(XML.attr)value);
SET K = K + 1;
END WHILE;
Input Message:
<InfoPublish>
<Item>
<ItemData>
<ItemAttr name="ITEM_NUMBER" status="ADD"><AttrValue value="10217180"/></ItemAttr>
<ItemAttr name="MANUFACTURER" status="ADD"><AttrValue value="Mossimo Red"/></ItemAttr>
<ItemAttr name="SHIPPING" status="ADD"><AttrValue value="all_states_apo_prot"/></ItemAttr>
</ItemData>
</Item>
</InfoPublish>
Ouput MEssage:
- <Item>
- <ItemData>
<ITEM_NUMBER>10217180</ITEM_NUMBER>
<MANUFACTURER>Mossimo Red</MANUFACTURER>
<SHIPPING>all_states_apo_prot</SHIPPING>
</ItemData>
</Item>
Now My problem is, I used this example xml given above which has 3 pairs in it and the code worked fine and the code works for any message upto 6KB.
When I put in an xml which is more 6kB, it is not working!!
I think my code is generic and so should work irrespective of the number of ItemAttrs' in the input msg.
Not working for input message:
<InfoPublish>
<Item>
<ItemData>
<ItemAttr name="ITEM_NUMBER" status="ADD"><AttrValue value="10217180"/></ItemAttr>
<ItemAttr name="MANUFACTURER" status="ADD"><AttrValue value="Mossimo Red"/></ItemAttr>
<ItemAttr name="SHIPPING" status="ADD"><AttrValue value="all_states_apo_prot"/></ItemAttr>
<ItemAttr name="GIFT" status="ADD"><AttrValue value="Y"/></ItemAttr>
<ItemAttr name="POST_OFFICE" status="ADD"><AttrValue value="Y"/>
<ItemAttr name="MERCHANDISE" status="ADD"><AttrValue value="234"/></ItemAttr>
<ItemAttr name="DEPARTMENT" status="ADD"><AttrValue value="2"/></ItemAttr>
...
...
...
</ItemData>
</Item>
</InfoPublish>
Plz help
madi |
|
Back to top |
|
 |
elvis_gn |
Posted: Fri Jan 27, 2006 8:00 pm Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi madi,
Yes your code is generic.
I think the problem is, you are using
Quote: |
SET OutputRoot.XML.Item.ItemData.{FIELDVALUE(cursor.(XML.attr)name)} = FIELDVALUE(cursor.AttrValue.(XML.attr)value); |
Instead use CREATE FIELD(for first record) and CREATE NEXTSIBLING(for the rest).....
Tell us if it is fixed.
Regards. |
|
Back to top |
|
 |
hemendra123 |
Posted: Sat Jan 28, 2006 8:12 pm Post subject: |
|
|
Novice
Joined: 30 May 2005 Posts: 20
|
Madi, Just try placing the PROPAGATE stmt in the loop, ofcourse after setting the outputroot, might help you. _________________ Hemendr |
|
Back to top |
|
 |
jefflowrey |
Posted: Sun Jan 29, 2006 3:32 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
That won't help at all. It will break out different messages, and I'm don't see any reason why Madi wants to do that.
Madi - don't use propagate unless you need different messages. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
mgk |
Posted: Mon Jan 30, 2006 1:31 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Hi,
Can you post what actually goes wrong here, as you do not say. Having said that, at a guess I would think elvis is correct. You are better off using CREATE FIELD for the first entry, and then using CREATE NEXTSIBLING for the rest. This is because if you have duplicate name attributes SET will cause previous ones to be rewritten, but CREATE will not.
Also DECLAREing youe cursor each time around the loop is slow and unnecessary. You should DECLARE it once outside the loop and MOVE it to the next item, specifing the REPEAT NAME clauses to skip over any whitespace (and then check LASTMOVE).
Finally jefflowrey is right as well, I see no need for PROPAGATE here, although as jeff's sig is "Things are going to change" and I was wondering when that sig is was going too .
Regards, _________________ 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 |
|
 |
madi |
Posted: Mon Jan 30, 2006 7:26 am Post subject: |
|
|
 Chevalier
Joined: 17 Jan 2006 Posts: 475
|
Hi Guys
I think it is a problem with the XML but I need to check that.
I agree that setting cursor everytime is a waste and I will change that.
I have a new problem but guess it is a common one for me.
I tried to deploy the exec grp when the database was down.
Now the databse is up and running but the toolkit is dead. It is not allowing me to deploy saying the CONFIG MGR is still deploying the last one.
Nothing comes up in the event log, its just not doing anything.
I tried to stop the broker using mqsistop but that is taking forever.
Whats the best way to deal with this situation coz its like a common problem for me because the database is really unstable.
plz help
madi |
|
Back to top |
|
 |
madi |
Posted: Mon Jan 30, 2006 11:08 am Post subject: |
|
|
 Chevalier
Joined: 17 Jan 2006 Posts: 475
|
Hi guys
thanks for all the help. I got it working
thanks again
madi |
|
Back to top |
|
 |
javaforvivek |
Posted: Mon Jan 30, 2006 10:37 pm Post subject: |
|
|
 Master
Joined: 14 Jun 2002 Posts: 282 Location: Pune,India
|
Quote: |
thanks for all the help. I got it working
|
which one you got working? your toolkit or your message transformation logic?
I tried your ESQL on my WMB, and it works fine without any modification to your code. But again, elvis and mgk have given you the optimized code and I recommend to use it instead of your original code.
These suggestions can be considered as one of the 'Best Practices' of writing ESQL!!  _________________ Vivek
------------------------------------------------------
...when you have eliminated the impossible, whatever remains, however improbable, must be the truth. |
|
Back to top |
|
 |
madi |
Posted: Tue Jan 31, 2006 7:16 am Post subject: |
|
|
 Chevalier
Joined: 17 Jan 2006 Posts: 475
|
Hi vivek
I meant the transformation logic.
thanks
madi |
|
Back to top |
|
 |
|