Comments? Feedback?

This wiki does not yet support public comments (a limitation of Google Sites), so we encourage you to post your comments either:

On Twitter by responding to @orbeon.

On our community mailing list: subscribe sending an email to ops-users-subscribe@ow2.org (content of subject/body doesn't matter), you'll get a response with the email to use to send your message to the community mailing list.

Recent site activity

How-to guides‎ > ‎XForms View‎ > ‎

Create a summary of errors

The problem

You have an XML document with a number of sub-documents, all with the same structure, say representing employees. Using a repeat, you can show all the employees with their properties, and use an error summary to list all the errors. Instead, you want to show a summary of the errors, that is a list of the employees for which there is at least one error.


When users click on given employee in this list, they are shown controls they can use to edit the information about the employee they clicked on.


The solution

Assume the employees are stored in an instance that looks like:

<xforms:instance id="employees">
    <employees>
        <employee id="1">
            <first-name>Jason</first-name>
            <last-name>Mraz</last-name>
            <expenses>9000</expenses>
        </employee>
        <employee id="2">
            <first-name>Lady</first-name>
            <last-name>Gaga</last-name>
            <expenses>50000</expenses>
        </employee>
        <employee id="3">
            <first-name>Boyoncé</first-name>
            <last-name/>
            <expenses>20000</expenses>
        </employee>
    </employees>
</xforms:instance>

In addition, you have a number of <xforms:bind> to validate the elements inside each <employee>. You can use the xxforms:valid() function to know which <employee> contains invalid nodes. So you can iterate over the employees that contain invalid nodes with:

<xforms:repeat nodeset="employee[not(xxforms:valid(., true()))]">

Inside the repeat, you provide a trigger that sets the currently shown employee id, which you store in another instance. Once you know the id of the employee users wish to edit, you provide a UI to edit that given employee:

<xforms:group ref="employee[@id = instance('ui')/current-employee]">
    <!-- Controls to edit the current employee -->
</xforms:group>

Run it and get the source