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

Re: displaying unique entries in a list

Subject: Re: displaying unique entries in a list
From: Mukul Gandhi <mukul_gandhi@xxxxxxxxx>
Date: Mon, 9 May 2005 02:30:27 -0700 (PDT)
displaying unique values in xquery
I modified the stylesheet as follows.. Its working.

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html" />

<xsl:template match="/xml">
  <html>
    <body>
      <h2>Test example of List output</h2>
      <hr/>
      <!--########## Begin Main Document ##########-->
      <xsl:apply-templates select="List" />
    </body>
  </html>
</xsl:template>

<!--######## Template for Department Main table data
######-->
<xsl:template match="List">
  <table border="1" width="100%">
    <xsl:apply-templates select="Entry/Department"/>
  </table>
</xsl:template>

<!--### Displays first page departments only ###-->
<xsl:template match="Entry/Department">
  <xsl:if test="not(. = preceding::Department)">
    <tr>
      <td>
       <span style="color:#000000">
  	 <a href=""><xsl:value-of select="." /></a>
       </span>
      </td>
    </tr>
  </xsl:if>
</xsl:template>

</xsl:stylesheet>

Regards,
Mukul

--- "Hallas,M" <M.Hallas@xxxxxxxxx> wrote:
> Dear all,
> 
> Hope that you can help with this problem I have
> displaying a list of data.
> 
> My XML looks like this:
> 
> <xml>
> <List>
> 	<Entry>
> 		<Session>2004/5</Session>
> 		<Department>Accounting and Finance</Department>
> 	</Entry>
> 	<Entry>
> 		<Session>2004/5</Session>
> 		<Department>Accounting and Finance</Department>
> 	</Entry>
> 	<Entry>
> 		<Session>2004/5</Session>
> 		<Department>Maths</Department>
> 	</Entry>
> 	<Entry>
> 		<Session>2004/5</Session>
> 		<Department>Maths</Department>
> 	</Entry>
> 	<Entry>
> 		<Session>2004/5</Session>
> 		<Department>Economic History</Department>
> 	</Entry>
> </List>
> </xml>
> 
> My xslt example is below:
> 
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:template match="/">
> <html>
> 	<body>
> 		<h2>Test example of List output</h2>
> 		<hr/>
> 		 <!--########## Begin Main Document ##########-->
> 		 <xsl:apply-templates />
> 	</body>
> </html>
> </xsl:template>
> 
> <!--######## Template for Department Main table data
> ######-->
> <xsl:template match="List">
> 	<table border="1" width="100%">
> 		<xsl:apply-templates select="Department"/>
> 	</table>
> </xsl:template>
> 
> <!--### Displays first page departments only ###-->
> <xsl:template match="Department">
>   <xsl:for-each select="/List/Entry/Department[not(.
> = preceding::Department)]">
>             <tr>
>               <td>
> 		   <span style="color:#000000">
> 			<a href=""><xsl:value-of select="." /></a>
> 		   </span>
> 	       </td>
>             </tr>
>   </xsl:for-each>
> </xsl:template>
> </xsl:stylesheet>
> 
> An earlier posted fix in the xlst allowed me to
> display just single unique entries in the html like
> this:
> 
> 	Accounting and Finance
> 	Maths
> 	Economic History
> 
> However I now get multiples of these unique values
> rather than one single list of the unique values.
> 
> Am I calling the template root incorrectly in the
> xslt? 
> Should I be using a loop of some sort to display the
> unique values only once?
> 
> Many thanks,
> 
> 
> Mike
> 
> 


		
Yahoo! Mail
Stay connected, organized, and protected. Take the tour:
http://tour.mail.yahoo.com/mailtour.html

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.