Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#22 Importing an xquery file from classpath

open
nobody
5
2012-10-08
2007-12-13
Anonymous
No

Hi,

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"
at "resource:org/exist/xquery/lib/test.xqm";

I think it'd be really great to have this feature as part of Saxon as well.

Thanks.

Regards
Kaizer
Email: kaizers@mastek.com

Discussion

  • Ivan Toshkov
    Ivan Toshkov
    2008-05-16

    Logged In: YES
    user_id=718
    Originator: NO

    One way to do that in Saxon is to create a subclass of ModuleURIResolver, which can handle loading xqueries off of CLASSPATH.