1

I am using Xerces2-J and have built a grammar pool as described in the Grammars FAQ

When parsing the document instance, I would like the parser to ignore any xsi:schemaLocation or xsi:noNamespaceSchemaLocation hints.

The FAQ says

registering a do-nothing EntityResolver will allow the application to deny validators from using any but the "approved" grammar set.

How is a "do-nothing" entity resolver implemented? The entity resolver needs to implement the XMLEntityResolver interface, which has one method:

public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier)
    throws XNIException, IOException;

Returning null will default to the system behavior of trying to resolve the resourceIdentifier. What return value can be used to simply ignore the resolveEntity request?

yas
  • 3,520
  • 4
  • 25
  • 38
  • 1
    the quote from the FAQ discusses *denying* using anything but the approved grammar set. I take it so that in that case it would throw an exception, so there might not be an option to ignore resolveEntity request. But that's just how I read the quote above, I have no knowledge about it. – eis Jan 19 '22 at 20:22
  • @eis thanks, yes your interpretation makes sense. From testing, xerces did not attempt to resolveEntity simply from the location hint, but only if a corresponding grammar was not in the grammar pool and also it was actually used in the instance (e.g. an element belonging to the schemaLocation hint namespace). – yas Jan 19 '22 at 21:34

0 Answers0