• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Validate XML file against XML Schema

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to the XML forum.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 393
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 393
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
--------------------
reply
    Bookmark Topic Watch Topic
  • New Topic