stevedlawrence commented on code in PR #1060:
URL: https://github.com/apache/daffodil/pull/1060#discussion_r1281851920


##########
daffodil-lib/src/test/scala/org/apache/daffodil/lib/util/TestXMLCatalogAndValidate.scala:
##########
@@ -446,48 +452,56 @@ class SchemaAwareFactoryAdapter() extends 
NoBindingFactoryAdapter {
   f.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true)
   f.setValidating(true)
   val p = f.newSAXParser()
-  val xr = p.getXMLReader()
+  val r = p.getXMLReader()
+
+  // We must use XMLReader setProperty() function to set the entity 
resolver--calling
+  // setEntityResolver with the Xerces XML reader causes validation to fail 
for some
+  // reason. We call the right function below, but unfortunately, scala-xml 
calls
+  // setEntityResolver in loadDocument(), which cannot be disabled and 
scala-xml does not
+  // want to change. To avoid this, we wrap the Xerces XMLReader in an 
XMLFilterImpl and
+  // override setEntityResolver to a no-op. However, XMLFilterImpl parse() 
calls
+  // setEntityResolver() on the XMLReader, which for the same reason as before 
causes
+  // issues. To fix this, we can override parse() to just pass through to the 
parent, but
+  // that means we must override the various set/get handler functions to also 
pass
+  // through to the parent.

Review Comment:
   I think the way we called it was probably a bit of a hack, so I'm not sure 
we really want to go back to that. We essentially skipped the intended load xml 
entrypoint (`loadDocument()`) which initializes a number of important things, 
and probably isn't something really we want to undo. I think we just got lucky 
before and got by without it, but they are now required.
   
   Probably what we really need to do is figure out how we can use 
`setEntityResolver` instead of `setProperty` with the Xerces `XMLReader`. I 
image it must be possible, but I think we're just doing something wrong that's 
messing up its internals. I didn't spend a ton of time on it, but I couldn't 
figure out what we are doing wrong. If we could figure that out this 
`XMLFilterImpl` stuff can just go away and we can use scala xml as the library 
intended.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to