on 03-06-2008 1:21 AM
Hi,
My scenario is JDBC to RFC. The table say "XXX" has a field which contain an XML string. This is the message that is required to be send to RFC. How will I convert this string to a message for mapping?
regards
write a small UDF which has input field 'a' you are getting
StringBuffer sb = new StringBuffer("");
return a.toString();
Assign it to the target field
Is this what your requirement is. let me know if I am wrong
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You got my requirement wrong. I have the xml already in a String, need to convert to a message.
for example my pay load is as below
<row>
<MESSAGE>
<header><firstName>UK</firstName><lastName>kk</lastName></header>
<MESSAGE>
</row>
The <MESSAGE> is the oracle column of a table that contain the xml string what you see in <header></header>.
Unni,
So you will get like the below structure is it?
<row>
<MESSAGE>
<header><firstName>UK</firstName><lastName>kk</lastName></header>
<MESSAGE>
</row>
<row>
<MESSAGE>
<header><firstName>US</firstName><lastName>RJ</lastName></header>
<MESSAGE>
</row>
<row>
<MESSAGE>
<header><firstName>IN</firstName><lastName>PI</lastName></header>
<MESSAGE>
</row>
You won't have any other stuff apart from FirstName and last name tag is it? Also FirstName must go to one target field and Last Name must go to other Target field , Am I correct?
raj.
Unni:
<header><firstName>UK</firstName><lastName>kk</lastName></header>
One more question, if there is value missing, like there is no value for Middle name then how it will be represented
<header><firstName>UK</firstName></MiddleName><lastName>kk</lastName></header>
or
<header><firstName>UK</firstName><MiddleName></MiddleName><lastName>kk</lastName></header>
Hi raj
My xml structure is quiet complex and its not wht i showed is eg. Your points are correct. Thats what I require to do.
Guru: My structure would be as below
<header><firstName>UK</firstName><MiddleName></MiddleName><lastName>kk</lastName></header>
For info sake it would good if you could explain the case where it occurs as <header><firstName>UK</firstName></MiddleName><lastName>kk</lastName></header>
also.
Thanks
Unni,
If you have less number of nodes then you can go for UDF, if not Java mapping would be the option. I will take an example and explain the same.
Example
Source
<Row>0..Unbounded
<Header/>1..1
</Row>
Target
<Records>0..Unbounded
<Fname/>0..1
<Mname/>0..1
<Lname/>0..1
</Records>
UDF1
// This UDF used to genereate no.of Records in the target.
//one input parameter, lets consider parameter name as Header- Advanced UDF
for(int i=0;i<Header.length;i++)
{
if( (Header<i>.indexOf("<Fname>") !=-1) || (Header<i>.indexOf("<mname>") !=-1) || (Header<i>.indexOf("<Lname>") !=-1) )
{
result.addValue("");
}
}
Header(Change Context)----->UDF1--
>Records
UDF2
// This UDF used to genereate nodes in the target.
//Two input parameter, lets consider parameter name as *Header*, and second as *node*- Advanced UDF
for(int i=0;i<Header.length;i++)
{
if(node.equals("1"))
{
// This if condition used to generate Fname node
if(str.indexOf("<Fname>")!=-1)
{
result.addValue(""+str.substring(str.indexOf("<Fname>")+7,str.indexOf("</Fname>"))+"");
result.addContextChange();
}
else
{
result.addSuppress();
result.addContextChange();
}
}
else if(node.equals("2"))
{
// This if condition used to generate Mname node
if(str.indexOf("<Mname>")!=-1)
{
result.addValue(""+str.substring(str.indexOf("<Mname>")+7,str.indexOf("</Mname>"))+"");
result.addContextChange();
}
else
{
result.addSuppress();
result.addContextChange();
}
}
else if(node.equals("3"))
{
// This if condition used to generate Lname node
if(str.indexOf("<Lname>")!=-1)
{
result.addValue(""+str.substring(str.indexOf("<Lname>")+7,str.indexOf("</Lname>"))+"");
result.addContextChange();
}
else
{
result.addSuppress();
result.addContextChange();
}
}
}
The logic is
Header(Change Context) , Constant (1) -
>UDF2----
>Fname
Header(Change Context) , Constant (2) -
>UDF2----
>Mname
Header(Change Context) , Constant (3) -
>UDF2----
>Lname
Since, I don't have a system right now, I couldn't able to give u snapshot, sorry abt that.
But I'm sure, it will work!
Hope it helps a bit.
raj.
Unni,
I haven't tested the code for all cases. Check it and let me know if you face some issues.
There are bunch of solutions which I gave to the SDN problems, you can have a look
http://flickr.com/photos/8764045@N06/
http://flickr.com/photos/23855877@N07/
raj.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.