[Zope] Zope XML processing

Gabe Wachob gwachob@findlaw.com
Tue, 02 Feb 1999 14:13:52 -0800


"Phillip J. Eby" wrote:

> Just a quickie note...  I've begun doing some XML processing using the
> xml-sig's xml library and Z Templates.  Specifically, walking a DOM tree in
> ZTML.  Just demo stuff so far, like:
>
> <!--#var standard_html_header-->
> <!--#with firstChild-->
> <PRE><!--#in childNodes
> -->'<!--#var tagName-->' Node: "<!--#var toxml html_quote-->"
> <!--#/in--></PRE>
> <!--#/with-->
> <!--#var standard_html_footer-->
>
> The only Python I had to write in order to integrate XML objects with my
> framework was:
>
> from xml.sax.saxexts import make_parser
> from xml.dom.sax_builder import SaxBuilder
>
> _parser = make_parser()
>
> def xml_loader_(filename,**kwargs):
>         h = SaxBuilder()
>         _parser.setDocumentHandler( h )
>         _parser.parseFile( open(filename,'r') )
>         return h.document
>
> xml_classinfo_ = None,xml_loader_
>
> I imagine integration with Zope would be a bit more complex, but not
> because of the XML aspects.  I may take a whack at making an XMLDocument
> product for Zope when I have some spare time, if nobody else is currently
> working on one.

Its really simple -- I've done a little bit in this direciton. I was trying to
build a "browseable" XML tree (ie, create a DOM tree from an XML file and then
use the <!--#tree--> contstruct to browse it "interactively"), but I couldn't
fight through all of the tree functionality and gave up on it.

On the xml-sig list, someone mentioned they had a XSL (tree construction part
only -- the important part) engine in python. I would like to see an app where
you can "try on" different XSL stylesheets for a given XML file, and then let
you publish the XML through the various XSL stylesheets depending on URL (or
something like that). Twould be nice to have the following absrtactins:
1) An XMLSource (normally, this would simply be an object which holds XML data
-- but it could be a client for an XML-producing application, or a wrapper for
a SQL query that creates an XML document on thefly, or so on). Would provide
functions like "getContent()" or perhaps even a XPointer-dereferencer (ie get
the first sibling of the last <blah> element, or whatever). Should also have a
"changedSince(time)" function so that if the XMLSource content is updated, an
application (or DTML code) can detect this and rerender.
2) A list of XSL stylesheets through which  you present the XML obtained from
the XMLSource
3) An XML source browser - pretty printing, expandable subtrees, etc.
4) XML validation (against a DTD stored in the product, or referred to by a
URL or something similar)
** and for fun -- stuff that is not Zope-specific **
5) Rudimentary XML editing
6) Forms-based XML editing
7) Some sort of way for expressing integrity and relational rules for entering
information into XML documents, so you could easily build business rules on
top of simple or more complex XML documents

The reason I mention 5,6,7 is to keep these things in mind when developing XML
products for Zope (and because Zope can address user interface issues).

    -Gabe, who'd do it all himself if he had time ;-)