[XML-SIG] Python DOM Unification -- level

Paul Prescod paul@prescod.net
Tue, 03 Aug 1999 15:05:33 -0500


Mike Olson wrote:
> 
>     We're  gonna have some free time in August to do some major work on 4DOM and
> 4XSLT, including getting 4XSLT up to date with the latest XSLT draft and
> breaking out the patterns into 4XPath (or some clever name).

Cool!

>     I wanted to bring up the DOM interface unification topic again as we will be
> working on 4DOM this month and may have time to experiment with some Lit/ python
> interfaces.  Last we left off, we couldn't decide how many and how lit the
> interfaces should be.  Is anyone still doing work to come up with a unified
> interface(s)?  Is it something we still want to consider? Should we
> (Fourthought) just produce a lit interface as pythonic as possible and then
> mold/wrap pydom and 4dom to meet it?

Well I think that the main issues for the pythonic interface are:

 * mappings should act as Python mappings. (in fact the only
standardized interfaces should probably be the __getitem__ stuff)

 * node lists should act as Python sequences. (ditto)

 * namespace properties should be modelled on the relevant operators in
XPath (I think that the real DOM will be copying XPath)

XPath support should probably be available both as a module and as
methods on the DOM. The module is cool because it could be made
available for any DOM. The methods are cool because they could be really
optimized for *this* DOM. Microsoft calls the XPath-using methods
"selectNodes" and "selectSingleNode". They also have "transformNode". 

Any DOM could add "simple" support by redirecting the methods to a
DOM-generic method. They could add optimized support by writing code for
the methods themselves. They could even use a mix where they call the
method for complex queries!

Many of the methods we discussed before like getChild, getText and so
forth can be done easily as queries like node.selectNodes( "text()" ),
node.selectNodes( "//text()" ) and so forth.

One issue awith selectNodes is how to count nodes. XSL mandates that
adjacent text nodes must be merged. The DOM does not (but probably
should!).

>     For my 2 cents worth, I guess I see a need for 2 interfaces.  The one
> defined by W3C and a totally pythonic interface.  Then a wrapper that can be
> used to turn a DOM compliant interface implementation into the pythonic
> interface.  ORB/ORBless I think we decided is orthagonal to this decision.

That all sounds right to me.

 Paul Prescod