on 04-30-2015 9:22 AM
Hi,
I have a mapping requirement - I am providing source xml and target xml . Please try to help in it.
Mapping conditions -
(1) If D_3035 is BY and its D_3039 is 71694800 then take last 4 characters of D_3039 where D_3035 is DP
(2) If D_3035 is BY and its D_3039 is 007222200 then take removing preceding zeroes of D_3039 where D_3035 is CN
Source XML -
<G_SG2>
<S_NAD>
<D_3035>BY</D_3035>
<C_C082>
<D_3039>71694800</D_3039>
<D_1131>160</D_1131>
</C_C082>
</S_NAD>
</G_SG2>
<G_SG2>
<S_NAD>
<D_3035>SE</D_3035>
<C_C082>
<D_3039>00381636677</D_3039>
<D_1131>200</D_1131>
</C_C082>
</S_NAD>
</G_SG2>
<G_SG2>
<S_NAD>
<D_3035>DP</D_3035>
<C_C082>
<D_3039>00393363667</D_3039>
<D_1131>210</D_1131>
</C_C082>
</S_NAD>
</G_SG2>
Target XML - you can take any xml with a field A like - <B> <A> value </A></B>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
You can try this UDF also.
Execution Type: All Values Of Context
public void groupByKeys(String[] d3035, String[] d3039, ResultList result, Container container) {
Map<String, String> map = new HashMap<String, String>();
for (int i = 0; i < d3035.length; i++) {
map.put(d3035[i], d3039[i]);
}
if (map.containsKey("BY")) {
if (map.get("BY").equals("71694800"))
result.addValue(map.get("DP"));
else if (map.get("BY").equals("007222200"))
result.addValue(map.get("CN"));
else
result.addValue("");
}else{
result.addValue("");
}
}
Mapping:
D_3035--->removeContexts--->
UDF----->Target
D_3039---->removeContexts-->
Regards,
Praveen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
96 | |
11 | |
11 | |
10 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.