https://saxonica.plan.io/https://saxonica.plan.io/favicon.ico2020-07-03T09:06:31ZSaxonica Developer CommunitySaxon - Support #4628: Ignoring dtd's declared in xml messages with dtd declarations https://saxonica.plan.io/issues/4628?journal_id=157682020-07-03T09:06:31ZMichael Kaymike@saxonica.com
<ul></ul><p>In general if you want control over the configuration options of the XML parser, then the best approach is to supply the XML parser yourself, rather than leaving Saxon to create one. Typically to do this, you supply input documents in the form of a SAXSource in which you have already initialised the XMLReader.</p>
<p>That's not always possible of course if you are invoking Saxon via the command line interface or, for example, from Ant. In that case there are a number of ways of influencing how Saxon configures the parser.</p>
<p>DTDs can define entity declarations, and if your document contains entity references, then in general failing to process the DTD will mean that entity references can't be resolved, which means parsing will fail. However, if you know that you aren't using entity references, then you can configure the parser with an EntityResolver that substitutes a different DTD from the one requested. You can ask Saxon to set an EntityResolver on any XmlReader (parser) that Saxon instantiates by using the Saxon configuration option Feature.ENTITY_RESOLVER_CLASS. For example, you could set this on the command line using <code>--entityResolverClass=my.entity.Resolver</code>.</p>
<p>If <code>accessExternalDTD</code> doesn't include "file", that's a security setting someone has put in the system to prevent access to DTDs using the file protocol. Security people are pretty paranoid about access to DTDs and external entities, but overriding security settings is generally unwise. Basically, the security people are telling you not to process this kind of document, and you need to have a debate with them about why they are imposing that restriction, rather than trying to find a way around it.</p> Saxon - Support #4628: Ignoring dtd's declared in xml messages with dtd declarations https://saxonica.plan.io/issues/4628?journal_id=158232020-07-13T04:01:13ZPratheek K
<ul></ul><p>Hi Michael,</p>
<p>The workaround with a custom EntityResolver, though seemed promising, resulted in the same error
'Failed to read external DTD '***.dtd', because 'file' access is not allowed due to restriction set by the accessExternalDTD'
I checked the saxon configuration and verfifed that my custom Entity resolver was registered, but was never called.</p>
<p>So, it seems that the above error is thrown before the EntityResolver is hit.</p> Saxon - Support #4628: Ignoring dtd's declared in xml messages with dtd declarations https://saxonica.plan.io/issues/4628?journal_id=158432020-07-15T13:19:39ZPratheek K
<ul></ul><p>Hi Michael,</p>
<p>I did some debugging and figured out that the reason why my EntityResolver was not called. Saxon is called by camel and camel supplies its own XMLReader and none of the configuration in ParseOption is applied on the parser. So in that case, ENTITY_RESOLVER_CLASS is not suitable.</p>
<p>Regards
Pratheek</p> Saxon - Support #4628: Ignoring dtd's declared in xml messages with dtd declarations https://saxonica.plan.io/issues/4628?journal_id=160072020-08-13T11:25:21ZMichael Kaymike@saxonica.com
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>Closed</i></li></ul>