I tried using saxon:lowest using an inline function and got an error when using Saxon EE 9.3.0.5

The following code:
<xsl:variable name="tree" as="element()*">
            <branch height="1" score="4"/>
            <branch height="2" score="5"/>
        </xsl:variable>
       
        <xsl:copy-of select="saxon:lowest($tree, function($x){$x/@score})"/>

returns the following error:
Severity: fatal
Description: Result of function supplied as second argument to lowest must be an atomic value


When using saxon:sort instead of saxon:lowest I get this error instead:
Description: Non-comparable types found while sorting: net.sf.saxon.tree.tiny.TinyAttributeImpl cannot be cast to net.sf.saxon.value.AtomicValue

I have also tried using a temporary tree instead of a sequence of nodes [using $tree/branch instead]. The same errors arise.

P.S. There is a stray quote mark on the documentation page for saxon:lowest.  In the last paragraph the following example is given:

saxon:lowest(sale, function($x){$x/@price * $x/@qty'})

I believe the quote after @qty is extraneous.





--

"A false conclusion, once arrived at and widely accepted is not dislodged easily, and the less it is understood, the more tenaciously it is held." - Cantor's Law of Preservation of Ignorance.