Re: [xml] xmlDOMWrapCloneNode problem


This might be better. What will really be better though is if it works
correctly for unlinked nodes too.

In fact in my algorithm the line of construction (clone where it is
needed) of the nodes is in reversed order, from children towards
parents. Changing the function xmlDOMWrapCloneNode to refuse unlinked
nodes will result in forcing me to change my design because this will
remove the workaround possibility I currently have (preserving all the
source documents alive until the clone is alive).


On Tue, Aug 14, 2012 at 12:18 PM, Noam Postavsky
<npostavs users sourceforge net> wrote:
George Georgiev <george georgiev sf gmail com> writes:

int main(int argc, char **argv)
        xmlNodePtr mathPr = xmlNewDocNode(doc2, mns, BAD_CAST"mathPr", NULL);
        xmlDOMWrapCloneNode(NULL,                // xmlDOMWrapCtxtPtr - optional
                            mathFont->doc,       // sourceDoc (must not be NULL)
                            mathFont,            // node to clone
                            &newChildNode,       // destNode
                            mathPr->doc,         // destDoc
                            mathPr,              // destParent
                            TRUE,                // deep = clone children
                            0                    // options (ATTRIBUTE_UNUSED)

        xmlAddChild(root, mathPr);

The trouble seems to be using an unlinked node as destParent: if I do
xmlAddChild() before xmlDOMWrapCloneNode(), there are no problems. It
might be sensible for xmlDOMWrapCloneNode() to signal an error for this

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]