XForms Constraint

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

XForms Constraint

quinquin2209
Hi,

I have a form where I want to have validation on the node occurrence prior submission. The occurrenance is not set in schema since it is business-specific.

In my PO, I have LineItem with multiple occurrence. Inside LineItem is OtherRef which also has multiple occurrence. E.g.

<PO>
   <LineItem>
      <ID>1</ID>
      <OtherRef>
          <Note>ABC</Note>
      </OtherRef>
      <OtherRef>
          <Note>ABC</Note>
      </OtherRef>
   </LineItem>
</PO>


My validation logic is that: for each line item, there must be at least 2 OtherRef.

I try the following:

<xforms:bind nodeset="LineItem/OtherRef" minOccurs="2"/>

But the form can be submitted without error even if the no. of OtherRef is less than 2.

Any way I can do this validation upon submission?

Queenie
Reply | Threaded
Open this post in threaded view
|

Re: XForms Constraint

fl.schmitt(ops-users)
quinquin2209,

> I try the following:
>
> <xforms:bind nodeset="LineItem/OtherRef" minOccurs="2"/>
>
> But the form can be submitted without error even if the no. of OtherRef is
> less than 2.

i think this happens because minOccurs isn't a valid model item
property. The documentation has some examples regarding mode item
properties:

http://www.orbeon.com/ops/doc/reference-xforms-ng#xforms-mips
http://www.w3.org/TR/xforms11/#model-xformsconstraints

In your case, you could use the "constraint" attribute and use the
count() XPath function to test if there are at least 2 OtherRef elements:

<xforms:bind nodeset="LineItem" contrasint="count(OtherRef) gt 1"/>

HTH
florian


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: XForms Constraint

quinquin2209
Thanks. It works fine for me.

I have a further question. In my form, I will have several constraints added. Is it possible to get different error messages when xforms-submit-error is fired from different constraints-violiation?

Queenie
Reply | Threaded
Open this post in threaded view
|

Re: Re: XForms Constraint

fl.schmitt(ops-users)
Queenie,

> I have a further question. In my form, I will have several constraints
> added. Is it possible to get different error messages when
> xforms-submit-error is fired from different constraints-violiation?

hmm - i'm not sure, but i think this would be quite complicated. There's
another way that's maybe better. In the Xforms Sandbox Samples, there's
an "error summary":

http://www.orbeon.com/ops/xforms-sandbox/sample/error-summary

It lets you collect validation errors and show them inside a table. This
error summary table can be displayed permanently (as in the online
example) or, for example, inside a dialog that could be shown using a
trigger. I you use this solution, you will have to decide when to show
that summary. One way could be to trigger it on xforms-submit-error, but
a submission error may be caused by other problems than validation errors.

HTH
florian


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws