xsl-list
[Top] [All Lists]

Re: Display unique values?

2006-01-23 14:41:14
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(_dot_)j(_dot_)welch(_at_)gmail(_dot_)com> wrote:

On 1/20/06, George Cristian Bina
<george(_at_)oxygenxml(_dot_)com> 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


--~------------------------------------------------------------------
XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>