[XML-SIG] Providing a DOMImplementationFactory

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Mon, 5 Feb 2001 00:12:15 +0100


The DOM level 3 draft proposes a mechanism for Java to locate a
DOMImplementation object. In short, Java programs can invoke

   org.w3c.dom.DOMImplementationFactory.getDOMImplementation()

which loads the implementation defined in the property
org.w3c.dom.DOMImplementation. Should Python offer a similar
mechanism? If so, how should it work?

I can think of the following strategy:
- offer two functions, 
  xml.dom.getDOMImplementation([name])
  xml.dom.registerDOMImplementation(name, implementation)

  That is not really a factory, but rather a locator (should that be
  an implementation factory?)

- In getDOMImplementation, use various approaches of returning an
  implementation:
  * if a name was given, and an implementation with that name was
    registered, return it. Well-known names should be published by
    posting to xml-sig@python.org, and subsequently recorded in
    xml.dom.__init__
  * if no name is given, but the PYTHON_DOM environment variable is set,
    this variable names a module which should have an .implementation
    attribute; this is then used. I don't know whether it is good or bad
    that Python does not provide Java-style properties...
  * if no name was given, and attempt to return a "best" implementation
    should be done, where best means "most featureful". Not sure how
    to compute this, though.

- The implementation of xml.dom.__init__ would provide a number of
  pre-registered DOM implementations, which would always include
  minidom and would include 4DOM if PyXML is installed.

- add-on packages (like 4Suite, or Zope) can install .pth files which
  register additional DOM implementations (starting with Python 2.1).

Please comment.

Regards,
Martin