The error is on this instruction:
<xsl:if test="$currentPage/@level > $minLevel">
Saxon 6.5.5 says:
Error at xsl:if on line 21 of file:/(Untitled): The value is not a node-set
One possible solution is to replace:
<xsl:param name="currentPage"/>
with:
<xsl:param name="currentPage" select="/.."/>
so that now the XSLT processor knows that $currentPage
contains a node.