Re: [xsl] Display unique values?

Subject: Re: [xsl] Display unique values?
From: Alan Fenn <afenn262@xxxxxxxxx>
Date: Mon, 23 Jan 2006 13:41:14 -0800 (PST)
Andrew,

Unfortunately, I'm using 1.0, since that's what's
supported by IE6 and Firefox. Fortunately, George's
solution worked quite well. Thanks for your help!

- Alan

--- andrew welch <andrew.j.welch@xxxxxxxxx> wrote:

> On 1/20/06, George Cristian Bina
> <george@xxxxxxxxxxxxx> wrote:
> > Hi Alan,
> >
> > Your stylesheet looks complicated, how about:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <xsl:stylesheet version="1.0"
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> >    <xsl:output version="1.0" encoding="UTF-8"
> indent="no"
> > omit-xml-declaration="no"
> >      media-type="text/html"/>
> >
> >    <xsl:template match="/">
> >      <html><table>
> >        <thead><tr>
> >          <td>Event</td><td>Device</td>
> >        </tr></thead>
> >        <tbody>
> >          <xsl:apply-templates/>
> >        </tbody>
> >      </table></html>
> >    </xsl:template>
> >
> >    <xsl:template match="Event">
> >      <tr>
> >        <td><xsl:value-of select="ID"/></td>
> >        <td>
> >          <xsl:for-each
> >
>
select="EventDevicesArchive/EventDevice/Device[not(text()=../preceding-sibling::EventDevice/Device/text())]">
> >              <xsl:value-of select="."/>
> >              <xsl:if test="position()!=last()">
> >                <xsl:text>, </xsl:text>
> >              </xsl:if>
> >          </xsl:for-each>
> >        </td>
> >      </tr>
> >    </xsl:template>
> > </xsl:stylesheet>
> 
> George has a given a 1.0 solution, if you can use
> XSLT 2.0 then you
> could use the distinct-values() function:
> 
> <xsl:for-each
>
select="EventDevicesArchive/EventDevice/Device[not(text()=../preceding-sibling::EventDevice/Device/text())]">
> 
> can become:
> 
> <xsl:for-each
>
select="distinct-values(EventDevicesArchive/EventDevice/Device)">
> 
> cheers
> andrew
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Current Thread