Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

writer.writeOpen(x) doesn't write namespaces #39

Closed
borissmidt opened this issue Feb 1, 2018 · 1 comment
Closed

writer.writeOpen(x) doesn't write namespaces #39

borissmidt opened this issue Feb 1, 2018 · 1 comment
Assignees
Labels
Milestone

Comments

@borissmidt
Copy link

borissmidt commented Feb 1, 2018

When i create an element with namespaces it will not write out the namespaces.

def writeDocument(writer: XMLWriter) 
  val rss = doc.addElement("rss")
     .addNamespace("g", "http://base.google.com/ns/1.0")
     .addNamespace("c", "http://base.google.com/cns/1.0")
   writer.writeOpen(rss)  // => doesn't work <rss>
   writer.write(rss) // => works <rss xmlns:c="http://base.google.com/ns/1.0" ... >

A normal write also writes out the namespaces

However when i write it using attributes it writes out the tag with namespaces.

def writeDocument(writer: XMLWriter) 
  val rss = XML.createElement("rss")
     .addAttribute("xmlns:g", "http://base.google.com/ns/1.0")
     .addAttribute("xmlns:c", "http://base.google.com/cns/1.0")
 writer.writeOpen(rss) // => works <rss xmlns:c="http://base.google.com/ns/1.0" ... >

btw it is scala code but that shouldn't matter.

@FilipJirsak FilipJirsak self-assigned this Feb 7, 2018
@FilipJirsak
Copy link
Contributor

Fixed, namespaces declared directly on an element are written out together with attributes.
Adding attributes which name starts with xmlns should be forbidden, but some applications depend on it so it will be fixed in version 3.0.

@FilipJirsak FilipJirsak added bug and removed question labels Jul 1, 2018
@FilipJirsak FilipJirsak added this to the 2.1.1 milestone Jul 1, 2018
FilipJirsak added a commit to FilipJirsak/dom4j that referenced this issue Mar 12, 2020
FilipJirsak added a commit that referenced this issue Apr 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants