Howdy folks,

Some of you may remember the announcement I made here
about releasing an XPCOM component for accessing an
SQL database through ODBC (August 2000).

It worked well enough but required a lot of JavaScript
glue code to pass data back and forth between the
XUL widgets and the database.

I've moved on to something that I think will be more
effective. That something is actually three related
ideas:

1. RDF datasource wrapper

Makes a result set look like an RDF datasource. Suppose
an SQL statement like "SELECT * FROM persons" returns the
following data:

Name 
        Address                 City            Country
--------------- 
----------------------- 
--------------- 
-------
Joe Cool        100 Main Street         Centerville     USA
Ben Stein       200 Lincoln Lane        Centerville     USA
Ali Gator       300 Swamp Road          Centerville     USA

The above data would be mapped to an RDF datasource
equivalent to the following RDF file:

<rdf:rdf>
     <rdf:Description id="1234"
        db:query="SELECT * FROM persons">
        <rdf:Seq>
            <rdf:li>
                <rdf:Description
                        persons:name="Joe Cool"
                        persons:street="100 Main Street"
                        persons:city="Centerville"
                        person:country="USA"/>
            </rdf:li>
            <rdf:li>
                <rdf:Description
                        persons:name="Ben Stein"
                        persons:street="200 Lincoln Lane"
                        persons:city="Centerville"
                        person:country="USA"/>
            </rdf:li>
            <rdf:li>
                <rdf:Description
                        persons:name="Ali Gator"
                        persons:street="300 Swamp Road"
                        persons:city="Centerville"
                        person:country="USA"/>
            </rdf:li>
        </rdf:Seq>
     </rdf:Description>
</rdf:rdf>

As you can see, the table (or more likely - the database name)
becomes a namespace for a collection of XML tags that represent
each of the columns in the table (or tables).

To me, the biggest appeal here is in being able to take advantage
of an SQL database engine to do what it does best: sorting and
selecting while deferring any last minute formatting to the XUL
templates. As an example of why this mixed approach will work better
- try sorting with a XUL template on a numeric field that isn't padded
with leading zeroes (though this will eventually be fixed no doubt).

Stay tuned for parts 2 and 3.

Regards,
Rick Parrish
[EMAIL PROTECTED]


Reply via email to