Validating xml against dtd Chat rooms on tights no registration
Alternatively if you use Stax for writing content (or a library that uses or can use stax), Woodstox also directly support validation when using XMLStream Writer.Here's a blog entry showing how that is done: Hey Stax Man, are there any XMLStream Writers that do pretty-print indenting?
It has built-in support for schema validation, and can convert Java objects to an XML document and vice-versa. In debian squeeze it is located in the package "libxerces-c-samples". As far as libraries goes, pretty much the de-facto standard is Xerces2 which has both C++ and Java versions.
Castor and JAXB are other Java libraries that serve a similar purpose to XMLBeans. The definition of the dtd and xsd has to be in the xml! Be fore warned though, it is a heavy weight solution.
But then again, validating XML against XSD files is a rather heavy weight problem.
As for a tool to do this for you, XMLFox seems to be a decent freeware solution, but not having used it personally I can't say for sure.
One more answer: since you said you need to validate files you are generating (writing), you might want to validate content while you are writing, instead of first writing, then reading back for validation.
Search for validating xml against dtd:
You can probably do that with JDK API for Xml validation, if you use SAX-based writer: if so, just link in validator by calling 'Validator.validate(source, result)', where source comes from your writer, and result is where output needs to go.