cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ovidiu Predescu <ovi...@apache.org>
Subject Re: Flow and XMLForm [LONG]
Date Thu, 23 May 2002 07:37:08 GMT
On Wed, 22 May 2002 14:32:10 -0700, mratliff@collegenet.com wrote:

> 
> Torsten,
> 
> I guess it depends on what one means by constraint.  XForms allows
> constraint dependency rules described using XPath.  So if you have
> two fields, "CLASS_RANK" and "CLASS_SIZE" you can (I think) write a
> rule that says "value of CLASS_RANK must be less than or equal to
> CLASS_SIZE", i.e, something like:
>
>       <xforms:bind ref="instance/CLASS_RANK" isValid="current()
> <= ../instance/CLASS_SIZE" />
> 
> But even if you have such an XPath expression, it's just text to a
> parser-- nothing to parse.  And so, very difficult to translate into
> javascript.  If instead you have a regex constraint you don't need
> to parse it, just drop the string into a javascript object and
> create the handlers that call the right method..

I agree. XPath translation to JavaScript would essentially mean
implementing a full blown XPath processor in JavaScript.

But perhaps a better approach is to make use of the JXPath engine,
which is an XPath processor working on Java beans or DOM trees, and
have it execute the constraints.

The JXPath based implementation however would work on the server side
only, for complex client side validation you're still left with no
support. But see below for an idea.

> Anyway, I need to handle forms that have much more complicated dependencies
> than the simple CLASS_SIZE/CLASS_RANK example given.  Such dependencies
> are easy to "describe" in javascript,  difficult to describe in
> XPath/Schematron.
> So now I'm thinking about some kind of "ur-language"

Quick question: what is "ur-language"?

> for describing dependency (and other?) relationships, abstract
> enough to be translateable into Schematron rule markup, javascript
> procedural code, or whatever else is needed.

I don't have an example handy, but in the case of constraints that
need to apply on one-to-many type of relationships, it might be very
difficult to do it. You might need to have "for-each", "if" and other
normal programming language constructs to express these dependencies
and constraints. SQL reference integrity checks are the closest
examples for such dependencies.

Perhaps the easiest way to deal with such problems is to split the
solution: use simple schema validation to express how individual
values should look like, and describe more complex dependencies in a
normal programming language like JavaScript. With continuations-based
flow control of pages, where form input is collected in JavaScript
variables, is very easy to implement this higher level validation
right in JavaScript.

For the client side, the data collected at every point in the
multi-page form can be placed inline as part of a script to be loaded
in the client browser. The same validation functions that operate on
the server side can then be executed on client browser, if this is
desired.

Of course there are lots of details that need to be figured
out. Perhaps a good idea at this point is to see some realistic
requirements, so if you have an example you could share with us it
would be great.

Regards,
-- 
Ovidiu Predescu <ovidiu@apache.org>

>>> I'm in the job market again, check out my resume and qualifications at:
http://www.geocities.com/SiliconValley/Monitor/7464/ (Apache, GNU, Emacs ...)

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message