aspose file tools*
The moose likes XML and Related Technologies and the fly likes Validate XML file against XML Schema 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 "Validate XML file against XML Schema" Watch "Validate XML file against XML Schema" New topic
Author

Validate XML file against XML Schema

Michael Lara
Greenhorn

Joined: Nov 25, 2002
Posts: 4
Hi! I am writing a java program which creates an XML file. I need to validate the file against a Schema file file.XSD. How can I do this in java? Please Help me. Thanks in advance.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Moving to the XML forum.


"JavaRanch, where the deer and the Certified play" - David O'Meara
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12789
    
    5
The current Xerces parser (see xml.apache.org) documentation says it provides "initial support for XML Schema (draft W3C standard)" I know that parser is evolving rapidly so you should check there for the latest.
Bill
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
Two ready to use code examples can be found from this page
1) A simple XML validator using xml schema (SAX).
2) A simple XML validator using xml schema (JDOM).
http://bobcat.webappcabaret.net/javachina/faq/xml_java_01.htm
Rajan Kumar
Greenhorn

Joined: Jun 03, 2002
Posts: 11
Instead of taking that much pain, have a look at Sun Multi-Schema XML Validator of Sun. I used it. Easy to use, and configure.
Nikhil Jain
Ranch Hand

Joined: May 15, 2005
Posts: 385
Hi,

I was using JING Api to validate RELAX NG SChema. But the problem with JING was its bad error handling. I tried out few examples of Sun Multi Schema Validator. The problem with this is that, this throws up the error as soon as it encouters it. I would like to give the detail list of errors. Could you please help me out.

Thanks
Shashank


SCJP 1.4, SCWCD 1.4, SCBCD 1.5
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Originally posted by Michael Lara:
Hi! I am writing a java program which creates an XML file. I need to validate the file against a Schema file file.XSD. How can I do this in java? Please Help me. Thanks in advance.


Check this out ,
http://faq.javaranch.com/view?HowToValidateXmlAgainstSchema


Rahul Bhattacharjee
LinkedIn - Blog
Nikhil Jain
Ranch Hand

Joined: May 15, 2005
Posts: 385
Sorry to re-write the post. Could someone please make this as a new post.

Thanks

***************

Hi,

I was using JING Api to validate RELAX NG SChema. But the problem with JING was its bad error handling. I tried out few examples of Sun Multi Schema Validator. The problem with this is that, this throws up the error as soon as it encouters it. I would like to give the detail list of errors. Could you please help me out.

Thanks
Shashank
--------------------
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Validate XML file against XML Schema