Hi,
I have seen that support for xsl:perform-sort has landed on the Apache
Xalan XSLT 3.0 development branch.
I have tried to write a test case that sorts a sequence of XPath 3.1/XDM
3.1 maps, it works fine with Saxon but gives an error with Xalan:
warning: VariableReference given for variable out of context or without
definition! Name = sorted-map-sequence1; SystemID: file:///sheet.xsl;
Line#: 22; Column#: 52
fatalError: java.lang.NullPointerException; SystemID: file:///sheet.xsl;
Line#: 32; Column#: 15
Test:
<?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"
xmlns:map="http://www.w3.org/2005/xpath-functions/map"
xmlns:array="http://www.w3.org/2005/xpath-functions/array"
exclude-result-prefixes="#all"
expand-text="yes">
<xsl:param name="map-sequence1" as="map(*)*" select="(map { 'name' :
'foo', 'value' : 3 }, map { 'name': 'bar', 'value' : 2 })"/>
<xsl:variable name="sorted-map-sequence1" as="map(*)*">
<xsl:perform-sort select="$map-sequence1">
<xsl:sort select="?value"/>
</xsl:perform-sort>
</xsl:variable>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/*">
<xsl:copy>
<xsl:for-each select="$sorted-map-sequence1">
<item>
<name>{?name}</name>
<value>{?value}</value>
</item>
</xsl:for-each>
</xsl:copy>
</xsl:template>
<xsl:template match="/">
<xsl:copy>
<xsl:apply-templates/>
<xsl:comment>Run with {system-property('xsl:vendor')} at
{current-dateTime()}</xsl:comment>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Result with Saxon is e.g.
<?xml version="1.0" encoding="UTF-8"?>
<root>
<item>
<name>bar</name>
<value>2</value>
</item>
<item>
<name>foo</name>
<value>3</value>
</item>
</root>
<!--Run with Saxonica at 2025-12-17T08:17:26.89Z-->