/** * Prepare an XQuery query for subsequent evaluation. The Query is supplied * in the form of a InputStream, with an optional encoding. If the encoding is not specified, * the query parser attempts to obtain the encoding by inspecting the input stream: it looks specifically * for a byte order mark, and for the encoding option in the version declaration of an XQuery prolog. * The encoding defaults to UTF-8. * The base URI of the query is taken from the static context, * and defaults to the current working directory. * * @param source An InputStream giving access to the text of the XQuery query to be compiled, as a stream * of octets * @param encoding The encoding used to translate characters to octets in the query source. The parameter * may be null: in this case the query parser attempts to infer the encoding by inspecting the source, * and if that fails, it assumes UTF-8 encoding * @return an XPathExpression object representing the prepared expression. * @throws net.sf.saxon.trans.XPathException * if the syntax of the expression is wrong, or if it references namespaces, * variables, or functions that have not been declared, or any other static error is reported. * @throws java.io.IOException if a failure occurs reading the supplied input. * @since 8.5 */ public XQueryExpression compileQuery(InputStream source, String encoding) throws XPathException, IOException { String query = QueryReader.readInputStream(source, encoding, config.getNameChecker()); return compileQuery(query); }
/** * Prepare an XQuery query for subsequent evaluation. The Query is supplied * in the form of a InputStream, with an optional encoding. If the encoding is not specified, * the query parser attempts to obtain the encoding by inspecting the input stream: it looks specifically * for a byte order mark, and for the encoding option in the version declaration of an XQuery prolog. * The encoding defaults to UTF-8. * The base URI of the query is taken from the static context, * and defaults to the current working directory. * * @param source An InputStream giving access to the text of the XQuery query to be compiled, as a stream * of octets * @param encoding The encoding used to translate characters to octets in the query source. The parameter * may be null: in this case the query parser attempts to infer the encoding by inspecting the source, * and if that fails, it assumes UTF-8 encoding * @return an XPathExpression object representing the prepared expression. * @throws net.sf.saxon.trans.XPathException * if the syntax of the expression is wrong, or if it references namespaces, * variables, or functions that have not been declared, or any other static error is reported. * @since 8.5 */ /*@Nullable*/ public synchronized XQueryExpression compileQuery(/*@NotNull*/ InputStream source, /*@Nullable*/ String encoding) throws XPathException { String query = QueryReader.readInputStream(source, encoding, config.getValidCharacterChecker()); return compileQuery(query); }
/** * Prepare an XQuery query for subsequent evaluation. The Query is supplied * in the form of a InputStream, with an optional encoding. If the encoding is not specified, * the query parser attempts to obtain the encoding by inspecting the input stream: it looks specifically * for a byte order mark, and for the encoding option in the version declaration of an XQuery prolog. * The encoding defaults to UTF-8. * The base URI of the query is taken from the static context, * and defaults to the current working directory. * * @param source An InputStream giving access to the text of the XQuery query to be compiled, as a stream * of octets * @param encoding The encoding used to translate characters to octets in the query source. The parameter * may be null: in this case the query parser attempts to infer the encoding by inspecting the source, * and if that fails, it assumes UTF-8 encoding * @return an XPathExpression object representing the prepared expression. * @throws net.sf.saxon.trans.XPathException * if the syntax of the expression is wrong, or if it references namespaces, * variables, or functions that have not been declared, or any other static error is reported. * @since 8.5 */ /*@Nullable*/ public synchronized XQueryExpression compileQuery(/*@NotNull*/ InputStream source, /*@Nullable*/ String encoding) throws XPathException { String query = QueryReader.readInputStream(source, encoding, config.getValidCharacterChecker()); return compileQuery(query); }
/** * Prepare an XQuery query for subsequent evaluation. The Query is supplied * in the form of a InputStream, with an optional encoding. If the encoding is not specified, * the query parser attempts to obtain the encoding by inspecting the input stream: it looks specifically * for a byte order mark, and for the encoding option in the version declaration of an XQuery prolog. * The encoding defaults to UTF-8. * The base URI of the query is taken from the static context, * and defaults to the current working directory. * * @param source An InputStream giving access to the text of the XQuery query to be compiled, as a stream * of octets * @param encoding The encoding used to translate characters to octets in the query source. The parameter * may be null: in this case the query parser attempts to infer the encoding by inspecting the source, * and if that fails, it assumes UTF-8 encoding * @return an XPathExpression object representing the prepared expression. * @throws net.sf.saxon.trans.XPathException * if the syntax of the expression is wrong, or if it references namespaces, * variables, or functions that have not been declared, or any other static error is reported. * @throws java.io.IOException if a failure occurs reading the supplied input. * @since 8.5 */ public XQueryExpression compileQuery(InputStream source, String encoding) throws XPathException, IOException { String query = QueryReader.readInputStream(source, encoding, config.getNameChecker()); return compileQuery(query); }
/** * Read a query module given a StreamSource * * @param ss the supplied StreamSource. This must contain a non-null systemID which defines the base * URI of the query module, and either an InputStream or a Reader containing the query text. In the * case of an InputStream the method attempts to infer the encoding; in the case of a Reader, this has * already been done, and the encoding specified within the query itself is ignored. * <p>The method reads from the InputStream or Reader contained in the StreamSource up to the end * of file unless a fatal error occurs. It does not close the InputStream or Reader; this is the caller's * responsibility.</p> * @param charChecker this checks XML characters against either the XML 1.0 or XML 1.1 rules * @return the text of the query */ public static String readSourceQuery(/*@NotNull*/ StreamSource ss, IntPredicate charChecker) throws XPathException { CharSequence queryText; if (ss.getInputStream() != null) { InputStream is = ss.getInputStream(); if (!is.markSupported()) { is = new BufferedInputStream(is); } String encoding = readEncoding(is); queryText = readInputStream(is, encoding, charChecker); } else if (ss.getReader() != null) { queryText = readQueryFromReader(ss.getReader(), charChecker); } else { throw new XPathException("Module URI Resolver must supply either an InputStream or a Reader"); } return queryText.toString(); }
/** * Read a query module given a StreamSource * @param ss the supplied StreamSource. This must contain a non-null systemID which defines the base * URI of the query module, and either an InputStream or a Reader containing the query text. In the * case of an InputStream the method attempts to infer the encoding; in the case of a Reader, this has * already been done, and the encoding specified within the query itself is ignored. * <p>The method reads from the InputStream or Reader contained in the StreamSource up to the end * of file unless a fatal error occurs. It does not close the InputStream or Reader; this is the caller's * responsibility.</p> * @param nameChecker this checks XML names against either the XML 1.0 or XML 1.1 rules * @return the text of the query */ public static String readSourceQuery(StreamSource ss, NameChecker nameChecker) throws XPathException { CharSequence queryText; if (ss.getInputStream() != null) { InputStream is = ss.getInputStream(); if (!is.markSupported()) { is = new BufferedInputStream(is); } String encoding = readEncoding(is); queryText = readInputStream(is, encoding, nameChecker); } else if (ss.getReader() != null) { queryText = readQueryFromReader(ss.getReader(), nameChecker); } else { throw new XPathException("Module URI Resolver must supply either an InputSource or a Reader"); } return queryText.toString(); }
/** * Read a query module given a StreamSource * @param ss the supplied StreamSource. This must contain a non-null systemID which defines the base * URI of the query module, and either an InputStream or a Reader containing the query text. In the * case of an InputStream the method attempts to infer the encoding; in the case of a Reader, this has * already been done, and the encoding specified within the query itself is ignored. * <p>The method reads from the InputStream or Reader contained in the StreamSource up to the end * of file unless a fatal error occurs. It does not close the InputStream or Reader; this is the caller's * responsibility.</p> * @param nameChecker this checks XML names against either the XML 1.0 or XML 1.1 rules * @return the text of the query */ public static String readSourceQuery(StreamSource ss, NameChecker nameChecker) throws XPathException { CharSequence queryText; if (ss.getInputStream() != null) { InputStream is = ss.getInputStream(); if (!is.markSupported()) { is = new BufferedInputStream(is); } String encoding = readEncoding(is); queryText = readInputStream(is, encoding, nameChecker); } else if (ss.getReader() != null) { queryText = readQueryFromReader(ss.getReader(), nameChecker); } else { throw new XPathException("Module URI Resolver must supply either an InputSource or a Reader"); } return queryText.toString(); }
/** * Read a query module given a StreamSource * * @param ss the supplied StreamSource. This must contain a non-null systemID which defines the base * URI of the query module, and either an InputStream or a Reader containing the query text. In the * case of an InputStream the method attempts to infer the encoding; in the case of a Reader, this has * already been done, and the encoding specified within the query itself is ignored. * <p>The method reads from the InputStream or Reader contained in the StreamSource up to the end * of file unless a fatal error occurs. It does not close the InputStream or Reader; this is the caller's * responsibility.</p> * @param charChecker this checks XML characters against either the XML 1.0 or XML 1.1 rules * @return the text of the query */ public static String readSourceQuery(/*@NotNull*/ StreamSource ss, IntPredicate charChecker) throws XPathException { CharSequence queryText; if (ss.getInputStream() != null) { InputStream is = ss.getInputStream(); if (!is.markSupported()) { is = new BufferedInputStream(is); } String encoding = readEncoding(is); queryText = readInputStream(is, encoding, charChecker); } else if (ss.getReader() != null) { queryText = readQueryFromReader(ss.getReader(), charChecker); } else { throw new XPathException("Module URI Resolver must supply either an InputStream or a Reader"); } return queryText.toString(); }