/// <summary> /// Compile a query supplied as a String. /// </summary> /// <remarks> /// Using this method the query processor is provided with a string of Unicode /// characters, so no decoding is necessary. Any encoding information present in the /// version declaration is therefore ignored. /// </remarks> /// <example> /// <code> /// XQueryExecutable q = compiler.Compile("distinct-values(//*/node-name()"); /// </code> /// </example> /// <param name="query">A string containing the source text of the query</param> /// <returns>An <c>XQueryExecutable</c> which represents the compiled query object. /// The XQueryExecutable may be run as many times as required, in the same or a different /// thread. The <c>XQueryExecutable</c> is not affected by any changes made to the <c>XQueryCompiler</c> /// once it has been compiled.</returns> /// <exception cref="StaticError">Throws a StaticError if errors were detected /// during static analysis of the query. Details of the errors will be added as StaticError /// objects to the ErrorList if supplied; otherwise they will be written to the standard /// error stream. The exception that is returned is merely a summary indicating the /// status.</exception> public XQueryExecutable Compile(String query) { try { JXQueryExpression exp = env.compileQuery(query); return(new XQueryExecutable(exp)); } catch (JXPathException e) { throw new StaticError(e); } }
/// <summary> /// Compile a query supplied as a Stream. /// </summary> /// <remarks> /// <para>The XQuery processor attempts to deduce the encoding of the query /// by looking for a byte-order-mark, or if none is present, by looking /// for the encoding declaration in the XQuery version declaration. /// For this to work, the stream must have the <c>CanSeek</c> property. /// If no encoding information is present, UTF-8 is assumed.</para> /// <para>The base URI of the query is set to the value of the <c>BaseUri</c> /// property. If this has not been set, then the base URI will be undefined, which /// means that any use of an expression that depends on the base URI will cause /// an error.</para> /// </remarks> /// <example> /// <code> /// XQueryExecutable q = compiler.Compile(new FileStream("input.xq", FileMode.Open, FileAccess.Read)); /// </code> /// </example> /// <param name="query">A stream containing the source text of the query</param> /// <returns>An <c>XQueryExecutable</c> which represents the compiled query object. /// The XQueryExecutable may be run as many times as required, in the same or a different /// thread. The <c>XQueryExecutable</c> is not affected by any changes made to the <c>XQueryCompiler</c> /// once it has been compiled.</returns> /// <exception cref="StaticError">Throws a StaticError if errors were detected /// during static analysis of the query. Details of the errors will be added as StaticError /// objects to the ErrorList if supplied; otherwise they will be written to the standard /// error stream. The exception that is returned is merely a summary indicating the /// status.</exception> public XQueryExecutable Compile(Stream query) { try { JXQueryExpression exp = env.compileQuery(new JDotNetInputStream(query), null); return(new XQueryExecutable(exp)); } catch (JXPathException e) { throw new StaticError(e); } }
// internal constructor internal XQueryEvaluator(JXQueryExpression exp) { this.exp = exp; this.context = new JDynamicQueryContext(exp.getConfiguration()); }
// internal constructor internal XQueryExecutable(JXQueryExpression exp) { this.exp = exp; }