Re: [xml] using xmlDocSetRootElement to move nodes between documents



On Wed, Jul 28, 2004 at 11:50:00AM +0200, Martijn Faassen wrote:
 You are right. There have been attempts to solve this with 
 xmlReconciliateNs
in tree.c this should solve namespace problems. Other potential problem is
entities references.

So basically the conclusion is that there is no safe way to move nodes 
between documents in libxml2 at this point in time? I don't mind having 
to call some function to 'import' nodes into a different tree, but it 
seems I have to worry about namespaces, dictionaries and entities at 
least. Right now I'm using xmlDocCopyNode(), which appears to work, 
isn't the right semantics for the API I'm trying to implement, which 
allows free movements of elements between trees.

What would a function look like that that can be used to safely import a 
node (and its subnodes) from one document to another? Could this 
function do its work relatively efficiently?

  The efficiency is the problem. Recursing down the subtree generate cost.
It's possible to share dictionaries for multiple documents, it's possible
to reconciliate namespaces, but entities if not substitued on parse are
a serious problem, you may have to add them on the internal subset of the
target.

Daniel

-- 
Daniel Veillard      | Red Hat Desktop team http://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]