on 09-25-2008 10:51 AM
Hi Experts,
In one of my interface i am passing whole required information in one field in XML format..
like
sender_name -
name
sender_address ---( passing whole address in XML format <sender_street>streetname</sender_street>
<sender_city>city</sender_city><sender_state>state</sender_state>)
.
Rec structure is:
sender name
sender street
sender city
sender state
i have to map the XML data in one field to the individual fields in target structure
I allready done java mapping for this its working fine ..is there anyway that i can achieve this by graphical mapping..
I know we go with UDF.
Regards
PT
Hi,
without UDF I guess it's not possible.
Here is a solution with a mix of UDF and graphical mappping.
You write one UDF with four parameters
a input string
b result of indexOf2(input string, Constant("<sender_city>")
c result of indexOf2(input string, Constant("</sender_city>")
d Constant("<sender_city>")
>int firstIndex = Integer.parseInt(b);
>int secondIndex = Integer.parseInt(c);
>if (firstIndex >= 0 && secondIndex >= 0) {
>return a.substring (firstIndex + d.length(), secondIndex);
>}
>return "";
You could use this UDF for all target fields and only need to change the constants.
This is an example for <sender_city>
Regards
Patrick
Edited by: Patrick Koehnen on Sep 25, 2008 12:26 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Please do following:
Assuming You know the exact lengths of all fields.
Apply this
SOURCE>Substring(start..End)> TARGET.
Regards,
Akshay.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have to use either Java mapping or UDF....
if anyone have idea of doing with Graphical mapping without UDF let me know..
Thanks
PT
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi PT Rao,
it is not possible with the graphical mapping even with the substring or any other string functions
becoz the input from the source keeps on changing
eg:
street : James Street
street: Frances Street
in the above example we see the lent of string is varying in this fashion the input keeps on changning
Regards
Sampath
Alternately you could even do it with a set of string functions.
<sender_street>streetname</sender_street>
<sender_city>city</sender_city>
<sender_state>state</sender_city>
1. In the UDF replace <sender_street>,<sender_city>,<sender_state> with "" and
</sender_street></sender_city>&</sender_state> with ,(comma) so that you string will become in the pattern streetname,city,state.
2. Now split the string at ,(comma) and return the required string in the different UDF.
Thanks
SaNv...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey,
if you can insert seprators such as "," or ";" you can do it using string functions of graphical mapping such as indexOf and substring.
regards,
Milan
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 also parse the XML inside the UDF i.e. incorporate the java mapping inside UDF.
1. Specify all the imports that are used by the java mapping in the UDF.
2. Pass the field sender_address to the UDF.
3. This code will parse conver your input a to a bytestream
byte[] bytes = a.getBytes();
ByteArrayInputStream InputStream = new ByteArrayInputStream(bytes);
4. Then as in the java mapping parse this InputStream and get the node value and return it.
You would require 4 UDF that would be simalar execept the node(i.e. getElementsByTagName & getNodeValue) that it looks to.
Thanks
SaNv...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.