cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From skoech...@n-soft.com (Sebastien Koechlin I-VISION)
Subject Re: Grouping of SQL result set
Date Mon, 10 Apr 2000 16:20:06 GMT
"Schmitt, Christian" wrote :

> <?xml version="1.0" encoding="UTF-8"?>
> <page>
> 
>  <ROWSET>
>    <ROW ID="0">
>      <ename>Scott</ename>
>      <dname>SALES</dname>
>    </ROW>
>    <ROW ID="1">
>      <ename>King</ename>
>      <dname>SALES</dname>
>    </ROW>
>    <ROW ID="2">
>      <ename>Adams</ename>
>      <dname>MARKETING</dname>
>    </ROW>
>  </ROWSET>
> 
> </page>

> Now my question is... Would I have to run the xml I'm getting back (the
> first one) through the processor again and apply a style sheet (xsl I
> suppose) and group the dname and ename in this style sheet? Or is there
> another way? Please bear with me, as I'm a newbie with this XML/XSL
> thing.

I tried to solve this with XSLT, but failed, It looks like my
variable isn't working in a attribut value. If someone can tell
me what is wrong...

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="ROWSET">
  <xsl:processing-instruction
name="cocoon-format">type="text/html"</xsl:processing-instruction>
    <html>
      <body bgcolor="white">
        <xsl:apply-templates
          select="ROW[position()=1 or
dname!=preceding-sibling::ROW/dname]"
          mode="group"/>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="ROW" mode="group">
    <xsl:variable name="dname"><xsl:value-of
select="dname"/></xsl:variable>
    <dl><dt><xsl:value-of select="$dname"/> :</dt><dd>
      <xsl:apply-templates
select="/page/ROWSET/ROW/ename[../dname='{$dname}']"/>
    </dd></dl>
  </xsl:template>

</xsl:stylesheet>

-- 
Seb

Mime
View raw message