Bugs item #1148333, was opened at 2005-02-22 20:32 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=116035&aid=1148333&group_id=16035
Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Maarten Coene (maartenc) Assigned to: Nobody/Anonymous (nobody) Summary: Unable to clone DOMNamespace nodes Initial Comment: (From the dom4j-dev mailinglist) 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 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=116035&aid=1148333&group_id=16035 ------------------------------------------------------- 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