cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Donald Ball <ba...@webslingerZ.com>
Subject Re: nested SQL queries
Date Wed, 29 Mar 2000 07:39:34 GMT
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 ;))?

- donald


Mime
View raw message