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

时间:2015-11-03 15:49:56

标签: xml xslt orbeon xforms

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

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

还有一个更新的&#34; SectionToBeUpdated&#34;在另一个例子中:

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

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

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

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

1 个答案:

答案 0 :(得分:1)

假设您的主要实例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/*"/>
相关问题