Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to validate XML against XSD in Java

 
Shrinivas Mujumdar
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello friends,
I have one doubt:
How to validate XML against XSD in Java?, I am using jdk 1.4.2_08.
One more thing is apart from jdk 1.5 where i will get the support for package javax.xml.validation

Thanx in Advance
Shrinivas Mujumdar
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use JDOM...

It will make document of XML only if it is valid...

JDOM APIs is not in JDK, you have to take jdom.jar into class path.
 
Rajagopal Manohar
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Shrinivas Mujumdar:
hello friends,
I have one doubt:
How to validate XML against XSD in Java?, I am using jdk 1.4.2_08.
One more thing is apart from jdk 1.5 where i will get the support for package javax.xml.validation

Thanx in Advance
Shrinivas Mujumdar


http://faq.javaranch.com/view?HowToValidateXmlAgainstAnySchema

-Rajagopal
 
Shrinivas Mujumdar
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Rajgopal,
Which version of Xerces.jar i am supposed to use? & how to check wheather my parser supports schema validation as mentioned in first line of link page?

Regards
Shrinivas
 
Rajagopal Manohar
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Shrinivas Mujumdar:
Hello Rajgopal,
Which version of Xerces.jar i am supposed to use? & how to check wheather my parser supports schema validation as mentioned in first line of link page?

Regards
Shrinivas


Ya I forgot the Crimson parser that comes bundled with java 1.4 does not support validation against schema

Regarding the first question any latest version of the xmlAPIs.jar and xercesImpl.jar from the apache website ought to do the trick

I think rather than relying on xerces api it is better to rely on Jaxp features

so maybe using code snippet is a better idea

 
Shrinivas Mujumdar
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Rajgopal, I will try this
Shrinivas Mujumdar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic