Being new to the DOM
programming world, I'm experimenting with some of the sample apps to learn about
DOM capabilities and limitations. I'm planning an application which will need to
parse multiple XML source documents, and create from them a new document
containing some components from each of the source documents. I have
successfully performed a deep clone of an element of document1, after which my
attempt to insert the new node into an element of document2 causes a
core dump.
If I modify the code
so that the node being inserted is created from scratch using
document2.createElement(), then the insertion has no trouble. So I'm wondering
if cloning from one tree, and then inserting the clone into a different tree is
even possible? If it is, then there must be some subtlety that I'm missing. If
it's not possible, then the only way I can think of to accomplish the same
result would be to traverse the node to be copied, and reconstruct it element by
element in the tree to which it is to be inserted. But that seems to
inconvenient to be reasonable.
Can someone lend
some advice to get me over this hump? My attempts to analyze the core file have
not provided much useful information. Even though I have built the Xerces
library with the debug option, I must not have given the debugger sufficient
search path information, because after the call to ParentNode::insertBefore() in
my own source file, the subsequent calls leading to the crash are displayed
without any of the symbolic information that would be needed to shed more light
on the problem. Any info on which source directories should be included in the
search path would also be appreciated. I'm currently telling it to look in:
$XERCESCROOT/src/dom:$XERCESCROOT/src/parsers:$XERCESCROOT/src/util:.
Thanks for any
help,
Bruce
Reid
