<?xml version='1.0' encoding='utf-8' ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:output method="html" indent="yes"/>
	<xsl:template name="Min">
	
		<!--This template will recursively -->
		<!--determine the minimum value in a nodeset -->
		
		
		<xsl:param name="list" />
		<xsl:param name="nMin" select="'0'"/>

		<xsl:choose>
			<xsl:when test="$list">

				<!-- Store the remaining list into a variable for subsequent -->
				<!-- recursive calls to this template 				       -->	
				<xsl:variable name="remainingList" select="$list[position() != 1]" />

				<!-- Calculate the new minimum value.  The value is set to   -->
				<!-- the currently passed in value, or the value in the node -->
				<!-- set, whichever is lower        				       -->	
				<xsl:variable name="nNewMin">
					<xsl:choose>
						<xsl:when test="$list[1] &lt; $nMin">
							<xsl:value-of select="$list[1]"	/>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="$nMin"	/>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:variable>

				<!-- Recursively call the current template with the newly 	 -->
				<!-- calculated minimum value								 -->
				<xsl:call-template name="Min">
					<xsl:with-param name="list" select="$remainingList"/>
					<xsl:with-param name="nMin" select="$nNewMin"/>
				</xsl:call-template>

		</xsl:when>

		<xsl:otherwise>
			<!-- If you have hit this section in the template, it indicates -->
			<!-- that no more elements need to be processed and that we	   -->
			<!-- return the minimum value instead of making any further     -->
			<!-- recursive calls 													   -->
			<xsl:value-of select="$nMin" />
		
		</xsl:otherwise>		
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>
