Bug #6234
closedmap call with sequence of more than one item as argument doesn't give an error
100%
Description
In a test I tried to call an XPath 3.1 map as a function, passing in a sequence of two items as the argument; SaxonJ gives an error but SaxonJS happily runs the code e.g.
<?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:param name="id-map" select="map { 1 : 2, 2 : (), 3 : 2, 4 : 3 }"/>
<xsl:template match="/" name="xsl:initial-template">
<test>{$id-map((3, 4))}</test>
<xsl:comment>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>
when run with xslt3 -it -xsl:test1.xsl
outputs
<?xml version="1.0" encoding="UTF-8"?><test>2</test><!--Run with SaxonJS 2.6 Node.js-->
As https://www.w3.org/TR/xpath-31/#id-maps defines calling a map as doing map:get
with the signature (https://www.w3.org/TR/xpath-functions-31/#func-map-get) map:get($map as map(*), $key as xs:anyAtomicType) as item()*
the code should give an error "XPTY0004 A sequence of more than one item is not allowed as the first argument of map".
Interestingly enough, for a direct call map:get($id-map, (3, 4))
SaxonJS gives the error "Required cardinality of second argument of map:get() is exactly one; supplied value contains 2 items (xs:integer('3'), xs:integer('4'))".
Please register to edit this issue
Also available in: Atom PDF Tracking page