Project

Profile

Help

Bug #5414

closed

Saxon-JS 2.3 doesn't reject xsl:map-entry key="()"

Added by Martin Honnen about 2 months ago. Updated 4 days ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
XX compiler
Sprint/Milestone:
Start date:
2022-03-23
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

Trying to understand what fails in https://saxonica.plan.io/issues/5384 I played around with xsl:map/xsl:map-entry and Saxon-JS 2.3 and found that it doesn't identify an empty sequence as an error if used as the key expression of an xsl:map-entry, for instance, the test case

<?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="map" as="map(xs:string, xs:integer)">
    <xsl:map>
      <xsl:map-entry key="()" select="4"/>
    </xsl:map>
  </xsl:param>
  
  <xsl:template match="/" name="xsl:initial-template">
    <root>test</root>
    <xsl:comment>{serialize($map, map { 'method' : 'json', 'indent' : true() })}</xsl:comment>
    <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>

compiles fine with xslt3:

xslt3 -t -nogo -xsl:empty-sequence-map-key-test1.xsl -export:empty-sequence-map-key-test1.sef.json
Saxon-JS 2.3 from Saxonica
Node.js version v14.16.0
Compiling stylesheet C:\SomePath\saxon-js-xsl-map-empty-key\empty-sequence-map-key-test1.xsl
Stylesheet compilation time: 0.33s
Stylesheet exported to SEF file C:\SomePath\saxon-js-xsl-map-empty-key\empty-sequence-map-key-test1.sef.json

but on running gives the error

<?xml version="1.0" encoding="UTF-8"?><root>test</root>Transformation failure: TypeError: Cannot read property 'hashCode' of null
Cannot read property 'hashCode' of null

It might, be, however, that the changes of https://saxonica.plan.io/issues/5230 fix this problem as well.

Actions #1

Updated by Michael Kay about 2 months ago

  • Status changed from New to In Progress

Added XSLT3 test case maps-909; confirmed that XPTY0004 is reported by SaxonJ.

Actions #2

Updated by Michael Kay about 2 months ago

Confirmed that the current build of SaxonJS throws "Transformation failure: TypeError: Cannot read property 'hashCode' of null" on this test case. (This is running the test as compiled using XX).

Actions #3

Updated by Michael Kay about 2 months ago

  • Category changed from XSLT Conformance to XX compiler
  • Status changed from In Progress to Resolved
  • Applies to JS Branch Trunk added
  • Fix Committed on JS Branch 2, Trunk added

It turned out the patch in comment #7 of bug #5230 wasn't quite strong enough; it added atomisation for xsl:map-entry/@key, but it didn't add a cardinality check. I've now achieved this by replacing the injected <data> instruction with an <atomSing> instruction which does a cardinality check (for a singleton) as well as atomisation.

Actions #4

Updated by Debbie Lockett 4 days ago

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

Bug fix applied in the SaxonJS 2.4 maintenance release.

Please register to edit this issue

Also available in: Atom PDF Tracking page