Author |
Message
|
nu1 |
Posted: Fri Feb 13, 2004 7:07 am Post subject: assign the i/p xml msg to an attribute of o/p xml msg |
|
|
Apprentice
Joined: 28 Nov 2003 Posts: 26
|
Hi,
I am getting an XML message message I want to assign a child node which has many attributes and child elements as the text content to an attribute of a child element of o/p xml message.
i/e.,
if I get
<parent>
<child1 attr1="xxx" attr2="yyy">
<sub1-child1>sub1-child1text</sub-child1>
<sub2-child1 attr1="bvj" attr2="yuiy">sub2-child2text</sub2-child1>
</child1>
<child2>child2text</child2>
<child3> child3text
</parent>
I want to send it as
<ABC>
<abcchild1 attr1='<child1 attr1="xxx" attr2="yyy"><sub1-child1>sub1-child1text</sub-child1><sub2-child1 attr1="bvj" attr2="yuiy">sub2-child2text</sub2-child1></child1>'>
</abcchild1>
<abcchild2>abcchild2text</abcchild2>
</ABC>
I am trying to copy each element and its attributes to some char variable and then assigning it to the attribute of child element of o/p xml message.
This is becoming very complex as I dont know how the child element is going to be. I am tring to use dynamic reference.
Please kindly let me know if you have some ideas.
Thanks _________________ -nu1 |
|
Back to top |
|
 |
Missam |
Posted: Fri Feb 13, 2004 11:17 am Post subject: |
|
|
Chevalier
Joined: 16 Oct 2003 Posts: 424
|
Why are you copying attribute's to varaibles.you can directly assing attributes of one element to attributes of other. |
|
Back to top |
|
 |
nu1 |
Posted: Fri Feb 13, 2004 12:09 pm Post subject: |
|
|
Apprentice
Joined: 28 Nov 2003 Posts: 26
|
The entire child element cannot be copied as an attribute of outputchild element.
Please kindly see my i/p and o/p that i wanted once again.
if I have an child element say
<child1 attribute1="sdssd" attributute2="vsdfsdf">
while sending this
I want something like
<out>
<aaaa attribute1='<child1 attribute1="sdssd" attributute2="vsdfsdf">' />
</out> _________________ -nu1 |
|
Back to top |
|
 |
wooda |
Posted: Mon Feb 16, 2004 5:32 am Post subject: |
|
|
 Master
Joined: 21 Nov 2003 Posts: 265 Location: UK
|
Hi nu1,
The technique you are using will mean you have to query and insert the xml tag/attribute names into the string yourself. And effectively build up the XML string you want from the values in the tree. As you rightly say a bit complicated especialy if you don't know in advance what attributes the element contains.
What version of integrator are you using ?
If you are using v5 then there is a neat trick you can try the following;
You can serialize the bit of the tree (ie your input element) you wish to insert into the output attribute value into a BLOB or BITSTREAM element, using the ASBITSTREAM ESQL function.
Then you insert the result into your output attribute casting it as a string.
This should give you what you want, but I think it's only supported on v5.
See the help topic entitled "Handling large XML messages" for an example.
If you are using v2.1 you may be able to do the same thing usng the BITSTREAM function. Not sure I havn't tried this. But it is worth a look. |
|
Back to top |
|
 |
Meow |
Posted: Mon Feb 16, 2004 8:28 am Post subject: |
|
|
 Voyager
Joined: 25 Jun 2003 Posts: 95
|
I am not able to use the ASBITSTREAM function when i have multiple elements at the same leve.
we cant use :
ASBITSTREAM(InputRoot.XML.parent.child1); -- as it has multiple child elements at the same leve.
ASBITSTREAM(InputRoot.XML.parent) for the same above reason.
Please let me know if the way i am trying to use ASBITSTREAM function is wrong.
I am novice to these functions of ESQL.
Please let me know.
Thanks,
 |
|
Back to top |
|
 |
wooda |
Posted: Tue Feb 17, 2004 4:12 am Post subject: |
|
|
 Master
Joined: 21 Nov 2003 Posts: 265 Location: UK
|
Meow -
How you tried using ASBITSTREAM on a single instance of your child element.
eg.
ASBITSTREAM(InputRoot.XML.parent.child1[1]);
this should be valid.
You can see how you might then iterate through all instances of the child using ASBITSTREAM on each. |
|
Back to top |
|
 |
|