Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to validate a DOM object ?

 
JeanLouis Marechaux
Ranch Hand
Posts: 906
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a DOM object which contains a xml document and a reference to its xsd.
I would like to validate the DOM against the XSD it contains.
The only way I found so far is :
- serialize the DOM
- parse the dom activating validation.
Is there another way to do it ?
Does not sound like a really efficient method, no ? I parse a document which has already been parsed !!
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately this is only possible if you are in compliance with DOM Level 3 core specs that supports iterative load-validate-change-save operations and DOM events.
If you are using the new version of Xerces ie., Xerces2-J from Apache and DOM Level 3 compliant namespace, you may be able to use DOMConfig to validate the document in memory. Checkout this article for more details.
[ May 07, 2003: Message edited by: Ajith Kallambella ]
 
JeanLouis Marechaux
Ranch Hand
Posts: 906
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ajith,
That's what I thought.
You confirmation will help me saving a lot of time in research
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic