I have an instance on the page. However, I want the content of this instance to have some content which is part of another instance.
<xf:instance id="subInstance">
<data xmlns="">
<xsl:choose>
<xsl:when test="$newType= 'false' ">
???
<xsl:copy-of select="????"/>
</xsl:when>
<xsl:otherwise>
<!-- add a new type -->
<type>
<name/>
<base/>
</type>
</xsl:otherwise>
</xsl:choose>
</data>
</xf:instance>
What should be in place of the question marks so that I can get the type from another instance ?
Or should I use xf:setvalue
to set the instance on xforms-model-construct-done
event? But isn't this the construction of the model itself ? I'm confused how to use values from another instance.
Can we use xf:insert somehow ?
<xf:action ev:event="xforms-model-construct">
<xf:insert nodeset="instance('subInstance')" origin="instance('defaultType')/type"/>
</xf:action>
This is not working. Is the event correct ? Since instance creation is part of model construction, I thought of using 'xforms-model-construct'. But still no luck !!
yes. The xf:insert does work. The event 'xforms-model-construct' was not being dispatched and that is why I felt it wasn't working. When I changed the event to 'xforms-model-construct-done', it worked.
<xf:action ev:event="xforms-model-construct">
<xf:insert nodeset="instance('subInstance')" origin="instance('defaultType')/type"/>
</xf:action>