Subject: Re: simple grouping question From: Les Howard <les@xxxxxxxxxxxxxxx> Date: Mon, 18 Sep 2000 13:07:19 -0400 |
I just figured it out. The "magic" I needed to get it working was: <xsl:if test="string(preceding-sibling::event[1]/date)!=string(date)"> <xsl:value-of select="date"/> </xsl:if> Looks like I need to find a good XPath tutorial. Les Les Howard wrote: > 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 -- "Anyone who slaps a 'this page is best viewed with Browser X' label on a Web page appears to be yearning for the bad old days, before the Web, when you had very little chance of reading a document written on another computer, another word processor, or another network." -Tim Berners-Lee in Technology Review, July 1996 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
simple grouping question, Les Howard | Thread | RE: simple grouping question, Ben Robb |
RE: breaking sorted material into s, Don Bruey | Date | Re: Rendering: filling tag attribut, Lee Goddard |
Month |