Hi all
I am doing a mapping in which the request xml comes this way
<header> ----- occurance 1 ............... </header> <detail> ------- occurance 0 to unbounded <F123ABC>1000</F123ABC> ------- occurance 0 to 1 <F456PQR>2000</F456PQR> ------- occurance 0 to 1 <G200XYZ></G200XYZ> ------- occurance 0 to 1 <G500PPP>12</G500PPP> ------- occurance 0 to 1 ................. </detail> <trailer> .............. </trailer>
Now my target structure is like this
<zheader> ----- occurance 1 ............... </zheader> <zdetail> ------- occurance 0 to unbounded <record type>...............</<record type> <Format>F</Format> ---if the tag <F123ABC> is not NULL then the data of format sortation and machine will be F,123 and ABC respectively and then whatever the between the TAG <F123ABC></F123ABC> will be fed in the *<quantity>* <sortation>123<sortation> <machine>ABC<machine> <quantity>1000</quantity> ................. </zdetail> <zdetail> ------- occurance 0 to unbounded <record type>...............</<record type> <Format>F</Format> ---if the tag <F456PQR> is not NULL then the data of format, sortation, and machine will be F,456 and PQR respectively and then whatever the between the TAG <F456PQR>2000</F456PQR> will be fed in the *<quantity>* <sortation>456<sortation> <machine>PQR<machine> <quantity>2000</quantity> ................. </zdetail> <ztrailer> .............. </ztrailer>
I tried this code in the UDF but it did not work
public void ud_splitDetail(String[] F123ABC,String[] F456PQR,String[] G200XYZ,String[] G500PPP,Detail,ResultList result,Container //write your code here int lenDetail=Detail.length; for(int i=0;i<lenDetail;i++) { //int len1=A.length; if(F123ABC<i>!=""){ result.addValue("F"); result.addContextChange();} if(F456PQR<i>!=""){ result.addValue("F"); result.addContextChange(); } if(G200XYZ<i>!=""){ result.addValue("F"); result.addContextChange(); } if(G500PPP<i>!=""){ result.addValue("F"); result.addContextChange(); } else result.addValue(""); result.addContextChange(); }
The above code is to take F for format and the same way it is for sortation, machine and quantity
But this code is not working properly, it gives a lots of F and other values. Could anyone give me some idea of how to code for the desired output
Your help is really appreciable
Thanks
Naina