I am trying to create an attribute with a namespace prefix. The following code does not seem to work:
Element newData = docFromXML.createElement("Data");
Attr typeAttr = docFromXML.createAttributeNS(namespaceContext.getNamespaceURI("ss"), "type");
typeAttr.setValue("String");
newData.setAttributeNode(typeAttr);
I expect the following:
<Data ss:type="String"></Data>
But the following is produced:
<Data type="String"></Data>
How do I explicitely add the namespace prefix "ss". The getNamespaceURI function returns the URL for the ss prefix in the DOM.