OutputStream destination, final Properties outputProps) throws XPathException, IOException { if (exp.getExpression().isUpdatingExpression() && updating) { exp.runUpdate(dynamicEnv, agent); Set affectedDocuments = exp.runUpdate(dynamicEnv); if (affectedDocuments.contains(dynamicEnv.getContextItem())) { QueryResult.serialize((NodeInfo)dynamicEnv.getContextItem(), SequenceIterator results = exp.iterator(dynamicEnv); DocumentInfo resultDoc = QueryResult.wrap(results, config); QueryResult.serialize(resultDoc, exp.pull(dynamicEnv, new StreamResult(destination), outputProps); } else { exp.run(dynamicEnv, new StreamResult(destination), outputProps);
public boolean usesContextItem() { return this.xQuery.usesContextItem(); }
/** * Perform the query, sending the results to a previously specified destination * @throws net.sf.saxon.s9api.SaxonApiException if any dynamic error occurs during the query * @throws IllegalStateException if no Destination has been supplied for the query results */ public void run() throws SaxonApiException { try { expression.run(context, destination.getReceiver(expression.getExecutable().getConfiguration()), null); } catch (TransformerException e) { throw new SaxonApiException(e); } }
/** * Run the query in pull mode. From Saxon 9.8 this method is identical to {@link #run(DynamicQueryContext, Result, Properties)} * (supplying the default serialization properties from the configuration as the third argument) * @param dynamicEnv the dynamic context for query evaluation * @param destination the Receiver to accept the query results *usually a serializer) * @throws XPathException if a dynamic error occurs during the evaluation * @deprecated since 9.8. */ public void pull(DynamicQueryContext dynamicEnv, SequenceReceiver destination) throws XPathException { run(dynamicEnv, destination, getConfiguration().getDefaultSerializationProperties()); }
/** * Evaluate the query, and return an iterator over its results. * <p>This method must not be used with an updating query.</p> * * @return an Iterator<XdmItem>. The XdmSequenceIterator class is a standard Java Iterator with an additional close() * method, which should be called to release resources if the client does not intend to read any more items * from the iterator. * * @throws SaxonApiUncheckedException if a dynamic error is detected while constructing the iterator. * It is also possible for an SaxonApiUncheckedException to be thrown by the hasNext() method of the * returned iterator if a dynamic error occurs while evaluating the result sequence. * @throws IllegalStateException if this is an updating query * @since 9.5.1.5. Previously the method returned Iterator<XdmItem>; the signature changed in Saxon 9.5.1.5 for reasons * described in bug 2016. */ public XdmSequenceIterator<XdmItem> iterator() throws SaxonApiUncheckedException { if (expression.isUpdateQuery()) { throw new IllegalStateException("Query is updating"); } try { return new XdmSequenceIterator<>(expression.iterator(context)); } catch (XPathException e) { throw new SaxonApiUncheckedException(e); } }
/** * Get the statically-determined cardinality of the result of the query. This is the most precise cardinality * that the processor is able to determine from static examination of the query. * * @return the statically-determined cardinality of the result of the query * @since 9.1 */ /*@NotNull*/ public OccurrenceIndicator getResultCardinality() { int card = exp.getExpression().getCardinality(); return OccurrenceIndicator.getOccurrenceIndicator(card); }
/** * Get an iterator over the results of the query * @throws SaxonApiUncheckedException if a dynamic error is detected while constructing the iterator. * It is also possible for an SaxonApiUncheckedException to be thrown by the hasNext() method of the * returned iterator if a dynamic error occurs while evaluating the result sequence. */ public Iterator<XdmItem> iterator() throws SaxonApiUncheckedException { try { return new XdmSequenceIterator(expression.iterator(context)); } catch (XPathException e) { throw new SaxonApiUncheckedException(e); } }
if (isUpdateQuery()) { throw new XPathException("Cannot call run() on an updating query"); if (!env.getConfiguration().isCompatible(getExecutable().getConfiguration())) { throw new XPathException("The query must be compiled and executed under the same Configuration", SaxonErrorCode.SXXP0004); if (contextItem instanceof NodeInfo && ((NodeInfo) contextItem).getTreeInfo().isTyped() && !getExecutable().isSchemaAware()) { throw new XPathException("A typed input document can only be used with a schema-aware query"); Controller controller = newController(env); if (result instanceof Receiver) { ((Receiver)result).getPipelineConfiguration().setController(controller); Properties actualProperties = validateOutputProperties(controller, outputProperties); XPathContextMajor context = initialContext(env, controller); closeStreamIfNecessary((StreamResult) result, mustClose);
Controller controller = newController(); initializeController(env, controller); controller.setUseDocumentProjection(getPathMap()); Properties actualProperties = validateOutputProperties(controller, outputProperties); XPathContextMajor context = initialContext(env, controller);
throws XPathException, IOException { if (wrap && !pullMode) { SequenceIterator results = exp.iterator(dynamicEnv); DocumentInfo resultDoc = QueryResult.wrap(results, config); QueryResult.serialize(resultDoc, exp.pull(dynamicEnv, new StreamResult(destination), outputProps); } else { exp.run(dynamicEnv, new StreamResult(destination), outputProps);
if (isUpdateQuery()) { throw new XPathException("Cannot call iterator() on an updating query"); if (!env.getConfiguration().isCompatible(getExecutable().getConfiguration())) { throw new XPathException("The query must be compiled and executed under the same Configuration", SaxonErrorCode.SXXP0004); Controller controller = newController(env); if (contextItem instanceof NodeInfo && ((NodeInfo)contextItem).getTreeInfo().isTyped() && !getExecutable().isSchemaAware()) { throw new XPathException("A typed input document can only be used with a schema-aware query"); XPathContextMajor context = initialContext(env, controller);
Controller controller = newController(); initializeController(dynamicEnv, controller); XPathContextMajor context = initialContext(dynamicEnv, controller); try { PendingUpdateList pul = config.newPendingUpdateList();
final UserFunction fn = expression.getMainModule().getUserDefinedFunction( function.getNamespaceURI(), function.getLocalName(), arguments.length); if (fn == null) { controller = expression.newController(context); } else { context.initializeController(controller);
final Controller aXQController = exp.newController (aDynamicQueryContext); final FunctionLibraryList aFuncLibList = exp.getExecutable ().getFunctionLibrary (); for (final FunctionLibrary aFuncLib : aFuncLibList.getLibraryList ())
map = this.xQuery.getPathMap(); } else { map = new PathMap(this.xQuery.getExpression());
queryModule = saxonQuery.getStaticContext(); Iterator<?> moduleIter = queryModule.getExecutable().getQueryLibraryModules(); ArrayList<ModuleImport> importedModules = new ArrayList<ModuleImport>(); AbstractExpression body = exprFor (saxonQuery.getExpression()); String defaultCollation = queryModule.getDefaultCollationName(); if (defaultCollation.equals (CODEPOINT_COLLATION)) {
/** * Protected constructor * @param expression the XQuery expression */ protected XQueryEvaluator(Processor processor, XQueryExpression expression) { this.processor = processor; this.expression = expression; this.context = new DynamicQueryContext(expression.getExecutable().getConfiguration()); }
Controller controller = newController(); EventIterator iter = iterateEvents(controller, dynamicEnv); Properties actualProperties = validateOutputProperties(controller, outputProperties); SerializerFactory sf = config.getSerializerFactory(); PipelineConfiguration pipe = config.makePipelineConfiguration();
if (expression.isUpdateQuery()) { throw new IllegalStateException("Query is updating; cannot run with streaming"); SerializationProperties params = expression.getExecutable().getPrimarySerializationProperties(); Receiver receiver = destination.getReceiver(config.makePipelineConfiguration(), params); expression.runStreamed(context, source, receiver, null); } catch (TransformerException e) { throw new SaxonApiException(e);
System.err.println("Processing " + sourceInput.getSystemId()); if (!exp.getUnderlyingCompiledQuery().usesContextItem()) { System.err.println("Source document ignored - query does not access the context item"); return; builder.setDocumentProjectionQuery(exp); if (explain) { exp.getUnderlyingCompiledQuery().explainPathMap();