/** * Get the static base URI for the query * * @return the static base URI */ public URI getBaseURI() { try { return new URI(env.getBaseURI()); } catch (URISyntaxException err) { throw new IllegalStateException(err); } }
/** * Get the static base URI for the query * @return the static base URI */ public URI getBaseURI() { try { return new URI(env.getBaseURI()); } catch (URISyntaxException err) { throw new IllegalStateException(err); } }
/** * Get the static base URI for the query * * @return the static base URI */ public URI getBaseURI() { try { return new URI(env.getBaseURI()); } catch (URISyntaxException err) { throw new IllegalStateException(err); } }
public Document convertToDocument(String xml) throws XQException { String baseURI = sqc.getBaseURI(); StringReader sr = new StringReader(xml); InputSource is = new InputSource(sr); is.setSystemId(baseURI); Source source = new SAXSource(is); source.setSystemId(baseURI); try { DocumentInfo doc = config.buildDocument(source); return (Document) DocumentOverNodeInfo.wrap(doc); } catch (XPathException ex) { throw new XQException(ex.getMessage()); } }
/** * 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); } }
/** * Create a QueryModule for a main module, copying the data that has been set up in a * StaticQueryContext object * @param sqc the StaticQueryContext object from which this module is initialized */ public QueryModule(StaticQueryContext sqc) throws XPathException { config = sqc.getConfiguration(); isMainModule = true; topModule = this; activeNamespaces = new Stack(); baseURI = sqc.getBaseURI(); try { locationURI = (baseURI == null ? null : new URI(baseURI)); } catch (URISyntaxException err) { throw new XPathException("Invalid location URI: " + baseURI); } executable = null; importers = null; init(sqc); resetFunctionLibraries(); }
/** * 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 query supplied as a file * * @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) * @return an XQueryExecutable representing the compiled query * @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.1 */ public XQueryExecutable compile(File query) throws SaxonApiException, IOException { try (FileInputStream stream = new FileInputStream(query)) { String savedBaseUri = env.getBaseURI(); env.setBaseURI(query.toURI().toString()); XQueryExecutable exec = new XQueryExecutable(processor, env.compileQuery(stream, encoding)); env.setBaseURI(savedBaseUri); return exec; } catch (XPathException e) { throw new SaxonApiException(e); } }
/** * Compile a query supplied as a file * * @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) * @return an XQueryExecutable representing the compiled query * @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.1 */ public XQueryExecutable compile(File query) throws SaxonApiException, IOException { try (FileInputStream stream = new FileInputStream(query)) { String savedBaseUri = env.getBaseURI(); env.setBaseURI(query.toURI().toString()); XQueryExecutable exec = new XQueryExecutable(processor, env.compileQuery(stream, encoding)); env.setBaseURI(savedBaseUri); return exec; } catch (XPathException e) { throw new SaxonApiException(e); } }
/** * Create a QueryModule for a main module, copying the data that has been set up in a * StaticQueryContext object * @param sqc the StaticQueryContext object from which this module is initialized */ public QueryModule(StaticQueryContext sqc) throws XPathException { config = sqc.getConfiguration(); isMainModule = true; topModule = this; activeNamespaces = new Stack(); baseURI = sqc.getBaseURI(); try { locationURI = (baseURI == null ? null : new URI(baseURI)); } catch (URISyntaxException err) { throw new XPathException("Invalid location URI: " + baseURI); } executable = null; importers = null; init(sqc); resetFunctionLibraries(); for (Iterator vars = sqc.iterateDeclaredGlobalVariables(); vars.hasNext(); ) { GlobalVariableDefinition var = (GlobalVariableDefinition)vars.next(); declareVariable(var); } }
"defaultElementTypeNamespace: {}; defaultFunctionNamespace: {}; emptyLeast: {}; inheritNamespaces: {}; " + "preserveNamespaces: {}; defaultNamespaces: {}; queryLanguageTypeAndVersion: {}]", sqc.getBaseURI(), sqc.isPreserveBoundarySpace(), sqc.getConstructionMode(), sqc.getDefaultCollationName(), sqc.getDefaultElementNamespace(), sqc.getDefaultFunctionNamespace(), sqc.isEmptyLeast(), sqc.isInheritNamespaces(), sqc.isPreserveNamespaces(), ns.toString(), sqc.getLanguageVersion());
topModule = this; activeNamespaces = new Stack<>(); baseURI = sqc.getBaseURI(); defaultCollationName = sqc.getDefaultCollationName(); try {
topModule = this; activeNamespaces = new Stack<>(); baseURI = sqc.getBaseURI(); defaultCollationName = sqc.getDefaultCollationName(); try {