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

RE: Distinct items?

Subject: RE: Distinct items?
From: eric@xxxxxxxxxxxx (Eric Vitiello)
Date: Tue, 27 Mar 2001 12:23:51 -0500
RE:  Distinct items?
OK, I just realized another step I'd like to do.  My XML is:


 <projects>
 	<item>
 		<year>1998</year>
		<title>This is the first item</title>
 	</item>
 	<item>
 		<year>2000</year>
		<title>This is the second item</title>
 	</item>
 	<item>
 		<year>1999</year>
		<title>This is the third item</title>
 	</item>
 	<item>
 		<year>2000</year>
		<title>This is the fourth item</title>
 	</item>
 	<item>
 		<year>1998</year>
		<title>This is the fifth item</title>
 	</item>
</projects>


with the following XSLT:

<xsl:for-each  select='//item[not(year = preceding-sibling::item/year)]'>
	<xsl:sort select="projects/item/year" data-type="number" order="descending"/>
	<xsl:sort select="projects/item/month" data-type="number" order="descending"/>
	<xsl:sort select="projects/item/day" data-type="number" order="descending"/>
		<xsl:value-of select="year"/>  
</xsl:for-each>

I get:

1998 1999 2000


I would like then to be able to list the data such as:

1998
  * This is the first item
  * This is the fifth item

1999
  * This is the third item

2000
  * This is the second item
  * This is the fourth item


Got code for that?

I'm just starting with XSLT, and the syntax of selects, etc keeps throwing me off.

--Eric

> Hello
> You can use this:
>  select='//item[not(year = preceding-sibling::item/year)]'>
> 
> I hope that helps
> 
> Edmund
> 
> -----Original Message-----
> From: eric@xxxxxxxxxxxx [mailto:eric@xxxxxxxxxxxx]
> 
> I would like to retrieve a list of items such as:
> 
> 1998 1999 2000
> 
> from the following XML:
> 
> <projects>
> 	<item>
> 		<year>1998</year>
> 	</item>
> 	<item>
> 		<year>1998</year>
> 	</item>
> 	<item>
> 		<year>1999</year>
> 	</item>
> 	<item>
> 		<year>2000</year>
> 	</item>
> 	<item>
> 		<year>2000</year>
> 	</item>
> </projects>
> 
> 
> 	
>  
> 
>  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.