learn java
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 The Software Craftsman this week in the Agile 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: 16541

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.

Customer surveys are for companies who didn't pay proper attention to begin with.
Don't get me started about those stupid light bulbs.
subject: Using XML Schema (XSD) for input validation