cancel
Showing results for 
Search instead for 
Did you mean: 

Graphical Mapping

former_member240483
Contributor
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

former_member240483
Contributor
0 Kudos

Thanks Patrick..we done the Java mapping its working fine just want to know whether it is possible with Graphical or not..

Thanks All for your time and inputs.

Regards

PT

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

Please do following:

Assuming You know the exact lengths of all fields.

Apply this

SOURCE>Substring(start..End)> TARGET.

Regards,

Akshay.

former_member240483
Contributor
0 Kudos

Have to use either Java mapping or UDF....

if anyone have idea of doing with Graphical mapping without UDF let me know..

Thanks

PT

Former Member
0 Kudos

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

santhosh_kumarv
Active Contributor
0 Kudos

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...

Former Member
0 Kudos

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

santhosh_kumarv
Active Contributor
0 Kudos

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...

former_member240483
Contributor
0 Kudos

Hi there,

Thanks for reply as i said earlier i allready done with the Java mapping i am just asking is there any way through graphical mapping with out UDF's with any standard graphical standard functions.

Regards

PT