You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Martin Honnen <ma...@gmx.de> on 2025/12/17 08:23:33 UTC
xsl:perform-sort with sequence of XDM maps gives error
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-->
Re: xsl:perform-sort with sequence of XDM maps gives error
Posted by Martin Honnen <ma...@gmx.de>.
Hi Mukul,
On 21/12/2025 13:27, Mukul Gandhi wrote:
> This issue as mentioned by you, has been resolved and Xalan's
> XSLT 3.0 development branch now has the fixes for this.
>
thanks for the fixes.
In general, for the recent improvements, it seems it is time to update
https://xalan.apache.org/xalan-j/xsl3/xalanj_xslt3.0_implementation_status.pdf
to mention stuff like xsl:perform-sort.
Great work, anyway.
Re: xsl:perform-sort with sequence of XDM maps gives error
Posted by Mukul Gandhi <ga...@gmail.com>.
Hi Martin,
This issue as mentioned by you, has been resolved and Xalan's
XSLT 3.0 development branch now has the fixes for this.
On Sat, Dec 20, 2025 at 10:43 PM Martin Honnen <ma...@gmx.de> wrote:
> great work, thanks for the fixes.
>
> I have found another issue, sorting a simple integer sequence doesn't work:
>
> <?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="seq1" as="xs:integer*" select="(3, 1, 2)"/>
>
> <xsl:variable name="sorted-seq1" as="xs:integer*">
> <xsl:perform-sort select="$seq1">
> <xsl:sort select="."/>
> </xsl:perform-sort>
> </xsl:variable>
>
> <xsl:output method="xml" indent="yes"/>
>
> <xsl:template match="/*">
> <xsl:copy>
> <xsl:for-each select="$sorted-seq1">
> <item>{.}</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>
>
>
> Fails with fatalError: java.lang.NumberFormatException; SystemID:
> file:///sheet.xsl; Line#: 29; Column#: 15
--
Regards,
Mukul Gandhi
Re: xsl:perform-sort with sequence of XDM maps gives error
Posted by Martin Honnen <ma...@gmx.de>.
Hi Mukul,
On 20/12/2025 17:40, Mukul Gandhi wrote:
> The mentioned XSL implementation issues, within your original mail
> as cited within mail trail, have been fixed within Xalan's XSLT 3.0
> development branch.
>
> You may try verifying these fixes.
great work, thanks for the fixes.
I have found another issue, sorting a simple integer sequence doesn't work:
<?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="seq1" as="xs:integer*" select="(3, 1, 2)"/>
<xsl:variable name="sorted-seq1" as="xs:integer*">
<xsl:perform-sort select="$seq1">
<xsl:sort select="."/>
</xsl:perform-sort>
</xsl:variable>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/*">
<xsl:copy>
<xsl:for-each select="$sorted-seq1">
<item>{.}</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>
Fails with fatalError: java.lang.NumberFormatException; SystemID:
file:///sheet.xsl; Line#: 29; Column#: 15
Re: xsl:perform-sort with sequence of XDM maps gives error
Posted by Mukul Gandhi <ga...@gmail.com>.
Hi Martin,
The mentioned XSL implementation issues, within your original mail
as cited within mail trail, have been fixed within Xalan's XSLT 3.0
development branch.
You may try verifying these fixes.
On Wed, Dec 17, 2025 at 1:53 PM Martin Honnen <ma...@gmx.de> wrote:
> 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>
--
Regards,
Mukul Gandhi
Re: xsl:perform-sort with sequence of XDM maps gives error
Posted by Mukul Gandhi <ga...@gmail.com>.
Hi Martin,
These Xalan XSLT 3.0 implementation issues have been solved
somewhat, and the code improvements have been committed to Xalan's
xslt 3.0 development branch.
The following XSLT 3.0 stylesheet is working fine now with Xalan-J's
xslt 3.0 development branch,
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:map="http://www.w3.org/2005/xpath-functions/map"
exclude-result-prefixes="map"
expand-text="yes"
version="3.0">
<xsl:output method="xml" indent="yes"/>
<xsl:variable name="map-sequence1" select="(map { 'name' : 'foo',
'value' : 3 },
map { 'name': 'bar',
'value' : 2 })" as="map(*)*"/>
<xsl:template match="/">
<result>
<xsl:variable name="sorted-map-sequence1" as="map(*)*">
<xsl:perform-sort select="$map-sequence1">
<xsl:sort select="map:get(.,'value')"/>
</xsl:perform-sort>
</xsl:variable>
<xsl:for-each select="$sorted-map-sequence1">
<item>
<name>{map:get(.,'name')}</name>
<value>{map:get(.,'value')}</value>
</item>
</xsl:for-each>
</result>
</xsl:template>
</xsl:stylesheet>
An XPath syntax like ?value is yet not supported by Xalan's XSLT 3.0
development branch. We need to use XPath function calls like map:get
as of now.
On Wed, Dec 17, 2025 at 1:53 PM Martin Honnen <ma...@gmx.de> wrote:
> 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-->
>
>
--
Regards,
Mukul Gandhi
Re: xsl:perform-sort with sequence of XDM maps gives error
Posted by Martin Honnen <ma...@gmx.de>.
On 17/12/2025 18:14, Mukul Gandhi wrote:
> Xalan's XSLT 3.0 development branch as of now, has xsl:perform-sort
> instruction's support to sort only XML element nodes and no other
> types of XDM items.
Thanks for the clarification.
>
> We may hope that, we'll have those new XSLT features implemented
> within Xalan in near future.
Sounds good, on paper it sounds like a relatively easy job as you
already have fn:sort support as well as `xsl:sort` on e.g. sequences
processed by other instructions like `xsl:for-each`.
Re: xsl:perform-sort with sequence of XDM maps gives error
Posted by Mukul Gandhi <ga...@gmail.com>.
Hi Martin,
On Wed, Dec 17, 2025 at 1:53 PM Martin Honnen <ma...@gmx.de> wrote:
> 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
Xalan's XSLT 3.0 development branch as of now, has xsl:perform-sort
instruction's support to sort only XML element nodes and no other
types of XDM items.
We may hope that, we'll have those new XSLT features implemented
within Xalan in near future.
--
Regards,
Mukul Gandhi