如何将重复的节点值复制到Orbeon中的另一个重复节点

时间:2012-07-05 07:01:38

标签: xpath orbeon xforms

我找不到将重复节点值复制到另一个重复节点的好方法。在通用编程语言中,我的意思是说将一个数组的内容复制到另一个数组。

            <xforms:instance id="main-instance">
                <contacts>
                    <contact>
                        <contact-id>111</contact-id>
                        <contact-name></contact-name>
                        <contact-location></contact-location>
                    </contact>
                    <contact>
                        <contact-id>222</contact-id>
                        <contact-name></contact-name>
                        <contact-location></contact-location>
                    </contact>
                    <contact>
                        <contact-id>333</contact-id>
                        <contact-name></contact-name>
                        <contact-location></contact-location>
                    </contact>
                </contacts>

                <alternate-contacts>
                    <contact>
                        <alt-contact-id></alt-contact-id>
                        <control-id></control-id>
                        <control-rules></control-rules>
                        <tranmission-method></tranmission-method>
                    </contact>
                    <contact>
                        <alt-contact-id></alt-contact-id>
                        <control-id></control-id>
                        <control-rules></control-rules>
                        <tranmission-method></tranmission-method>
                    </contact>
                    <contact>
                        <alt-contact-id></alt-contact-id>
                        <control-id></control-id>
                        <control-rules></control-rules>
                        <tranmission-method></tranmission-method>
                    </contact>
                </alternate-contacts>
            </xforms:instance>

选中复选框(开始操作的事件)时,我应将第一个contact-id值复制到第一个alt-contact-id,依此类推。

            <xforms:action ev:event="xforms-value-changed">
                //TO DO here
            </xforms:action>

请提供您的想法

编辑:因此,选中此复选框后,<alternate-contacts>节点应如下所示

                <alternate-contacts>
                    <contact>
                        <alt-contact-id>111</alt-contact-id>
                        <control-id></control-id>
                        <control-rules></control-rules>
                        <tranmission-method></tranmission-method>
                    </contact>
                    <contact>
                        <alt-contact-id>222</alt-contact-id>
                        <control-id></control-id>
                        <control-rules></control-rules>
                        <tranmission-method></tranmission-method>
                    </contact>
                    <contact>
                        <alt-contact-id>333</alt-contact-id>
                        <control-id></control-id>
                        <control-rules></control-rules>
                        <tranmission-method></tranmission-method>
                    </contact>
                </alternate-contacts>

1 个答案:

答案 0 :(得分:2)

您正在寻找XForms 2.0即将推出的iterate attribute 1 ,但已经受到Orbeon Forms的支持,您似乎根据您的标签使用它题。有了它,你可以写:

<xforms:action iterate="/root/contacts/contact">
    <xforms:var name="position" value="position()"/>
    <xforms:var name="id" value="contact-id"/>
    <xforms:setvalue ref="/root/alternate-contacts/contact[$position]/alt-contact-id" value="$id"/>
</xforms:action>

另请使用此代码查看full example


1 此功能已被支持很长时间,您必须使用xxforms:iterate="…"来表示这是一个扩展,但由于这很快将成为标准,您现在可以使用iterate="…"