<feed xmlns="http://www.w3.org/2005/Atom" xmlns:foaf="http://xmlns.com/foaf/0.1/"><title>norman.walsh.name: Comments on /2009/09/26/sqltoxml</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/09/26/sqltoxml"/><id>http://norman.walsh.name/2009/09/26/sqltoxml/comments.atom</id><updated>2012-02-13T05:45:43.7207Z</updated><entry><title>Comment 1 on /2009/09/26/sqltoxml</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/09/26/sqltoxml#comment0001"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0001</id><published>2009-10-01T04:17:07Z</published><updated>2009-10-01T04:17:07Z</updated><author><name>Doug</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>
Basically what you are doing is applying a transformation from an RDBM schema to some specific XML schema. XSLT is very good at transforming XML to XML, or XML to text. Obviously its not so good at the reverse mapping of 'anything' into XML. There's a program called <a rel="nofollow" href="http://pyana.sourceforge.net/">pyana</a> though which allegedly enhances XSLT transforms with python functionality, but there, still, I think the python is constrained to work with a source XML document rather than 'anything'.
</p>
    <p>
For work recently though, I've been trying to make adhoc mappings of data from PostgreSQL and Oracle databases into an XML metadata schema. Basically what I did was take an instance document of the desired target XML schema and pepper it with elements like  and  containing raw python code or SQL expressions respectively. This template is fed into a python-based XML parser that evaluates the SQL and python elements and replaces those elements with the result of its evaluations. Consequently this is an 'anything' to XML transformer, and its limited purely  by python's limitations (well, that and my crap code).
</p>
    <p>
But anyway, to do it properly it also requires, and has, program constructs like  and , which you would recognise as XSLT constructs. Probably it would benefit from more XSLT-like functionality like
 and  elements.
</p>
    <p>
It would be cool if something like this was written/designed and spec'ed by experts though. Be nice to use something robust from off-the-shelf ...</p>
  </div></content></entry><entry><title>Comment 2 on /2009/09/26/sqltoxml</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/09/26/sqltoxml#comment0002"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0002</id><published>2009-10-01T15:42:54Z</published><updated>2009-10-01T15:42:54Z</updated><author><name>Sam Page</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>As part of your subsequent downstream processing, would you next transform this database-centric XML to a more concise form?
</p>
    <p>
For example, rather than go straight to VCard from the XML above, make it a two-step process with something like this in the middle...
</p>
    <p>
&lt;Contacts&gt;&lt;Contact&gt;&lt;Name&gt;Norm Walsh&lt;/Name&gt;&lt;Address&gt;&lt;Line&gt;221B Baker Street&lt;/Line&gt;&lt;City&gt;London&lt;/City&gt;&lt;PostalCode&gt;NW1 6XE&lt;/PostalCode&gt;&lt;Country&gt;England&lt;/Country&gt;&lt;/Address&gt;&lt;/Contact&gt; ...
</p>
    <p>
I find that 2-step process hides a fairly ugly but not difficult transform in the first part, leaving an ideal input for the final transform (to VCard) output. Makes the whole transform more maintainable.
</p>
    <p>
If only there were an XML transform pipeline language to tie it all together, oh wait... ;)
</p>
    <p>
With this particular XML, you could argue for another initial transform that just throws away the data elements you're not interested in to simplify the input. That could be a pretty common operation with database-centric dumps like this one. You could then choose to drive the data element selection with a common transform and an XML file to make the field selections. And the pipeline document would be common as well among this type of transform.
</p>
    <p>
Are thoughts like these guilty of using an XML toolset hammer? Perhaps. I think your approach is worthwhile and generally useful, therefore these 'extensions' might also be.
</p>
    <p>
I'd be interested in your thoughts, because you wield an exceptionally mighty XML hammer! Thanks.</p>
  </div></content></entry><entry><title>Comment 3 on /2009/09/26/sqltoxml</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/09/26/sqltoxml#comment0003"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0003</id><published>2009-10-06T14:11:21Z</published><updated>2009-10-06T14:11:21Z</updated><author><name>Norman Walsh</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>In this particular case, I have an existing vCard-to-something else toolchain, so I went from the SQL dump to vCard. But as a general rule, I'm in favor of using a series of simple transformations instead of one complex transformation where practical.</p>
  </div></content></entry></feed>

