I would like to populate the contents of my XML file with an XForm replay section. First of all, I need to create strings based on the following entries in 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 this 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 amount 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 as follows:
<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 have no such experience with XForms, so it would be great if someone could give me a hint.
source
share