Using a SAX parser, is there a way to include a local DTD file when parsing an XML message that doesn't contain a DOCTYPE tag?

Alessandro A. Garbagnati

Hi,
There is a way to achieve that.
Check the org.xml.sax.EntityResolver interface:

If a SAX application needs to implement customized handling for external entities, it must implement this interface and register an instance with the SAX parser using the parser's setEntityResolver method.

The parser will then allow the application to intercept any external entities (including the external DTD subset and external parameter entities, if any) before including them.

Many SAX applications will not need to implement this interface, but it will be especially useful for applications that build XML documents from databases or other specialised input sources, or for applications that use URI types other than URLs.
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact