aspose file tools*
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 Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Using XML Schema (XSD) for input validation" Watch "Using XML Schema (XSD) for input validation" New topic
Author

Using XML Schema (XSD) for input validation

Rory Newton
Greenhorn

Joined: Aug 27, 2009
Posts: 1
Hi,

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:simpleType>
<xs:restriction base="xs:integer">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>

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.

Thanks.

Rory
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Using XML Schema (XSD) for input validation