Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validation - best approach

 
Jen Again
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jen Again
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic