commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Graham <grahamdavid1...@yahoo.com>
Subject Re: [validator] Schematron-type/XPath Validator
Date Fri, 21 May 2004 12:59:02 GMT
This sounds interesting but I don't know anything about XPath so a more in
depth example would be useful.  I'm also worried about adding another
dependency; maybe this could be an optional download?

David

--- Don Brown <mrdon@twdata.org> wrote:
> I wrote a simple Validator that uses JXPath to implement a 
> schematron-style validation where fields are evaluated against boolean 
> XPath expressions.  The idea is from the XMLForms project 
> (http://www.xmlform.org), previously of Cocoon.  JXPath makes it easy to
> 
> write complex validations on many types of objects that can span object 
> trees.
> 
> The initialization of the validator looks like this:
> 
> <validator name="jxpath"
>                 
> classname="org.apache.commons.validator.JXPathValidator"
>                  method="isValid"
>                  
> methodParams="java.lang.Object,org.apache.commons.validator.Field"
>                  msg=""/>
> 
> and a sample usage:
> 
> <field property="value" depends="jxpath">
>   <var>
>     <var-name>test</var-name>
>     <var-value>number(.) > 0 and number(.) &lt; 10</var-value>
>   </var>
> </field>
> 
> The test variable contains the xpath expression to evaluate.  The 
> "property" attribute contains the xpath expression to narrow the scope 
> of the tested xpath.  Thanks to JXPath, this validator works on many 
> different types of Java objects, including JavaBeans, and can handle 
> field property xpath expressions that match multiple "nodes" or values.
> 
> If this validator would be useful for the commons-validator project, I 
> can supply code for the validator, unit tests, and any patches to 
> existing files, through bugzilla of course.
> 
> Don
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 



	
		
__________________________________
Do you Yahoo!?
Yahoo! Domains  Claim yours for only $14.70/year
http://smallbusiness.promotions.yahoo.com/offer 

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message