RE: validating an xform

And further to John Clark's point, I would think that if you omitted the 
resource child element, resource attribute and action attribute, then you 
would get an xforms-submit-error with error-type of resource-error.  But 
in the processing model, we obtain the submission resource only after the 
validation check has been done.  So, you only get the resource-error if 
the validation succeeds, and you get the validation-error otherwise.

The specification indicates that omission of the resource is an error, but 
it unfortunately does not dot-the-i and mention generation of 
xforms-submit-error with error-type of resource-error as the way of 
reporting that error, but this seems to be just an editorial omission 
which I propose herewith that the editor should fix. :-)

John M. Boyer, Ph.D.
STSM, Interactive Documents and Web 2.0 Applications
Chair, W3C Forms Working Group
Workplace, Portal and Collaboration Software
IBM Victoria Software Lab
E-Mail: boyerj@ca.ibm.com 

Blog: http://www.ibm.com/developerworks/blogs/page/JohnBoyer
Blog RSS feed: 
http://www.ibm.com/developerworks/blogs/rss/JohnBoyer?flavor=rssdw





From:
"Clark, John" <CLARKJ2@ccf.org>
To:
xforms <www-forms@w3.org>
Date:
11/25/2008 06:44 AM
Subject:
RE: validating an xform



In addition to Erik's observation, you can use XForms submissions to 
perform arbitrarily powerful validations (or other types of processing) on 
the server, without navigating away from the current form.  The key to 
doing this uses `replace="instance"` as well as the `instance` and 
`target` attributes, which specify which instance and node should be 
replaced, respectively.  This means that remote service should return XML, 
which is then spliced into the target node in the instance specified, as 
you would expect.  (By default, a submission uses `replace="all"`, which 
will replace the entire page with the result data from the submission, 
which is likely the behaviour that you're experiencing now.)  This might 
look like:

  <xf:submission id="validate"
    resource="http://example.org/path/to/validation/service"
    method="post" ref="instance('data-to-validate')"
    replace="instance" instance="validation-results" target="/*"/>

Of course, you can definitely combine client-side validation with 
server-side validation in a natural way.  We do this in our application. 
We have an array of type checks on fields that are implemented using model 
item properties (applied with `xf:bind` elements), and then we submit to a 
server process to do more complex validation, currently implemented in 
Schematron.  The Schematron validator then returns SVRL (an XML dialect 
for describing Schematron validation results, see <
http://www.schematron.com/validators.html>), which the form can then use 
to inform the user about the result of validation.

Let us know if this doesn't give you enough information to move forward.

Take care,

    John L. Clark


-----Original Message-----
From: www-forms-request@w3.org on behalf of Erik Bruchez
Sent: Tue 11/25/2008 2:48 AM
To: xforms
Subject: Re: validating an xform


> I'm new to the list. I'd like to ask your help to clarify some things
> because I don't know what is the best practice for my issues. The
> problem is the following: I have an xform where input widgets can have
> some constraints (e.g. a field can only accept integers from an
> interval, or some fields are required, etc.). How to check if the form
> satisfies these constraints?
> (1) Should it be done on the client side with JavaScript? or

In XForms, you often validate without JavaScript! See for example:

   <xforms:bind nodeset="age" constraint="number(.) > 10" 
required="true()" type="xs:integer"/>

In addition, for implementations that support it, you can also use XML 
Schema types, which are quite powerful.

All this is part of the beauty of XForms!

-Erik

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/





===================================

P Please consider the environment before printing this e-mail


Cleveland Clinic is ranked one of the top hospitals
in America by U.S. News & World Report (2008). 
Visit us online at http://www.clevelandclinic.org for
a complete listing of our services, staff and
locations.


Confidentiality Note:  This message is intended for use
only by the individual or entity to which it is addressed
and may contain information that is privileged,
confidential, and exempt from disclosure under applicable
law.  If the reader of this message is not the intended
recipient or the employee or agent responsible for
delivering the message to the intended recipient, you are
hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited.  If
you have received this communication in error,  please
contact the sender immediately and destroy the material in
its entirety, whether electronic or hard copy.  Thank you.

Received on Tuesday, 25 November 2008 18:27:29 UTC