[ https://issues.apache.org/jira/browse/XERCESJ-1720?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17016095#comment-17016095 ]
Vithursa commented on XERCESJ-1720: ----------------------------------- Hi [~elharo] , Thanks for the reply. Even though it looks same, I need to have *xmlns=""* because, in higher level XML processing it prevents adding a different namespace. (I need to use this feature - [1]) [1] https://docs.wso2.com/display/ESB490/PayloadFactory+Mediator#PayloadFactoryMediator-Example4:Suppressingthenamespace > 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