Sure, that would be fine. I'll submit the code, the test, and the patches, so you can choose what should go there and what shouldn't.

Don

Robert Leland wrote:

Don Brown wrote:

I have seen how powerful JXPath can be in projects like PMD
Just to be cautious maybe we could place the code initially in a contrib folder, to take a look at it ?



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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






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



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



Reply via email to