[Zope] xml possibilities

Passin, Tom tpassin at mitretek.org
Tue Jan 13 15:17:11 EST 2004


[garry saddington]
> 
> On Tuesday 13 January 2004 19:20, Andreas Jung wrote:
> > what is your *real* problem?
> >
> > http upload is fairly easy
> > creating a dtml method with the content is trivial
> > using zsql is trivial
> 
> The real problem is taking an xml document with about 50 data 
> items and 
> inserting the data items (not the whole file) into Postgresql 
> via the web 
> using zope. There will be many such files each with the same 
> data items but 
> with different values. Then I would like to be able to export 
> an xml document 
> in the same format as the one above from the database via the 
> web using zope. 

You seem to be talking about converting an xml file into an sql
statement that inserts the data into a database (or updates it, but of
course you need to know which it is).

To do this, you should use XML processing techniques, not text or
regular expression handling.

I would try to use an xslt stylesheet to convert from xml to sql.  I
have done that in the past with good results.  You can get help on xslt
stylesheets from the Mulberrry xslt list - read the xslt FAQs and query
the archive first, though.

Otherwise, you should probably use SAX to process the xml, for
row-oriented data like yours (though there are other possibilities).

However you do it, you will need to create an external method that can
hand off the xml to the external Python code, and return the sql string.

Once you work out how to do the xml processing, the rest need not be too
hard.  There are several xml and xslt libraries for Python, plus you
could always execute a command line program from the Python code.

Cheers,

Tom P



More information about the Zope mailing list