[Zope-dev] XML to SQL or XML into tables

Kent Polk kent@goathill.org
24 May 2000 18:17:42 GMT


On 24 May 2000 07:20:00 -0500, Thomas Weholt wrote:
>Hello,
>
>Has anybody tried to somehow get xml-data into SQL-statements or in some
>other way use xml-data as datasource for insertion into tables?
>It shouldn`t be impossible, if we could just agree on some format or DTD to
>use. 

I'm headed that way - I'm planning on using XML-RPC to insert table
records into an SQL database. I have the client stuff written -
creates the XML files with the data the way I need it.  I've written
an xml.sax parser to parse the table records. It works great :^)
What different paths are currently available via Zope to parse my
XML files for insertion into an SQL database?

Currently, my sax parser identifies the database and builds a
dictionary of tables, with a list of dictionaries which represent
the table records to insert. Right now I have all level 1 tags
representing tables with level 2 tags representing the records.
Record attributes and tag levels beyond the record level are used
to create the record dictionary.  I'm basically using the W3C
recommendations for representing a simple relational database.

There might be some value in using the tags to indicate structure
and the attributes to indicate data, but I'm not sure that level
of complexity is needed. Seems to me that a simple well-behaved
XML file could suffice. I think there is value in using specific
tags and attributes to identify databases and tables, but beyond
that why not just use tags to represent the data? table names are
tags, their attributes, tags and and data are the record data.

Since each table record needs to have a column name associated with
it (to build a record dictionary), that would seem to allow only
attributes and subtags (with their data), not data directly.  I'm
wondering why not just use attributes to describe the record data
unless it's a blob or such that is easier to handle with a tag?

[...]
>Any thoughts? I know this could at least sort out alot of troubles I`m
>having right now getting data from external sources into Zope.
>I`m going to try and make a product or a method etc. that uses xmllib doing
>this, but if anybody has done it allready I`d be very happy do "abuse" their
>effort. :->

If the XML data isn't significantly large, I would consider leaving
it as XML in the database and just query it.  This looks like an
excellent job for Racks and Predicates. :^)