Re: [xml] namespace handling
- From: Daniel Veillard <veillard redhat com>
- To: Kasimier Buchcik <kbuchcik 4commerce de>
- Cc: xml gnome org
- Subject: Re: [xml] namespace handling
- Date: Mon, 12 May 2003 15:40:15 -0400
On Mon, May 12, 2003 at 06:09:49PM +0200, Kasimier Buchcik wrote:
premise:
If a namespace-node is created, libxml2 wants it to reference a
namespace declaration (node->ns --> some-node->nsDef) existent in the
ancestor-or-self axis.
yes
Now, let's take some DOM 2 methods:
createElementNs(...)
If I create an element like this I have to ensure that the namespace
is available in libxml2 - even if I may never add this element to
a tree.
[...]
Are there any other solutions existent?
Admit that DOM is severely broken as an API.
createAttributeNs(...)
Here it gets a bit messy: where to declare the namespace?
I cannot attach it to any nsDef since there might be no tree
existent yet (if building a tree from scratch).
Does a solution exist?
No clean solution. Creating the Attribute/Element without any context
is a serious problem.
importNode(...)
If I import a tree (deep=true) into an other document and would use
xmlDocCopyNode, this function would lead to xmlStaticCopyNode and
xmlCopyProp being processed, both trying to reconciliate namespaces,
resulting in all namespaces being recreated at the given tree.
Adding this tree to the desired document would imply:
a. Leave the created namespaces - this could lead to a lot of
declarations.
b. OR try substitute the namespaces with proper namespaces in the
ancestor axis.
Undefined in the spec. Do whatever.
removeChild(...)
If I detach a tree from the document, namespace references to
"out of the tree" may still exist. What to do?
From the detached tree ? yes but it's not deletion. If deleting, then
no you should not have this problem if deletion is recursive.
Considering these examples, I might doubt if libxml2's philosophy of
handling namespaces is adequate for working with DOM 2 (or DOM 3).
libxml2 namespace handling predates DOM2. It's far cleaner, i.e.
the href to prefix mapping is associated in a single place, it is also
more efficient in term of space requirement.
So you may want to consider the following proposals:
1. A list of namespaces on the xmlDoc.
Was okay with namespaces from 1998, completely useless with current
namespaces which are scope based I'm afraid.
I don't think I'm ready to completely break libxml2 and libxslt code
to handle namespaces in a very different way. It would also impact
all the APIs which work with xmlNsPtr, really no I don't think it's
an option at this point.
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]