[XML-SIG] Contents of xmlcore?

Paul Prescod paul@prescod.net
Wed, 28 Jun 2000 07:30:40 -0700

"Fred L. Drake, Jr." wrote:
> ...
>   Based on the recent mess regarding the DOM API, I'm not inclined to
> include a DOM-like API until we have a specification for the Python
> DOM API.  I won't have time to write one before 1.6 is done.  ;(

Argh. We have four such specifications:

	* 4dom
	* pydom
	* minidom
	* http://www.python.org/doc/howto/xml/node14.html

Nothing has changed for MONTHS. I'm somewhat dismayed that the XML stuff
is being held to a much higher status than anything else. In what other
area would an API remain the same for months, fend off an attack from
one of the leading gurus in the Python world and then be refused entry
because it is not written up in a more formal document than a howto?

Okay, fine. 

Here's the Python DOM 1 mapping:

DOM nodes must be represented by Python objects.

The DOM describes node types. Node type equality is defined in the DOM
according to integer equality based on a .nodeType property. Nodetype
equality should be checked in the same way in the Python DOM. Using
isinstance is not recommended.

DOM nodelists should be represented by Python sequence (typically list)
objects. These lists must be considered read-only (as in the DOM) but
implementations need not enforce this. The DOM "item" and "length"
methods are not required because the Python equivalents are sufficient.

DOM namednodemaps must be represented by Python mapping objects. Once
again, the DOM methods are optional because Python equivalents are
sufficient. Integer indexing of these objects is not allowed. Index into
the keys() list instead. These objects should be read-write (as in the

The DOMString interface must be represented by Python string or Unicode
string objects.

There is no provision for interoperability between DOMs. It may or may
not be possible to move objects between DOMs. The DOM does not require
this interoperability and most DOM implementations (for all languages)
do not provide it.

DOM attributes must be provided to client software both as Python
attributes and through _get_XXX and _set_XXX methods. The underlying
implementation may use Python object attributes or something more
sophisticated (with __getattr__). The _get_XXX syntax is subject to
change in the future because many have expressed dissatisfaction with
it. Therefore client software is encouraged to use the attribute syntax.

Exceptions thrown by a DOM should either be built-in Python exceptions
or should inherit from the appropriate Python exception.

INDEX_SIZE_ERR is a kind of IndexError
DOMSTRING_SIZE_ERR is a kind of MemoryError
HIERARCHY_REQUEST_ERR is a kind of TypeError
WRONG_DOCUMENT_ERR is a kind of TypeError
INVALID_CHARACTER_ERR is a kind of TypeError
NO_DATA_ALLOWED_ERR is a kind of AssertionError
NOT_FOUND_ERR is a kind of IndexError
NOT_SUPPORTED_ERR is a kind of AssertionError
INUSE_ATTRIBUTE_ERR is a kind of AssertionError

 Paul Prescod - Not encumbered by corporate consensus
The calculus and the rich body of mathematical analysis to which it 
gave rise made modern science possible, but it was the algorithm that 
made the modern world possible.
	- The Advent of the Algorithm (pending), by David Berlinski