[XML-SIG] Namespace support for DOM

A.M. Kuchling akuchlin@cnri.reston.va.us
Sun, 27 Dec 1998 12:07:42 -0500


After reading over the current namespace working draft, I thought a
little bit about how PyDOM should support it.  I'd like to hear
opinions on this...

       Thought 1: the idea of walking over the whole tree and
annotating it is bad, because if you modify the tree, the annotations
become outdated and you have to recompute them.  

       Thought 2: similar reasoning applies to modifying element or
attribute names by removing the namespace prefix.

       Thought 3: therefore, the better course of action is to have
functions or methods that dynamically compute what namespaces apply by
looking at a node's ancestors.

       Thought 4: looking at the draft, the bits that are needed are
functions or methods to do the following:

	  1) Get a dictionary mapping namespace prefixes to URIs, and
vice versa; this would be done by walking up the tree looking at
xmlns:* attributes.

	  2) Get the default namespace (might be prefix = "" in the
dictionary returned from the previous function)

	  3) Divide an element or attribute name into the prefix and
the rest of the name.

This means that namespace-using applications won't have everything
done for them; Python code might look vaguely like:

XSL_URI = "http://www.w3.org/..."
uri = node.get_namespace_mapping()

# Next line assumes node is an Element tag
nsp, name = divide_qualified_name( node.tagName )

if uri[nsp] == XSL_URI:
    # node is a tag in the XSL namespace; react appropriately

elif uri[nsp] == other_namespace:
    # do something else

Proposed interfaces need to be tried out by actually implementing
something on top of them, in order to find areas that have been
missed.  Can anyone suggest some namespace-using application that
would be useful as a test case?  It would also provide another demo
application.  The transformation portion of XSL is one candidate, but
I haven't read enough of the XSL draft to get an idea of how big the
job would be.  Anyone know of something small?

-- 
A.M. Kuchling			http://starship.skyport.net/crew/amk/
The bitterest tears shed over graves are for words left unsaid and for deeds
left undone.
    -- Harriet Beecher Stowe