aspose file tools*
The moose likes XML and Related Technologies and the fly likes How to validate an XML document against a xsd file ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How to validate an XML document against a xsd file ?" Watch "How to validate an XML document against a xsd file ?" New topic
Author

How to validate an XML document against a xsd file ?

Francesco Marchioni
author
Ranch Hand

Joined: Sep 22, 2003
Posts: 191
Hi all,
I have an xml file loaded in memory (Actually in a String but I can parse it).
I'd like to check the file against an .xsd document (the xml document must respect rules in the xsd file) Does anybody know how to do it in Java?
Thanks a lot
Francesco


WildFly 8 Administration Book - JBoss Tutorials
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
This has been asked before, so a search on this forum would have helped immediately...
Anyway, here are a couple of resources to try out:
http://www.coderanch.com/t/125376/XML/Validating-XML-against-xsd-schemata
http://bobcat.webappcabaret.net/javachina/faq/xml_java_01.htm#jaxp_sax_Q60
http://www-106.ibm.com/developerworks/edu/x-dw-xvalid-i.html


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Francesco Marchioni
author
Ranch Hand

Joined: Sep 22, 2003
Posts: 191
Thanks for your answer. Regards
Francesco
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to validate an XML document against a xsd file ?