This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

simple grouping question


I'm new to XSLT/XPath and have what I think is a simple question that I
just can't figure out.  I'm producing an HTML table and want to suppress
the value in a particular column if the previous element in that column
had the same value.  I've been through the faq and found some examples
relating to grouping that are similar to what I want to do, but I have
been unable to get it work.

Here's a shortened up version of my XML:

<events>
  <event>
    <date>9/19/2000</date>
    <name>foo</name>
  </event>
  <event>
    <date>9/19/2000</date>
    <name>bar</name>
  </event>
  <event>
    <date>9/20/2000</date>
    <name>baz</name>
  </event>
</events>

And this is what I would like the output to look like.

<table border="1">
<tr><td>9/19/2000</td><td>foo</td></tr>
<tr><td></td><td>bar</td></tr>
<tr><td>9/20/2000</td><td>baz</td></tr>
</table>

I'm using some XSLT like the following to do the translation:

<xsl:template match="events">
    <table border="1">
      <xsl:apply-templates select="event"/>
    </table>
 </xsl:template>

<xsl:template match="event">
  <tr>
    <td>
      <xsl:value-of select="date"/>
    </td>
    <td>
      <xsl:value-of select="name"/>
    </td>
  </tr>
</xsl:template>

which works, but doesn't suppress the date column value if the value is
the same.

Any assistance you can provide in putting me on the right path would be
most appreciated.

Thanks,

Les


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]