on 10-14-2008 9:39 AM
Hi All,
I have a scenario in which I need to perform the following mapping logic:
Source Structure:
<SrcMsg>
<Node1>
<Details>"<Name>XYZ</Name><Description>Desc1</Description><Id>ID123</Id>"</Details>
</Node1>
</SrcMsg>
Target Structure:
<TrgMsg>
<Node1>
<TargetID>ID123</TargetID>
</Node>
</TrgMsg>
i.e. I need to extract the data from Id tag within Details of Source message.
The Details node will have the following data as string
<Name>XYZ</Name><Description>Desc1</Description><Id>ID123</Id>
Thanks,
Abhishek.
Hi,
write a UDF:
{
int i = a.indexOf("<Id>");
int j = a.indexOf("</Id>");
return a.substring(i+4,j);
// 4 'coz length of "<ID>" is 4
}
Edited by: Ritu Sinha on Oct 14, 2008 2:17 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Thanks for all those helpful answers.
In the same mapping program I am having another issue:
<Source>
<SRCNode>(0..unbounded)
<Code>(0..1)
</Number>(0..1)
</Code>
</Description>(0..1)
</SRCNode>
</Source>
<Target>
</TRGTNode>(0..unbounded)
</Target>
Here I have implemented the logic If Number = 10 & Description exists then map SRCNode to TRGTNode i.e TRGTNode should repeat for all SRCNodes who have Field = 10.
The problem that I am facing is TRGTNode is repeating only for the first instance of Number = 10 and not for all the other instances of Number = 10.
Thanks,
Abhishek.
Edited by: abhishek salvi on Oct 15, 2008 1:41 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Avishek,
This is certainly related to the context of the source node. You need to adjust the context from the source according to you mapping requirements using either a standard function or simply setting the context of the source node to different levels of context. Though I believe (by reading your problem statement) simply using the standard function "Remove Context" at the end of the mapping logic for Target Node would solve your problem. Let us know if this works for you.
Regards,
Suddha
Hi Abhishek,
Write UDF exactly like
String b = "";
for(int i=0;i<a.length;i++)
b = a square bracket i.substring( a square bracket i.indexOf("Id") +3, a square bracket i.lastIndexOf("Id") - 2);
result.addValue(b);
Here source will be Detail field and Target will be Target ID.
Thanks!
Edited by: sudhir tiwari on Oct 14, 2008 11:08 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If the type of data is always same, u may simply substring till index of <ID> and then use the remaining data for mapping. Standard functions or UDF could be used in such case.
Regards,
Prateek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
write a UDF for TargetID with Details tag as input to it.
int i1 = details.indexOf("<Id>");
int i2 = details.indexOf("</Id>");
return (details.substring(i1+4,i2));
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey,
This is a simple and straight forward mapping.
Just map the source Id to target node TargetID.
Ohh.. if the input is a string then you would require a UDF to extract the value
Thanks
SaNv...
Edited by: Sãnthosh Kûmãr V on Oct 14, 2008 2:18 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.