Actually, we should not be support cloneNode() at all in Xalan's source
tree implementation. It could very well be a bug, but I'm tempted to just
deprecate the functionality and not fix it, as we never use it internally.
Since you cannot modify an instance of the source tree once it's created,
it's not clear to me what you can do with cloneNode() except to clone an
entire document. You'd never be able to add the node to another part of
the tree anyway, so there doesn't seem to be much value to supporting this.
If you really need a fully-functioning DOM, then use the Xerces DOM, which
can be wrapped for transformations. This is much less efficient, but I
don't want Xalan to get into the business of implementing the DOM. We
never modify the source tree internally, and always build it in
document-order, so it's highly optimized for read-only access.
Dave
john Tourtellott
<[EMAIL PROTECTED] To: xalan-c-users
<[email protected]>
.com> cc: (bcc: David N
Bertoni/Cambridge/IBM)
Sent by: Subject: XalanNode::cloneNode()
behavior doesn't seem to match documentation
[EMAIL PROTECTED]
s.com
06/29/2002 11:57
AM
1. The documentation for the cloneNode() method in the XalanNode class
and subclasses indicates that "Cloning an Element copies all attributes
and their values, ... but this method does not copy any text it contains
unless it is a deep clone, since the text is contained in a child Text
node." My experience cloning an element (specifically, calling
XalanSourceTreeElement::cloneNode) is that the method always copies the
first child node (which in my case, is a text node) regardless of
whether it is a deep clone or not. Looking at the copy constructor in
XalanSourceTreeElement.cpp seems to confirm this.
2. Also, the documentation for the "deep" parameter states that "If
true, recursively clone the subtree under the specified node; if false,
clone only the node itself", but I see no sign of this recursive
behavior in the Xalan source code. My test programs confirm this also.
Am I missing something here? Is there a way to clone an XalanNode
without copying it's child text node?
Also, is there a way to recursively clone a node and it's full subtree?
john