Efficient read-only cloning?

EntityReference is supposed to (appear to) contain a read-only copy of the
data stored in the Entity. I'm looking for a more elegant method of
achieving that.

The alternatives I've looked at are:

1) Store the Entity's children as read-only, and preserve that when they
get cloned into the EntityReference. Works, but makes editing them a bit
awkward in tools which permit manipulation of both the DTD and the
document.

2) Have EntityReference's replicate-entity-contents code do an additional
walk over the cloned subtree to set this flag. Works, but requires that the
subtrees be walked twice -- once to clone, and again to set them readonly.

3) Add a "boolean makeReadOnly" parameter to cloneNode() which sets this
flag during the same tree-walk that copies everything else. Works, but
would have to be made part of the official DOM API since otherwise
applications that subclass the DOM wouldn't know that they had to patch
this version of cloneNode() to support their added fields.


Of those three, I'm most attracted by the third; it's easy, fast, and might
be useful in other situations where readonly nodes were desired. But I
suspect it's too late to lobby for this to be included in DOM Level 1...?

______________________________________
Joe Kesselman  / IBM Research
Unless stated otherwise, all opinions are solely those of the author.

Received on Tuesday, 22 September 1998 12:54:56 UTC