【问题标题】:concat of multiple elements in xformsxforms中多个元素的连接
【发布时间】:2011-03-17 12:11:39
【问题描述】:

我有以下数据实例。

<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 和 concat 时,它对我不起作用。

【问题讨论】:

    标签: xpath xforms orbeon


    【解决方案1】:

    以下方法可以解决问题:

    <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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-30
      • 1970-01-01
      • 2013-09-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多