Nice use case you've shared for XPath and XSLT. I've felt like responding to this.
I've understood the intent of this use case, by reading the following C language program that you've shared on your blog,
bool is_even(unsigned int n) {
if (n == 0)
return true;
else
return is_odd(n - 1);
}
bool is_odd(unsigned int n) {
if (n == 0)
return false;
else
return is_even(n - 1);
}
You wrote that you've solved this use case, with pure XPath 3, using Saxon. Ofcourse, Saxon is expected to be able to solve this for XML technologies, since its grately compliant to XSLT 3.0 and XPath 3.1 specs.
XalanJ currently has an XSLT 3.0 development branch on its codebase repos, where XalanJ team has implemented various XSLT 3.0 and XPath 3.1 language features.
I wrote the following XSLT 3.0 stylesheet to solve this use case (I've translated the C program, that you've cited on your blog and I've reproduced that as mentioned above),
<xsl:stylesheet xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"
version="3.0">
<xsl:output method="xml" indent="yes"/>
<xsl:variable name="isEven" select="function($n) { if ($n eq 0) then true() else $isOdd($n - 1) }"/>
<xsl:variable name="isOdd" select="function($n) { if ($n eq 0) then false() else $isEven($n - 1) }"/>
<xsl:template match="/">
<result>
<one>
<xsl:value-of select="$isEven(255)"/>
</one>
<two>
<xsl:value-of select="$isOdd(255)"/>
</two>
</result>
</xsl:template>
</xsl:stylesheet>
Running the above XSLT 3.0 stylesheet with XalanJ's dev codebase build (and with Saxon HE 12.2 as well), produces following expected XSLT transformation result,
<?xml version="1.0" encoding="UTF-8"?><result>
<one>false</one>
<two>true</two>
</result>