Hi Raj

Thanks for spotting this bug in Element.createCopy().

I've just checked the patch into CVS along with a JUnit test case that
ensures the createCopy() method works (its in
src/test/org/dom4j/TestCopy.java if you're interested).

I've just manually kicked off a daily build so if you download the latest
daily build it should contain your patch.

While I was in this part of the code I optimised the implementation code to
use integer iteration rather than Iterators as well and I retired the now
cruft "appendAdditionalNamespaces()" method which is no longer required
(additional namespaces get copied inside the appendContent() method).

Many thanks....


>   I found the problem with the deep copy issue that I had written to
> you about.
>
>   In AbstractElement.java there is a method called appendAttributes
> which reads as follows:
>
>     // add to me content from another element
>     // analagous to the addAll(collection) methods in Java 2 collections
>     public void appendAttributes(Element element) {
>         for (Iterator i = attributeIterator(); i.hasNext(); ) {
[snip]
>     }
>
>   The for loop should iterate over the attributes of the element that is
> passed to it. Instead, it is iterating through the attributes of the
> cloned element (none exist yet). Hence the problem.
>
>   I changed the for loop to read as follows:
>
>         for (Iterator i = element.attributeIterator(); i.hasNext(); ) {
>
>   I got my test to work as expected after I made this change.

Well spotted!

>   Again, thanks for creating a nice API and putting it out in the public
> domain.

And thanks for using it Raj!

James


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


_______________________________________________
dom4j-dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to