I am using XQuery as part of my Java application. I have a need to define namespaces and some commonly used functions in an xquery file which would be packaged in a jar. This file would then be imported by other xqueries. however, the imported file would have to be loaded from the classpath. I came across an open source implementation which does this. The link is http://exist.sourceforge.net/xquery.html. A brief description of the way they do it -
If the XQuery module is part of a Java application, it might also be an option, to pack the module into a Java archive (.jar file) along with the Java classes and use the following import to load the module from a Java package:
import module namespace status="http://exist-db.org/xquery/admin-interface/status"
I think it'd be really great to have this feature as part of Saxon as well.