Saxonica/Saxon-Forms

Cannot insert attributes to existing node

Opened this issue · 1 comments

Per XForms 1.1, I should be able to copy attributes into tags defined in the xf:model. However, when attempting this, I get the following error:

message: "Cannot write attribute (Q{}optional=true) after writing child nodes (level=3, start tag = demo:ingredient)...name: "XError", code: "XTDE0410", xsltLineNr: "2105", xsltModule: "file:/C:/Users/John/Documents/GitHub/Saxon-Forms/src/saxon-xforms.xsl" }

The trigger is defined as:

<xf:trigger>
	<xf:label>Make ingredient optional</xf:label>
	<xf:action ev:event="DOMActivate">
		<xf:insert context="." nodeset="demo:ingredients/demo:ingredient" origin="instance('i-optional')/@optional"/>
		<xf:setfocus control="edit-ingredient-repeat-input"/>
	</xf:action>
</xf:trigger>

Where i-optional is defined as

<xf:instance id="i-optional">
	<demo:ingredient optional="true"/>
</xf:instance>

See also https://gist.github.com/JDziurlaj/437ef86eaac38f4dc83c6bdef49d829e
Running SaxonJS 2.5

As a workaround I can get this to function if I specify position="child" for xf:insert which seems to avoid the problematic copy-of in the XSLT.