When running an XQuery that includes a library module like [1], it works fine the first time, but attempts to re-use the compiler to compile another query apparently result in the function from the imported library not being resolved.

This is a known bug which will be fixed in the next maintenance release:


In an attempt to work around this, I was trying XQueryCompiler.compileLibrary(File query) function, but that seems to always give syntax errors on libraries, like:

This should fail saying the method needs Saxon-EE: I'll change it to improve the diagnostics.

Then I gave XQueryCompiler.compileLibrary(String query) a try, and it tells me that feature is only available on Saxon-EE.
Yes, that's correct.

I suppose for now the workaround for queries that import libraries is to create a new compiler for every query?

Yes. Sorry for the inconvenience.

Michael Kay