In 2.0:
max(for $x in Test return count($x/Set))
In 1.0:
<xsl:variable name="max">
<xsl:for-each select="Test">
<xsl:sort select="count(Set)" data-type="number"/>
<xsl:if test="position()=last()">
<xsl:value-of select="count(Set)"/>
In both cases this assumes the parent of the Test elements is the context node.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference