Bug #4818
closedfn:sort with three arguments gives error TypeError: d.compareTo is not a function
100%
Description
I have run into an issue with fn:sort
and Saxon-JS 2, when I use <xsl:sequence select="sort(date, (), function($d) { $d })"/>
I get an error TypeError: d.compareTo is not a function
. Tested with Saxon-JS 2.0 from Saxonica Node.js version v12.18.0.
Sample:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="3.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="#all"
expand-text="yes">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="root">
<xsl:copy>
<xsl:sequence select="sort(date, (), function($d) { $d })"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/" name="xsl:initial-template">
<xsl:next-match/>
<xsl:comment xmlns:saxon="http://saxon.sf.net/">Run with {system-property('xsl:product-name')} {system-property('xsl:product-version')} {system-property('Q{http://saxon.sf.net/}platform')}</xsl:comment>
</xsl:template>
</xsl:stylesheet>
Input sample:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<date>2020-11-03+02:00</date>
<date>2020-11-01+02:00</date>
<date>2020-11-02+02:00</date>
<date>2020-11-05+02:00</date>
<date>2020-11-04+02:00</date>
<date>2020-11-06+02:00</date>
</root>
The above is a reduced sample and using the straightforward one argument sort(date)
works but in the original sample I needed the three argument form e.g. sort(foo, (), function($f) { $f/bar })
and got the same error.
Please register to edit this issue
Also available in: Atom PDF Tracking page