Hi Toby

> AbstractNode returns only a shallow copy of current Node.

The general idea in dom4j is that clone() returns a deep copy. This should
also be true of the createCopy() methods on the Element interface.


> It seems to me
> that Documents aren't cloneable? Is that true?

It currently looks like it. I'll fix that really soon! Thanks for spotting
this. I'll check in a patch and a JUnit test case to CVS shortly...


> If i invoke #isReadOnly() of a
> instance of Document; it always returns false!


The dom4j API currently supports document fragment flyweights, such that the
same document fragments (e.g. an Element tree or a single Attribute) could
be reused across several documents to reduce memory and increase
performance. A common use case could be for attribute enumerations such as
align="CENTER", "RIGHT", "LEFT" - 3 flyweight Attribute instances could be
shared across all HTML documents. This reduces object construction and
increases performance for repeated parses of similar DTDs or schemas.

One added complication that this brings is that a shareable document
fragment Node cannot support the parent relationship (as a Node can have
only one parent).

The isReadOnly() and supportsParent() methods on the Node interface was
intendend for use to indicate flyweight Nodes which can be shared across
documents. So for any node which says its readOnly and doesn't support the
parent relationship, then the clone() method could return a reference to
"this" - as no deep copy is required.


> Don't you support cloned Documents in DOM4J at all, or isn't it
implemented
> for now?
> If planned, when could you provide it?

It was a mistake not to have it now - I'll be providing it shortly.

> Another question: Doesn't a Document have to support deep copies?

All Nodes which support the parent relationship (and so cannot be shared
across Document instances) must perform deep copies.

James


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


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

Reply via email to