Paul Prescod paul@prescod.net
Fri, 23 Apr 1999 16:16:05 -0500

"Andrew M. Kuchling" wrote:
>         (I do like the convenience functions like DOMFromString;
> something similar should definitely be added, perhaps to dom.utils.)

As I said in my other messages, I want minidom to be a of PyDOM and 4DOM
and hopefully the start of a common API. In that vein, minidom makes some
decisions and extensions that we should discuss:

dom = DOMFromString( string, SAXbuilder=None )
dom = DOMFromURL( URL, SAXbuilder=None )
dom = DOMFromFile( file, SAXbuilder=None )

The default SAXBuilder would probably be the PyDOM or minidom builder.

Minidom uses mixed lower-first for property names. For compatibility with
PyDOM, properties can be requested through get_ methods. My question is:
do we really need get_ methods? They don't seem very Pythonish to me. Or
maybe we can use them as implementation mechanism (_get_) but not expose
them to the client.

I prefer the class-specific properties to the weird generic ones: tagName
to nodeName, value to nodeValue and so forth. Obviously PyDOM and 4DOM
would implement both but I don't see any reason to support that redundancy
in minidom.

I made some namespace extensions because we can't wait forever to do
namespace support.

getAttribute( "foo", "http://www.blah.bar" )

Looks up the obvious attribute.

element.localName gets the second have of the element type name.

element.uri gets the URI associated with the prefix.

element.prefix gets the element's prefix. I don't think that the
namespaces view that prefixes are irrelevant should obviate the XML 1.0
view that they are NOT. Even if we accept the namespaces view of the world
entirely, prefixes are chosen to be mmenonmic so they shouldn't be
discared by software.

element.attributes returns an attribute mapping object that I think
behaves exactly like PyDOMs except for namespace support:

x.attributes["foo", "http://www.blah.bar"]

This also works, however:

x.attributes["bar:foo"] (just as in PyDOM)

Namespace attributes ARE maintained as attributes. keys(), items() and
values() should be the same as PyDOM.

I should unify my Error class with PyDOM's.

I am considering the following enhancements:

element.elements: returns a list of element children.

element.getText: returns a list of deep list of data from the text nodes.
Do your own string.join to choose an appropriate join character.

element.getChild("FOO") returns the first child (not descendant) element
with specified element type name.

element.getChild("FOO", "http://...") does the obvious thing.

element.getChild( "#PCDATA" ) gets a list of child text nodes.

 Paul Prescod  - ISOGEN Consulting Engineer speaking for only himself

Company spokeswoman Lana Simon stressed that Interactive 
Yoda is not a Furby. Well, not exactly. 

"This is an interactive toy that utilizes Furby technology," 
Simon said. "It will react to its surroundings and will talk." 
  - http://www.wired.com/news/news/culture/story/19222.html