Hi,
what about such XSLT:

<xsl:template match="/">
    <rowset>
    <xsl:apply-templates select="//name"/>
    </rowset>
</xsl:template>

<xsl:template match="name">
  <xsl:variable name="name"><xsl:value-of select="."/></xsl:variable>
  <xsl:variable name="firstName"><xsl:value-of
select="../firstName"/></xsl:variable>
  <xsl:variable name="pos"><xsl:value-of select="position()"/></xsl:variable>
  <xsl:if test="count(//row[$pos>position()]/name[(.=$name) and
(../firstName=$firstName)])=0">
    <row>
      <name><xsl:value-of select="$name"/></name>
      <firstName><xsl:value-of select="$firstName"/></firstName>
      <xsl:apply-templates select="//favouriteColor[(../firstName=$firstName)
and (../name=$name)]"/>
    </row>
  </xsl:if>
</xsl:template>

<xsl:template match="favouriteColor">
    <favouriteColor><xsl:value-of select="."/></favouriteColor>
</xsl:template>

Best regards
Roman

"Hahn Kurt (CHA)" wrote:

> The query I tested is a simple "select -from - where" statement (useless to
> send you that), here's an example of what I get with this query:
> <rowset>
> <row>
>         <name>Mr. Brown</name>
>         <firstName>John</firstName>
>         <favouriteColor>green</favouriteColor>
> </row>
>
> <row>
>         <name>Mr. Brown</name>
>         <firstName>John</firstName>
>         <favouriteColor>red</favouriteColor>
> </row>
>
> <row>
>         <name>Mr. Brown</name>
>         <firstName>John</firstName>
>         <favouriteColor>yellow</favouriteColor>
> </row>
> </rowset>
> because Mr. Brown has many favourite colors....
> But I should get something like this (which I could do in a PL/SQL block,
> but how can I achieve this through Cocoon??)
> <rowset>
> <row>
>         <name>Mr. Brown</name>
>         <firstName>John</firstName>
>         <favouriteColor>green</favouriteColor>
>         <favouriteColor>red</favouriteColor>
>         <favouriteColor>yellow</favouriteColor>
> </row>
> </rowset>
>
> -----Message d'origine-----
> De : Luca Morandini [mailto:[EMAIL PROTECTED]]
> Envoye : jeudi, 25. avril 2002 11:39
> A : [EMAIL PROTECTED]
> Objet : RE: Returning result from two select statements in one file
>
> Kurt,
>
> I beg your pardon, but I haven't understood it yet... are you talking about
> a sub-query or the processing of a cursor ?
>
> May you just show us the query you've already tested ?
>
> Best regards,
>
> ---------------------------------------------
>                Luca Morandini
>                GIS Consultant
>               [EMAIL PROTECTED]
> http://utenti.tripod.it/lmorandini/index.html
> ---------------------------------------------
>
> > -----Original Message-----
> > From: Hahn Kurt (CHA) [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, April 25, 2002 11:01 AM
> > To: '[EMAIL PROTECTED]'
> > Subject: RE: Returning result from two select statements in one file
> >
> >
> > It is not really an issue about SQL, but the question is how I do
> > in Cocoon
> > what I normally would have to do in a stored procedure: Simply, I can not
> > execute one query to get all my results, I need two select statements that
> > are dependent on each other in order to get the combined result.
> > Is there a
> > possibility to do that? It looks as if map:aggregate is useful only if the
> > two queries are independent, but they aren't.
> > Example: The first select returns a row, and dependent on the
> > result of that
> > row, a second select returns zero, one ore more rows that should
> > be added to
> > the first returned row (as if they belonged to the result from the first
> > select..).
> >
> > Is that understandable?
> > KH
> >
> >
> > -----Message d'origine-----
> > De : Luca Morandini [mailto:[EMAIL PROTECTED]]
> > Envoye : jeudi, 25. avril 2002 10:01
> > A : [EMAIL PROTECTED]
> > Objet : RE: Returning result from two select statements in one file
> >
> >
> > Kurt,
> >
> > it seems to me more of an SQL than a Cocoon issue... may you share your
> > query with us  ?
> >
> > Best regards,
> >
> >
> > ---------------------------------------------
> >                Luca Morandini
> >                GIS Consultant
> >               [EMAIL PROTECTED]
> > http://utenti.tripod.it/lmorandini/index.html
> > ---------------------------------------------
> >
> >
> > > -----Original Message-----
> > > From: Hahn Kurt (CHA) [mailto:[EMAIL PROTECTED]]
> > > Sent: Thursday, April 25, 2002 9:26 AM
> > > To: '[EMAIL PROTECTED]'
> > > Subject: Returning result from two select statements in one file
> > >
> > >
> > > I'm developing a Cocoon application wich produces PDF files from a file
> > > which is generated by a DB access (Oracle). The problem is the
> > query: The
> > > results I should get looks like this:
> > >
> > > <row>
> > > <field1>text</field1>
> > > ...
> > > <fieldN>text</fieldN>
> > > <field1FromSecondSelect>text</field1FromSecondSelect>
> > > ...
> > > <fieldNFromSecondSelect>text</fieldNFromSecondSelect>
> > > </row>
> > > where "fieldFromSecondSelect" are 0 or more rows which are returned and
> > > should be grouped with the main "select". In PL/SQL, I could
> > > write a stored
> > > procedure with a cursor that's returning me the second result set, but
> > > what's the way to do that in Cocoon? So far, I "succeeded" to
> > > write a select
> > > statement that's returning me all I need, but whenever the sub-select
> > > returns more than 1 row, the corresponding result from the main query is
> > > returned several times too, like this:
> > >
> > > <row>
> > > <field1>text</field1>
> > > ...
> > > <fieldN>text</fieldN>
> > > <field1FromSecondSelect>text</field1FromSecondSelect>
> > > </row>
> > >
> > > <row>
> > > <field1>same text again</field1>
> > > ...
> > > <fieldN>same text again</fieldN>
> > > <field2FromSecondSelect>text</field2FromSecondSelect>
> > > </row>
> > >
> > > <row>
> > > <field1>same text again</field1>
> > > ...
> > > <fieldN>same text again</fieldN>
> > > <field3FromSecondSelect>text</field3FromSecondSelect>
> > > </row>
> > >
> > > and so on. This means I would have to sort this multiple fields
> > > later, in a
> > > XSL, but that doesn't seem a very smart thing to do, I guess.
> > >
> > > Any suggestions?
> > >
> > > KH
> > >
> > > ---------------------------------------------------------------------
> > > Please check that your question has not already been answered in the
> > > FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
> > >
> > > To unsubscribe, e-mail: <[EMAIL PROTECTED]>
> > > For additional commands, e-mail: <[EMAIL PROTECTED]>
> > >
> >
> >
> > ---------------------------------------------------------------------
> > Please check that your question has not already been answered in the
> > FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
> >
> > To unsubscribe, e-mail: <[EMAIL PROTECTED]>
> > For additional commands, e-mail: <[EMAIL PROTECTED]>
> >
> > ---------------------------------------------------------------------
> > Please check that your question has not already been answered in the
> > FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
> >
> > To unsubscribe, e-mail: <[EMAIL PROTECTED]>
> > For additional commands, e-mail: <[EMAIL PROTECTED]>
> >
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <[EMAIL PROTECTED]>
> For additional commands, e-mail: <[EMAIL PROTECTED]>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <[EMAIL PROTECTED]>
> For additional commands, e-mail: <[EMAIL PROTECTED]>


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

Reply via email to