Project

Profile

Help

Bug #6234

closed

map call with sequence of more than one item as argument doesn't give an error

Added by Martin Honnen about 1 year ago. Updated about 2 months ago.

Status:
Closed
Priority:
Normal
Category:
XPath Conformance
Sprint/Milestone:
Start date:
2023-10-28
Due date:
% Done:

100%

Estimated time:
Applies to JS Branch:
2, Trunk
Fix Committed on JS Branch:
2, Trunk
Fixed in JS Release:
SEF Generated with:
Platforms:
Company:
-
Contact person:
-
Additional contact persons:
-

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'))".

Actions #1

Updated by Michael Kay about 1 year ago

As this suggests a gap in test coverage, I've created a new test set map-call that adapts all the map:get() tests in QT3 to call the map as a function.

Actions #2

Updated by Debbie Lockett 7 months ago

  • Status changed from New to Resolved
  • Assignee set to Debbie Lockett
  • Applies to JS Branch Trunk added
  • Fix Committed on JS Branch 2, Trunk added

Fix in applyFn runtime implementation (in CoreFn.js), to check that supplied argument is a single item for a dynamic function call to map or array. Committed on saxonjs2 and main branches.

Actions #3

Updated by Debbie Lockett about 2 months ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in JS Release set to SaxonJS 2.7

Bug fix applied in the SaxonJS 2.7 maintenance release.

Please register to edit this issue

Also available in: Atom PDF Tracking page