cancel
Showing results for 
Search instead for 
Did you mean: 

Send XML data into XML field

Former Member
0 Kudos

Hi Experts!

Its very usgent.

How to send XML data into target XML field in JAVA mapping. I am mapping source idoc to target message type.

Eg:

Source data coming from Idoc:

E1EDKT1

-E1EDKT2

-TDLINE = <name1>test</name1> <name2> abc<//name2>

Target Data type

Recordset

name

Expected result: <name><name1>test</name1><name2>abc</name2></name>

But I am getting following output: <name>&ltname1&gttest*ltname1&gt&ltname2&gtabc&ltname2&gt</name>

Here < replacing with &lt , > replacing with &gt, I do not want like this.

Please help me our on this. Thanks for your help.

Thanks,

Hari

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

Hi Chris,

Thanks for your reply. I am using JAVA mapping. Can you please explain with more details of your code:

String xml = BEG_OF_DOC + <your full tdline content> + END_OF_XML (set BEG_OF & END_OF strings to the relevant XML content)

DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();

Document document = parser.parse(new InputSource(new StringReader(xml)));

Here is the my code:

StringBuffer ZOIMstr = new StringBuffer();

for(int k = 0; k < E1EDKT1.getChildNodes().getLength(); k++)

if(E1EDKT1.getChildNodes().item(k).getNodeName().equals("E1EDKT2"))

ZOIMstr.append(E1EDKT1.getChildNodes().item(k).getFirstChild().getFirstChild().getNodeValue());

Addenda.appendChild(Addenda.getOwnerDocument().createTextNode(ZOIMstr.toString()));

return Addenda;

Former Member
0 Kudos

Hi Experts!

Can you please answer to my question.

Thanks,

Hari

Former Member
0 Kudos

Storing such TDLINE content (XML string structure) into an output text (value) node will make XML parsing mechanism resolve the "<" and ">" symbols as entities (cuz they can't be used as node content), that's why you get the "&lt" and "&gt" sequences ... Are you using graphical mapping or custom java mapping ? In case of java mapping, are you using DOM technic ?

Maybe you could do sthg like this :

String xml = BEG_OF_DOC + <your full tdline content> + END_OF_XML (set BEG_OF & END_OF strings to the relevant XML content)

DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();

Document document = parser.parse(new InputSource(new StringReader(xml)));

Chris

Edited by: Christophe PFERTZEL on Sep 28, 2009 4:07 PM

Edited by: Christophe PFERTZEL on Sep 28, 2009 4:10 PM

Former Member
0 Kudos

starting tag is : <![CDATA[

end tag is: ]]>

Former Member
0 Kudos

Starting tag : [H0]|R.F.C:XXXXNNNNNNXNN||2.0|||D00|||||00150161||2009-09-15T12:14:21|09876|20090914|Contado|000|O|Factura comercial |||0.00|||0.00 |||0.00 ||||||15 ||99999||||MXN||20090914||||||||||TRECE PESOS80 /100 M.N.||||||||||GOODYEAR SERVICIOS COMERC|GSC010102U56|7507002300000|RIO NILO|88|OFIC.104||Naucalpan|EntreManzanos y Peras|DELEGACION CUAUHTEMOC|Estado de Mexico|Mexico|06500|E0616211102|||||||||||||||Prolongación Paseo de laReforma|1015||Desarrollo Santa Fe|||Álvaro Obregón|DistritoFederal|Mexico|0 1109||||||||||||Cliente MexicoTeste|XXXXNNNNNNXNN|Paseo de la Reforma|Paseo de laReforma|204|2-A|Juárez|||Cuauhtemoc|DistritoFederal|Mexico|12345|||||||||||||Cliente MexicoTeste|XXXXNNNNNNXNN|Paseo de la Reforma|Paseo de laReforma|204|2-A|Juárez|||Cua uhtemoc|DistritoFederal|Mexico|12345|||||||||||||||185/60R15 EAGLE EXCELLENCE 84H||1.000 |C/U|1|1.2 ||0.00 ||0.00 ||0.00 |||||1 2.00 |15 |0|1.000||00000000|||||EAN09||1.2 |13.80 |1.80|0|||||||||||||||||||||||||||||||||||1.20 |0.00 |0.00 |0.00|0.0 0 |0.00 |1.80 ||13.80 |12.00 |1.00 |15 |0|||||||||||||||||1 ||||||||||||2.0|150161|2009-09-15T12:14:21|0000010455|2009|ingreso|Pago en una sola exhibición|Contado|12.00|13.80|GSC010102U56|GOODYEARSERVICIOS COMERCIALES S. DE|RIO NILO|88|OFIC.104|COLONIA CUAUHTEMOC|DELEGACION CUAUHTEMOC|Estado de Mexico|Mexico|06500|ProlongaciónPaseo de la Reforma|1015|Desarrollo Santa Fe|Mexico|Álvaro Obregón|Distrito Federal|Mexico|01109|XXXXNNNNNNXNN|Cliente MexicoTeste|Paseo de la Reforma|204|2-A|Juárez|Ciudad de México|Cuauhtemoc|Distrito Federal|Mexico|12345|1.000|C/U|000000000000100320|185/60R15EAGLE EXCELLENCE 84 H|12.00|12.00|IVA|15.00|1.80|1.80||||M em/oYyhfFPYwtngJyL/F5KDg2kIqM01D71n8cGAe7kjRquXIw4mItotI4BjyNisrtuYnc6I7lfYijRmC9bMpsphAe0pXauWS9s9lxvZleDIu2Ht6ciiDp26Tjd3uINwZ CuJK+bXvjKSkqMF4WE0TvtsSTg5olFekGQwaGA=||

Former Member
0 Kudos

I used the method createCDATASection in java mapping, xml file create with out special symbols, but file creating with begin tag <![CDATA and end tag with ]]>.

But customer was requesting us to remove those CDATA tags. Can you please let me know how to remove those tags.

Former Member
0 Kudos

Hi Hari,

If you use correctly the brackets etc. you will not have that in your file. So please recheck once again. It only used to put your xml data into xml field.

Regards,

---Satish

Former Member
0 Kudos

Thanks for your quick reply. Even I tried end to end testing, xml file created with special symbols (&lt, &gt etc). Even I tried to open xml file in notepad, its giving special symbols. Here I am using java mapping to create the xml data. My question: how to send the xml data into xml filed?

Thaks,

Hari

Former Member
0 Kudos

Hari,

You can use CDATA for this. Please see some help here or search for cdata in sdn. You have couple of blogs on them.

http://www.exampledepot.com/egs/org.w3c.dom/AddCdata.html

http://www.java-tips.org/java-se-tips/org.xml.sax/accessing-character-data-cdata-of-xml-element.html

Regards,

---Satish

Former Member
0 Kudos

Hi Hari,

It depends upon the browser where you open. I dont think this should cause issues. Try running end to end scenario and then see the output. You should have the output as desried by you.

Regards,

---Satish