xslt queries in xml to SQL queries

Crutcher crutcher at gmail.com
Sun Feb 26 13:49:48 EST 2006


> I don't know what it is with comp.lang.python/python-list these days
> and the cheap put-downs. Unless you know the person you're responding
> to personally, and thus the above counts as some kind of banter, you
> would do better to keep the insults to yourself.

You are completely right, I was overly familiar.

Let me restate my central thesis.

1) It is possible to do what he is asking to do.
2) It requires expert knowledge of XSLT to do it well, and then it
would still require a bit of work.
3) There are simpler ways to do it, both using and not using xslt, than
this.

You could also do something like this:

<options ...>
  <sql-hack query="select name from servers">
    <option><sql-value value="name"></option>
    </sql-hack>
  </options>

and then do an XPath search for sql-hack nodes, and process them with
your python.

If you are happy staying on the python ranch, you could even do this:

<options ...>
  <python><![CDATA[
rows = sql('select names from servers')
for row in rows:
  xml('<option>%s</option>' % row[0])
    ]]>
    </python>
  </options>

With this, you find the python sections, and exec them in a context
with sql defined to do queries against your db and xml defined to parse
the xml you give it, and emit it in place of the python element.


> But given the existence of XML database systems,
> I don't think the idea of accessing them (or things pretending to be like them)
> via XML technologies is outrageous at all.

No, not outrageous. But this wasn't about quering XML database systems.
This was about implementing something which looked like, but did not
act like, XSLT. It's just bad design.




More information about the Python-list mailing list