Re: Retrieving Distinct text

Subject: Re: Retrieving Distinct text
From: "Pete Johnston" <P.Johnston@xxxxxxxxxxxxxxxxxx>
Date: Thu, 15 Jul 1999 10:43:49 GMT
[Amit Khemka]

> Is it possible using XSL, to extract Distinct Values for a given element. 
[example snipped]

I'm sure there are more elegant solutions, but I think something like 
the following should work for your example:

<xsl:template match="companies">

<xsl:sort select="city"/>


<xsl:template match="company">

<xsl:variable name="x" expr="city"/>

<xsl:if test='not(from-following-siblings(*[city=$x]))'>

<xsl:value-of select="city"/>

<xsl:if test="not(position()=last())"><xsl:text>, </xsl:text></xsl:if>


Pete Johnston
University of Glasgow
Pete Johnston (Effective Records Management Project)
Archives & Business Records Centre
University of Glasgow
77-87 Dumbarton Road
Glasgow G11 6PW   E-Mail: p.johnston@xxxxxxxxxxxxxxxxxx
Scotland, U.K.    URL:

Tel:  (UK) 0141 339 8855 ext. 0166 or (UK) 0141-330-4159
Fax:  (UK) 0141-330-4158

 XSL-List info and archive:

Current Thread