<?xml version="1.0" encoding="utf-8"?>
<!--
	Copyright © 2003 Ned Martin
	http://copyright.the-i.org/

	Show all comments (the-i.org)
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="html" encoding="utf-8"/>
	<xsl:key name="comments" match="comment" use="@page"/>
	<xsl:template match="comments">
		<p title="Number of comments and the date of the most recent comment">
			<xsl:value-of select="count(comment)"/>
			<xsl:text> comments have been left on this site, with the most recent having been posted on </xsl:text>
			<span title="GMT">
				<xsl:text disable-output-escaping="yes">&lt;?php format_date('</xsl:text>
				<xsl:value-of select="comment[last()]/@date"/>
				<xsl:text disable-output-escaping="yes">'); ?></xsl:text>
			</span>
			<xsl:text> by </xsl:text>
			<xsl:value-of select="comment[last()]/@author"/>
			<xsl:text>. </xsl:text>
		</p>
		<!-- <ul title="List of all the comments left on this site"> -->
		<xsl:apply-templates select="comment[generate-id()=generate-id(key('comments',@page))]" mode="headers"/>
		<!-- </ul> -->
	</xsl:template>
	<xsl:template match="comment">
		<!-- <dt> -->
		<span>
			<xsl:attribute name="title"><xsl:text>Comment posted by </xsl:text><xsl:value-of select="@author"/><xsl:text> at </xsl:text><xsl:value-of select="substring(@date,12,5)"/><xsl:text> GMT on </xsl:text><xsl:value-of select="substring(@date,9,2)"/><xsl:text>-</xsl:text><xsl:value-of select="substring(@date,6,2)"/><xsl:text>-</xsl:text><xsl:value-of select="substring(@date,1,4)"/></xsl:attribute>
			<xsl:value-of select="@author"/>
			<xsl:text disable-output-escaping="yes"> - &lt;?php format_date('</xsl:text>
			<xsl:value-of select="@date"/>
			<xsl:text disable-output-escaping="yes">'); ?>: </xsl:text>
			<!-- </dt> -->
			<!-- <dd> -->
			<!-- <xsl:attribute name="title"><xsl:text>Comment posted by </xsl:text><xsl:value-of select="@author"/><xsl:text> at </xsl:text><xsl:value-of select="substring(@date,12,5)"/><xsl:text> GMT on </xsl:text><xsl:value-of select="substring(@date,9,2)"/><xsl:text>-</xsl:text><xsl:value-of select="substring(@date,6,2)"/><xsl:text>-</xsl:text><xsl:value-of select="substring(@date,1,4)"/></xsl:attribute> -->
			<xsl:apply-templates/>
			<!-- </dd> -->
		</span>
		<xsl:text disable-output-escaping="yes">&lt;br /></xsl:text>
	</xsl:template>
	<xsl:template match="comment" mode="headers">
		<p class="comments">
			<xsl:attribute name="title"><xsl:text>Comments for </xsl:text><xsl:value-of select="@page"/></xsl:attribute>
			<a title="View associated page" href="{@page}">
				<xsl:text disable-output-escaping="yes">&lt;?php include_tag('title','</xsl:text>
				<xsl:value-of select="@page"/>
				<xsl:text disable-output-escaping="yes">'); ?></xsl:text>
			</a>
			<xsl:text> (</xsl:text>
			<xsl:value-of select="count(key('comments',@page))"/>
			<xsl:text disable-output-escaping="yes"> comments) &lt;br /></xsl:text>
			<!-- <dl title="Comments"> -->
			<xsl:apply-templates select="key('comments',@page)">
				<xsl:sort select="@date"/>
			</xsl:apply-templates>
			<!-- </dl> -->
		</p>
	</xsl:template>
</xsl:stylesheet>
