[ https://issues.apache.org/jira/browse/XERCESJ-1720?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17016085#comment-17016085 ]
Elliotte Rusty Harold commented on XERCESJ-1720: ------------------------------------------------ It's not totally clear why you need this. The example you give is essentially the same with or without the xmlns attributes. There's probably something in the code somewhere that recognizes this and removes those attributes as unnecessary. > Generate DOM Element with empty namespace using Apache xerces > -------------------------------------------------------------- > > Key: XERCESJ-1720 > URL: https://issues.apache.org/jira/browse/XERCESJ-1720 > Project: Xerces2-J > Issue Type: Bug > Components: Documentation > Affects Versions: 2.8.1 > Reporter: Vithursa > Priority: Minor > Labels: query > > I have a requirement to generate an XML which should have empty namespace. An > example XML should looks like: > {code:xml} > <name xmlns:cap="http://sap.com/xi/BASIS"> > <cap:attributeID> > <attribute1 xmlns="" >xxxx</attribute1> > <attribute2 xmlns="" >xxxx</attribute2> > </cap:attributeID> > </name> > {code} > > As mentioned above, I need to add *xmlns* attribute with empty string. I > have tried following ways to achieve it but none of them worked: > {code:java} > DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); > DocumentBuilder docBuilder; > docBuilder = docFactory.newDocumentBuilder(); > Document doc = docBuilder.newDocument(); > element = doc.createElement("attribute1"); // It did not have any namespace. > Output becomes as, <attribute1>xxxx</attribute1>. > {code} > {code:java} > element = doc.createElementNS("", "name"); // Output : > <attribute1>xxxx</attribute1> > {code} > {code:java} > element = doc.createElement("name"); > element.setAttribute("xmlns", ""); // Output : <attribute1>xxxx</attribute1> > {code} > {code:java} > element = doc.createElement("name"); > element.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", ""); > // Output : <attribute1>xxxx</attribute1> > {code} > What is the correct way of adding an empty string as namespace to cater my > requirement? Can someone provide guidance on this? > Thanks, > Vithursa -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: j-dev-unsubscr...@xerces.apache.org For additional commands, e-mail: j-dev-h...@xerces.apache.org