[jira] [Commented] (XERCESJ-1720) Generate DOM Element with empty namespace using Apache xerces
[ https://issues.apache.org/jira/browse/XERCESJ-1720?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17016910#comment-17016910 ] Elliotte Rusty Harold commented on XERCESJ-1720: Don't treat namespaces as an attribute. Just assign the namespaces on each element and attribute as desired and let the serializer work it out. I don't see a bug in Xerces here. I think this issue can be closed. > 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} > > > > > > > {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, . > {code} > {code:java} > element = doc.createElementNS("", "name"); // Output : > > {code} > {code:java} > element = doc.createElement("name"); > element.setAttribute("xmlns", ""); // Output : > {code} > {code:java} > element = doc.createElement("name"); > element.setAttributeNS("http://www.w3.org/2000/xmlns/";, "xmlns", ""); > // Output : > {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
[jira] [Commented] (XERCESJ-1720) Generate DOM Element with empty namespace using Apache xerces
[ https://issues.apache.org/jira/browse/XERCESJ-1720?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17016629#comment-17016629 ] Vithursa commented on XERCESJ-1720: --- Hi [~elharo], {quote}xmlns="" is only needed when there's a default namespace in scope and you need to remove it. {quote} As you mentioned, my requirement is to add *xmlns = ""* in order to prevent default namespace getting added. Let me explain requirement in detail. I am generating an XML which should be appended as child for a root element, over which I do not have any control. Root element would have a format like this: {code:xml} {code} My requirement is not add the root element's namespace to child. Since, I do not have any control over the root element, I am trying to add xmlns="" in child so that, it prevents the default namespace being added. If I have root element as, {code:xml} 123 {code} then it is possible that when appending the child element, the namespace of root element will not get added. Hence, I need to generate XML element with namespace *xmlns=""*. Is it possible to do so? Thanks, Vithursa > 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} > http://sap.com/xi/BASIS";> > > > > > > {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, . > {code} > {code:java} > element = doc.createElementNS("", "name"); // Output : > > {code} > {code:java} > element = doc.createElement("name"); > element.setAttribute("xmlns", ""); // Output : > {code} > {code:java} > element = doc.createElement("name"); > element.setAttributeNS("http://www.w3.org/2000/xmlns/";, "xmlns", ""); > // Output : > {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
[jira] [Commented] (XERCESJ-1720) Generate DOM Element with empty namespace using Apache xerces
[ https://issues.apache.org/jira/browse/XERCESJ-1720?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17016217#comment-17016217 ] Elliotte Rusty Harold commented on XERCESJ-1720: That higher level processing sounds broken. In the example you give xmlns="" is not different from no xmlns attribute at all. xmlns="" is only needed when there's a default namespace in scope and you need to remove it. > 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} > http://sap.com/xi/BASIS";> > > > > > > {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, . > {code} > {code:java} > element = doc.createElementNS("", "name"); // Output : > > {code} > {code:java} > element = doc.createElement("name"); > element.setAttribute("xmlns", ""); // Output : > {code} > {code:java} > element = doc.createElement("name"); > element.setAttributeNS("http://www.w3.org/2000/xmlns/";, "xmlns", ""); > // Output : > {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
[jira] [Commented] (XERCESJ-1720) Generate DOM Element with empty namespace using Apache xerces
[ 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} > http://sap.com/xi/BASIS";> > > > > > > {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, . > {code} > {code:java} > element = doc.createElementNS("", "name"); // Output : > > {code} > {code:java} > element = doc.createElement("name"); > element.setAttribute("xmlns", ""); // Output : > {code} > {code:java} > element = doc.createElement("name"); > element.setAttributeNS("http://www.w3.org/2000/xmlns/";, "xmlns", ""); > // Output : > {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
[jira] [Commented] (XERCESJ-1720) Generate DOM Element with empty namespace using Apache xerces
[ 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} > http://sap.com/xi/BASIS";> > > > > > > {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, . > {code} > {code:java} > element = doc.createElementNS("", "name"); // Output : > > {code} > {code:java} > element = doc.createElement("name"); > element.setAttribute("xmlns", ""); // Output : > {code} > {code:java} > element = doc.createElement("name"); > element.setAttributeNS("http://www.w3.org/2000/xmlns/";, "xmlns", ""); > // Output : > {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