jQuery in Action, 3rd edition
The moose likes JSF and the fly likes Using XML Schema (XSD) for input validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Using XML Schema (XSD) for input validation" Watch "Using XML Schema (XSD) for input validation" New topic

Using XML Schema (XSD) for input validation

Rory Newton

Joined: Aug 27, 2009
Posts: 1

Does anyone know if it is possible to use the facets of an XML Schema element to validate input to a form. So, for example if one had the following snippet in an XSD file somehow referenced to a JSF component:

<xs:element name="length">
<xs:restriction base="xs:integer">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="10"/>

an error would be triggered if a value of '11' was entered. I've seen similar things done with XForms, but I would really like to stick with JSF. Any help much appreciated.


Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17144

JSF has its own validation system. You could probably create an XSL to take an XForms definition and transform it into a JSF View, but the elements involved are totally different.

In addition to the basic JSF validators, you might also be interested in the MyFaces validator extensions, which allow JSF-based views to validate based on annotations in the backing beans and in the domain model objects.

IIRC, JBoss Seam also devotes a fair amount of coverage to input validation.

There's a whole standard in the works for validations, but it's still in progress.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link: http://aspose.com/file-tools
subject: Using XML Schema (XSD) for input validation
It's not a secret anymore!