I basically want to loop through all occurances of DATA tag
and need the output Like
Quote:
<Employee>Employee</Employee>
<Person>Person</Person>
<Custom>Custom</Custom>
<Rubber>Rubber</Rubber>.... and so on
My code for Transformation looks somethin likes this
Quote:
DECLARE newPath CHARACTER;
DECLARE myref REFERENCE TO InputBody.DATA;
WHILE LASTMOVE(myref)=TRUE DO
SET newPath = myref.Table;
EVAL('SET OutputRoot.XML.DATA.' || newPath || ' = newPath');
MOVE myref NEXTSIBLING;
END WHILE;
But it works only for the First Instance and Not For Other Instances
also if i change my code like this
Quote:
WHILE LASTMOVE(myref)=TRUE DO
SET newPath = myref.Table;
EVAL('SET OutputRoot.XML.DATA.' || newPath || ' = newPath');
SET myref=myref+1;
MOVE myref NEXTSIBLING;
END WHILE;
It Says " Invalid Field Reference " Error..
Can Anyone tell me how i can modify my code to refer to subsequent instances of <DATA> and get the Output
I also Used cardinality Function But in Vain... If LastMove will not work here, how to use CARDINALITY to acheive my Transformation
Hi,
First of all the Input XML you have given is not a valid XML.A valid XML should contain only one root element.Lets think the input XML is like this
And you have problem with
WHILE LASTMOVE(myref) = TRUE DO
if you want to check the LASTMOVE..first you have to move your myref to desired element as i shown below
Quote:
Declare newPath Character;
DECLARE index Integer;
SET index = 1;
DECLARE myref REFERENCE TO InputBody.Record.Data[1];
DECLARE outref REFERENCE TO OutputRoot.XML.Record;
MOVE myref TO InputBody.Record.Data[1];
WHILE LASTMOVE(myref) = TRUE DO
SET newPath = InputBody.Record.Data[index].Table;
EVAL('SET OutputRoot.XML.Record.' || newPath || ' = ' || ' newPath ');
SET index = index + 1;
MOVE myref TO InputBody.Record.Data[index];
END WHILE;
Hope the above code for compute node works for you
Thanx
Sam
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