[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: returning distinct results

Subject: RE: returning distinct results
From: "Tim" <xsl@xxxxxxxxxxxxxx>
Date: 30 Aug 2001 16:32:05 -0000
xml xsl distinct results
Thanks Bryan,  that's what I needed.  Just added /text() :
select="//town[not(./text()=preceding::town/text())]
and it worked.

Thanks again, Tim.
> 
> Tim,
> 
> Try 	select="//town[not(.=preceding::town)]" 	as your select
> statement
> 
> Bryan
> 
> -----Original Message-----
> From: Tim [mailto:xsl@xxxxxxxxxxxxxx]
> Sent: Thursday, August 30, 2001 12:55 PM
> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  returning distinct results
> 
> 
> Hi,
> 
> I have a list of branches some of which are in the same town.  I 
would 
> like to generate some html to display just the list of towns in a two 
> column list.  I have the columns working but I can't work out how to 
> remove duplicate towns.
> 
> I am trying to order by town name and see if the previous name 
matches 
> the current but the //town[position()-1] returns an empty set.
> 
> Any ideas would be great.
> 
> Ta,
> Tim.
> 
> Example XML:
> <branches>
>  <branch>
>   <name>A branch</name>
>   <town>Aberdeen</town>
>  </branch>
>  <branch>
>   <name>Another branch</name>
>   <town>Aberdeen</town>
>  </branch>
>  <branch>
>   <name>Yet Another branch</name>
>   <town>Bournemouth</town>
>  </branch>
> </branches>
> 
> XSL:
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
> xmlns:fo="http://www.w3.org/1999/XSL/Format">
> 	<xsl:template match="/">
> 			<xsl:call-template name="alltowns"/>
> 	</xsl:template>
> 	
> 	<xsl:template name="alltowns">
> 		<xsl:variable name="t-size" select="count(//town)"/>
>   		<xsl:variable name="half" select="ceiling($t-size div 
> 2)"/>
> 		<table>
> 		<tr>
> 		<td>
>    		<ul>
> 			
> 			<xsl:for-each select="//town[position() &lt;= 
> $half]">
> 				<xsl:if test="position() = 1 | //town
> [position()-1]/text() != ./text()">
> 					<li><a><xsl:attribute 
> name="href">locationDetails.jsp?town=<xsl:value-of 
> select="."/></xsl:attribute><xsl:value-of select="."/></a></li>
> 				</xsl:if>
> 			</xsl:for-each>
> 		</ul>
> 		</td>
> 		<td>
>    		<ul>
> 			<xsl:for-each select="//town[position() &gt; 
> $half]">
> 					<li><a><xsl:attribute 
> name="href">locationDetails.jsp?town=<xsl:value-of 
> select="."/></xsl:attribute><xsl:value-of select="."/></a></li>	
	
> 	</xsl:for-each>
> 		</ul>
> 		</td>
> 		</tr>
> 		</table>
> 	</xsl:template>
> </xsl:stylesheet>
> 
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 
> 



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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.