Hi Shobana,

JiBX does not currently support schema validation, though it does enforce some aspects of schema constraints (making sure that numeric values match their expected types, that required attributes and elements are present, and that elements are properly ordered). Both the 1.1 and 2.0 versions of JiBX will work with StAX parsers which can be used for validating documents. The 2.0 version may also add support for building validation into Java classes generated from a schema definition.

That said, I'll point out that schema validation is generally highly overrated. Schema can only express constraints on individual values, not on the linkages between values. This means that applications generally need to do their own validation of data from documents which have already been schema validated. Schema validation also tends to be expensive in terms of processing time. For all these reasons, schema constraints are best considered as design-time specifications and debugging tools rather than something to be checked at runtime.

If you really need full validation right now (and can't wait for a 1.1 version, which should be released by the end of the year), your best approach is probably to read an input document into a byte array in memory, then first parse it with a validating SAX parser and then unmarshal it using JiBX only if the SAX parse is successful. The JiBX unmarshalling time is likely to be considerably faster than the validating SAX parse, so this won't actually cost you much more than just the validation step does in isolation.

 - Dennis

Shobana wrote:

Hi,

I am new to JibX. I am going to use JiBX for mapping an xml document
into Java objects. I want to perform schema validation for the xml
document. Is this possible with JibX? If not, is it good to validate
the xml document against schema using DOM parser or SAX parser (xerces) and use Jibx for
loading values of xml document?Please suggest the best alternative.
Thanks in advance, Shobana

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to