0
votes

My problems is this:

I have 2 instances in my model:

<xf:instance id="Include-model">
    <data>
        <value type="xs:string">true</value>
    </data>
</xf:instance>

this is wired up to a checkbox, and

<xf:instance id="items-model">
    <items>
        <item>1</item>
        <item>2</item>
        <item>3</item>
</xf:instance>

and I have a bind declared as:

<xforms:bind id="items-bind" nodeset="items[instance('Include-model')/value = 'true']">

the checkbox correctly updates the Include-model, but the bind does not update to reflect this. Basically, if the checkbox is checked I need to display the items, otherwise hide them. The initial state is correct, but changes are not reflected in the bind when I check/uncheck the checkbox.

Eternal gratitude to all who can help.

2

2 Answers

0
votes

You might try

<xforms:bind id="items-bind" nodeset="instance('items-model')" relevant="instance('Include-model')/value = 'true'" />
0
votes

First up, I could see there are multiple issues in the code snippets you give here.

  1. closing tag is missing here. It should look like

        <xforms:instance id="items-model">
            <items>
                <item>1</item>
                <item>2</item>
                <item>3</item>
            </items>
        </xforms:instance>
    
  2. The nodeset in the bind mentioned is for items. It should be for item. Since there is no information given whether it a code pulled from form-builder or "hand-written" code, i cannot say it is correct or not. For a "hand-written" codes the bind defnition in your case will look like this

        <xforms:bind id="items-bind" nodeset="instance('items-model')/item[instance('Include-model')/value = 'true']" />
    

Below is the complete Xforms code you can run for this case. Try running with value as 'true' and again value as 'false' to understand how bind is working.

<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
    xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
    xmlns:xforms="http://www.w3.org/2002/xforms">

    <xhtml:head>
      <xhtml:title>Xforms</xhtml:title>

      <xforms:model>

        <xforms:instance id="Include-model">
            <data>
                <value type="xs:string">true</value>
            </data>
        </xforms:instance>


        <xforms:instance id="items-model">
            <items>
                <item>1</item>
                <item>2</item>
                <item>3</item>
            </items>
        </xforms:instance>

        <xforms:bind id="items-bind" nodeset="instance('items-model')/item[instance('Include-model')/value = 'true']" />


      </xforms:model>

    </xhtml:head>

    <xhtml:body>

        <table>
            <tr>
                <td>Bind items are
                    <xforms:output value="
                        string-join(xxforms:bind('items-bind'), ' -- ')
                        " />
                </td>
            </tr>
        </table>

    </xhtml:body>

</xhtml:html>