Just wanted to mention something that might be of interest to some.
The FormBeanBinder binds request parameters to both JavaBeans and DOM nodes.
It can even bind to mixed objects, e.g. JavaBeans with DOM nodes as their
attributes.
It is a nice property of JXPath which might not be obvious.



----- Original Message -----
From: "Ivelin Ivanov" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: "Oliver Becker" <[EMAIL PROTECTED]>; "Rick Jelliffe"
<[EMAIL PROTECTED]>; "Dmitri Plotnikov" <[EMAIL PROTECTED]>
Sent: Sunday, March 24, 2002 7:03 AM
Subject: [Announcement] Fast Schematron Validation Here !


>
> We've got the rainbow !
>
> +===========================================+
> +    *Fast* Java API for Schematron Validation *Ready* !      +
> +===========================================+
> +    Validates both JavaBeans and DOM nodes                       +
> +===========================================+
>
> It's been another long and fruitful Saturday here in Austin...
>
> I am grateful to everyone in the Cocoon community as well as Dmitri
> Plotnikov for his help with JXPath, Rick Jelliffe for his guidance with
> Schematron and Oliver Becker for the clarifications on his XSLT based Java
> API for Schematron.
>
>
> As I mentioned already, I've decided to implement Schematron in Java using
> JXPath.
> The result is surprisingly little code (~1K lines) and quite exciting
speed
> (~20ms per validation for the demo setup).
>
> What's more:
>    - Does not need Castor mapping
>    - Does not do XSL transformation
>    - Direct access through the JXPath library
>
> * Someone let me know if this can be implemented too much faster *
>
> I hope this answers some outstanding questions like:
> "How do we validate HTML Forms ?"
> "How do we reuse validation rules and code for HTML Forms, Web Services
and
> domain validation ?"
> "What language do we use or build to implement validation?"
>
> I am not sure if the credits should all go to Schematron or more to XPath,
> but
> Schematron being so simple and powerful is clearly my choice:
> - Schemas can grow organicly. One can start with a few simple rules and
grow
> the document with time.
> - Native support for validation in "phases". Unlike XML Schema, one
doesn't
> need to provide a complete document in order to be able to perform
> validation.
> - Pin-points the bad elements and provides user-friendly reporting.
> - Very, very simple to learn if one knows XPath. (I just can stop
repeating
> that.)
>
>
> Please play with the new demo and send me your feedback.
> I've tried to add more JavaDoc since last time.
> Note that since there are 2 demos now, the URLs are different:
> xmlform/demo1 for the original demo and
> xmlform/demo2 for the new demo
> The new demo extends the first one with an additional page which is shown
on
> successful submit.
> This shows a possible sitemap control logic based on validation results.
>
> Having in addition the efficient HTML Form -> JavaBean binding, I'm
> convinced we're not too far from making Cocoon a prime time app server.
>
> The only area which is not completely fleshed out yet is rendering the
HTML
> Forms.
> The currently proposed simplistic solution apparently works for many
people,
> but there are still strong opinons for a
> XForms style model. I would need more specific suggestions on the latter,
so
> that we can have a good understanding
> and eventually vote on one or the other.
>
> Download from:
> http://prdownloads.sourceforge.net/freebuilder/CocoonForm_0-7.zip
>
>
> ========================
> P.S.: For those who are too busy to install the demo, but would like to
> participate in the discussion, I attach key snippets of code below:
> ========================
>
> ----------------------------------------------------------------
> sitemap.xmap:
>
> ...
>                         <!--
>                           Demo2:
>                           1) The Action binds the HTML form to a JavaBean
> and inserts it in the session
>                           2) The Action uses the Java Schematron Validator
> to perform fast validation
>                           3) The Action inserts into request the
validation
> result (if negative)
>                           4) Selector branches control depending on the
> outcome of 3)
>                           5) If 3) produced validation errors, then the
path
> is similar to Demo1
>                           6) If 3) did not produce validation errors, then
> Success page is displayed
>                         -->
>    <map:match pattern="demo2">
>                             <map:act type="ValidationFormAction"/>
>                             <map:select type="request-attribute">
>                                 <map:parameter name="attribute-name"
> value="validationPassed"/>
>                                 <!-- validation passed, go to next
page -->
>                                 <map:when test="true">
>                                     <map:call resource="display-success"/>
>                                 </map:when>
>                                 <!-- validation failed, go to the same
> page -->
>                                 <map:otherwise>
>                                   <map:generate
> src="insertFormBean-Demo2.xml"/>
>                                   <map:transform type="castor"/>
>                                   <map:transform
> src="formbean2html-Demo2.xsl"/>
>                                   <map:serialize type="html"/>
>                                 </map:otherwise>
>                             </map:select>
>    </map:match>
>   </map:pipeline>
> ...
>
> ----------------------------------------------------------------
>
> class ValidatingFormAction
>
> ...
>   public Map act(...)
>   {
>       ...
>       String formName = "xmlForm";
>       TestBean  jBean = (TestBean) session.getAttribute( formName );
>       if (jBean == null)
>         {
>           // first time here, populate the bean with initial values
>           jBean = new  TestBean();
>           session.setAttribute( formName, jBean);
>         }
>       else
>         {
>         // been here before, update the bean with client's values
>         FormBeanBinder.bind(request, jBean);
>       }
>       // validate state of the bean against a Schematron schema.
>       // Schema Phase is "Full"
>       Properties props = new Properties();
>       props.put("phase", "Full");
>       ValidationResult vres = validator_.validate(jBean, props);
>       // if the validation result is not empty, then
>       // make the validation result available to the pipeline
>       // it can be later checked by a <map:selector/>
>       // or inserted in the SAX stream by a CastorTransformer
>       // or maybe even both
>       if (!vres.isEmpty())
>       {
>         request.setAttribute ( formName + "ValidationResult", vres );
>       }
>       request.setAttribute ( "validationPassed",  new Boolean(
> vres.isEmpty() ) );
>       // apply additional buziness logic to the bean
>       jBean.incrementCount();
>
>       return objectModel;
>   }
>
> ...
> }
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to