aspose file tools*
The moose likes XML and Related Technologies and the fly likes validating in-memory dom against an external DTD Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "validating in-memory dom against an external DTD" Watch "validating in-memory dom against an external DTD" New topic
Author

validating in-memory dom against an external DTD

Tomchi Tang
Greenhorn

Joined: Apr 25, 2003
Posts: 15
I have created a new document from scratch using DOM. Before writing it to the file, I want to validate it against a DTD. Any pointers would be appreciated.
Thanks
Tomchi
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
You could consider using the Validator class from XMLUnit (take a look at the testValidation() method in the examples page).


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Of course I forgot to mention the other way I had in mind: write the document into a string (appending the doctype reference to the correct place) and feed it to a parser with validation set on.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: validating in-memory dom against an external DTD
 
Similar Threads
IN Memory DOM document validation
Does JAXP have a way of revalidating a DOM Tree
XML Testing
How to validate XML against DTD / Schema using DOM
parsing XML document against DTD!!!