如何从另一个实例设置实例的值?

How can I set the value of instance from 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>

应该用什么代替问号,以便我可以从另一个实例中获取类型?

或者我应该使用 xf:setvaluexforms-model-construct-done 事件上设置实例吗?但这不就是模型本身的构造吗?我对如何使用另一个实例的值感到困惑。

我们可以使用 xf:insert 吗?

<xf:action ev:event="xforms-model-construct">
          <xf:insert nodeset="instance('subInstance')" origin="instance('defaultType')/type"/>
      </xf:action>

这是行不通的。事件是否正确?由于实例创建是模型构建的一部分,所以我想到了使用 'xforms-model-construct'。但仍然没有运气!!

是的。 xf:insert 确实有效。事件 'xforms-model-construct' 没有被发送,这就是我觉得它不起作用的原因。当我将事件更改为 'xforms-model-construct-done' 时,它起作用了。

<xf:action ev:event="xforms-model-construct">
    <xf:insert nodeset="instance('subInstance')" origin="instance('defaultType')/type"/>
</xf:action>