[xml] more on recursive xmlCopyNode

Sorry for cluttering the main thread, i first
had to create an accout for my home mail address:


no i dont have a patch yet. Mainly because i did not
want to fix something that is not supposed to be a bug.

And because i dont have the right tools at home to do this.
But i looked at tree.c and think that the previously described
behaviour of xmlStaticCopyNode depends directly on what
can be found in xmlCopyProp:

We have the problem that copying <a> of

a)  <root xmlns:pr="uri"><a><pr:b><c pr:attr="val"/></b></a></root>

works, while copying <a> of

b)  <root xmlns:pr="uri"><a><b><c pr:attr="val"/></b></a></root>

does not.

Line 2825 (xmlCopyProp) of tree.c (version 2.4.16) perfectly
reflects this: in case a) copying <pr:b> copies the pr namespace
into the destination tree. Thus

   ns = xmlSearchNs(target->doc, target, cur->ns->prefix); (line2826)

is able to find it, and link pr:attr's ns to it.

But i dont understand the next 2 lines: They try to find the namespace
in the source tree, but search on the target node upwards to the
source doc? Shouldnt this be

   ns = xmlSearchNs(cur->doc, cur, cur->ns->prefix);

instead of

   ns = xmlSearchNs(cur->doc, target, cur->ns->prefix);

Anyway: Would this suffice? Dont we have to copy the namespace to
cut the dependency to the source tree in case we dont copy to the same
xml Document? Wouldnt it make sense to look in the source document
even if a target document exists?

Please let me know what you think.


PS: is the mailing list the right place to discuss this or is it
reserved to more general topics?

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