Documentbuilderfactory validating

A “valid” document, by comparison, is one where the document's corresponds to some specification.A document may be well-formed — and usable — but not valid.Instead it read from an doesn't match the actual content.

It should be pretty easy to have all DTDs available locally if you configure an entity resolver (using an XML catalog or whatever) but I don't really see what XMLUnit could do to help apart from making i easier to specify an entity resolver.

Your code looks as if you'd still be using XMLUnit 1.x. I tried bumping to xmlunit-matchers 2.3.0, since I generally do prefer matchers, but it seems like the API is a little bit too different to just switch over, so initially I am moving it to xmlunit-legacy 2.3.0. Maybe there is a way to have the best of both worlds.

Still enable all validation, but set the factories up such that all schemas and DTDs are actually loaded locally, for instance, and if the callback doesn't return a DTD, it either fails fast or skips validation.

By comparison, with a SAX parser you have to know exactly what you're looking for at the time you parse.

Useful if you're unmarshalling JAXB objects or extracting data from a large file, not so useful if you're exploring a data structure.

Leave a Reply