Java: How to prevent 'systemId' in EntityResolver#resolveEntity(String publicId, String systemId) from being absolutized to current working directory

做~自己de王妃 提交于 2019-12-04 04:33:10

Apparently, there is another interface called EntityResolver2 which is the extension of the old EntityResolver. (Talk about confusing names!)

Anyway, I found that EntityResolver2 achieved what I wanted, that is, it does not make any changes to the systemId, so it will always exactly be what was specified in the XML document.

From the EntityResolver Javadocs:

If the system identifier is a URL, the SAX parser must resolve it fully before reporting it to the application.

Also, the org.xml.sax docs have this to say about the resolve-dtd-uris feature:

It does not apply to EntityResolver.resolveEntity(), which is not used to report declarations...

I think you've either got to set your base-URI to something you can live with, or use public-IDs instead of system-IDs.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!