Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

dom4j adds default namespace in all elements

843834Sep 24 2008 — edited Sep 25 2008
I'm using dom4j to handle XML documents, but I'm having the problem that dom4j adds the default namespace in all child elements.

Consider the following example document:

String xml = "<resource-lists xmlns=\"urn:ietf:params:xml:ns:resource-lists\">"
+ "<list name=\"friends\">"
+ "<entry uri=\"sip:one@test.com\" />"
+ "<entry uri=\"sip:two@test.com\" />"
+ "<entry uri=\"sip:three@test.com\" />"
+ "</list></resource-lists>";

I'm constructing a dom4j Document out of it:

Document dom4jDoc = DocumentHelper.parseText(xml);

(Both Document and DocumentHelper are from package org.dom4j.)

When looking through the dom tree (in debug mode in Eclipse), I can see that dom4j has added the default namespace ("urn:ietf:params:xml:ns:resource-lists" in the example above) in each of the child elements, both the <list> element and the <entry> elements.

Anyone knows how to get around this? It's in conflict with XCAP, rfc4825:

"The server MUST NOT add namespace bindings representing namespaces used by the element or its children, but declared in ancestor elements; the client will either know these bindings already (since it has a cached copy of the whole document), or it can learn them by explicitly querying for the bindings."
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 23 2008
Added on Sep 24 2008
2 comments
913 views