This seems like a bug to me. The only workaround I can think of at the
moment is to write your DOMDocument as XML to a String and parse that
String again to obtain a copy of your document.
thanks for the report
regards,
Maarten
[EMAIL PROTECTED] schreef:
Hello there, I'm new to this mailing list...
I was doing some evaluation on dom4j as a replacement for Xerces, and
using the
org.w3c.dom interface support.
Everything seems to be working so far - retrofitting it into an
application that I'm
working on. But I'm having trouble with calling to
domDocument.cloneNode(true).
The XML being used contains namespace attributes in the root element
(ex: xmlns:xyz="some URL")
This results in an IllegalAddException being thrown for when it tries
to clone a DOMNamespace
node. Here's the interesting part of the stack trace:
org.dom4j.IllegalAddException: The node
"[EMAIL PROTECTED] [Namespace: prefix mapped to
URI "http://filenet.com/namespaces/wcm/apps/1.0"]" could not be
added to the element "response" because: The Node already has an
existing parent of "response"
at org.dom4j.tree.AbstractElement.addNode
(AbstractElement.java:2139)
at org.dom4j.tree.AbstractElement.add (AbstractElement.java:1424)
at org.dom4j.tree.AbstractElement.add (AbstractElement.java:1335)
at org.dom4j.tree.AbstractBranch.appendContent
(AbstractBranch.java:252)
at org.dom4j.tree.DefaultElement.clone (DefaultElement.java:271)
at org.dom4j.tree.AbstractBranch.appendContent
(AbstractBranch.java:252)
at org.dom4j.tree.DefaultDocument.clone
(DefaultDocument.java:133)
at org.dom4j.dom.DOMNodeHelper.cloneNode (DOMNodeHelper.java:199)
at org.dom4j.dom.DOMDocument.cloneNode (DOMDocument.java:180)
at
com.filenet.wcm.toolkit.server.util.FilterData.mergeObjectSets
(C:/starburst/per170/www/001/dev/apps/java/src/com/filenet/wcm/toolkit/server/util/FilterData.java:1211)
at com.filenet.wcm.toolkit.server.util.FilterData.getResults
(C:/starburst/per170/www/001/dev/apps/java/src/com/filenet/wcm/toolkit/server/util/FilterData.java:1431)
So I took a quick scan through the dom4j sources, and figured out that
the clone methods do not actually clone a node if
it is readonly. Instead it just returns the node itself from the
clone. Not set up to debug, but I'm assuming that this
node is in fact readonly.
Is there something special to do to make cloning work with an XML that
has namespace attributes, or is it a bug?
Thanks.
-J
------------------------------------------------------- SF email is
sponsored by - The IT Product Guide Read honest & candid reviews on
hundreds of IT Products from real users. Discover which products truly
live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________ dom4j-dev mailing list
dom4j-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-dev
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
dom4j-dev mailing list
dom4j-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-dev