From SQL to XML
The apache
module mod_sqil
is
a lightweight RDBMS to XML mapper. It implements an XML dialect named
SQI(nterface)L. What it does is best shown by an example:
<?xml version='1.0' encoding='UTF-8'?>
<test xmlns:sqil="http://heute-morgen.de/namespaces/sqil">
<sqil:parameter name="lbl" type="http-get" />
<records>
<sqil:statement rowname="row" rownum="idx" count="count">
SELECT
artist AS <sqil:field name="artist" />,
titel AS <sqil:field name="titel" />
FROM platten
<sqil:if-exists name="lbl">
WHERE label = <sqil:bind name="lbl" />
</sqil:if-exists>
</sqil:statement>
</records>
</test>
will
output database content as follows <?xml version="1.0" encoding="utf-8"?>
<test>
<parameter name="lbl" value="ZYX" />
<records>
<row><idx>1</idx><artist>The Age Of Love</artist><titel>The Age Of Love - Original</titel></row>
<row><idx>2</idx><artist>Benny Benassi</artist><titel>Hypnotica</titel></row>
<row><idx>3</idx><artist>Armand van Helden</artist><titel>Funk Phenomena 2K</titel></row>
<row><idx>4</idx><artist>2 Unlimited</artist><titel>No Limit 2.3</titel></row>
<row><idx>5</idx><artist>Wink</artist><titel>Higher State Of Consciousness</titel></row>
<row><idx>6</idx><artist>Isaac Hayes</artist><titel>Shaft 2001 Remix</titel></row>
<row><idx>7</idx><artist>InGrid</artist><titel>You Promised Me - SFaction Mix</titel></row>
<count>7</count>
</records>
</test>
This
is a simple tool for a
single purpose: Querying SQL databases. It is not intended
to output arbitrarily formatted XML. If you need that, there are mod_transform
and others like it to do further processing on the output. You can also do this to give the client database access via AJAX.
You
will need
- the SQIL
spec,
- the module
source and
- a configuration
example
to get this running.
It
requires
- apache 2.2,
- mod_form, the latest version of mod_xmlns and
- librecode.
If
you encounter problems feel free to contact me.