• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validate XML file against XML Schema

 
Michael Lara
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the XML forum.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Nikhil Jain
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
--------------------
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic