DOMException: NAMESPACE_ERR: An attempt is made to create or modify an object in a way that is invalid with respect to namespaces
I am getting this DOMException when I try to create an attribute.
org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
at com.sun.org.apache.xerces.internal.dom.AttrNSImpl.setName(Unknown Source)
at com.sun.org.apache.xerces.internal.dom.AttrNSImpl.<init>(Unknown Source)
at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.createAttributeNS(Unknown Source)
at xml.XmlCreator.dom(XmlCreator.java:308)
at xml.XmlCreator.readTestSetRecordsForXmlFile(XmlCreator.java:262)
at xml.XmlCreator.createFile(XmlCreator.java:112)
at xml.XmlCreator.doInBackground(XmlCreator.java:83)
at xml.XmlCreator.doInBackground(XmlCreator.java:1)
at javax.swing.SwingWorker$1.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at javax.swing.SwingWorker.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
My code:
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
docFactory.setNamespaceAware(true);
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
DOMSource source = new DOMSource(doc);
Attr attributeNS = doc.createAttributeNS(attributeNS(rsValues)[1], attributeNS(rsValues)[0]);
attributeNS(rsValues)[1]
returns urn:iso:std:iso:20022:tech:xsd:pacs.003.001.02
attributeNS(rsValues)[1]
returnsxmlns
What is causing this?
+3
source to share
No one has answered this question yet
See similar questions:
or similar: