cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefano Mazzocchi <stef...@apache.org>
Subject Re: nested SQL queries
Date Wed, 29 Mar 2000 12:03:07 GMT
Donald Ball wrote:
> 
> On Sat, 25 Mar 2000, Stefano Mazzocchi wrote:
> 
> > Donald Ball wrote:
> > >
> > > is there any good reason that one would want to do this using some special
> > > sql filter/processor/taglib syntax rather than using the xsl:key function?
> >
> > care to evaluate a little more people not directly connected with your
> > neurons? ;-)
> 
> Sure. Most people want nested queries so that can generate a hierarchy:
> 
> <department>
>  <name>Programming</name>
>   <person>
>    <name>Stefano Mazzocchi</name>
>   </person>
>   <person>
>    <name>Donald Ball</name>
>   </person>
> </department>
> <department>
>  <name>Lounging Around</name>
>   <person>
>    <name>Pierpaolo Fumagalli</name>
>   </person>
> </department>
> 
> However, it seems like you could make a case for generating this instead:
> 
> <department id="1">
>  <name>Programming</name>
> </department>
> <department id="2">
>  <name>Lounging Around</name>
> </department>
> 
> <person id="1" department-id-ref="1">
>  <name>Stefano Mazzochi</name>
> </person>
> <person id="2" department-id-ref="1">
>  <name>Donald Ball</name>
> </person>
> <person id="3" department-id-ref="2">
>  <name>Pierpaolo Fumagalli</name>
> </person>
> 
> and using xsl:key to reference the related information. something like
> this:
> 
> <xsl:key name="department_key" match="department" use="@id"/>
> 
> <xsl:for-each select="person">
>         <xsl:for-each select="key('department_key',.)">
>                 Department: <xsl:value-of select="name"/><br/>
>         </xsl:for-each>
>         Name: <xsl:value-of select="name"/><br/>
> </xsl:for-each>
> 
> It might be the case that this is better than doing nested queries, at
> least in some cases. Certainly it makes expressing many-to-many
> relationships simpler. Maybe someone who's either used xsl:key or wants
> nested queries can argue in favor of one of these approaches (or both, of
> course ;))?

Smart, indeed!

I think that nested queries might become kind of impractical, expecially
when you are not doing SQL stuff but rather OODBMS lookup thru ODMG or
EJB (thru castor or something else).

I think that using that xsl:key trick would solve lots of problems...
gee, I wish you wrote more documentation on how to use your stuff...

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<stefano@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Missed us in Orlando? Make it up with ApacheCON Europe in London!
------------------------- http://ApacheCon.Com ---------------------



Mime
View raw message