在xforms中连接多个元素

时间:2011-03-17 12:11:39

标签: xpath xforms orbeon

我有以下数据实例。

<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
xmlns:exforms="http://www.exforms.org/exf/1-0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xhtml:head>
    <xforms:instance id="instanceData">
        <form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
            xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <fruits>
                <fruit>
                    <fruit-name>Mango</fruit-name>
                </fruit>
                <fruit>
                    <fruit-name>Apple</fruit-name>
                </fruit>
                <fruit>
                    <fruit-name>Banana</fruit-name>
                </fruit>
            </fruits>
            <all-fruits></all-fruits>
        </form>
    </xforms:instance>
</xhtml:head>
</xhtml:html>

我想在 all-fruits 标签中包含所有水果名称,如下所示

<all-fruits>Mango Apple Banana</all-fruits>

请建议一些实现相同的方法。当尝试使用xxforms时,它对我不起作用:iterate and concat。

1 个答案:

答案 0 :(得分:2)

以下是诀窍:

<xforms:bind nodeset="all-fruits"
             calculate="string-join(../fruits/fruit/fruit-name, ' ')"/>

以下是完整的来源,因此您可以运行它:

<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
            xmlns:exforms="http://www.exforms.org/exf/1-0"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:xforms="http://www.w3.org/2002/xforms">
    <xhtml:head>
        <xforms:model>
            <xforms:instance id="instanceData">
                <form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                      xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                    <fruits>
                        <fruit>
                            <fruit-name>Mango</fruit-name>
                        </fruit>
                        <fruit>
                            <fruit-name>Apple</fruit-name>
                        </fruit>
                        <fruit>
                            <fruit-name>Banana</fruit-name>
                        </fruit>
                    </fruits>
                    <all-fruits></all-fruits>
                </form>
            </xforms:instance>
            <xforms:bind nodeset="all-fruits" calculate="string-join(../fruits/fruit/fruit-name, ' ')"/>
        </xforms:model>
    </xhtml:head>
    <xhtml:body/>
</xhtml:html>
相关问题