[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Distinct items?
HA! I figured that one out! two nested for-each loops... the first select is: select='//item[not(year = preceding-sibling::item/year)]' The second level is: select="/projects/item[year = $x]" (the second has the x variable defined as the current year in the loop. Thanksfor your help on the original problem, Edmund! --Eric (learning XSLT one small step at a time) > 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 > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|