You can always convert the DTD to a schema (using for example trang), and perform an in-memory validation against the schema for each document.
To do that, you would create one javax.xml.validation.ValidationHandler
with the converted schema, and feed it to a DOM4J SAXWriter
.
Another option is of course to
- Parse each document without validation into a DOM4J
Document
- Add a DOM4j
DefaultDocumentType
to the parsed document
- Write the document to a temporary string buffer
- Parse again, but this time with a validating
SAXReader