How to load a relative system DTD into a StAX parser?
You are going to need to provide your own implementation of the XMLResolver
interface (it's been known as EntityResolver in the SAX world) to help the parser find the DTD. The XMLInputFactory
has the setXMLResolver()
method that would do it for you.
Some more information on the subject:
- XML Entity and URI Resolvers
It's also a good idea to take a look under the hood to understand what exactly is going on when parsers need to resolve a SYSTEM URI. Woodstox, for example, has an internal (and a default) implementation of the XMLResolver
(as well as a proxy between the SAX's EntityResolver
and a StAX XMLResolver
). Look at what it does with your DTD "filename" and you will see why it's working the way it is.