Project

Profile

Help

Feature #2886

closed

Converting JS Objects to XDM maps

Added by Debbie Lockett over 8 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Low
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
2016-08-18
Due date:
% Done:

100%

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

Description

[Mike email 24/07/2016]

JS-to-XDM conversion shouldn't construct a HashTrie as the conversion of a JS object; rather it should wrap the JS object as a JSValue, and a JSValue should behave like a map. To make a JSValue behave like a map, it needs to implement the same methods as HashTrie, at least for read access:

containsKey - true if the object contains the given key

get - if the object contains the given key, return the result of doing JS-to-XDM conversion on the corresponding value

inSituPut - throw error

put - throw error

remove - throw error

keys - return all the keys as XDMString objects

forAllPairs - a composite of keys() and get()

conforms - roughly the same logic as HashTrie.conforms()

and

SaxonJS.U.isMap(item) should return true if item is a JSValue.

With this, we don't have the conflict between JS objects (like Style) that are converted to maps, and others (like Window) that are wrapped as a JSValue.

Actions #1

Updated by Debbie Lockett about 8 years ago

  • Status changed from New to In Progress

The methods have been added to JSValue as suggested, so that it behaves like a map.

Corresponding changes made to the convertFromJS and convertParamFromJS methods in Expr.js. The changes to convertParamFromJS in fact mean that the value of a stylesheetParam can now also be a map (as long as the type was not declared at least! so still be work to be done here...)

Some unit tests have been written which test these conversions (e.g. when supplying stylesheetParams, and using global functions); but still also need to write more which use the interactive functions/instructions ixsl:get, ixsl:call, ixsl:style, etc.

Actions #2

Updated by Debbie Lockett almost 8 years ago

  • Status changed from In Progress to Resolved

Marking this as resolved, as JS unit test coverage is much improved, and many of these demonstrate the conversion to JSValues (e.g. tests of interactive functions/instructions).

Relatedly, but on a bit of a tangent to the original Feature issue, the use of stylesheet parameters has also been sorted out:

Stylesheet parameters of declared type map() and array() can now be supplied using the stylesheetParams option on SaxonJS.transform (fix committed on the 9.7 and 9.8 dev branches - so allowed from 9.7.0.14).

Stylesheet parameters with no declared type, or declared type item(), are converted to the 'assumed' type using Expr.convertToJS.

Various JS unit tests added.

Actions #3

Updated by Debbie Lockett almost 8 years ago

  • Status changed from Resolved to Closed
  • Fixed in version set to 0.9.1

Bug fix applied in the Saxon-JS 0.9.1 beta release.

Actions #4

Updated by Community Admin over 7 years ago

  • % Done changed from 0 to 100
  • Fixed in JS Release set to Saxon-JS 0.9.1
  • Applies to JS Branch 0.9 added
  • Fix Committed on JS Branch 0.9 added

Please register to edit this issue

Also available in: Atom PDF Tracking page