XForms - 将子节点从一个实例复制到另一个实例

XForms - copy child nodes from one instance to another

我的问题是我的主实例中有这样一个部分:

 <DocumentBody>
    :     :    :
    <SectionToBeUpdated />
    :     :    :
 </DocumentBody>

还有一个更新的 "SectionToBeUpdated" 在不同的实例中:

   <SectionToBeUpdated>
       <Section />
       <Section />
       <Section />
   </SectionToBeUpdated>

我需要的行为是删除主实例中 SectionToBeUpdated 的所有子元素,并替换为另一个实例中 SectionToBeUpdated 的子元素。

每次尝试时,我都会将整个 SectionToBeUpdated 部分嵌套在主实例中现有的 SectionToBeUpdated 部分中。

我希望这是可以理解的? TIA

假设您的主实例 ID 是 main-instance,而您的另一个以 <SectionToBeUpdated> 作为根元素的实例是 section-template,应该执行以下操作:

<xf:delete
    ref="instance('main-instance')/SectionToBeUpdated/*"/>
<xf:insert
    context="instance('main-instance')/SectionToBeUpdated"
    origin="instance('section-template')/SectionToBeUpdated/*"/>