Saxon on .NET: How to provide a XmlResolver for documents returned by collection()?

Emanuel Wlaschitz <[email protected]> Wed, 25 Nov 2020 13:00:15 +0000
Newsgroups gmane.text.xml.saxon.help
Message-ID <[email protected]>
We've recently started to make more and more use of the collection() function and its ability to iterate files in a folder, which made a lot of custom C# code obsolete that we had to use in the past.
While trying to replace (a lot more) code with (a lot less) XSLT calling collection(), we ran into the following error (which results in the transformation to fail): 

collection(): failed to parse XML file file:/D:/Test/sample1.xml: I/O error reported by XML parser processing file:/D:/Test/sample1.xml: Could not find file 'D:\Test\doctype.dtd'.

Obviously, that folder does not contain doctype.dtd (which is referenced by the DOCTYPE declaration of sample1.xml, as System ID); and for the most part we don't want (or need) it there.
And for other purposes (which was mainly document() in the past) we've registered a XmlResolver as XsltTransformer.InputXmlResolver that redirects (and/or ignores) all requests for DTD or XSD files.

However, it appears the default CollectionFinder does not use XsltTransformer.InputXmlResolver; otherwise we wouldn't be seeing that error.
We've also looked into implementing our own CollectionFinder (or rather: deriving from StandardCollectionFinder so we don't have to implement everything from scratch), but we couldn't find the appropriate place to plug in our code.
The only thing that seemed remotely related was the context parameter in findCollection, but its uriResolver field was null.

And that's where our adventure ended, so we turned to the ML:

How can we get our custom XmlResolver into the default CollectionFinder?
If that's not how it works, where would we plug our own code in a custom CollectionFinder?
Also, after looking at "Writing your own Collection Finder": Is this even what we should be doing? The Collection Finder returns resources (as a sequence of URIs), not documents.

In case it matters, we've tried this on Saxon-HE 9.9.1.2N and 10.2N, but we plan on moving to 10.3N soon.

Thanks in advance,
Emanuel