W3C home > Mailing lists > Public > www-forms@w3.org > November 2008

RE: validating an xform

From: Clark, John <CLARKJ2@ccf.org>
Date: Tue, 25 Nov 2008 09:39:34 -0500
Message-ID: <F122C25B4CD6F34BB119A9759367960104595C4B@CCHSCLEXMB59.cc.ad.cchs.net>
To: xforms <www-forms@w3.org>
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 14:40:31 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 10 March 2012 06:22:14 GMT