Author |
Message
|
mahesh2069 |
Posted: Fri Oct 25, 2013 2:42 am Post subject: I failed to create following XML Structure,Help Me to resolv |
|
|
Centurion
Joined: 26 Jun 2013 Posts: 103
|
Hi All,
I wanna create XML Structure like bellow.
Code: |
<root>
<attr>xxx</attr>
<attr>xxx</attr>
<attr_Many>xxxx</attr_Many>
<attr>xxxx</attr>
</root>
|
For that I had written following code.
Code: |
SET OutputRoot.XMLNSC.root.attr[1]='xxx';
SET OutputRoot.XMLNSC.root.attr[2]='xxx';
SET OutputRoot.XMLNSC.root.attrMany='xxxx';
SET OutputRoot.XMLNSC.root.attr[3]='xxx';
|
But I failed to create out XML structure as above mentioned.
I got
Code: |
<root>
<attr>xxx</attr>
<attr>xxx</attr>
<attr>xxxx</attr>
<attr_Many>xxxx</attr_Many>
</root>
|
But I need 3rd 'attr' element after 'attr_Many' element. Help me how to resolve the issue. _________________ Thanks & Regards
Mahesh Mediboyina
WMB Developer |
|
Back to top |
|
 |
Simbu |
Posted: Fri Oct 25, 2013 3:07 am Post subject: |
|
|
 Master
Joined: 17 Jun 2011 Posts: 289 Location: Tamil Nadu, India
|
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Oct 25, 2013 4:58 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Code: |
SET OutputRoot.XMLNSC.root.attr[1]='xxx'; |
is just plain wrong.
Should be something like
Code: |
SET OutputRoot.XMLNSC.root.(XMLNSC.Attribute)attr[1]='xxx'; |
Now go read the infocenter and find out why: see also specific types.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
dogorsy |
Posted: Fri Oct 25, 2013 5:57 am Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
fjb_saper wrote: |
Code: |
SET OutputRoot.XMLNSC.root.attr[1]='xxx'; |
is just plain wrong.
Should be something like
Code: |
SET OutputRoot.XMLNSC.root.(XMLNSC.Attribute)attr[1]='xxx'; |
Now go read the infocenter and find out why: see also specific types.  |
Not really !!... The op was not creating a XMLNSC.Attribute, was creating a nameValue field, it just happened to be named attr.
See the message example the OP added in the first post.
what you suggested would create:
Code: |
<root attr='xxx' attr='yyy' etc/>
|
which is not the same.
Simbu's answer is the correct one. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Oct 25, 2013 7:12 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Should have taken more time reading the post...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
dogorsy |
Posted: Fri Oct 25, 2013 7:21 am Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
fjb_saper wrote: |
Should have taken more time reading the post...  |
No problem. However, I do agree the OP should read the infocenter.. |
|
Back to top |
|
 |
mahesh2069 |
Posted: Fri Oct 25, 2013 12:36 pm Post subject: Please reslove this issue, atrribute and Vlaue of Element |
|
|
Centurion
Joined: 26 Jun 2013 Posts: 103
|
Hi All,
I need to construct a Structure like
Code: |
<items>
<item>
<attr name="baseRetailUomCd">GR</attr>
<attr name="mfgrSugdRtlAmt"></attr>
<attrMany name="spclHndlgMsg">
<value> </value>
</attrMany>
<attr name="vendorDeptNbr">1</attr>
<attr name="consumerItemNbr">8960562</attr>
</item>
</items>
|
For that I wrote code like this
Code: |
SET OutputRoot.XMLNSC.items.item.attr[1].(XMLNSC.Attribute)name='baseRetailUomCd';
SET OutputRoot.XMLNSC.items.item.attr[1]='GR';
SET OutputRoot.XMLNSC.items.item.attr[2].(XMLNSC.Attribute)name='mfgrSugdRtlAmt';
SET OutputRoot.XMLNSC.items.item.attrMany.(XMLNSC.Attribute)name='spclHndlgMsg';
SET OutputRoot.XMLNSC.items.item.attr.(XMLNSC.Attribute)name = 'baseRetailUomCd';
-- CREATE LAST CHILD OF OutputRoot.XMLNSC.items.item NAME 'attr' VALUE 'GR';
/*
WITH HELP OF WE CAN CREATE EITHER ATTRIBUTE OR VALUE OF ELEMENT.. BUT I NEED BOTH
*/
SET OutputRoot.XMLNSC.items.item.attr[3].(XMLNSC.Attribute)name='vendorDeptNbr';
SET OutputRoot.XMLNSC.items.item.attr[3]='1';
/*
ABOVE STATEMENT NOT CREATE NEXT SIBLING 'attrMany ' ,IT GOES ON TOP OF 'attrMany ' , STRUCTURE WILL DIFFER FROM GIVEN
*/
|
PLZ HELP ME RESOLVE THIS ISSUE _________________ Thanks & Regards
Mahesh Mediboyina
WMB Developer |
|
Back to top |
|
 |
dogorsy |
Posted: Fri Oct 25, 2013 12:42 pm Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
As Simbu said, use CREATE LASTCHILD
Look at the syntax in the infocenter. the reason it is not working is because you have not specified all the parameters you need.
DO NOT EXPECT people to write it for you. You do your homework and try it out.
So, you said you can create either, but not both. What is preventing you from coding TWO create statements ?!
Last edited by dogorsy on Fri Oct 25, 2013 12:43 pm; edited 1 time in total |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Oct 25, 2013 12:43 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You've gotten multiple pointers. You now need to play around with your code and view the results. I'm sure that within a few iterations you'll get the right stuff.
Remember
Code: |
CREATE [Last Child | previous sibling | next sibling ] etc... |
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
mgk |
Posted: Fri Oct 25, 2013 2:40 pm Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
What you are missing is that when you try to create item.attr[3] ESQL will count from item[1] to find attr[2] and always create attr[3] immediately after attr[2]. So to create the structure want you need to use CREATE LASTCHILD for all "attr" children after "attrMany". So you could just use CREATE LASTCHILD for all elements in this structure... Alternatively, if you only have one instance of "attrMany" you could create all the "attr" elements first and then use a REFERENCE to insert "attrMany" afterwards. Bear in mind that if you have a lot of "attr" elements, using a REFERENCE rather than indexing with [] will perform better.
Kind 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 |
|
 |
dogorsy |
Posted: Sat Oct 26, 2013 4:29 am Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
and, the description of the problem has also changed.
Does that mean that once you get an answer to a problem, you move on to the next thing you don't know and that way you get free training ? |
|
Back to top |
|
 |
mgk |
Posted: Sat Oct 26, 2013 6:46 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Quote: |
and, the description of the problem has also changed. |
I disagree. If you look carefully, you'll see it is the same problem restated but with more information. Something I actually approve of
Kind 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 |
|
 |
dogorsy |
Posted: Sat Oct 26, 2013 3:35 pm Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
In the first post the OP wanted to generate
Code: |
<root>
<attr>xxx</attr>
<attr>xxx</attr>
<attr_Many>xxxx</attr_Many>
<attr>xxxx</attr>
</root> |
and he was told how,
then he said he wanted to generate
Code: |
<items>
<item>
<attr name="baseRetailUomCd">GR</attr>
<attr name="mfgrSugdRtlAmt"></attr>
<attrMany name="spclHndlgMsg">
<value> </value>
</attrMany>
<attr name="vendorDeptNbr">1</attr>
<attr name="consumerItemNbr">8960562</attr>
</item>
</items>
|
If it was the same problem, it would have the same solution. So no point in asking again.
The first problem was that the OP did no know how to create the 3rd subscript of the element attr after the element attrMany.
The new problem is that he does not know how to CREATE an element with a value and an attribute.
To me, that is 2 problems. |
|
Back to top |
|
 |
|