axis-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dinesh Premalal <>
Subject Re: Issue in using 'detach' for cloning
Date Fri, 15 Feb 2008 07:44:28 GMT
Hi Bill, Samisa,
Samisa Abeysinghe <> writes:
>> So I'm beginning to think there should be two functions, one is a
>> shallow copy of all the data elements and text values, sharing the
>> attributes and namespaces, the second is a true clone of all the
>> structures throughout the tree.  And certainly you are right that
>> the easiest way to implement clone as a deep copy is to serialize
>> the tree and deserialize it into a new structure.    
> I agree with you 100%. With ref counts, what we effectively have is a
> shallow copy, and that would work, as ling as the two "virtual" copies
> are supposed to be identical. If in any case, one wants to modify one
> tree independent of the other, then the shallow copy with ref counts
> would not work, in which case you can look to the alternative of
> serilizing and deserializing for a deep copy.

Though Bill's ref count solution sounds bit complex, I like that
suggestion. Because it's efficient than serialize and deserialize
solution that Samisa suggest. As Samisa pointed out, It seems that ref
count solution doesn't stand for when someone needs to change modify
one tree independent of the other.

We can have two"virtual" copies as long as they are identical. When
user needs to modify one tree , can't we make copy of that tree and
allow him to modify. This will explain it clearly [1]. To be clear on
what I mean here,  

Say that user have detach node and original node. AFAIU, According to
ref count solution , detach node still pointing to original node's
namespaces and attributes (with increased ref counts). When user going
to make a modification to an attribute in detach node, simply we can't
let to modify original tree's attribute. Instead we could make a copy
of original tree's attribute and let the user to change it. 

If we handle this way, we don't need to serialize and deserialze whole
node again. Does it sounds more complex than we need? Any thoughts ?




To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message