Thứ Hai, 4 tháng 8, 2014

Use validator to validate xml against a shema

Using validator to validate xml against a shema 

 Module 1 ;
Create a program that accepts two command line parameters. The first parameter must specify the name of an XML document and the second parameter must specify the name of a schema. The program should validate the XML document against the specified schema by creating a DOM source on the
document.

Xml file
XSD file

Main class
Create object doc from source file tomcat-users.xml

Making validator object from tomcat-user.xsd

Use validator to validate object doc, then notify result
Result:


Moudule 2:
Create a program that accepts two command line parameters. The first parameter must specify the name of an XML document and the second  parameter must specify the name of Schema. The program must also validate the XML document against the specified schema by creating a SAX source on the
document.
Xml file
XSD file

Main class
Create an instance of inputSource, is to read from tomcat-users.xml
Create validator object to read tomcat-users.xsd

Use this validator to validate the inputSource object
Results


Conclusion:
Both of them are used to validate a xml documnet. We all have to prepare xml file and its xsd file and make two kinds of object: an input object and a validator object.
In Dom validation way, the input object is an object of Document class, and in Sax validaton way is an object of Inputsource class. And they use the same to create validator object.





Không có nhận xét nào:

Đăng nhận xét