Dear list,
We are building our own DOM implementation on top of libxml2, and
running into some problems implementing copying documents. We depend on
(ab)using the oldNs member of the document struct to implement the dom's
"namespaces are bound to the node, not to the prefix" rules, but
attributes such as xml:lang appear to be corrupted.
We're probably on our own manipulating oldNs directly, but I've think
we've also found an inconsistency in how libxml handles oldNs, which
might also give problems elsewhere.
Our problem is as follows: xmlSearchNs always assumes that 'doc->oldNs',
if it exists, is the namespace for the 'xml:' prefix. However,
xmlCopyDoc breaks this assumption because of the way it copies oldNs to
the new document, as follows:
- xmlCopyDoc copies oldNs using xmlCopyNamespaceList
- xmlCopyNamespaceList invokes xmlCopyNamespace on every namespace
- xmlCopyNamespace invokes xmlNewNs to do the copy
- xmlNewNs will not copy a namespace with prefix "xml"
A simple workaround for us is to do:
- if (doc->oldNs != NULL)
- ret->oldNs = xmlCopyNamespaceList(doc->oldNs);
+ if (doc->oldNs != NULL) {
+ xmlTreeEnsureXMLDecl(ret);
+ ret->oldNs->next = xmlCopyNamespaceList(doc->oldNs);
+ }
but I wonder if this is a 'proper' solution, and hope you have any input
Arnold Hendriks
--
Arnold Hendriks<[email protected]>
Postbus 545, 7500 AM Enschede, The Netherlands
B-Lex IT B.V. Web: http://www.b-lex.com/
Phone: +31 (0)53 4836543 Mobile: +31 (0)6 51710159
KvK: 08174333 (Oost-Nederland) MSN: [email protected]
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml