Don
Niall Pemberton wrote:
Given all the recent furore over collections is JXPath's dependency on it due to Beanutils or does it use collections classes directly?
Also I was surprised JXPath depends on the servlet api and is this a dependancy validator is OK to inherit?
http://jakarta.apache.org/commons/jxpath/dependencies.html
Niall
----- Original Message ----- From: "Don Brown" <[EMAIL PROTECTED]>
To: "Jakarta Commons Developers List" <[EMAIL PROTECTED]>
Sent: Friday, May 21, 2004 5:41 PM
Subject: Re: [validator] Schematron-type/XPath Validator
http://www.devguru.com/Technologies/xslt/quickref/xslt_index_functions.htmlYeah, I think putting it in contrib as Robert suggested might be a good start, however even if it shipped with Validator, it wouldn't be needed unless you wanted to use the jxpath validator. XPath is basically an expression language to locate nodes. While intended for XML documents, JXPath makes it possible to use it with JavaBeans, DynaBeans, and a bunch more. In addition to node location syntax, XPath includes various functions like the number() one in my example.
A XPath tutorial: http://www.zvon.org/xxl/XPathTutorial/General/examples.html XPath functions:
inOf course this validator wouldn't be for everyone, particularly those with no XPath knowledge, but for those of us that work with it every day, it allows us to re-use that knowledge to do complex things quickly and efficiently. One less language/syntax to learn is a good thing! :)
Don
David Graham wrote:
This sounds interesting but I don't know anything about XPath so a more
depth example would be useful. I'm also worried about adding another dependency; maybe this could be an optional download?
David
--- Don Brown <[EMAIL PROTECTED]> 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(.) < 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]
__________________________________ Do you Yahoo!? Yahoo! Domains – Claim yours for only $14.70/year http://smallbusiness.promotions.yahoo.com/offer
--------------------------------------------------------------------- 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]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
