You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Jay Cain <ja...@cett.msstate.edu> on 2001/01/08 08:03:48 UTC

[PATCH] Preserve element identifiers when cloning Document

This is a patch for DocumentImpl.java allowing it to preserve element
identifiers when deep cloning. Basically, it checks a hashtable for the
element being cloned and assigns the associated identifier to the new
element.

The descriptions of the modified methods need to be rehashed.

- - - - -
Jay Cain
Center for Educational and Training Technology
Mississippi State University

> -----Original Message-----
> From: Peter Kharchenko [mailto:peterk@interactivebusiness.com]
> Sent: Thursday, January 04, 2001 3:38 PM
> To: xerces-j-dev@xml.apache.org
> Subject: cloning DocumentImpl object
>
>
> Hi there,
>  I can't seem to find a way to make a complete clone of a Document object
> (that would fully replicate the behavior of the original, for example
> identifier table is copied, so one can do getElementById() etc). Note
> that cloning must be deep, that is all of the nodes belonging to that
> document must be copied.
>  I've seen similar questions brought up before, but never saw a good
> answer to that.
>
>  Here's the problem in details:
> There are a few ways one could attempt to clone that DocumentImpl object.
> 	- using overloaded Object.clone() method. That doesn't work, since
> clone() doesn't copy children.
> 	- using cloneNode(true) doesn't work either since
> identifier tables are
> not copied.
>
>  Is there a standard way of creating a fully-functional deep clone of a
> DocumentImpl object ?
>
> thanks in advance,
>
> -peter.
>
> P.S. since what I really need is a deep clone that preserves identifier
> table, I might just rewrite importNode() function to do just that, but
> that feels like a cheapo hack.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org

RE: [PATCH] Preserve element identifiers when cloning Document

Posted by Jay Cain <ja...@cett.msstate.edu>.
I've submitted two patches concerning this issue and have gotten no feedback
whatsoever. Is the patch going to be applied or what? Isn't this supposed to
be an open-source project? As far as I know, I've followed the proceedures
for submitting a patch and there have been no replies. What gives?

- - - - -
Jay Cain
Center for Educational and Training Technology
Mississippi State University


[PATCH] Preserve element identifiers when cloning Document

Posted by Jay Cain <ja...@cett.msstate.edu>.
Here is an updated patch for DocumentImpl. The element identifiers are
preserved when a deep clone is performed. Is there a need to be able to turn
this feature off?

Also, a minor change was made for DOM conformity. importNode now throws
NOT_SUPPORTED_ERR instead of HIERARCHY_REQUEST_ERR when an import of a
document node is attempted, which is according the DOM specifications. This
shouldn't cause any problems, especially if the DOM Java bindings were used
as the reference. If it will cause problems, it's only one line of code to
change.

The tests passed and the documentation has been updated.

- - - - -
Jay Cain
Center for Educational and Training Technology
Mississippi State University