W3C home > Mailing lists > Public > www-ql@w3.org > October to December 2003

Re: namespace node implementation

From: Xavier Franc <xfranc@online.fr>
Date: Wed, 22 Oct 2003 13:16:10 +0200
Message-ID: <3F9666FA.1030901@online.fr>
To: www-ql@w3.org

Per Bothner wrote:
> * Each element has a "namespace mapping", which maps prefixes to uris, 
> and which can be implemented as a hash-table or a vector (propery-list). 
>   (Since the namespace mapping is primarily used for serialization, it 
> makes more sense to use a space-efficient vector.)
> * Once created a namespace mapping is immutable, and so can be shared 
> between element nodes.
> * When parsing an XML document, if an element has no namespace 
> attributes we re-use the namespace mapping of its parent.  If it has 
> namespace attributes, we create a new namespace mapping which is the 
> combination of the parent's namespace mapping with the new namespace 
> attributes.
> * When serializing an element, we print all the namespaces in the 
> element's namespace mapping, except for ones that are redundant because 
> they have already been serialized in an enclosing element.
> * When an element is constructed, its namespace mapping includes all the 
> "active namespaces nodes" (in the sense of the specification) plus any 
> of the namespaces in the prologue or predefined that are referenced in 
> the current element *or* (if this is a direct element constructor) in 
> any enclosed direct element constructors.  (This rule is meant to 
> minimize the number of distinct namespace mapping we have to create. 
> The implemengtatin may need to be a little bit clever here.)
> * When an element is (conceptually) copied (re-parented), we use its 
> existing namespace mapping.  We do *not* create a new namespace mapping 
> to incorporate any namespace in the parent.

this is roughly speaking the way it works in Qizx (my own engine),
and probably in others.
some remarks:

- when copying an existing node into a constructed tree, there is a choice about
   copying in-scope prefix/ns mappings (aka "namespace nodes"):
	1- copy all in-scope mappings: more verbose output but
	   better chances to avoid creating synthetic namespace
	   declarations (something like xmlns:ns1="...") required by missing mappings.
	2- copy only mappings defined on the node itself: more concise
	3- copy no mappings at all: wont result in nice serialization
	4- copy only if used in sub-tree: best but not efficient

    currently Qizx takes the option 2, but now I think it would be better
    to switch to the 1.

- namespace/prefix pairs defined in the prologue are not actually copied onto nodes
   but they are used as hints or "preferred prefixes" for serialization.

Xavier FRANC
Received on Wednesday, 22 October 2003 07:14:49 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:17:16 UTC