org.xmlresolver.XMLResolver.getEntityResolver() always returns a org.xml.sax.ext.EntityResolver2 #183
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
(This is with XmlResolver 6.0.2)
If I pass an org.apache.xerces.parsers.SAXParser an org.xml.sax.ext.EntityResolver2 interface it will call EntityResolver2.getExternalSubset(String, String) if the XML file has no DTD declaration for example.
If the EntityResolver2 interface is implemented by org.xmlresolver.adapters.SAXAdapter and there is no entry for the Document element root name in the catalog and org.xmlresolver.ResolverFeature.ALWAYS_RESOLVE is set to true (the default) SAXAdapter will return the document which is being parsed (if that document has an associated URI in the InputSource). Apart from not being what is intended, this causes an error to be thrown by the parser because the XML input file is not a DTD, and we get something like
net.sf.saxon.s9api.SaxonApiException: org.xml.sax.SAXParseException; systemId: file:///Users/johnf/dev26/core/xml-compare-main/target/test-classes/white-box/unstaged-data/xmlresolver/EntityResolver2_1.xml; lineNumber: 2; columnNumber: 2; The markup declarations contained or pointed to by the document type declaration must be well-formed.Since org.xmlresolver.XMLResolver.getEntityResolver() is implemented by calling org.xmlresolver.XMLResolver.getEntityResolver2() and implements both org.xml.sax.ext.EntityResolver2 and org.xml.sax.EntityResolver interfaces, we can't avoid using an EntityResolver2 without wrapping inside a class that doesn't implement EntityResolver2. The other choice is to turn ALWAYS_RESOLVE off, which we can't do in other circumstances, and since ours is a third party JAR we can't edit the catalogs that are used.
(The old catalog resolver only implemented EntityResolver and therefore did not have this problem.)
`
The file is simply
<StandardXmlRootElement/>By wrapping I mean something like the following
`
}
`