cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hunsberger, Peter" <Peter.Hunsber...@stjude.org>
Subject RE: XMLForm & JSF
Date Tue, 08 Apr 2003 15:33:17 GMT
Bruno Dumon <bruno@outerthought.org> asked:

> One advantage of commons validator is that it has built-in support for
validating
> common datatypes like numbers and dates, taking the locale in
consideration. BTW, 
> how do you do such things in schematron, e.g. checking that an entered
string is a
> number?

I suspect you may know the basics? But in case not:

With Schematron you can use any test that is valid Xpath or XSLT.  Thus,
functions like "number()", "starts-with()", "contains()" work as expected,
but you can also have more complicated dependency checking like
"boolean(foo)" to assert that an element must have a child "foo" element,
etc.  A complete example from

	http://www.zvon.org/ZvonSW/ZvonSchematron/Reference/Output/

Should give you the basic idea:

<sch:schema xmlns:sch="http://www.ascc.net/xml/schematron" > 
     <sch:title>Selected e-mails</sch:title> 
     <sch:pattern name="Check address"> 
          <sch:rule context="email"> 
               <sch:assert test="contains(.,'@')"> @ is missing in an
email</sch:assert> 
          </sch:rule> 
     </sch:pattern> 
</sch:schema>

It states that the contents of the "email" element must contain an "@".  You
can simple add more rules as needed.

I've not had to do locale sensitive testing but I can see several ways to do
the basics: you can use the locale to select matchers out of embedded
structures or alternatively I suppose, as a worst case, you could allways
code up a choose block using the "lang()" function. For numbers there is
also a worst case of specifying the decimal-format yourself in a choose
block...

We'll likely have to start on I18N compatibility for our project this
fall/winter so I expect I'll be able to answer you question completely then.

If you know XSLT/Xpath a Google search on "Schematron" will provide enough
information to get you well on the way in a couple of hours...









Mime
View raw message