/** * Compile a library module supplied as a string. The code generated by compiling the library is available * for importing by all subsequent compilations using the same XQueryCompiler; it is identified by an * "import module" declaration that specifies the module URI of the library module. No module location * hint is required, and if one is present, it is ignored. * <p>The base URI of the query should be supplied by calling {@link #setBaseURI(java.net.URI)} </p> * <p>Separate compilation of library modules is supported only under Saxon-EE</p> * * @param query the text of the query * @throws SaxonApiException if the query compilation fails with a static error * @since 9.2 */ public void compileLibrary(String query) throws SaxonApiException { try { env.compileLibrary(query); } catch (XPathException e) { throw new SaxonApiException(e); } }
/** * Compile a library module supplied as an InputStream. The code generated by compiling the library is available * for importing by all subsequent compilations using the same XQueryCompiler; it is identified by an * "import module" declaration that specifies the module URI of the library module. No module location * hint is required, and if one is present, it is ignored. * <p>The encoding of the input stream may be specified using {@link #setEncoding(String)}; * if this has not been set, the compiler determines the encoding from the version header of the * query, and if that too is absent, it assumes UTF-8. </p> * <p>The base URI of the query should be supplied by calling {@link #setBaseURI(java.net.URI)} </p> * <p>Separate compilation of library modules is supported only under Saxon-EE</p> * * @param query the text of the query * @throws SaxonApiException if the query compilation fails with a static error * @since 9.2 */ public void compileLibrary(InputStream query) throws SaxonApiException { try { env.compileLibrary(query, encoding); } catch (XPathException | IOException e) { throw new SaxonApiException(e); } }
/** * Compile a library module supplied as a Reader. The code generated by compiling the library is available * for importing by all subsequent compilations using the same XQueryCompiler; it is identified by an * "import module" declaration that specifies the module URI of the library module. No module location * hint is required, and if one is present, it is ignored. * <p>The base URI of the query should be supplied by calling {@link #setBaseURI(java.net.URI)} </p> * <p>Separate compilation of library modules is supported only under Saxon-EE</p> * * @param query the text of the query * @throws SaxonApiException if the query compilation fails with a static error * @since 9.2 */ public void compileLibrary(Reader query) throws SaxonApiException { try { env.compileLibrary(query); } catch (XPathException | IOException e) { throw new SaxonApiException(e); } }
/** * Compile a library module supplied as a Reader. The code generated by compiling the library is available * for importing by all subsequent compilations using the same XQueryCompiler; it is identified by an * "import module" declaration that specifies the module URI of the library module. No module location * hint is required, and if one is present, it is ignored. * <p>The base URI of the query should be supplied by calling {@link #setBaseURI(java.net.URI)} </p> * <p>Separate compilation of library modules is supported only under Saxon-EE</p> * * @param query the text of the query * @throws SaxonApiException if the query compilation fails with a static error * @since 9.2 */ public void compileLibrary(Reader query) throws SaxonApiException { try { env.compileLibrary(query); } catch (XPathException | IOException e) { throw new SaxonApiException(e); } }
/** * Compile a library module supplied as a string. The code generated by compiling the library is available * for importing by all subsequent compilations using the same XQueryCompiler; it is identified by an * "import module" declaration that specifies the module URI of the library module. No module location * hint is required, and if one is present, it is ignored. * <p>The base URI of the query should be supplied by calling {@link #setBaseURI(java.net.URI)} </p> * <p>Separate compilation of library modules is supported only under Saxon-EE</p> * * @param query the text of the query * @throws SaxonApiException if the query compilation fails with a static error * @since 9.2 */ public void compileLibrary(String query) throws SaxonApiException { try { env.compileLibrary(query); } catch (XPathException e) { throw new SaxonApiException(e); } }
/** * Compile a library module supplied as an InputStream. The code generated by compiling the library is available * for importing by all subsequent compilations using the same XQueryCompiler; it is identified by an * "import module" declaration that specifies the module URI of the library module. No module location * hint is required, and if one is present, it is ignored. * <p>The encoding of the input stream may be specified using {@link #setEncoding(String)}; * if this has not been set, the compiler determines the encoding from the version header of the * query, and if that too is absent, it assumes UTF-8. </p> * <p>The base URI of the query should be supplied by calling {@link #setBaseURI(java.net.URI)} </p> * <p>Separate compilation of library modules is supported only under Saxon-EE</p> * * @param query the text of the query * @throws SaxonApiException if the query compilation fails with a static error * @since 9.2 */ public void compileLibrary(InputStream query) throws SaxonApiException { try { env.compileLibrary(query, encoding); } catch (XPathException | IOException e) { throw new SaxonApiException(e); } }
/** * Compile a library module supplied as a file. The code generated by compiling the library is available * for importing by all subsequent compilations using the same XQueryCompiler; it is identified by an * "import module" declaration that specifies the module URI of the library module. No module location * hint is required, and if one is present, it is ignored. * <p>The encoding of the input stream may be specified using {@link #setEncoding(String)}; * if this has not been set, the compiler determines the encoding from the version header of the * query, and if that too is absent, it assumes UTF-8.</p> * <p>Separate compilation of library modules is supported only under Saxon-EE</p> * * @param query the file containing the query. The URI corresponding to this file will be used as the * base URI of the query, overriding any URI supplied using {@link #setBaseURI(java.net.URI)} (but not * overriding any base URI specified within the query prolog) * @throws SaxonApiException if the query compilation fails with a static error * @throws IOException if the file does not exist or cannot be read * @since 9.2 */ public void compileLibrary(File query) throws SaxonApiException, IOException { try (FileInputStream stream = new FileInputStream(query)) { String savedBaseUri = env.getBaseURI(); env.setBaseURI(query.toURI().toString()); env.compileLibrary(stream, encoding); env.setBaseURI(savedBaseUri); } catch (XPathException e) { throw new SaxonApiException(e); } }
/** * Compile a library module supplied as a file. The code generated by compiling the library is available * for importing by all subsequent compilations using the same XQueryCompiler; it is identified by an * "import module" declaration that specifies the module URI of the library module. No module location * hint is required, and if one is present, it is ignored. * <p>The encoding of the input stream may be specified using {@link #setEncoding(String)}; * if this has not been set, the compiler determines the encoding from the version header of the * query, and if that too is absent, it assumes UTF-8.</p> * <p>Separate compilation of library modules is supported only under Saxon-EE</p> * * @param query the file containing the query. The URI corresponding to this file will be used as the * base URI of the query, overriding any URI supplied using {@link #setBaseURI(java.net.URI)} (but not * overriding any base URI specified within the query prolog) * @throws SaxonApiException if the query compilation fails with a static error * @throws IOException if the file does not exist or cannot be read * @since 9.2 */ public void compileLibrary(File query) throws SaxonApiException, IOException { try (FileInputStream stream = new FileInputStream(query)) { String savedBaseUri = env.getBaseURI(); env.setBaseURI(query.toURI().toString()); env.compileLibrary(stream, encoding); env.setBaseURI(savedBaseUri); } catch (XPathException e) { throw new SaxonApiException(e); } }
XQueryCompiler xqcomp = processor.newXQueryCompiler(); StaticQueryContext sqc = xqcomp.getUnderlyingStaticContext(); sqc.compileLibrary(connection.getInputStream(), "utf-8"); XQueryExpression xqe = sqc.compileQuery("import module namespace f='" + ns + "'; ."); QueryModule qm = xqe.getMainModule();
XQueryCompiler xqcomp = processor.newXQueryCompiler(); StaticQueryContext sqc = xqcomp.getUnderlyingStaticContext(); sqc.compileLibrary(connection.getInputStream(), "utf-8"); XQueryExpression xqe = sqc.compileQuery("import module namespace f='" + ns + "'; ."); QueryModule qm = xqe.getMainModule();