<?xml version="1.0"?>
<!--
	&copy; Jon Hanna 2002
-->
<!--
	I really couldn't care less what anyone does with this, but claiming
	that they wrote it would be just sad and in asserting my right
	of intellectual property I assert my right to publicly ridicule
	anyone who does.
-->
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rss="http://purl.org/rss/1.0/"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="rdf rss">
	<xsl:output
		method="xml"
		version="1.0"
		omit-xml-declaration="yes"
		media-type="application/html+xml"/>
	<xsl:template match="/">
		<html>
			<xsl:choose>
				<xsl:when test="rdf:RDF">
					<xsl:apply-templates/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:call-template name="invalidRoot"/>
				</xsl:otherwise>
			</xsl:choose>
		</html>
	</xsl:template>
	<xsl:template match="/rdf:RDF">
		<xsl:variable name="channels" select="count(rss:channel)"/>
		<xsl:choose>
			<xsl:when test="$channels=0">
				<xsl:call-template name="noElement">
					<xsl:with-param name="localname" select="'channel'"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="$channels>1">
				<xsl:call-template name="tooManyElements">
					<xsl:with-param name="localname" select="'channel'"/>
					<xsl:with-param name="count" select="$channels"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="rss:channel"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="/rdf:RDF/rss:channel">
		<xsl:variable name="titles" select="count(rss:title)"/>
		<xsl:variable name="links" select="count(rss:link)"/>
		<xsl:variable name="descriptions" select="count(rss:description)"/>
		<xsl:variable name="itemsEls" select="count(rss:items)"/>
		<xsl:variable name="images" select="count(rss:image)"/>
		<xsl:variable name="textinputs" select="count(rss:textinput)"/>
		<xsl:choose>
			<xsl:when test="$titles=0">
				<xsl:call-template name="noElement">
					<xsl:with-param name="localname" select="'title'"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="$titles>1">
				<xsl:call-template name="tooManyElements">
					<xsl:with-param name="localname" select="'title'"/>
					<xsl:with-param name="count" select="$titles"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="$links=0">
				<xsl:call-template name="noElement">
					<xsl:with-param name="localname" select="'link'"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="$links>1">
				<xsl:call-template name="tooManyElements">
					<xsl:with-param name="localname" select="'link'"/>
					<xsl:with-param name="count" select="$links"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="$descriptions=0">
				<xsl:call-template name="noElement">
					<xsl:with-param name="localname" select="'description'"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="$descriptions>1">
				<xsl:call-template name="tooManyElements">
					<xsl:with-param name="localname" select="'description'"/>
					<xsl:with-param name="count" select="$descriptions"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="$itemsEls=0">
				<xsl:call-template name="noElement">
					<xsl:with-param name="localname" select="'items'"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="$itemsEls>1">
				<xsl:call-template name="tooManyElements">
					<xsl:with-param name="localname" select="'items'"/>
					<xsl:with-param name="count" select="$itemsEls"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="$images>1">
				<xsl:call-template name="tooManyOptElements">
					<xsl:with-param name="localname" select="'image'"/>
					<xsl:with-param name="count" select="$images"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="$textinputs>1">
				<xsl:call-template name="tooManyOptElements">
					<xsl:with-param name="localname" select="'textinput'"/>
					<xsl:with-param name="count" select="$textinputs"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<head>
					<title>RSS Validation Results</title>
					<link rel="stylesheet" href="rssvalid.css" />
				</head>
				<body>
					<h1>RSS Validation Results</h1>
					<p>
						Note that this only attempts to validate the core RSS elements and the
						attributes that requires. No attempt is made to validate any of the
						elements or attributes from other modules.
					</p>
					<p>
						I am unsure whether RSS allows the use of explicitly named list items in
						the <code>rdf:Seq</code>, or whether it allows the option of using an
						<code>rdf:Bag</code> in the <code>items</code> element to indicate that
						there is no ordering being imposed by the author. I have assumed that both
						of these are not allowed.
					</p>
					<hr />
					<h2>Errors and Warnings</h2>
					<xsl:if test="count(//*[@rdf:about=following::*/@rdf:about or @rdf:about=descendant::*/@rdf:about])">
						<h3>Duplicate rdf:about</h3>
						<p>There are at least two items with the same value for their
						<code>rdf:about</code>
						attribute.</p>
						<p>This is forbidden by the 
						<a href="http://purl.org/rss/1.0/spec">RSS Spec</a>.</p>
					</xsl:if>
					<xsl:apply-templates select="rss:*"/>
					<xsl:apply-templates select="/rdf:RDF/rss:item"/>
					<hr />
					<h2>Rendering of RSS document</h2>
					<p>The following is an attempt to render this RSS, paying attention
					only to those elements and attributes defined in the core
					<a href="http://purl.org/rss/1.0/spec">RSS Spec</a>, and ignoring all
					other modules and namespaces.
					</p>
					<xsl:apply-templates select="." mode="render"/>
				</body>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="rss:title|rss:description|rss:name">
		<xsl:call-template name="checkIsPCDATA"/>
	</xsl:template>
	<xsl:template match="rss:channel/rss:image">
		<xsl:call-template name="checkIsEmpty"/>
		<xsl:call-template name="checkResourceAttr"/>
		<xsl:variable name="numLinked" select="count(/rdf:RDF/rss:image[@rdf:about=current()/@rdf:resource])"/>
		<xsl:choose>
			<xsl:when test="$numLinked=0">
				<h3>No image Element Match Found</h3>
				<p>There is an <code>image</code> in the <code>channel</code>
				for which no matching
				<code>image</code> can be found within the root <code>rdf:RDF</code>
				element.
				</p>
				<p>The match should be done by having an <code>image</code> in the
				<code>rdf:RDF</code> which has a <code>rdf:about</code> attribute
				which matches the <code>rdf:resource</code> attribute of the
				<code>image</code> in the <code>channel</code>.</p>
			</xsl:when>
			<xsl:when test="$numLinked>1">
				<h3>Too many image Element Matches Found</h3>
				<p>There are more than one <code>image</code> elements in the root
				<code>rdf:RDF</code> element which have an <code>rdf:about</code>
				attribute matching the <code>rdf:resource</code> of the
				<code>image</code> element in the <code>channel</code>.
				</p>
				<p>
					It is impossible to know how to proceed with rendering images.
				</p>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="/rdf:RDF/rss:image[@rdf:about=current()/@rdf:resource]"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="/rdf:RDF/rss:image">
		<xsl:variable name="titles" select="count(rss:title)"/>
		<xsl:variable name="urls" select="count(rss:url)"/>
		<xsl:variable name="links" select="count(rss:link)"/>
		<xsl:choose>
			<xsl:when test="$titles=0">
				<xsl:call-template name="noElementNonFatal">
					<xsl:with-param name="localname" select="'title'"/>
				</xsl:call-template>		
			</xsl:when>
			<xsl:when test="$titles>1">
				<xsl:call-template name="tooManyElementsNonFatal">
					<xsl:with-param name="localname" select="'title'"/>
					<xsl:with-param name="count" select="$titles"/>
				</xsl:call-template>		
			</xsl:when>
			<xsl:when test="$urls=0">
				<xsl:call-template name="noElementNonFatal">
					<xsl:with-param name="localname" select="'url'"/>
				</xsl:call-template>		
			</xsl:when>
			<xsl:when test="$urls>1">
				<xsl:call-template name="tooManyElementsNonFatal">
					<xsl:with-param name="localname" select="'url'"/>
					<xsl:with-param name="count" select="$urls"/>
				</xsl:call-template>		
			</xsl:when>
			<xsl:when test="$links=0">
				<xsl:call-template name="noElementNonFatal">
					<xsl:with-param name="localname" select="'link'"/>
				</xsl:call-template>		
			</xsl:when>
			<xsl:when test="$links>1">
				<xsl:call-template name="tooManyElementsNonFatal">
					<xsl:with-param name="localname" select="'link'"/>
					<xsl:with-param name="count" select="$links"/>
				</xsl:call-template>		
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="rss:*"/>
				<xsl:if test="@rdf:about!=rss:url">
					<h3>url Doesn't Match rdf:about (Warning)</h3>
					<p>It is recommended, but not compulsory, that the 
					<code>url</code> child of an image match the
					<code>rdf:about</code> attribute.</p>
				</xsl:if>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="rss:channel/rss:textinput">
		<xsl:call-template name="checkIsEmpty"/>
		<xsl:call-template name="checkResourceAttr"/>
		<xsl:variable name="numLinked" select="count(/rdf:RDF/rss:textinput[@rdf:about=current()/@rdf:resource])"/>
		<xsl:choose>
			<xsl:when test="$numLinked=0">
				<h3>No textinput Element Match Found</h3>
				<p>There is a <code>textinput</code> in the <code>channel</code>
				for which no matching
				<code>textinput</code> can be found within the root <code>rdf:RDF</code>
				element.
				</p>
				<p>The match should be done by having an <code>textinput</code> in the
				<code>rdf:RDF</code> which has a <code>rdf:about</code> attribute
				which matches the <code>rdf:resource</code> attribute of the
				<code>textinput</code> in the <code>channel</code>.</p>
			</xsl:when>
			<xsl:when test="$numLinked>1">
				<h3>Too many textinput Element Matches Found</h3>
				<p>There are more than one <code>textinput</code> elements in the root
				<code>rdf:RDF</code> element which have an <code>rdf:about</code>
				attribute matching the <code>rdf:resource</code> of the
				<code>textinput</code> element in the <code>channel</code>.
				</p>
				<p>
					It is impossible to know how to proceed with rendering textinputs.
				</p>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="/rdf:RDF/rss:textinput[@rdf:about=current()/@rdf:resource]"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="rdf:RDF/rss:textinput">
		<xsl:variable name="names" select="count(rss:name)"/>
		<xsl:variable name="titles" select="count(rss:title)"/>
		<xsl:variable name="descriptions" select="count(rss:description)"/>
		<xsl:variable name="links" select="count(rss:link)"/>
		<xsl:choose>
			<xsl:when test="$names=0">
				<xsl:call-template name="noElementNonFatal">
					<xsl:with-param name="localname" select="'name'"/>
				</xsl:call-template>		
			</xsl:when>
			<xsl:when test="$names>1">
				<xsl:call-template name="tooManyElementsNonFatal">
					<xsl:with-param name="localname" select="'name'"/>
					<xsl:with-param name="count" select="$names"/>
				</xsl:call-template>		
			</xsl:when>
			<xsl:when test="$titles=0">
				<xsl:call-template name="noElementNonFatal">
					<xsl:with-param name="localname" select="'title'"/>
				</xsl:call-template>		
			</xsl:when>
			<xsl:when test="$titles>1">
				<xsl:call-template name="tooManyElementsNonFatal">
					<xsl:with-param name="localname" select="'title'"/>
					<xsl:with-param name="count" select="$titles"/>
				</xsl:call-template>		
			</xsl:when>
			<xsl:when test="$descriptions>1">
				<xsl:call-template name="tooManyElementsNonFatal">
					<xsl:with-param name="localname" select="'description'"/>
					<xsl:with-param name="count" select="$descriptions"/>
				</xsl:call-template>		
			</xsl:when>
			<xsl:when test="$links=0">
				<xsl:call-template name="noElementNonFatal">
					<xsl:with-param name="localname" select="'link'"/>
				</xsl:call-template>		
			</xsl:when>
			<xsl:when test="$links>1">
				<xsl:call-template name="tooManyElementsNonFatal">
					<xsl:with-param name="localname" select="'link'"/>
					<xsl:with-param name="count" select="$links"/>
				</xsl:call-template>		
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="rss:*"/>
				<xsl:if test="@rdf:about!=rss:link">
					<h3>link Doesn't Match rdf:about (Warning)</h3>
					<p>It is recommended, but not compulsory, that the 
					<code>link</code> child of an image match the
					<code>rdf:about</code> attribute.</p>
				</xsl:if>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="rss:items">
		<xsl:variable name="Seqs" select="count(rdf:Seq)"/>
		<xsl:choose>
			<xsl:when test="$Seqs=0">
				<h3>No rdf:Seq Element</h3>
				<p>An <code>items</code>
				must have a child with
				a local name of <code>Seq</code> and a Namespace URI of
				<code>http://www.w3.org/1999/02/22-rdf-syntax-ns#</code>.</p>
				<p>This document has an <code>items</code>
				element with no such children.</p>
			</xsl:when>
			<xsl:when test="$Seqs>1">
				<h3>Too Many rdf:Seq Elements</h3>
				<p>An <code>items</code> element
				must have <em>one</em> child with
				a local name of <code>Seq</code> and a Namespace URI of
				<code>http://www.w3.org/1999/02/22-rdf-syntax-ns#</code>.</p>
				<p>This document has an <code>items</code>
				with <xsl:value-of select="$Seqs"/> such children.</p>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="rdf:Seq/rdf:*"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="rdf:Seq/rdf:*">
		<xsl:if test="substring(local-name(),1,1)='_'
		and string(number(substring(local-name(),2)))!='NaN'
		and not(contains(number(substring(local-name(),2)),'.'))">
			<h3>Explicit RDF List Item Used</h3>
			<p>
				The <a href="http://purl.org/rss/1.0/spec">RSS Spec</a> is unclear as to
				whether it allows explicitly numbered RDF list items. It appears that they
				do not. Use <code>rdf:li</code> instead.
			</p>
			<xsl:if test="count(following-sibling::*[local-name()=local-name(current())])">
				<h3>Explicit RDF List Item Duplication</h3>
				<p>
					There is more than one explictly numbered RDF list items with a local
					name of <code><xsl:value-of select="local-name()"/></code>.
				</p>
			</xsl:if>
		</xsl:if>
		<xsl:if test="local-name()='li'">
			<xsl:call-template name="processListItem"/>
		</xsl:if>
	</xsl:template>
	<xsl:template name="processListItem">
		<xsl:call-template name="checkResourceAttr"/>
		<xsl:call-template name="checkIsEmpty"/>
		<xsl:apply-templates select="following-sibling::rdf:*[@rdf:resource=current()/@rdf:resource or @resource=current()/@rdf:resource or @rdf:resource=current()/@resource or @resource=current()/@resource][1]" mode="checkDuplicateResource"/>
		<xsl:variable name="numLinked" select="count(/rdf:RDF/rss:item[@rdf:about=current()/@rdf:resource or @rdf:about=current()/@resource])"/>
		<xsl:choose>
			<xsl:when test="$numLinked=0">
				<h3>No item Element Match Found</h3>
				<p>There is an item in the <code>channel</code>'s <code>items</code>
				for which no matching
				<code>item</code> can be found within the root <code>rdf:RDF</code>
				element.
				</p>
				<p>The match should be done by having an <code>item</code> in the
				<code>rdf:RDF</code> which has a <code>rdf:about</code> attribute
				which matches the <code>rdf:resource</code> attribute of the
				<code>image</code> in the <code>channel</code>.</p>
			</xsl:when>
			<xsl:when test="$numLinked>1">
				<h3>Too many item Element Matches Found</h3>
				<p>There are more than one <code>item</code> elements in the root
				<code>rdf:RDF</code> element which have an <code>rdf:about</code>
				attribute matching the <code>rdf:resource</code> of the
				item element in the <code>channel's</code> <code>items</code>.
				</p>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="rdf:*" mode="checkDuplicateResource">
		<xsl:if test="local-name()='li'
		or (substring(local-name(),1,1)='_'
		and string(number(substring(local-name(),2)))!='NaN'
		and not(contains(number(substring(local-name(),2)),'.')))">
			<h3>Duplicate rdf:resource (warning)</h3>
			<p>There is more than one item in the <code>channel</code>'s
			<code>Seq</code>uence with the same rdf:resource. This may not
			be what you intended.</p>
		</xsl:if>
	</xsl:template>
	<xsl:template match="rss:link|rss:url">
		<xsl:call-template name="checkIsPCDATA"/>
		<xsl:call-template name="allowedURI"/>
	</xsl:template>
	<xsl:template name="checkResourceAttr">
		<xsl:choose>
			<xsl:when test="@resource and namespace-uri()='http://www.w3.org/1999/02/22-rdf-syntax-ns#' and not(@rdf:resource)">
				<h3>Unqualified rdf:resource Attribute (Warning)</h3>
				<p>The unqualified use of the rdf:resource attribute (i.e. without
				a namespace prefix) on RDF elements is deprecated by the RDF Standard.
				</p>
				<p>There is one in this document with no such attribute.</p>
			</xsl:when>
			<xsl:when test="not(@rdf:resource)">
				<h3>No rdf:resource Attribute</h3>
				<p><code><xsl:value-of select="local-name()"/></code>
				elements inside
				<code><xsl:value-of select="local-name(../.)"/></code>
				elements must have an attribute with a local name of
				<code>resource</code> and a Namespace URI of
				<code>http://www.w3.org/1999/02/22-rdf-syntax-ns#</code>.
				</p>
				<p>There is one in this document with no such attribute.</p>
			</xsl:when>
			<xsl:when test="string-length(@rdf:resource)&lt;7">
				<!-- Naive test, but it's a start. -->
				<h3>rdf:resource value appears invalid</h3>
				<p><code><xsl:value-of select="local-name()"/></code>
				elements inside
				<code><xsl:value-of select="local-name(../.)"/></code>
				elements must have an attribute with a local name of
				<code>resource</code> and a Namespace URI of
				<code>http://www.w3.org/1999/02/22-rdf-syntax-ns#</code> which
				contains a URI.
				</p>
				<p>
					The value of
					&quot;<code><xsl:value-of select="@rdf:resource"/></code>&quot;
					does not appear to be a valid URI.
				</p>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="rss:item">
		<xsl:choose>
			<xsl:when test="not(@rdf:about)">
				<h3>item Without rdf:about</h3>
				<p>There is an <code>item</code> element which lacks an
				<code>rdf:about</code> attribute.</p>
				<p>This is invalid.</p>
			</xsl:when>
			<xsl:when test="not(/rdf:RDF/rss:channel/rss:items//rdf:*[@rdf:resource=current()/@rdf:about])
			and not(/rdf:RDF/rss:channel/rss:items//rdf:*[@resource=current()/@rdf:about])">
				<h3>Unreferenced item (Warning)</h3>
				<p>The <code>item</code> element with an rdf:about attribute of
				<code>&quot;<xsl:value-of select="@rdf:about"/>&quot;</code> is not
				referenced in the <code>channel</code> and therefore not an item
				in this RSS document.
				</p>
			</xsl:when>
		</xsl:choose>
		<xsl:variable name="titles" select="count(rss:title)"/>
		<xsl:variable name="descriptions" select="count(rss:description)"/>
		<xsl:variable name="links" select="count(rss:link)"/>
		<xsl:choose>
			<xsl:when test="$titles=0">
				<xsl:call-template name="noElementNonFatal">
					<xsl:with-param name="localname" select="'title'"/>
				</xsl:call-template>		
			</xsl:when>
			<xsl:when test="$titles>1">
				<xsl:call-template name="tooManyElementsNonFatal">
					<xsl:with-param name="localname" select="'title'"/>
					<xsl:with-param name="count" select="$titles"/>
				</xsl:call-template>		
			</xsl:when>
			<xsl:when test="$descriptions>1">
				<xsl:call-template name="tooManyElementsNonFatal">
					<xsl:with-param name="localname" select="'description'"/>
					<xsl:with-param name="count" select="$descriptions"/>
				</xsl:call-template>		
			</xsl:when>
			<xsl:when test="$links=0">
				<xsl:call-template name="noElementNonFatal">
					<xsl:with-param name="localname" select="'link'"/>
				</xsl:call-template>		
			</xsl:when>
			<xsl:when test="$links>1">
				<xsl:call-template name="tooManyElementsNonFatal">
					<xsl:with-param name="localname" select="'link'"/>
					<xsl:with-param name="count" select="$links"/>
				</xsl:call-template>		
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="rss:*"/>
				<xsl:if test="@rdf:about!=rss:link">
					<h3>link Doesn't Match rdf:about (Warning)</h3>
					<p>It is recommended, but not compulsory, that the 
					<code>link</code> child of an image match the
					<code>rdf:about</code> attribute.</p>
				</xsl:if>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template name="allowedURI">
		<xsl:variable name="URI" select="translate(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
		<xsl:if test="not(starts-with($URI,'http://')) and
		not(starts-with($URI,'https://')) and
		not(starts-with($URI,'ftp://')) and
		not(starts-with($URI,'mailto:') and parent::rss:textinput)">
				<h3>Bad URI!</h3>
				<p>
					RSS has the following rules for URIs:
				</p>
				<blockquote cite="http://purl.org/rss/1.0/spec">
					<p>
						&#x2026;only the following schemes are acceptable
						in url and link elements: http:, https:, ftp:.
						mailto: is acceptable in the textinput's link
						element only.
					</p>
				</blockquote>
				<p>There is a <code><xsl:value-of select="local-name()"/></code> element with
				<xsl:choose>
					<xsl:when test="string-length()">
						a URI of <code><xsl:value-of select="."/></code>
					</xsl:when>
					<xsl:otherwise>
						a null URI
					</xsl:otherwise>
				</xsl:choose>
				<xsl:text>, which violates this
				rule.</xsl:text></p>
		</xsl:if>
	</xsl:template>
	<xsl:template name="checkIsPCDATA">
		<xsl:if test="count(*)">
				<h3><xsl:value-of select="local-name()"/> only allows #PCDATA content.</h3>
				<p>RSS's <code><xsl:value-of select="local-name()"/></code> element only allows
				#PCDATA (text) content.</p>
				<p>This document contains a <code><xsl:value-of select="local-name()"/></code>
				element with a <code><xsl:value-of select="local-name(*)"/></code> child element.
				</p>
		</xsl:if>
	</xsl:template>
	<xsl:template name="checkIsEmpty">
		<xsl:choose>
			<xsl:when test="string-length(normalize-space()) or count(*)">
				<h3><xsl:value-of select="local-name()"/> Must Be Empty</h3>
				<p><code><xsl:value-of select="local-name()"/></code>
				elements inside
				<code><xsl:value-of select="local-name(../.)"/></code>
				elements must be empty.
				</p>
				<p>There is one in this document which contains
				<xsl:choose>
					<xsl:when test="count(*)">
						a <code><xsl:value-of select="local-name(*)"/></code>
						element.
					</xsl:when>
					<xsl:otherwise>
						the content:
						<blockquote>
							<code><xsl:value-of select="."/></code>
						</blockquote>
					</xsl:otherwise>
				</xsl:choose>
				</p>
			</xsl:when>
			<xsl:when test="string-length()">
				<h3><xsl:value-of select="local-name()"/> Only Empty after Normalisation (Warning)</h3>
				<p><code><xsl:value-of select="local-name()"/></code>
				elements inside
				<code><xsl:value-of select="local-name(../.)"/></code>
				elements must be empty.
				</p>
				<p>
					There is one in this document which contains whitespace.
					It will be considered equivalent to an empty element by some
					processors, but is not strictly empty.
				</p>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
	<xsl:template name="invalidRoot">
		<xsl:variable name="ns" select="namespace-uri(/*)"/>
		<head>
			<title>Invalid Document Root Element</title>
			<link rel="stylesheet" href="rssvalid.css" />
		</head>
		<body>
			<h1>Invalid Document Root Element</h1>
			<p>The RSS1.0 document must have a document root element with
			a local name of <code>RDF</code> and a Namespace URI of
			<code>http://www.w3.org/1999/02/22-rdf-syntax-ns#</code>.</p>
			<p>This document has a document root element with a local
			name of <code><xsl:value-of select="local-name(/*)"/></code>
			and
			<xsl:choose>
				<xsl:when test="string-length($ns)">
					<xsl:text>a Namespace URI of </xsl:text>
					<code><xsl:value-of select="$ns"/></code>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>no Namespace URI</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
			<xsl:text>.</xsl:text></p>
			<p>Cannot process further.</p>
		</body>
	</xsl:template>
	<xsl:template name="noElement">
		<xsl:param name="localname"/>
		<head>
			<title>No <xsl:value-of select="$localname"/> Element</title>
			<link rel="stylesheet" href="rssvalid.css" />
		</head>
		<body>
			<h1>No <xsl:value-of select="$localname"/> Element</h1>
			<p>The <code><xsl:value-of select="name()"/></code>
			element must have a child with
			a local name of <code><xsl:value-of select="$localname"/></code> and a Namespace URI of
			<code>http://purl.org/rss/1.0/</code>.</p>
			<p>This document has a no such element.</p>
			<p>Cannot process further.</p>
		</body>
	</xsl:template>
	<xsl:template name="noElementNonFatal">
		<xsl:param name="localname"/>
			<h3>No <xsl:value-of select="$localname"/> Element</h3>
			<p>A <code><xsl:value-of select="name()"/></code>
			element inside a
			<code><xsl:value-of select="name(..)"/></code> element
			must have a child with
			a local name of <code><xsl:value-of select="$localname"/></code> and a Namespace URI of
			<code>http://purl.org/rss/1.0/</code>.</p>
			<p>This document has a <code><xsl:value-of select="name()"/></code>
			element which violates this rule.</p>
	</xsl:template>
	<xsl:template name="tooManyElements">
		<xsl:param name="localname"/>
		<xsl:param name="count"/>
		<head>
			<title>Too Many <xsl:value-of select="$localname"/>
		Elements</title>
			<link rel="stylesheet" href="rssvalid.css" />
		</head>
		<body>
			<h1>Too Many <xsl:value-of select="$localname"/>
		Elements</h1>
			<p>The <code><xsl:value-of select="name()"/></code>
			must have <em>one</em> child with
			a local name of <code><xsl:value-of select="$localname"/></code> and a Namespace URI of
			<code>http://purl.org/rss/1.0/</code>.</p>
			<p>This document has a <xsl:value-of select="$count"/> such elements.</p>
			<p>Cannot process further.</p>
		</body>
	</xsl:template>
	<xsl:template name="tooManyElementsNonFatal">
		<xsl:param name="localname"/>
		<xsl:param name="count"/>
			<h3>Too Many <xsl:value-of select="$localname"/>
		Elements</h3>
			<p>A <code><xsl:value-of select="name()"/></code> element
			that is a child of a <xsl:value-of select="name(..)"/>
			must have <em>one</em> child with
			a local name of <code><xsl:value-of select="$localname"/></code> and a Namespace URI of
			<code>http://purl.org/rss/1.0/</code>.</p>
			<p>This document has such a <code><xsl:value-of select="name()"/></code>
			with <xsl:value-of select="$count"/> such children.</p>
	</xsl:template>
	<xsl:template name="tooManyOptElements">
		<xsl:param name="localname"/>
		<xsl:param name="count"/>
		<head>
			<title>Too Many <xsl:value-of select="$localname"/>
		Elements</title>
			<link rel="stylesheet" href="rssvalid.css" />
		</head>
		<body>
			<h1>Too Many <xsl:value-of select="$localname"/>
		Elements</h1>
			<p>The <code><xsl:value-of select="name()"/></code>
			must have <em>zero or one</em> children with
			a local name of <code><xsl:value-of select="$localname"/></code> and a Namespace URI of
			<code>http://purl.org/rss/1.0/</code>.</p>
			<p>This document has a <xsl:value-of select="$count"/> such elements.</p>
			<p>Cannot process further.</p>
		</body>
	</xsl:template>
	<xsl:template match="rss:channel" mode="render">
		<div class="rss">
			<h3>
				<xsl:apply-templates select="rss:image" mode="render"/>
				<a href="{rss:link}"><xsl:value-of select="rss:title"/></a>
			</h3>
			<p>
				<xsl:value-of select="rss:description"/>
			</p>
			<xsl:apply-templates select="rss:items/rdf:Seq/rdf:li" mode="render"/>
		</div>
	</xsl:template>
	<xsl:template match="rss:channel/rss:image" mode="render">
		<xsl:apply-templates select="/rdf:RDF/rss:image[@rdf:about=current()/@rdf:resource]" mode="render"/>
	</xsl:template>
	<xsl:template match="rdf:RDF/rss:image" mode="render">
		<a href="{rss:link}">
		<img src="{rss:url}" alt="{rss:title}"/>
		</a>
	</xsl:template>
	<xsl:template match="rdf:li" mode="render">
		<xsl:apply-templates select="/rdf:RDF/rss:item[@rdf:about=current()/@rdf:resource or @rdf:about=current()/@resource]" mode="render"/>
	</xsl:template>
	<xsl:template match="rss:item" mode="render">
		<h4>
			<a href="{rss:link}"><xsl:value-of select="rss:title"/></a>
		</h4>
		<xsl:if test="rss:description">
			<p>
				<xsl:value-of select="rss:description"/>
			</p>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>
