I'm using Compute node for transformation....
My problem is to create a child dynamically basing on the condition-- if cardinality of <person>sub tree in input tree is 2 then <nnick> sub tree in outputtree has to be created 2 times.
if cardinality of <person>sub tree in input tree is 4 then <nnick> sub tree in output tree has to be created 4 times. plz help me
Posted: Fri Jul 25, 2014 4:31 am Post subject: Re: How to create an xml output tree (sub tree) dynamically
Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
vdharanikota wrote:
if cardinality of <person>sub tree in input tree is 2 then <nnick> sub tree in outputtree has to be created 2 times.
if cardinality of <person>sub tree in input tree is 4 then <nnick> sub tree in output tree has to be created 4 times. plz help me
Help with what? You've correctly identified that you need to generate one <nnick> stanza for each input <person>; so what are you stuck on? There's no conceptual difference in ESQL (you mention Compute so I assume ESQL) between creating a single stanza and 1-n stanzas.
If you can explain your problem in a bit more detail, you might get some more detailed advice. _________________ Honesty is the best policy.
Insanity is the best defence.
Joined: 29 Nov 2011 Posts: 490 Location: UK...somewhere
Code:
DECLARE count INTEGER 0;
FOR person AS InputRoot.XMLNSC.root.people.person[] DO
CREATE LASTCHILD OF OutputRoot.XMLNSC.root2.people.nnick NAME 'nickname' || CAST(count AS CHARACTER) VALUE 'Blokey' ||person.fname;
SET count = count + 1;
END FOR;
I think this will do what you are after (well almost!) - but this is pretty basic - in future please try yourself , and ask question only if you have problems.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum