This XSLT 1.0 solution uses recursive templates to parse a delimited list of values to return the min/max value from the list.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:variable name="a" select="'3'"/>
<xsl:variable name="b" select="'1'"/>
<xsl:variable name="c" select="'9'"/>
<xsl:variable name="d" select="'5'"/>
<xsl:template match="/">
<xsl:text>
Smallest: </xsl:text>
<xsl:call-template name="min">
<xsl:with-param name="values" select="concat($a,',',$b,',',$c,',',$d)"/>
</xsl:call-template>
<xsl:text>
Largest: </xsl:text>
<xsl:call-template name="max">
<xsl:with-param name="values" select="concat($a,',',$b,',',$c,',',$d)"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="min">
<xsl:param name="values" />
<xsl:param name="delimiter" select="','"/>
<xsl:param name="min"/>
<xsl:variable name="currentValue" >
<xsl:choose>
<xsl:when test="contains($values, $delimiter)">
<xsl:value-of select="substring-before($values,$delimiter)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$values"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="minimumValue">
<xsl:choose>
<xsl:when test="$min and $min > $currentValue">
<xsl:value-of select="$currentValue"/>
</xsl:when>
<xsl:when test="$min">
<xsl:value-of select="$min"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$currentValue" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="substring-after($values,$delimiter)">
<xsl:call-template name="min">
<xsl:with-param name="min" select="$minimumValue" />
<xsl:with-param name="values" select="substring-after($values,$delimiter)" />
<xsl:with-param name="delimiter" select="$delimiter"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$minimumValue" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="max">
<xsl:param name="values" />
<xsl:param name="delimiter" select="','"/>
<xsl:param name="max"/>
<xsl:variable name="currentValue" >
<xsl:choose>
<xsl:when test="contains($values, $delimiter)">
<xsl:value-of select="substring-before($values,$delimiter)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$values"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="maximumValue">
<xsl:choose>
<xsl:when test="$max and $currentValue > $max">
<xsl:value-of select="$currentValue"/>
</xsl:when>
<xsl:when test="$max">
<xsl:value-of select="$max"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$currentValue" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="substring-after($values,$delimiter)">
<xsl:call-template name="max">
<xsl:with-param name="max" select="$maximumValue" />
<xsl:with-param name="values" select="substring-after($values,$delimiter)" />
<xsl:with-param name="delimiter" select="$delimiter"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$maximumValue" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
When executed, produces the following output:
Smallest: 1
Largest: 9
select
must evaluate to a node-set. (w3.org/TR/xslt#for-each) – Splotch