This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Validate xml against schema  RSS feed

 
Jeppe Sommer
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am trying to validate a xml file against a schema using SAX.

My problem is, that no error messages is thrown, even if I change the xml file to not match the schema. The method always return true.

What could be the problem?

I use xerces2 java 2.9.1.

 
kri shan
Ranch Hand
Posts: 1489
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to validate the same xml and xsd using xml tools first. - xmlSpy..
 
Jeppe Sommer
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried to validate the xml file using the online validator at:
http://www.oioubl.info/validator/default.aspx

In the xml file I changed the element called "UBLVersionID" to "UBLVersionID2" to be able to throw the validation error. This change is also visible using the online validator.

The result of the validation:


Any ideas how I can find out what is wrong in my code?
 
Jeppe Sommer
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright it works now.

The problem was that I called the wrong error handler. My mistake!

It should be "new DOMErrorHandler()" and not "new org.xml.sax.helpers.DefaultHandler()".
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!