This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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
XML Testing
Does JAXP have a way of revalidating a DOM Tree
IN Memory DOM document validation
parsing XML document against DTD!!!
How to validate XML against DTD / Schema using DOM