Re: [xml] xmlCopyNode with namespace



On Thu, Feb 21, 2002 at 11:24:04AM +0100, Uwe Fechner wrote:
Hello,

the functions:

xmlCopyNode
xmlCopyProp
xmlDocCopyNode
xmlDocCopyProp

don't copy the namespace node, that is bound to the original
node.

Is this a bug or a feature?

  It depends. There is actually no namespace node in the libxml tree
representation. There is only namespace declaration nodes corresponding
to the associated "xmlns" attributes. Those are shared, there is just
references for the declaration.
  When copying a node recursively, the namespace declaration carried
in the subtree are copied too and the references in that subtree are kept
coherent. If the subtree had references to namespace definitions outside the
itself, then those need to be tracked down and updated if you happen to
prune the copied result outside of the scope of those namespace declarations
for example in a different document.
   Check the xmlReconciliateNs() function, it attempts to do this but
I didn't tested it frankly.

If it's a feature, it would be nice, if it's documented in
the api-doc.

   Well, I never managed to convince myself that the current
behaviour is the one to cast in stone.

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard redhat com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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