cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Donald Ball <ba...@webslingerZ.com>
Subject Inheritance in XML for SQLProcessor
Date Tue, 14 Dec 1999 08:35:57 GMT
Hey guys. I was working on adding some new features to SQLProcessor when I
just got a little fed up with the way I'm doing 'default' attributes for
query tags. Currently, when I'm working with a query element, I must
possibly look to two referenced nodes, connection and querydefs to
determine connection and query attributes. E.g.:

<connectiondefs>
 <connection name="foo">
  ...
 </connection>
 <querydefs name="bar" attribute="value"/>
</connectiondefs>

<query connection="foo" defs="bar">
 ...
</query>

in this instance, the query node references a 'foo' connection node for
some connection parameters and a 'bar' querydefs node for some query
attributes. The syntax, however, isn't formalized, and it seems like
things would be clearer and easier both in the java code and the XML
documents if I had a standard syntax for allowing XML nodes to inherit
attributes from other XML nodes. I coded up a quick solution that lets me
do something like this:

<sqldefs
 ID="23"
 driver="org.gjt.mm.mysql.Driver"
 doc-element="options"
 row-element="option"
/>

<query extends="sqldefs.23">
 select * from foo_Table
</query>

The algorithm is quite simple. If the processor doesn't find an attribute
on the query node that it's looking for, it looks for the referenced by
the extends attribute and, if it exists, repeats the procedure on the
referenced node. Ideally, I'd like to allow an XPath expression in the
extends attribute, but since we don't have a library function to do that
yet, I'm using my own silly syntax - node_name.ID_attribute_value.

I never liked the blahdefs node names anyway, it was just a quick'n'dirty
reimplementation and extension of Oracle's XSQL servlet syntax. Moving to
this syntax will mean that existing users will be forced to alter their
XML files, unfortunately. Is there anyone who's terribly averse to this
change? If so, please speak up since I'd like to implement this before we
get to the stage that changes in the DTD require lots of changes. There
are three basic implications to consider:

1. Existing connection and querydefs nodes must be converted and possibly
merged. I don't think anyone's using SQLProcessor for anything useful in
production yet except for me, so this probably isn't a huge deal.

2. It's possible to inherit attributes from grandparents with this syntax.
I think that's desirable, but others may disagree.

3. We'll have broken almost completely from Oracle's XSQL servlet syntax.
I don't necessarily like this but a) we've already have many more features
and b) I don't want to be tied to their syntax.

4. I'm not aware of any standards that have been proposed for XML
attribute inheritance. If there are any, it would be ideal if SQLProcessor
could just support one of them.

Anyway, speak up if you care, otherwise I'm going to move ahead with this.
FYI, the reason I'm so gung-ho about changing this right now is because it
should make it easier to add transaction and subquery support, like so:

<transaction>
 <query .../>
 <query .../>
</transaction>

<query ID="parent" ...>
 select id,department_name from department_table
 <query extends="query.parent">
  select first_name,last_name from employee_table where department_id = {$id}
 </query>
</query>

(where {$id} corresponds to the id column value from the resultset of the
outer query)

and I'm rather in need of the latter feature for a project I'm working on
right now. :)

- donald


Mime
View raw message