Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 27th, 2010, 03:47 PM
Registered User
 
Join Date: Sep 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Code:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:key name="date" match="date" use="." />
<xsl:template match="events">

<html>
<body>

     <xsl:for-each select="date[count(. | key('date', .)[1]) = 1]">
		<xsl:sort select="." />
		<h2><xsl:value-of select="." /></h2>
		<xsl:for-each select="key('date', .)">
			<p><xsl:value-of select="../title" /></p>
		</xsl:for-each>
	</xsl:for-each>

</body>
</html>

</xsl:template>
</xsl:stylesheet>

this code outputs nothing...
 
Old September 28th, 2010, 06:57 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Use
for-each select="event/date[count(. | key('date', .)[1]) = 1]"
instead of what you have.
And be aware that sorting dates in the format yyyy-mm-dd is possible, but some of the XML input samples you posted have a format like 8th October 2010 and sorting on that is not possible, you would first need to transform the format into something sortable with XSLT 1.0 (i.e. 'yyyy-mm-dd' or yyyymmdd).
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog





Similar Threads
Thread Thread Starter Forum Replies Last Post
Grouping on Multiple Field nisargmca XSLT 2 May 10th, 2010 02:42 AM
grouping multiple xml files in one file bcogney XSLT 3 April 21st, 2006 03:58 AM
Multiple Grouping in List ROCXY XSLT 0 January 7th, 2006 05:16 AM
Grouping multiple paragraph styles under 1 parent ROCXY XML 0 January 4th, 2006 09:42 AM
access calendars multiple dates RobertCoats Access 0 June 23rd, 2005 02:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.