Should it be possible to access a DOM property of an element node using the syntax "?propertyName" instead of ixsl:get(., 'propertyName')?
Added by Martin Honnen about 7 years ago
The documentation on @ixsl:get@, https://www.saxonica.com/saxon-js/documentation/index.html#!ixsl-extension/functions/get says
Within an XPath expression, JavaScript objects are now treated as XPath maps. So ixsl:get($object, "prop") and $object?prop are interchangeable
What does "JavaScript" object mean in that context, only native JavaScript objects or also DOM/host objects?
I have code like
that works fine but that quoted statement made me believe I could rewrite it as
However, on compilation with Saxon 9.8.0.7 EE I get an error
Static error at char 12 in xsl:sequence/@select on line 16 column 119 of test2017122003.xsl: XPTY0004: Required item type of value of variable $vv:LHS13038103 is function(*); supplied value (.) has item type element(Q{}div)
Is that as intended? Does the quote only refer to pure JavaScript objects created with e.g. @{ foo : 'bar' }@ or @new Object()@?
Replies (1)
RE: Should it be possible to access a DOM property of an element node using the syntax "?propertyName" instead of ixsl:get(., 'propertyName')? - Added by Debbie Lockett about 7 years ago
This is closely related to some of the issues in https://saxonica.plan.io/issues/3545. In particular, we'd realised that that statement about treating JavaScript objects as XDM maps (in the documentation for ixsl:get()) needs clarification... (basically you can do map:get() or lookup, and map:contains() but that's about it).
But yes, the intention is that you should be able to use lookup (map:get()) here. It should work for any JavaScript objects, not only literal objects, so that includes DOM objects. So I think the compile time error in this case is a bug.
Please register to reply