4

I would like to populate with the content of my XML File a XForm repeat section. First of all, I need to create rows based on the following records of the XML file:

<Entity code="a" type="AdditionalServices" active="true" sortOrder="1">
                <Description language="de">a</Description>
                <Description language="en">a</Description>
            </Entity>
<Entity code="b" type="AdditionalServices" active="true" sortOrder="2">
                <Description language="de">b</Description>
                <Description language="en">b</Description>
            </Entity>
<Entity code="c" type="AdditionalServices" active="true" sortOrder="3">
                <Description language="de">c</Description>
                <Description language="en">c</Description>
            </Entity>
<Entity code="d" type="AdditionalServices" active="true" sortOrder="4">
                <Description language="de">d</Description>
                <Description language="en">d</Description>
            </Entity>
<Entity code="e" type="AdditionalServices" active="true" sortOrder="5">
                <Description language="de">e</Description>
                <Description language="en">e</Description>
            </Entity>
<Entity code="f" type="AdditionalServices" active="true" sortOrder="6">
                <Description language="de">f</Description>
                <Description language="en">f</Description>
            </Entity>

I can do it with the following:

<fr:grid>
    <xh:table >
        <xh:thead>
        <xh:tr>
            <xh:th>Code</xh:th>
        </xh:tr>
        </xh:thead>
        <xh:tbody >
            <xf:repeat ref="instance('fr-form-instance')//Entity[@type='AdditionalServices']" appearance="full">
                <xh:tr>
                    <xh:td>
                        <xf:input ref="@code"></xf:input>   
                    </xh:td>
            </xf:repeat>
        </xh:tbody>
    </xh:table>
</fr:grid>

And then show the quantity that is stored in the following XML Section:

<CalcAdditionalServices>
    <AdditionalServicesCode>d</AdditionalServicesCode>
    <Quantity>1</Quantity>
</CalcAdditionalServices>
<CalcAdditionalServices>
    <AdditionalServicesCode>e</AdditionalServicesCode>
    <Quantity>2</Quantity>
</CalcAdditionalServices>

My code is the following:

<xh:td>
<xf:input ref="instance('fr-form-instance')//CalcAdditionalServices[AdditionalServicesCode/text()=current()/@code]//Quantity"></xf:input>
</xh:td>

I get only the first quantity:

Code   Qty
a      
b
c
d      1
e
f

I don't have that much experience with XForms, so it would be great if someone can give me a tip.

ebruchez
  • 7,760
  • 6
  • 29
  • 41
klgr
  • 191
  • 1
  • 1
  • 12

1 Answers1

0

The System didn't create the second node.

<CalcAdditionalServices>
    <AdditionalServicesCode>e</AdditionalServicesCode>
    <Quantity>2</Quantity>
</CalcAdditionalServices>

We changed our replace method and everything looks fine now.

klgr
  • 191
  • 1
  • 1
  • 12