cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dima <d...@merlin.octarine.net>
Subject Re: hierarchical resultsets & xml
Date Wed, 23 Aug 2000 17:53:53 GMT

> me, i found it was soooo much easier to do with SAX than with
>DOM so i didn't bother.

Would greately appreciate if you expand on the subject a bit more. Your
opinion might be quite interesting.

thanks.
d.

On Wed, 23 Aug 2000, Donald Ball wrote:

> On Tue, 22 Aug 2000, Kevin J Walters wrote:
> 
> > s> It appears that the root of the problem is that JDBC doesn't do hierarchical
> > s> recordsets (I don't think it's in jdbc 2.0 either - does anyone know this
> > s> for sure?).  So I can't directly construct a query that brings back
> > s> 
> > s> department 1
> > s>         Employee 1
> > s>         Employee 2
> > s> department 2
> > s>         Employee 3
> > s>         Employee 4
> > s> etc...(that wouldn't use standard sql anyway, it'd be oracle-specific)
> > 
> > I do a similar thing with multiple resultsets. I wasn't too sure how i 
> > should do this and ended up with a 
> > 
> > 1) stored procedure which generates an ordered set of result sets
> >    and tags each one with an additional column to indicate what it is
> > 2) a cocoon page which converts this into xml via a mess of java.
> > 
> > The stored proc is a bit inefficient because it's tailored to the
> > cocoon page, in particular the order binds the two together. In your
> > case i would return 4 resultsets.
> > 
> > A more natural (and efficient) approach would be to return all the
> > stuff to the client in multple resultsets (2 in your case) and then
> > have the client sort through the bits it wanted, but i didn't want to
> > put the load on the web server (in this case), and i didn't want the
> > java in my cocoon page to have build a local copy of the data - i just
> > output getString() stuff. I also have an advantage since this app is
> > small scale, no updates, and only returns 5-10 resultsets with less
> > than 100 rows total.
> > 
> > The downside of not having a copy of the data in the 'servlet' is that 
> > i can't cache the sybase queries which might be a nice addition...
> 
> Two solutions:
> 
> 1. you can do both queries seperately and then merge the results in XSLT.
> hint - massive speedup for using xsl:key. you _can_ end up getting a bunch
> of data you don't need, but them's the breaks.
> 
> 2. you can do nested queries using the SQLTransformer with cocoon2. basic
> syntax:
> 
> <sql:execute-query>
>  <sql:query>select id,name from department_table</sql:query>
>  <sql:execute-query>
>   <sql:query>select id,name from employee_table where department_id = 
>    <sql:ancestor-value level="1" name="id"/>
>   </sql:query>
>  </sql:execute-query>
> </sql:execute-query>
> 
> should give you something like
> 
> <rowset>
>  <row>
>   <id>1</id>
>   <name>Engineering</name>
>   <rowset>
>    <row>
>     <id>23</id>
>     <name>Donald Ball</name>
>    </row>
>    ...
>   </rowset>
>  </row>
>  ...
> </rowset>
> 
> i'd be pleased as punch if someone could backport this to the cocoon1 sql
> logicsheet. me, i found it was soooo much easier to do with SAX than with
> DOM so i didn't bother. alternately, if someone wanted to port this to a
> logicsheet for cocoon2, that'd be fab. one of these days i might get a
> chance to do some cocoon coding again, but i fear it's still a while off.
> 
> - donald
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
> 


Mime
View raw message