Bug #4607
closedTransformation failure from XX-compiled SEF for Saxon-Forms
100%
Description
Using an XX-compiled SEF of saxon-xforms.xsl, generated with Saxon-JS 2.0 on Node.js, fails at run time. E.g. in sample1.html from https://github.com/Saxonica/Saxon-Forms
Transformation failure: Error SENR0001 at saxon-xforms.xsl#1025
Cannot add a map to an XDM node tree
An SEF generated with Saxon-EE 10 seems to work OK.
Files
Updated by Debbie Lockett over 4 years ago
- Status changed from New to In Progress
This may not actually be a bug in the XX compiler at all. After some searching, I have pinned down the issue to being a stray xsl:map-entry
instruction in the saxon-xforms.xsl stylesheet (at line 2803). When the instruction is removed, an XX-compiled SEF seems to work correctly without errors at runtime.
So there is a question as to why (or how) the XJ compiler and XX compiler handle compilation of this instruction differently, and what the correct behaviour really is, but actually it comes from a coding mistake. See the <xsl:map-entry key="$instance-key" select="$instance-with-explicit-namespaces"/>
instruction in the code below. Generally the purpose of the template is to do some side-effect actions (js function calls), rather than write to the current result tree. For some reason it seems the XX compiled version does try to write a map to the current result tree, but the XJ compiled version doesn't.
<xsl:template name="xforms-model-construct">
<xsl:param name="model" as="element(xforms:model)" required="yes" tunnel="yes"/>
<xsl:variable name="model-key" as="xs:string" select="if (exists($model/@id)) then xs:string($model/@id) else $global-default-model-id"/>
<xsl:variable name="instances" as="element(xforms:instance)*" select="$model/xforms:instance"/>
<xsl:for-each select="$instances">
<xsl:variable name="instance-with-explicit-namespaces" as="element()">
<xsl:apply-templates select="./*" mode="namespace-fix"/>
</xsl:variable>
<xsl:variable name="instance-key" as="xs:string" select="if (exists(@id)) then xs:string(@id) else $global-default-instance-id"/>
<xsl:map-entry key="$instance-key" select="$instance-with-explicit-namespaces"/>
<xsl:sequence select="js:setInstance($instance-key,$instance-with-explicit-namespaces)"/>
<xsl:if test="position() = 1">
<xsl:sequence select="js:setDefaultInstance($instance-with-explicit-namespaces)"/>
</xsl:if>
</xsl:for-each>
<xsl:call-template name="xforms-rebuild">
<xsl:with-param name="get-bindings" as="xs:boolean" select="true()"/>
<xsl:with-param name="model-key" as="xs:string" select="$model-key" tunnel="yes"/>
</xsl:call-template>
<xsl:call-template name="xforms-recalculate"/>
</xsl:template>
Updated by Debbie Lockett over 4 years ago
- File bug4607.html bug4607.html added
- File bug4607.xsl bug4607.xsl added
- File bug4607XX.sef.json bug4607XX.sef.json added
- File bug4607.sef.json bug4607.sef.json added
See attached reduced repro for the issue. The problem seems to be that when the output method is xml, xhtml, html, or text, the XX compiler automatically adds the build-tree="tree"
property to this output definition, which the XJ compiler does not. The run-time error then occurs with the XX SEF when a map is added to the principal result tree.
Updated by Debbie Lockett over 4 years ago
- Status changed from In Progress to Resolved
- Fix Committed on JS Branch 2.0 added
Patch committed (in Saxon-JS 2 branch) in XX compiler (in static-normalize/normalize.xsl) to remove unconditional addition of build-tree attribute to output definition (when output method is xml, xhtml, html, or text). I can't see any regression caused by this change (XSLT3 and QT3 tests suites have been run).
Tests added to JS2 unit tests on dev branch: bugs/bug4607_01 should not throw error for map in unused principal result tree; bug4607_02 should throw error when principal result tree (with map) is appended to page (with "destination":"appendToPage"
in SaxonJS.transform
call).
Updated by Community Admin almost 4 years ago
- Applies to JS Branch 2 added
- Applies to JS Branch deleted (
2.0)
Updated by Community Admin almost 4 years ago
- Fix Committed on JS Branch 2 added
- Fix Committed on JS Branch deleted (
2.0)
Updated by Debbie Lockett almost 4 years ago
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in JS Release set to Saxon-JS 2.1
Bug fix applied in the Saxon-JS 2.1 maintenance release.
Please register to edit this issue
Also available in: Atom PDF Tracking page