Re: [xsl] XML to Database Inserts via XSLT

Subject: Re: [xsl] XML to Database Inserts via XSLT
From: Barry Lay <blay@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 09 Mar 2005 17:28:24 -0500
Brian Chrisman wrote:

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?

Oracle lets you create an "Object-Relational" view on top of a relational database that pretty much does what you describe. It also allows direct manipulation of the underlying table data with XML. It looked like a very nice fit for a web application - XML both ways with XSL to convert the results to HTML for presentation. Unfortunately we discovered that for more than trivial data volumes the approach was just too slow to be practical. I'll admit that this was not using Oracle 10g so maybe things have improved, but they would have to improve a lot to be superior than the old fashion way of dealing with databases.

A large part of the delay in retrieving data from a database is the data transport - queries in typical web applications tend to run pretty quickly in the database itself. Complex reports are an exception of course; those generally require extra design work on the database side if they are common. The result of this unfortunate fact is that doing a lot of little queries as part of your application will quickly result in very noticeable delays if they have to go to the physical database each time. A better solution is to cache a subset of the data locally and query against that. This cache can most certainly be a DOM that is organized according to your application requirements. Fetching the data from the database into the DOM is a single operation and many modern databases will provide the data in XML directly. On the update side you need to keep track of the changes and convert those to actual database updates. There are a variety of techniques for doing this from having the front end flag the changes to having the model smart enough to recognize them. We used attributes in the DOM to keep track of the changes and XSL to convert the updated DOM to SQL statements to get the job done. Its not as conceptually clean as your suggestion but it kept the users from rioting.

Maybe some future version of EJB will be more XML friendly.


Current Thread