cancel
Showing results for 
Search instead for 
Did you mean: 

Namespace missing in java mapping DOM ?

Former Member
0 Kudos

Hi,

I am creating java mapping using DOM, but why i cannot create a namespace using this code ?

Document targetDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Node docRoot = targetDoc.appendChild(targetDoc.createElementNS("urn:sap-com:atp:ABC40:base", "ns1:Vendor_SQL"));

TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");

// create source and result wrappers and perform transformation
DOMSource source = new DOMSource(targetDoc);
StreamResult result = new StreamResult(outputStream);   
transformer.transform(source, result);

expected result in xml :

<?xml version="1.0" encoding="UTF-8"?>
<ns0:Vendor_SQL xmlns:ns0="urn:sap-com:atp:ABC40:base">
</ns0:Vendor_SQL>

result :

<?xml version="1.0" encoding="UTF-8"?>
<ns0:Vendor_SQL>
</ns0:Vendor_SQL>

Please advise whether i was missing any other required step ?

Note : testing using NWDS 7.0 SP 17

Thank You and Best Regards

Fernand

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Lesmana,

Can you change the second line in the code like below and give a try::

Node docRoot = targetDoc.appendChild(targetDoc.createElementNS("ns1:urn:sap-com:atp:ABC40:base", "ns1:Vendor_SQL"));

Regards,

---Saish

Answers (0)