File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes Validation - best approach Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Validation - best approach" Watch "Validation - best approach" New topic
Author

Validation - best approach

Jen Again
Greenhorn

Joined: Jul 22, 2002
Posts: 4
I'm trying to determine the best approach for coding the following solution:
I have an XML document coming in (which conforms to a particular DTD). I would like to validate the node values and return a report (XML transformed to HTML) to the users enumerating the errors found in the document.
The validation falls into three categories - required fields, data type validation, and validation against a set of allowable values.
Does anyone have a suggestion as to the best approach to the problem? Is a schema the way to go (and would validation against a schema produce a list of all nodes that failed?) or should I loop through the document using Java classes to perform the validation checks?
Thanks in advance for any help!
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
Originally posted by Jen Again:
The validation falls into three categories - required fields, data type validation, and validation against a set of allowable values.

The Apache Xerces for java has validation capabilities,to know how to do it u can see the tutorial at http://www-105.ibm.com/developerworks/education.nsf/xml-onlinecourse-bytitle/7155C6A19EC801DB86256ACE006F5270?OpenDocument and http://www-105.ibm.com/developerworks/education.nsf/xml-onlinecourse-bytitle/C47D818796E6E2D186256BF10068802C?OpenDocument
Another way is use Sun MSV - i tried but no success at that time. here is the relevant link http://dcb.sun.com/practices/devnotebook/xml_msv.jsp
The problem with all above is "the validation error thrown can only be understood by xml programmers "
To avoid this u can use XSLT based validation,this also i never tried and the related discussion can be found at http://www.coderanch.com/t/125161/XML/xslt


Spritle Software Blogs
Jen Again
Greenhorn

Joined: Jul 22, 2002
Posts: 4
Thanks for the input Balaji! After going through the tutorials and tracing through code to determine where the validation exceptions are thrown, I've decided that indeed the schema approach gives me too little control.
So I've started working on an XSL solution. Thanks again!
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
Originally posted by Jen Again:
So I've started working on an XSL solution. Thanks again!

Nice, Please share ur experience with us once you are through.
Regards
Balaji
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Validation - best approach