[Twisted-Python] RE: Helps if I could type ... there is no reportlacb.com of course.

Andy Robinson andy at reportlab.com
Fri Sep 6 18:51:14 EDT 2002


> The one thing I don't see PyRXP doing is this:
> 
> >     * adhere to a subset of both DOM and SAX APIs for both 
> event-based and
> >     synchronous processing of XML data

Absolutely true.  Our own need was to read in complete
XML documents.  We generate reports where the data is usually an XML 
document and we will never want a partial document.  In addition,
we would always validate if the performance hit was minimal. So
we went for a 'tree structure' as output.  It would be trivial to 
layer something else on top which generated events as an alternative API,
but AFAICT pyexpat does that pretty well for anyone who does not
want validation.  Or am I missing something?

Our own feelings are to aim for simple Pythonic APIs rather
than full SAX and DOM, which "feel like Java" to me and
tend to be verbose.  
> 
> I shouldn't have phrased this as API adherence but more as a semantic
> requirement.  I want to do parsing and routing of XML such as 
> jabber's "XML
> streams", as a network protocol and not as a document parser.  Of 
> course I also
> want a document parser, for other purposes.  
> at least passing DOM 
> adherence
> means that I can rewrite much less of the existing Twisted/XML code :-)

Our take on that was to make a small 'lazy cursor' using getattr
to step into the tuple tree, so I can do expressions like
"xml.invoice.customerDetails.addressLine1" and let it drill
down for me.  We did not worry about DOM compatibility as DOM syntax
is less readable than Python syntax.  Far from perfect but only about 
50 lines long.  One could easily make DOM and SAX wrappers for
the pyRXP tuple tree, although under the hood the SAX one would
be working on a ully parsed tree structure.

We would love to do more on pyRXP but are very short of time
and have already met all our own requirements.  Is this a
candidate to become part of Twisted's XML toolkit, or specifically
for Jabber?  Is anyone else prepared to do a little on the pyRXP
code with us and share some work?

Thanks,

Andy





More information about the Twisted-Python mailing list