Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 3462

Re: XML Namespace

$
0
0

Hi Sam,

              You can add a java mapping in the OM to create the necessary namespace.

Can you please provide the xml payload you are getting and the one you intend to send.

 

Here is however a sample code to add the namespace

 

input

-----------

 

<?xml version="1.0" encoding="UTF-8"?><root></root>

 


output

---------

 

<?xml version="1.0" encoding="UTF-8" standalone="no"?><root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation="my.xsd"></root>

 


code

--------

 

DocumentBuilderFactory factory =DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = factory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
Element root = doc.createElement("root");
root
.setAttributeNS("http://www.w3.org/2001/XMLSchema-instance",
  
"xsi:noNamespaceSchemaLocation","my.xsd");
doc
.appendChild(root);
DOMImplementationLS dls =(DOMImplementationLS) doc.getImplementation();
System.out.println(dls.createLSSerializer().writeToString(doc));

 

 

Regards

Anupam


Viewing all articles
Browse latest Browse all 3462

Trending Articles