XML to SQL or XML into Tables SomeHow

Phil pharris at crosswinds.net
Thu May 25 23:45:23 CEST 2000


Couldn't you use xslt to do the transformation, since that is its purpose


"Thomas Weholt" <thomas at cintra.no> wrote in message
news:392e080f.1310806219 at news.online.no...
> Hi,
>
> I want to submit a special formattet xml, nothing more than xml based
> on a specified DTD, to a module/script that "transforms" the xml data
> to a valid SQL insert-statement.
>
> Ex.
>
> <xml-data>
> <database name="test">
> <table name ="person">
> <row>
>     <field field_name="name" value="thomas">
>       <field field_name="sex" value="male">
> </row>
> <row>
>     <field field_name="name" value="bill">
>       <field field_name="sex" value="male">
> </row>
> <row>
>     <field field_name="name" value="jane">
>       <field field_name="sex" value="female">
> </row>
> </table>
> </database>
> </xml-data>
>
> I want an output like :
>
> # SQL-statements
>
> use test;
> insert into person
> (name, sex)
> values
> ("thomas", "male");
>
> insert into person
> (name, sex)
> values
> ("bill", "male");
>
> insert into person
> (name, sex)
> values
> ("jane", "female");
>
> ##################
>
> Perhaps the entries must have a specified type like
> <field field_name="name" value="thomas" field_type="string"> etc.
>
> For simple insertion statements this shouldn`t that hard to do, but
> I`m having a hard time locating the stuff to do it.
>
> I`ve looked at RAX, SAX, Pyxie etc. If somebody could give me a hint
> on how to "transform" the example above I`d be happy to try and make a
> more generic module out of it. I just need some help to get started.
>
> Thomas





More information about the Python-list mailing list