-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FactoryAdapter loadDocument() modifies XMLReader and breaks it #689
Comments
I do not think that making setting various SAX handlers on the XMLReader configurable or optional, let alone disabling it altogether and relying on the caller to figure out what methods need to be called and actually calling them is a good idea: Scala XML should be able to install the SAX handlers it needs (or, in the case of the Now that the |
It looks like However, I was able to do as you suggest but with a custom |
(XMLFilterImpl.parse() can be overwritten ;))
Glad it worked out! |
I had originally tried that and it didn't seem to work and I didn't look too much into it. But I now realize that if |
We have an
XMLReader
(via Xerces used for validation) that breaks ifsetEntityResolver()
is called. Instead, theEntityResolver
must be set by callingsetProperty(..., ...)
with the resolver object as the value. IfsetEntityResolver
is called, thisXMLReader
sees the loaded XML as invalid and fails to parse. Note that in thisXMLReader
,getEntityResolver() returns null when the entity resolver is set via
setProperty`.Unfortunately, the
loadDocument
function in theFactoryAdapter
sets an entity resolver ifgetEnitytResolver
returns null:https://github.com/scala/scala-xml/blob/main/shared/src/main/scala/scala/xml/parsing/FactoryAdapter.scala#L120
This causes our XMLReader to fail when used with a
FactoryAdapter
. It looks like this was added in commit 1cc9ea8 and moved to the FactoryAdapter in subsequent changes, so wasn't an issue prior to v2.2.0 as best I can tell.Can setting the entity resolver (and maybe other
XMLReader
changes made inloadDocument
) be made configurable so we can disable it if needed?Or maybe alternatively, change the
def reader
in XMLLoader.scala so that it makes these changes only to the XMLReader it creates? For exampleThis way if we override the reader to provide a custom one we avoid potentially breaking changes, and have full control over the reader, with the understanding that we may need to call some or all of the other functions ourselves to work with a FactoryAdapter.
The text was updated successfully, but these errors were encountered: