Bug #5031
closedixsl:set-property: ... not found for supplied object
100%
Description
This might not be a bug, just me not understanding the error message.
I have the following code which usually works fine:
<xsl:message>AAAA $content-uri: <xsl:value-of select="$content-uri"/> empty(LDH): <xsl:value-of select="empty(ixsl:get(ixsl:window(), 'LinkedDataHub'))"/> empty(ac:new-object()): <xsl:value-of select="empty(ac:new-object())"/></xsl:message>
<ixsl:set-property name="{$content-uri}" select="ac:new-object()" object="ixsl:get(ixsl:window(), 'LinkedDataHub')"/>
<!-- store this content element -->
<xsl:message>BBBB</xsl:message>
<ixsl:set-property name="content" select="." object="ixsl:get(ixsl:get(ixsl:window(), 'LinkedDataHub'), $content-uri)"/>
<!-- store the initial SELECT query (without modifiers) -->
<xsl:message>CCCC</xsl:message>
However under some conditions I get this kind of error and I don't get why (includes the debug output):
xsl:message: AAAA $content-uri: https://noi.example.org/queries/default/select-children/#this empty(LDH): false empty(ac:new-object()): false
Warning ixsl:set-property: 'https://noi.example.org/queries/default/select-children/#this' not found for supplied object
xsl:message: BBBB
Warning ixsl:get: object property 'https://noi.example.org/queries/default/select-children/#this' not found
Uncaught J {message: "Required cardinality of value in 'ixsl:set-propert…xpression is exactly one; supplied value is empty", stack: "Error\n at new J (https://noi.example.org/static…linkeddatahub/js/saxon-js/SaxonJS2.rt.js:819:457)", name: "XError", code: "XPTY0004", xsltLineNr: "583", …}
What am I missing here? What does the warning even mean?
Updated by Martynas Jusevicius over 3 years ago
I understand the second <ixsl:set-property>
fails if the first one did. But why would the first one fail?
Updated by Martynas Jusevicius over 3 years ago
Looking at the <ixsl:set-property>
documentation, what does this text even mean?
If the specified property does not exist, then there is no error, but a warning is output in the console log.
How does one set the property value for the first time then?
Updated by Martynas Jusevicius over 3 years ago
Martin Honnen probably solved this:
My guess is that your argument of the property name, which is
https://noi.example.org/queries/default/select-geo-resources/#this
"causes" the problem as the potential argument can be a JavaScript "dot" expression e.g.foo.bar.baz
and the Saxon library tries to split up that expression by usingsplit(".")
. In your case the dots are not meant as Javascript "path step" seperators to be split up into e.g.foo
bar
andbaz
but are to be taken literally as the name of a single property you want to create. Not sure what is the right way around that, perhaps theixsl:set-property
needs an additional attribute to indicate whether your property name is meant to be used literally or as a dot separated path.
I still need to test this, but this checks out as I had no problems when using localhost
instead of noi.example.org
.
Any suggested workarounds? URL-encoding the property name does not encode the dots.
Updated by Debbie Lockett over 3 years ago
- Category set to IXSL extensions
- Status changed from New to In Progress
- Assignee set to Debbie Lockett
Again, Martin is correct that the problem arises from your use of dot characters in the property names. Effectively Saxon-JS does not allow property names to include dot characters (instead these are used as separators for nested properties), though this is not explicitly stated. The rules for JavaScript property names are complicated because bracket notation actually allows property names to contain characters (e.g. the dot character) that are forbidden in dot notation. We should clarify what Saxon-JS permits in the documentation.
Also, as noted in #note-2, the documentation for ixsl:set-property
needs to be tidied up (the sentence about warnings for unknown properties is indeed wrong).
As suggested on xml.com on Slack, the best work around is to replace the use of dots in the property names.
Updated by Debbie Lockett over 3 years ago
- Status changed from In Progress to Resolved
- Fix Committed on JS Branch 2 added
I have committed documentation updates to add some warnings that you can't use ixsl:get()
and ixsl:set-property
to get and set properties with names which contain dot characters. At this stage we are rejecting the suggestion to add a new attribute to indicate whether the property name is meant to be used literally or as a dot separated path. It is fairly straightforward to work around this: either avoid property names with dot characters; or write your own JavaScript global function to set these (https://www.saxonica.com/saxon-js/documentation/index.html#!development/global).
(See also bug #5046 for other documentation improvements for ixsl:set-property
; including the issue raised in #note-2.)
Updated by Debbie Lockett over 3 years ago
- % Done changed from 0 to 100
- Fixed in JS Release set to Saxon-JS 2.3
Bug fix applied in the Saxon-JS 2.3 maintenance release.
Updated by Debbie Lockett over 3 years ago
- Status changed from Resolved to Closed
Updated by Martynas Jusevicius about 2 years ago
Can I get this reopened? :)
How do I set a property which is a QName
with a URL in it? I need to construct the following:
SaxonJS.transform({
"stylesheetParams": { "Q{https://www.w3.org/ns/ldt#}base": baseUri }
});
so I'm doing this:
<xsl:variable name="stylesheet-params" select="ldh:new-object()"/>
<ixsl:set-property name="Q{https://www.w3.org/ns/ldt#}base" select="$ldt:base" object="$stylesheet-params"/>
but of course I get an error:
Encountered null or undefined in path to nested object for ixsl:set-property: 'Q{https://www.w3'
If you will not consider removing special meaning of .
in ixsl:set-property/@name
(I get it's problematic due to backwards compatibility), can we at least get an option where this behavior is disabled? Because in situations like this it's a PITA.
Also welcoming suggestions for a workaround :)
Updated by Norm Tovey-Walsh about 2 years ago
Rather than re-open this old one, can I ask you to please create a new issue for this case?
Please register to edit this issue
Also available in: Atom PDF Tracking page