Thangamani J
Thangamani J

Reputation: 1

How to apply xforms:repeat in two parallel columns

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

Grape Strawberry

AND

Mango Orange

Apple Grape

Banana Strawberry

Upvotes: 0

Views: 200

Answers (1)

avernet
avernet

Reputation: 31763

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

Upvotes: 2

Related Questions