2015-11-03 107 views
0

我的問題是,我在我的主實例作爲這樣一個部分:的XForms - 從一個實例複製子節點到另一個

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

而且還更新「SectionToBeUpdated」在不同的情況下這樣:

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

我要求的行爲是在主實例SectionToBeUpdated的所有子元素被移除,並與SectionToBeUpdated在其他情況下的子元素替換。

每次嘗試時,我都會在主實例的現有SectionToBeUpdated節中嵌套整個SectionToBeUpdated節。

我希望這是可以理解的嗎? TIA

回答

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/*"/>