Re: [xsl] XML to Database Inserts via XSLT

Subject: Re: [xsl] XML to Database Inserts via XSLT
From: Brian Chrisman <incubus@xxxxxxxxxxxxxx>
Date: Wed, 9 Mar 2005 13:28:18 -0800
On Wed, Mar 09, 2005 at 02:53:51PM -0600, JBryant@xxxxxxxxx wrote:
> Well, Saxon has an extension to work with databases, so that you don't 
> have to build up SQL commands as you are doing here. However, Dr. Kay 
> (developer of Saxon) has made it very clear that the SQL extension is an 
> example of an extension, not something he supports as part of Saxon. 
> Still, I've used the thing to build small databases (because I work with a 
> bunch of SQL addicts who would rather code against a database than an XML 
> file). If you know Java, you could also write your own database extensions 
> for Saxon. I'm sure the same is possible for other XSLT processors, but 
> Saxon is the one I know.

Is there a place where I can read more about this particular 
extension and/or extensibility of the processor in general?

At a former contract, we built an XMLRPC server instance which
held a DOM(libxml) object in memory (in a perl process, it was
fairly small <20MB) which we used as a database... The RPC 
mechanism allowed me to submit a stylesheet from a CGI program,
and have it transform the DOM object... returning the resulting
XML. (this was pretty fast as the object didn't have to reparse)

Compared to my other web-database programming projects, this made
my business logic (and front end) extremely easy to write, as I 
had access to the entire database from within my stylesheets
through xpath... no marshalling the data through SQL and all
that crap...

I was wondering if such a thing could be done using an RDBMs.
Obviously they're pretty different beasts, considering that
XML has a hierarchical structure by default while the relationships
between objects in an RDBMS look more like a graph or some such...

But I was thinking that perhaps placing a 'temporary hierarchy' (which 
I guess would be somewhat like a 'view'), over the relational 
structure of the database, would allow the database to look like
an XML/hierarchical structure?

I guess the idea would be to:
a) somehow define the way that the relationships between
  the existing entities in the database will collapse into
  a tree structure for an application of an XSLt stylesheet.
b) apply the stylesheet to the database... much like
  applying it to an XML document... only with the xpath
  expressions being evaluated by calls to the temporary
  tree structure in the database.

I'm not sure if this makes much sense... I do know that
I've never had an easier time programming a web application
than when I was able to apply a stylesheet directly to
a database (in this case, the aforementioned libxml document
residing in memory on an RPC server) without any sort of
database lookups getting in the way.... so I'd be interested 
in any ideas people have about how I could do such a thing
with a large relational database.

I looked at sleepycat and a couple other "XML native" 
databases... but from what I could tell, they all pulled
the XML document into memory in order to apply a stylesheet
to it.  For a 20MB database, perhaps that's not a problem,
but for a 20GB database, it definitely is.  It's possible
my research was incomplete, but I did look for quite a
while over the course of a couple months.

I hope this question is reasonably clear, but it seems like
a pretty complex and abstract subject.  I'd be glad
to flesh out any comments that I can...


(Originally, in a design attempt, I was picking one object
and exporting a hierarchy of objects linked to that
object recursively... and then applying a stylesheet to
that... but this wasn't even close to what I actually 

Current Thread