开发者

How to apply xforms:repeat in two parallel columns

开发者 https://www.devze.com 2023-02-25 06:14 出处:网络
I have n number of records in form data instance. i would like to iterate them and show it in 2 columns using xforms technology.

I have n number of records in form data instance. i would like to iterate them and show it in 2 columns using xforms technology.

Consider i have following data instances:

<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>
                <fruit>
                    <fruit-name>Orange</fruit-name>
                </fruit>
                <fruit>
                    <fruit-name>Grape</fruit-name>
                </fruit>
                <fruit>
                    <fruit-name>Strawberry</fruit-name>
                </fruit>
            </fruits>
        </form>
    </xforms:instance>

i would like to show them in either of the following ways in the screen

Mango Apple

Banana Orange

Gr开发者_运维知识库ape Strawberry

AND

Mango Orange

Apple Grape

Banana Strawberry


This will do the trick:

<xhtml:table>
    <xforms:repeat nodeset="fruits/fruit[position() mod 2 = 1]">
        <xhtml:tr>
            <xhtml:td><xforms:output value="fruit-name"/></xhtml:td>
            <xhtml:td><xforms:output value="following-sibling::fruit/fruit-name"/></xhtml:td>
        </xhtml:tr>
    </xforms:repeat>
</xhtml:table>

Full source

0

精彩评论

暂无评论...
验证码 换一张
取 消