diff --git a/exist-core/pom.xml b/exist-core/pom.xml
index 96cbbc310cf..262ffd0ac90 100644
--- a/exist-core/pom.xml
+++ b/exist-core/pom.xml
@@ -705,6 +705,7 @@
src/main/java/org/exist/xmlrpc/ACEAiderSerializer.java
src/main/java/org/exist/xquery/Cardinality.java
src/test/java/org/exist/xquery/ImportModuleTest.java
+ src/main/java/org/exist/xquery/Materializable.java
src/test/java/org/exist/xquery/XQueryContextAttributesTest.java
src/main/java/org/exist/xquery/functions/map/MapType.java
src/test/java/org/exist/xquery/functions/session/AbstractSessionTest.java
@@ -856,6 +857,7 @@ The original license statement is also included below.]]>
src/main/java/org/exist/xmlrpc/ACEAiderSerializer.java
src/main/java/org/exist/xquery/Cardinality.java
src/test/java/org/exist/xquery/ImportModuleTest.java
+ src/main/java/org/exist/xquery/Materializable.java
src/test/java/org/exist/xquery/XQueryContextAttributesTest.java
src/main/java/org/exist/xquery/functions/map/MapType.java
src/test/java/org/exist/xquery/functions/session/AbstractSessionTest.java
diff --git a/exist-core/src/main/java/org/exist/dom/QName.java b/exist-core/src/main/java/org/exist/dom/QName.java
index 8edfe148552..ab86dbf6f39 100644
--- a/exist-core/src/main/java/org/exist/dom/QName.java
+++ b/exist-core/src/main/java/org/exist/dom/QName.java
@@ -21,7 +21,7 @@
*/
package org.exist.dom;
-import org.exist.interpreter.Context;
+import org.exist.xquery.Context;
import org.exist.storage.ElementValue;
import org.exist.util.XMLNames;
import org.exist.xquery.Constants;
diff --git a/exist-core/src/main/java/org/exist/dom/persistent/SortedNodeSet.java b/exist-core/src/main/java/org/exist/dom/persistent/SortedNodeSet.java
index 90d1fd14935..88ecfb38641 100644
--- a/exist-core/src/main/java/org/exist/dom/persistent/SortedNodeSet.java
+++ b/exist-core/src/main/java/org/exist/dom/persistent/SortedNodeSet.java
@@ -274,7 +274,7 @@ private static final class IteratorItem extends OrderedLinkedList.Node {
public IteratorItem(final NodeProxy proxy, final PathExpr expr) {
this.proxy = proxy;
try {
- final Sequence seq = expr.eval(proxy);
+ final Sequence seq = expr.eval(proxy, null);
final StringBuilder buf = new StringBuilder();
final OrderedLinkedList strings = new OrderedLinkedList();
Item item;
diff --git a/exist-core/src/main/java/org/exist/http/urlrewrite/ModuleCall.java b/exist-core/src/main/java/org/exist/http/urlrewrite/ModuleCall.java
index af7a9973faa..1ef109f08cd 100644
--- a/exist-core/src/main/java/org/exist/http/urlrewrite/ModuleCall.java
+++ b/exist-core/src/main/java/org/exist/http/urlrewrite/ModuleCall.java
@@ -95,12 +95,12 @@ public void doRewrite(final HttpServletRequest request, final HttpServletRespons
final ContextItemDeclaration cid = call.getContext().getContextItemDeclartion();
final Sequence contextSequence;
if (cid != null) {
- contextSequence = cid.eval(null);
+ contextSequence = cid.eval(null, null);
} else {
contextSequence = null;
}
- final Sequence result = call.eval(contextSequence);
+ final Sequence result = call.eval(contextSequence, null);
if (LOG.isDebugEnabled()) {
LOG.debug("Found: {}", result.getItemCount());
}
diff --git a/exist-core/src/main/java/org/exist/interpreter/Compiled.java b/exist-core/src/main/java/org/exist/interpreter/Compiled.java
deleted file mode 100644
index 110f46ecca5..00000000000
--- a/exist-core/src/main/java/org/exist/interpreter/Compiled.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * eXist-db Open Source Native XML Database
- * Copyright (C) 2001 The eXist-db Authors
- *
- * info@exist-db.org
- * http://www.exist-db.org
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.exist.interpreter;
-
-import org.exist.source.Source;
-import org.exist.xquery.XPathException;
-import org.exist.xquery.XQueryContext;
-import org.exist.xquery.value.Sequence;
-
-public interface Compiled extends IPathExpr {
-
- public void reset();
-
- /**
- * @return the {@link Context} used to create this query
- */
- public XQueryContext getContext();
-
- public void setContext(Context context);
-
- /**
- * Execute the compiled query, optionally using the specified
- * sequence as context.
- *
- * @param contextSequence the context sequence.
- *
- * @throws XPathException if an error occurs during evaluation.
- */
- public Sequence eval(Sequence contextSequence) throws XPathException;
-
- /**
- * Is the compiled expression still valid? Returns false if, for example,
- * the source code of one of the imported modules has changed.
- */
- public boolean isValid();
-
- /**
- * Gets the source of this query.
- *
- * @return This query's source
- */
- public Source getSource();
-}
diff --git a/exist-core/src/main/java/org/exist/interpreter/Compiler.java b/exist-core/src/main/java/org/exist/interpreter/Compiler.java
deleted file mode 100644
index e6fc59aff2f..00000000000
--- a/exist-core/src/main/java/org/exist/interpreter/Compiler.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * eXist-db Open Source Native XML Database
- * Copyright (C) 2001 The eXist-db Authors
- *
- * info@exist-db.org
- * http://www.exist-db.org
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.exist.interpreter;
-
-import java.io.IOException;
-import java.util.Properties;
-
-import org.exist.source.Source;
-import org.exist.storage.XQueryPool;
-import org.exist.xquery.XPathException;
-import org.exist.xquery.value.Sequence;
-
-public interface Compiler {
-
- public Context newContext();
-
- public XQueryPool getXQueryPool();
-
- public Compiled compile(Context context, String expression) throws XPathException;
-
- public Compiled compile(Context context, Source source) throws XPathException, IOException;
-
- public Compiled compile(Context context, Source source, boolean xpointer) throws XPathException, IOException;
-
- public Sequence execute(Compiled expression, Sequence contextSequence) throws XPathException;
-
- public Sequence execute(Compiled expression, Sequence contextSequence, Properties outputProperties) throws XPathException;
-
- public Sequence execute(Compiled expression, Sequence contextSequence, boolean resetContext) throws XPathException;
-
- public Sequence execute(Compiled expression, Sequence contextSequence, Properties outputProperties, boolean resetContext) throws XPathException;
-
- public Sequence execute(String expression, Sequence contextSequence) throws XPathException;
-
-}
\ No newline at end of file
diff --git a/exist-core/src/main/java/org/exist/interpreter/ContextNS.java b/exist-core/src/main/java/org/exist/interpreter/ContextNS.java
deleted file mode 100644
index 2e0c4d69411..00000000000
--- a/exist-core/src/main/java/org/exist/interpreter/ContextNS.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * eXist-db Open Source Native XML Database
- * Copyright (C) 2001 The eXist-db Authors
- *
- * info@exist-db.org
- * http://www.exist-db.org
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.exist.interpreter;
-
-import java.util.Map;
-
-import org.exist.util.hashtable.NamePool;
-import org.exist.xquery.XPathException;
-import org.exist.xquery.value.AnyURIValue;
-
-public interface ContextNS {
-
- /**
- * Declare a user-defined static prefix/namespace mapping.
- *
- * eXist internally keeps a table containing all prefix/namespace mappings it found in documents, which have been previously stored into the
- * database. These default mappings need not to be declared explicitely.
- *
- * @param prefix the namespace prefix.
- * @param uri the namespace URI.
- *
- * @throws XPathException if an error occurs whilst declaring the namespace.
- */
- public void declareNamespace(String prefix, String uri) throws XPathException;
-
- public void declareNamespaces(Map namespaceMap);
-
- /**
- * Removes the namespace URI from the prefix/namespace mappings table.
- *
- * @param uri the namespace URI.
- */
- public void removeNamespace(String uri);
-
- /**
- * Declare an in-scope namespace. This is called during query execution.
- *
- * @param prefix the namespace prefix.
- * @param uri the namespace URI.
- */
- public void declareInScopeNamespace(String prefix, String uri);
-
- public String getInScopeNamespace(String prefix);
-
- public String getInScopePrefix(String uri);
-
- public String getInheritedNamespace(String prefix);
-
- public String getInheritedPrefix(String uri);
-
- /**
- * Return the namespace URI mapped to the registered prefix or null if the prefix is not registered.
- *
- * @param prefix the namespace prefix.
- *
- * @return namespace
- */
- public String getURIForPrefix(String prefix);
-
- /**
- * Get URI Prefix
- *
- * @param uri the namespace URI.
- *
- * @return the prefix mapped to the registered URI or null if the URI is not registered.
- */
- public String getPrefixForURI(String uri);
-
- /**
- * Returns the current default function namespace.
- *
- * @return current default function namespace
- */
- public String getDefaultFunctionNamespace();
-
- /**
- * Set the default function namespace. By default, this points to the namespace for XPath built-in functions.
- *
- * @param uri the namespace URI.
- *
- * @throws XPathException if an error occurs whilst setting the default function namespace.
- */
- public void setDefaultFunctionNamespace(String uri) throws XPathException;
-
- /**
- * Returns the current default element namespace.
- *
- * @return current default element namespace schema
- *
- * @throws XPathException if an error occurs whilst getting the default element namespace schema.
- */
- public String getDefaultElementNamespaceSchema() throws XPathException;
-
- /**
- * Set the default element namespace. By default, this points to the empty uri.
- *
- * @param uri the namespace URI.
- *
- * @throws XPathException if an error occurs whilst setting the default element namespace schema.
- */
- public void setDefaultElementNamespaceSchema(String uri) throws XPathException;
-
- /**
- * Returns the current default element namespace.
- *
- * @return current default element namespace
- *
- * @throws XPathException if an error occurs whilst getting the default element namespace.
- */
- public String getDefaultElementNamespace() throws XPathException;
-
- /**
- * Set the default element namespace. By default, this points to the empty uri.
- *
- * @param uri the namespace URI.
- * @param schema the schema
- *
- * @throws XPathException if an error occurs whilst getting the default element namespace.
- */
- public void setDefaultElementNamespace(String uri, String schema) throws XPathException;
-
- /**
- * Returns true if namespaces for constructed element and document nodes should be preserved on copy by default.
- *
- * @return true if namespaces are preserved, false otherwise.
- */
- public boolean preserveNamespaces();
-
- /**
- * Set whether namespaces should be preserved.
- *
- * @param preserve true if namespaces should be preserved, false otherwise.
- */
- public void setPreserveNamespaces(final boolean preserve);
-
- /**
- * Returns true if namespaces for constructed element and document nodes should be inherited on copy by default.
- *
- * @return true if namespaces are inheirted, false otherwise.
- */
- public boolean inheritNamespaces();
-
- /**
- * Set to true if namespaces for constructed element and document nodes should be inherited on copy by default.
- *
- * @param inherit true if namespaces are inheirted, false otherwise.
- */
- public void setInheritNamespaces(final boolean inherit);
-
- /**
- * Returns the shared name pool used by all in-memory documents which are created within this query context. Create a name pool for every document
- * would be a waste of memory, especially since it is likely that the documents contain elements or attributes with similar names.
- *
- * @return the shared name pool
- */
- public NamePool getSharedNamePool();
-
- /**
- * Set the base URI for the evaluation context.
- *
- * This is the URI returned by the fn:base-uri() function.
- *
- * @param uri the namespace URI.
- */
- public void setBaseURI(AnyURIValue uri);
-
- /**
- * Set the base URI for the evaluation context.
- *
- * A base URI specified via the base-uri directive in the XQuery prolog overwrites any other setting.
- *
- * @param uri the namespace URI.
- * @param setInProlog true if the base-uri was defined in the prolog.
- */
- public void setBaseURI(AnyURIValue uri, boolean setInProlog);
-
- /**
- * Determine if the base-uri is declared.
- *
- * @return true if the base-uri is declared, false otherwise.
- */
- public boolean isBaseURIDeclared();
-
- /**
- * Get the base URI of the evaluation context.
- *
- * This is the URI returned by the fn:base-uri() function.
- *
- * @return base URI of the evaluation context
- *
- * @throws XPathException if an error occurs whilst setting the base-uri
- */
- public AnyURIValue getBaseURI() throws XPathException;
-
- public void pushInScopeNamespaces();
-
- /**
- * Push all in-scope namespace declarations onto the stack.
- *
- * @param inherit true if namespaces should be inheirted when pushing
- */
- public void pushInScopeNamespaces(boolean inherit);
-
- public void popInScopeNamespaces();
-
- public void pushNamespaceContext();
-
- public void popNamespaceContext();
-}
\ No newline at end of file
diff --git a/exist-core/src/main/java/org/exist/interpreter/ExpressionVisitor.java b/exist-core/src/main/java/org/exist/interpreter/ExpressionVisitor.java
deleted file mode 100644
index 91a87a3ab99..00000000000
--- a/exist-core/src/main/java/org/exist/interpreter/ExpressionVisitor.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * eXist-db Open Source Native XML Database
- * Copyright (C) 2001 The eXist-db Authors
- *
- * info@exist-db.org
- * http://www.exist-db.org
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.exist.interpreter;
-
-import org.exist.xquery.Expression;
-
-public interface ExpressionVisitor {
-
- public void visit(Expression expression);
-
-}
diff --git a/exist-core/src/main/java/org/exist/interpreter/Function.java b/exist-core/src/main/java/org/exist/interpreter/Function.java
deleted file mode 100644
index 77d55512206..00000000000
--- a/exist-core/src/main/java/org/exist/interpreter/Function.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * eXist-db Open Source Native XML Database
- * Copyright (C) 2001 The eXist-db Authors
- *
- * info@exist-db.org
- * http://www.exist-db.org
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.exist.interpreter;
-
-import java.util.List;
-
-import org.exist.dom.QName;
-import org.exist.xquery.Expression;
-import org.exist.xquery.XPathException;
-import org.exist.xquery.value.Item;
-import org.exist.xquery.value.Sequence;
-
-public interface Function extends IPathExpr {
-
- /**
- * Set the parent expression of this function, i.e. the
- * expression from which the function is called.
- *
- * @param parent the parent expression.
- */
- public void setParent(Expression parent);
-
- /**
- * Returns the expression from which this function
- * gets called.
- *
- * @return the parent expression.
- */
- public Expression getParent();
-
- /**
- * Set the (static) arguments for this function from a list of expressions.
- *
- * This will also check the type and cardinality of the
- * passed argument expressions.
- *
- * @param arguments the statis arguments to the function.
- *
- * @throws XPathException if an error occurs whilst setting the arguments.
- */
- public void setArguments(List arguments) throws XPathException;
-
- public Sequence[] getArguments(Sequence contextSequence, Item contextItem) throws XPathException;
-
- /**
- * Get an argument expression by its position in the
- * argument list.
- *
- * @param pos the position of the argument
- *
- * @return the argument at the position
- */
- public Expression getArgument(int pos);
-
- /**
- * Get the number of arguments passed to this function.
- *
- * @return number of arguments
- */
- public int getArgumentCount();
-
- /**
- * Return the name of this function.
- *
- * @return name of this function
- */
- public QName getName();
-
- /**
- * Get the signature of this function.
- *
- * @return signature of this function
- */
- public FunctionSignature getSignature();
-
- public boolean isCalledAs(String localName);
-
-}
\ No newline at end of file
diff --git a/exist-core/src/main/java/org/exist/interpreter/FunctionCall.java b/exist-core/src/main/java/org/exist/interpreter/FunctionCall.java
deleted file mode 100644
index db3edba5d25..00000000000
--- a/exist-core/src/main/java/org/exist/interpreter/FunctionCall.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * eXist-db Open Source Native XML Database
- * Copyright (C) 2001 The eXist-db Authors
- *
- * info@exist-db.org
- * http://www.exist-db.org
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.exist.interpreter;
-
-import org.exist.dom.persistent.DocumentSet;
-import org.exist.dom.QName;
-import org.exist.xquery.XPathException;
-import org.exist.xquery.value.Item;
-import org.exist.xquery.value.Sequence;
-
-public interface FunctionCall extends Function {
-
- /**
- * Called by {@link Context} to resolve a call to a function that has not
- * yet been declared. XQueryContext remembers all calls to undeclared functions
- * and tries to resolve them after parsing has completed.
- *
- * @param functionDef the function definition.
- *
- * @throws XPathException if an error occurs whilst resolving the forward references
- */
- public void resolveForwardReference(Function functionDef) throws XPathException;
-
- public QName getQName();
-
- /**
- * Evaluate the function.
- *
- * @param contextSequence the context sequence.
- * @param contextItem the context item
- * @param seq the sequence
- *
- * @return the result sequence.
- *
- * @throws XPathException if an error occurs during evaluatiion
- */
- public Sequence evalFunction(Sequence contextSequence, Item contextItem, Sequence[] seq) throws XPathException;
-
- public Sequence evalFunction(Sequence contextSequence, Item contextItem, Sequence[] seq, DocumentSet[] contextDocs) throws XPathException;
-
- public boolean isRecursive();
-
-}
\ No newline at end of file
diff --git a/exist-core/src/main/java/org/exist/interpreter/FunctionId.java b/exist-core/src/main/java/org/exist/interpreter/FunctionId.java
deleted file mode 100644
index 4274940c933..00000000000
--- a/exist-core/src/main/java/org/exist/interpreter/FunctionId.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * eXist-db Open Source Native XML Database
- * Copyright (C) 2001 The eXist-db Authors
- *
- * info@exist-db.org
- * http://www.exist-db.org
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.exist.interpreter;
-
-/**
- * Used to uniquely identify a function by its function name and arity.
- *
- */
-public interface FunctionId extends Comparable {
-
-}
diff --git a/exist-core/src/main/java/org/exist/interpreter/FunctionSignature.java b/exist-core/src/main/java/org/exist/interpreter/FunctionSignature.java
deleted file mode 100644
index 98038ef8843..00000000000
--- a/exist-core/src/main/java/org/exist/interpreter/FunctionSignature.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * eXist-db Open Source Native XML Database
- * Copyright (C) 2001 The eXist-db Authors
- *
- * info@exist-db.org
- * http://www.exist-db.org
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.exist.interpreter;
-
-import org.exist.dom.QName;
-import org.exist.xquery.value.SequenceType;
-
-public interface FunctionSignature {
-
- public QName getName();
-
- public int getArgumentCount();
-
- public FunctionId getFunctionId();
-
- public SequenceType getReturnType();
-
- public void setReturnType(SequenceType type);
-
- public SequenceType[] getArgumentTypes();
-
- public void setArgumentTypes(SequenceType[] types);
-
- public String getDescription();
-
- public boolean isOverloaded();
-
- public boolean isDeprecated();
-
- public String getDeprecated();
-
- public void setDeprecated(String message);
-
-}
\ No newline at end of file
diff --git a/exist-core/src/main/java/org/exist/interpreter/IPathExpr.java b/exist-core/src/main/java/org/exist/interpreter/IPathExpr.java
deleted file mode 100644
index caf05c82383..00000000000
--- a/exist-core/src/main/java/org/exist/interpreter/IPathExpr.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * eXist-db Open Source Native XML Database
- * Copyright (C) 2001 The eXist-db Authors
- *
- * info@exist-db.org
- * http://www.exist-db.org
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.exist.interpreter;
-
-import java.io.Writer;
-import java.util.List;
-
-import org.exist.dom.persistent.DocumentSet;
-import org.exist.xquery.Expression;
-
-public interface IPathExpr extends Expression {
-
- /**
- * Add an arbitrary expression to this object's list of child-expressions.
- *
- * @param expr the expression.
- */
- public void add(Expression expr);
-
- /**
- * Add all the child-expressions from another PathExpr to this object's
- * child-expressions.
- *
- * @param path the path expression.
- */
- public void add(IPathExpr path);
-
- /**
- * Add another PathExpr to this object's expression list.
- *
- * @param path the path expression.
- */
- public void addPath(IPathExpr path);
-
- /**
- * Add a predicate expression to the list of expressions. The predicate is
- * added to the last expression in the list.
- *
- * @param pred the predicate.
- */
- public void addPredicate(IPredicate pred);
-
- /**
- * Replace the given expression by a new expression.
- *
- * @param oldExpr the old expression
- * @param newExpr the new expression to replace the old
- */
- public void replaceExpression(Expression oldExpr, Expression newExpr);
-
- public Expression getParent();
-
- public DocumentSet getDocumentSet();
-
- /**
- * @deprecated use {@link #getSubExpression(int)}
- *
- * @param pos the position of the expression.
- *
- * @return the expression
- */
- @Deprecated
- public Expression getExpression(int pos);
-
- public Expression getLastExpression();
-
- /**
- * @deprecated use {@link #getSubExpressionCount()}
- *
- * @return the length of the path expression
- */
- @Deprecated
- public int getLength();
-
- public void setUseStaticContext(boolean staticContext);
-
- public void accept(ExpressionVisitor visitor);
-
- public void replaceLastExpression(Expression s);
-
- public String getLiteralValue();
-
- public void reset();
-
- public boolean isValid();
-
- public void dump(Writer writer);
-
- public void setContext(Context context);
-
- public List getSteps();
-
-}
\ No newline at end of file
diff --git a/exist-core/src/main/java/org/exist/interpreter/IPragma.java b/exist-core/src/main/java/org/exist/interpreter/IPragma.java
deleted file mode 100644
index e5a074ba883..00000000000
--- a/exist-core/src/main/java/org/exist/interpreter/IPragma.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * eXist-db Open Source Native XML Database
- * Copyright (C) 2001 The eXist-db Authors
- *
- * info@exist-db.org
- * http://www.exist-db.org
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.exist.interpreter;
-
-import org.exist.dom.QName;
-import org.exist.xquery.AnalyzeContextInfo;
-import org.exist.xquery.Expression;
-import org.exist.xquery.XPathException;
-import org.exist.xquery.value.Item;
-import org.exist.xquery.value.Sequence;
-
-public interface IPragma {
-
- public void analyze(AnalyzeContextInfo contextInfo) throws XPathException;
-
- public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException;
-
- public void before(Context context) throws XPathException;
-
- public void before(Context context, Expression expression) throws XPathException;
-
- public void after(Context context) throws XPathException;
-
- public void after(Context context, Expression expression) throws XPathException;
-
- public void resetState(boolean postOptimization);
-
- public String getContents();
-
- public QName getQName();
-}
\ No newline at end of file
diff --git a/exist-core/src/main/java/org/exist/interpreter/IPredicate.java b/exist-core/src/main/java/org/exist/interpreter/IPredicate.java
deleted file mode 100644
index f52824912f5..00000000000
--- a/exist-core/src/main/java/org/exist/interpreter/IPredicate.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * eXist-db Open Source Native XML Database
- * Copyright (C) 2001 The eXist-db Authors
- *
- * info@exist-db.org
- * http://www.exist-db.org
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.exist.interpreter;
-
-import org.exist.xquery.XPathException;
-import org.exist.xquery.value.Item;
-import org.exist.xquery.value.Sequence;
-
-public interface IPredicate extends IPathExpr {
-
- public Sequence preprocess() throws XPathException;
-
- public Boolean matchPredicate(Sequence contextSequence, Item contextItem, int mode) throws XPathException;
-
- public Sequence evalPredicate(Sequence outerSequence, Sequence contextSequence, int mode) throws XPathException;
-
- public int getExecutionMode();
-}
\ No newline at end of file
diff --git a/exist-core/src/main/java/org/exist/interpreter/LocalVariable.java b/exist-core/src/main/java/org/exist/interpreter/LocalVariable.java
deleted file mode 100644
index 8b498cb9e93..00000000000
--- a/exist-core/src/main/java/org/exist/interpreter/LocalVariable.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * eXist-db Open Source Native XML Database
- * Copyright (C) 2001 The eXist-db Authors
- *
- * info@exist-db.org
- * http://www.exist-db.org
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.exist.interpreter;
-
-import org.exist.xquery.Variable;
-
-public interface LocalVariable extends Variable {
-
- public void setAfter(T var);
-
- public void addAfter(T var);
-
- public T getBefore();
-
-
-}
diff --git a/exist-core/src/main/java/org/exist/interpreter/WatchDog.java b/exist-core/src/main/java/org/exist/interpreter/WatchDog.java
deleted file mode 100644
index af0fedce105..00000000000
--- a/exist-core/src/main/java/org/exist/interpreter/WatchDog.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * eXist-db Open Source Native XML Database
- * Copyright (C) 2001 The eXist-db Authors
- *
- * info@exist-db.org
- * http://www.exist-db.org
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.exist.interpreter;
-
-import org.exist.dom.memtree.MemTreeBuilder;
-import org.exist.xquery.Expression;
-import org.exist.xquery.Option;
-import org.exist.xquery.TerminatedException;
-import org.exist.xquery.XPathException;
-
-public interface WatchDog {
-
- public void setTimeoutFromOption(Option option) throws XPathException;
-
- public void setMaxNodes(int maxNodes);
-
- public void setMaxNodesFromOption(Option option) throws XPathException;
-
- public void proceed(Expression expr) throws TerminatedException;
-
- public void proceed(Expression expr, MemTreeBuilder builder) throws TerminatedException;
-
- public void cleanUp();
-
- public void kill(long waitTime);
-
- public Context getContext();
-
- public long getStartTime();
-
- public void reset();
-
- public boolean isTerminating();
-
-}
\ No newline at end of file
diff --git a/exist-core/src/main/java/org/exist/security/internal/SMEvents.java b/exist-core/src/main/java/org/exist/security/internal/SMEvents.java
index 5e397104be0..f7a78ee2c1e 100644
--- a/exist-core/src/main/java/org/exist/security/internal/SMEvents.java
+++ b/exist-core/src/main/java/org/exist/security/internal/SMEvents.java
@@ -125,13 +125,13 @@ protected void runScript(Subject subject, String scriptURI, String script, QName
final Sequence contextSequence;
final ContextItemDeclaration cid = context.getContextItemDeclartion();
if(cid != null) {
- contextSequence = cid.eval(null);
+ contextSequence = cid.eval(null, null);
} else {
contextSequence = NodeSet.EMPTY_SET;
}
call.analyze(new AnalyzeContextInfo());
- call.eval(contextSequence);
+ call.eval(contextSequence, null);
}
} catch(final XPathException e) {
//XXX: log
diff --git a/exist-core/src/main/java/org/exist/xquery/AbstractExpression.java b/exist-core/src/main/java/org/exist/xquery/AbstractExpression.java
index d5f14506307..7ca962dbd75 100644
--- a/exist-core/src/main/java/org/exist/xquery/AbstractExpression.java
+++ b/exist-core/src/main/java/org/exist/xquery/AbstractExpression.java
@@ -66,11 +66,6 @@ public int getContextId() {
return contextId;
}
- @Override
- public Sequence eval(Sequence contextSequence) throws XPathException {
- return eval(contextSequence, null);
- }
-
@Override
public void resetState(boolean postOptimization) {
contextDocSet = null;
diff --git a/exist-core/src/main/java/org/exist/xquery/ArrowOperator.java b/exist-core/src/main/java/org/exist/xquery/ArrowOperator.java
index fb1a9955efa..3afcf45b71a 100644
--- a/exist-core/src/main/java/org/exist/xquery/ArrowOperator.java
+++ b/exist-core/src/main/java/org/exist/xquery/ArrowOperator.java
@@ -93,7 +93,7 @@ public Sequence eval(Sequence contextSequence, final Item contextItem) throws XP
if (contextItem != null) {
contextSequence = contextItem.toSequence();
}
- contextSequence = leftExpr.eval(contextSequence);
+ contextSequence = leftExpr.eval(contextSequence, null);
final FunctionReference fref;
if (fcall != null) {
diff --git a/exist-core/src/main/java/org/exist/xquery/CastExpression.java b/exist-core/src/main/java/org/exist/xquery/CastExpression.java
index e9202b72b9f..570aaef6c41 100644
--- a/exist-core/src/main/java/org/exist/xquery/CastExpression.java
+++ b/exist-core/src/main/java/org/exist/xquery/CastExpression.java
@@ -217,7 +217,7 @@ public void setArguments(final List arguments) throws XPathException
@Override
public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException {
- return castExpression.eval(contextSequence);
+ return castExpression.eval(contextSequence, null);
}
}
}
diff --git a/exist-core/src/main/java/org/exist/xquery/CompiledXQuery.java b/exist-core/src/main/java/org/exist/xquery/CompiledXQuery.java
index d21f1f9240b..8d95d666751 100644
--- a/exist-core/src/main/java/org/exist/xquery/CompiledXQuery.java
+++ b/exist-core/src/main/java/org/exist/xquery/CompiledXQuery.java
@@ -24,6 +24,7 @@
import java.io.Writer;
import org.exist.source.Source;
+import org.exist.xquery.value.Item;
import org.exist.xquery.value.Sequence;
import org.xmldb.api.base.CompiledExpression;
@@ -51,12 +52,14 @@ public interface CompiledXQuery extends CompiledExpression {
* sequence as context.
*
* @param contextSequence the context sequence
+ * @param contextItem a single item, taken from context. This defines the item,
+ * the expression should work on.
*
* @return the result.
*
* @throws XPathException if an error occurs during evaluation.
*/
- public Sequence eval(Sequence contextSequence) throws XPathException;
+ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException;
/**
* Is the compiled expression still valid? Returns false if, for example,
diff --git a/exist-core/src/main/java/org/exist/interpreter/Context.java b/exist-core/src/main/java/org/exist/xquery/Context.java
similarity index 99%
rename from exist-core/src/main/java/org/exist/interpreter/Context.java
rename to exist-core/src/main/java/org/exist/xquery/Context.java
index 4cc72d3b7b4..3c6d28e3966 100644
--- a/exist-core/src/main/java/org/exist/interpreter/Context.java
+++ b/exist-core/src/main/java/org/exist/xquery/Context.java
@@ -19,7 +19,7 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.exist.interpreter;
+package org.exist.xquery;
import java.io.IOException;
import java.util.*;
diff --git a/exist-core/src/main/java/org/exist/xquery/DebuggableExpression.java b/exist-core/src/main/java/org/exist/xquery/DebuggableExpression.java
index e1d339c030b..96ca504b481 100644
--- a/exist-core/src/main/java/org/exist/xquery/DebuggableExpression.java
+++ b/exist-core/src/main/java/org/exist/xquery/DebuggableExpression.java
@@ -61,10 +61,6 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
}
}
- public Sequence eval(Sequence contextSequence) throws XPathException {
- return eval(contextSequence, null);
- }
-
public void setPrimaryAxis(int axis) {
expression.setPrimaryAxis(axis);
}
diff --git a/exist-core/src/main/java/org/exist/xquery/Expression.java b/exist-core/src/main/java/org/exist/xquery/Expression.java
index 78404d39309..de4afa9c099 100644
--- a/exist-core/src/main/java/org/exist/xquery/Expression.java
+++ b/exist-core/src/main/java/org/exist/xquery/Expression.java
@@ -25,16 +25,12 @@
import org.exist.source.Source;
import org.exist.xquery.parser.XQueryAST;
import org.exist.xquery.util.ExpressionDumper;
-import org.exist.xquery.value.Item;
-import org.exist.xquery.value.Sequence;
/**
* Base interface implemented by all classes which are part
- * of an XQuery/XPath expression. The main method is
- * {@link #eval(Sequence, Item)}. Please
- * read the description there.
+ * of an XQuery/XPath expression.
*/
-public interface Expression {
+public interface Expression extends Materializable {
// Flags to be passed to analyze:
/**
@@ -101,63 +97,16 @@ public interface Expression {
/**
* Statically analyze the expression and its subexpressions.
- *
+ *
* During the static analysis phase, the query engine can detect
* unknown variables and some type errors.
*
* @param contextInfo the context infomation.
- *
+ *
* @throws XPathException if an error occurs during the analysis.
*/
public void analyze(AnalyzeContextInfo contextInfo) throws XPathException;
- /**
- * Evaluate the expression represented by this object.
- *
- * Depending on the context in which this expression is executed,
- * either the context sequence, the context item or both of them may
- * be set. An implementing class should know how to handle this.
- *
- * The general contract is as follows: if the {@link Dependency#CONTEXT_ITEM}
- * bit is set in the bit field returned by {@link #getDependencies()}, the eval method will
- * be called once for every item in the context sequence. The contextItem
- * parameter will be set to the current item. Otherwise, the eval method will only be called
- * once for the whole context sequence and contextItem will be null.
- *
- * eXist tries to process the entire context set in one, single step whenever
- * possible. Thus, most classes only expect context to contain a list of
- * nodes which represents the current context of the expression.
- *
- * The position() function in XPath is an example for an expression,
- * which requires both, context sequence and context item to be set.
- *
- * The context sequence might be a node set, a sequence of atomic values or a single
- * node or atomic value.
- *
- * @param contextSequence the current context sequence.
- * @param contextItem a single item, taken from context. This defines the item,
- * the expression should work on.
- *
- * @return the result sequence.
- *
- * @throws XPathException if an error occurs during evaluation.
- */
- public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException;
-
- /**
- * Evaluate the expression represented by this object.
- *
- * An overloaded method which just passes the context sequence depending on the
- * expression context.
- *
- * @param contextSequence the current context sequence.
- *
- * @return the result sequence.
- *
- * @throws XPathException if an error occurs during evaluation.
- */
- public Sequence eval(Sequence contextSequence) throws XPathException;
-
public void setPrimaryAxis(int axis);
public int getPrimaryAxis();
diff --git a/exist-core/src/main/java/org/exist/xquery/ExternalModuleImpl.java b/exist-core/src/main/java/org/exist/xquery/ExternalModuleImpl.java
index f0b659f1fe6..1a6c5054f76 100644
--- a/exist-core/src/main/java/org/exist/xquery/ExternalModuleImpl.java
+++ b/exist-core/src/main/java/org/exist/xquery/ExternalModuleImpl.java
@@ -237,7 +237,7 @@ public boolean isVarDeclared(QName qname) {
}
decl.analyze(declContextInfo);
- decl.eval(getContext().getContextItem());
+ decl.eval(getContext().getContextItem(), null);
var = mStaticVariables.get(qname);
}
if (var == null) {
diff --git a/exist-core/src/main/java/org/exist/xquery/ForExpr.java b/exist-core/src/main/java/org/exist/xquery/ForExpr.java
index 826f2052097..bb1fceec5ac 100644
--- a/exist-core/src/main/java/org/exist/xquery/ForExpr.java
+++ b/exist-core/src/main/java/org/exist/xquery/ForExpr.java
@@ -245,7 +245,7 @@ private void processItem(LocalVariable var, Item contextItem, Sequence in, Seque
//Reset the context position
context.setContextSequencePosition(0, null);
- resultSequence.addAll(returnExpr.eval(null));
+ resultSequence.addAll(returnExpr.eval(null, null));
// free resources
var.destroy(context, resultSequence);
diff --git a/exist-core/src/main/java/org/exist/xquery/GeneralComparison.java b/exist-core/src/main/java/org/exist/xquery/GeneralComparison.java
index e600c6a373a..f7fcd34ba92 100644
--- a/exist-core/src/main/java/org/exist/xquery/GeneralComparison.java
+++ b/exist-core/src/main/java/org/exist/xquery/GeneralComparison.java
@@ -326,7 +326,7 @@ public NodeSet preSelect( Sequence contextSequence, boolean useContext ) throws
LOG.trace("Using QName index on type {}", Type.getTypeName(indexType));
}
- final Sequence rightSeq = getRight().eval( contextSequence );
+ final Sequence rightSeq = getRight().eval(contextSequence, null);
// if the right hand sequence has more than one item, we need to merge them
// into preselectResult
@@ -469,7 +469,7 @@ public Sequence eval( Sequence contextSequence, Item contextItem ) throws XPathE
if( ( !Dependency.dependsOn( rightOpDeps, Dependency.CONTEXT_ITEM ) ) ) {
result = quickNodeSetCompare( contextSequence );
} else {
- final NodeSet nodes = ( NodeSet )getLeft().eval( contextSequence );
+ final NodeSet nodes = ( NodeSet )getLeft().eval(contextSequence, null);
result = nodeSetCompare( nodes, contextSequence );
}
} else {
@@ -477,7 +477,7 @@ public Sequence eval( Sequence contextSequence, Item contextItem ) throws XPathE
}
} else {
contextStep.setPreloadedData( preselectResult.getDocumentSet(), preselectResult );
- result = getLeft().eval( contextSequence ).toNodeSet();
+ result = getLeft().eval(contextSequence, null).toNodeSet();
// the expression can be called multiple times, so we need to clear the previous preselectResult
preselectResult = null;
}
@@ -627,7 +627,7 @@ protected Sequence nodeSetCompare( NodeSet nodes, Sequence contextSequence ) thr
final AtomicValue lv = item.atomize();
do {
- final Sequence rs = getRight().eval( context.getNode().toSequence() );
+ final Sequence rs = getRight().eval(context.getNode().toSequence(), null);
for( final SequenceIterator i2 = Atomize.atomize(rs).iterate(); i2.hasNext(); ) {
final AtomicValue rv = i2.nextItem().atomize();
@@ -642,7 +642,7 @@ protected Sequence nodeSetCompare( NodeSet nodes, Sequence contextSequence ) thr
for( final NodeProxy item : nodes ) {
final AtomicValue lv = item.atomize();
- final Sequence rs = getRight().eval( contextSequence );
+ final Sequence rs = getRight().eval(contextSequence, null);
for( final SequenceIterator i2 = Atomize.atomize(rs).iterate(); i2.hasNext(); ) {
final AtomicValue rv = i2.nextItem().atomize();
@@ -687,7 +687,7 @@ protected Sequence quickNodeSetCompare( Sequence contextSequence ) throws XPathE
final long start = System.currentTimeMillis();
//get the NodeSet on the left
- final Sequence leftSeq = getLeft().eval( contextSequence );
+ final Sequence leftSeq = getLeft().eval(contextSequence, null);
if( !leftSeq.isPersistentSet() ) {
return( genericCompare( leftSeq, contextSequence, null ) );
@@ -704,7 +704,7 @@ protected Sequence quickNodeSetCompare( Sequence contextSequence ) throws XPathE
}
//get the Sequence on the right
- final Sequence rightSeq = getRight().eval( contextSequence );
+ final Sequence rightSeq = getRight().eval(contextSequence, null);
//nothing on the right, so nothing to do
if( rightSeq.isEmpty() ) {
@@ -1260,7 +1260,7 @@ protected Collator getCollator( Sequence contextSequence ) throws XPathException
String collationURI;
if( collationArg instanceof Expression ) {
- collationURI = ( ( Expression )collationArg ).eval( contextSequence ).getStringValue();
+ collationURI = ( ( Expression )collationArg ).eval(contextSequence, null).getStringValue();
} else if( collationArg instanceof StringValue ) {
collationURI = ( ( StringValue )collationArg ).getStringValue();
} else {
diff --git a/exist-core/src/main/java/org/exist/xquery/GroupByClause.java b/exist-core/src/main/java/org/exist/xquery/GroupByClause.java
index 82e31951818..1d22c8c277f 100644
--- a/exist-core/src/main/java/org/exist/xquery/GroupByClause.java
+++ b/exist-core/src/main/java/org/exist/xquery/GroupByClause.java
@@ -90,7 +90,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
final List groupingValues = new ArrayList<>();
final List groupingKeys = new ArrayList<>();
for (GroupSpec spec: groupSpecs) {
- final Sequence groupingSeq = spec.getGroupExpression().eval(null);
+ final Sequence groupingSeq = spec.getGroupExpression().eval(null, null);
if (groupingSeq.getItemCount() > 1) {
throw new XPathException(this, ErrorCodes.XPTY0004, "Grouping variable " + spec.getKeyVarName() + " " +
"evaluates to more than one item");
@@ -164,7 +164,7 @@ public Sequence postEval(final Sequence seq) throws XPathException {
final LocalVariable var = data.variables.get(entry.getKey());
var.setValue(entry.getValue());
}
- final Sequence r = returnExpr.eval(null);
+ final Sequence r = returnExpr.eval(null, null);
result.addAll(r);
}
} finally {
diff --git a/exist-core/src/main/java/org/exist/xquery/Lookup.java b/exist-core/src/main/java/org/exist/xquery/Lookup.java
index b7b33d078d2..717dfb1672b 100644
--- a/exist-core/src/main/java/org/exist/xquery/Lookup.java
+++ b/exist-core/src/main/java/org/exist/xquery/Lookup.java
@@ -81,7 +81,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
} else if (contextExpression == null) {
leftSeq = contextSequence;
} else {
- leftSeq = contextExpression.eval(contextSequence);
+ leftSeq = contextExpression.eval(contextSequence, null);
}
final int contextType = leftSeq.getItemType();
@@ -96,7 +96,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
"expression to the left of a lookup operator needs to be a sequence of maps or arrays");
}
if (keyExpression != null) {
- keys = keyExpression.eval(contextSequence);
+ keys = keyExpression.eval(contextSequence, null);
if (keys.isEmpty()) {
return Sequence.EMPTY_SEQUENCE;
}
diff --git a/exist-core/src/main/java/org/exist/xquery/Materializable.java b/exist-core/src/main/java/org/exist/xquery/Materializable.java
new file mode 100644
index 00000000000..7f1782f8989
--- /dev/null
+++ b/exist-core/src/main/java/org/exist/xquery/Materializable.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2014, Evolved Binary Ltd
+ *
+ * This file was originally ported from FusionDB to eXist-db by
+ * Evolved Binary, for the benefit of the eXist-db Open Source community.
+ * Only the ported code as it appears in this file, at the time that
+ * it was contributed to eXist-db, was re-licensed under The GNU
+ * Lesser General Public License v2.1 only for use in eXist-db.
+ *
+ * This license grant applies only to a snapshot of the code as it
+ * appeared when ported, it does not offer or infer any rights to either
+ * updates of this source code or access to the original source code.
+ *
+ * The GNU Lesser General Public License v2.1 only license follows.
+ *
+ * ---------------------------------------------------------------------
+ *
+ * Copyright (C) 2014, Evolved Binary Ltd
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; version 2.1.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.exist.xquery;
+
+import org.exist.xquery.value.Item;
+import org.exist.xquery.value.Sequence;
+
+import javax.annotation.Nullable;
+
+/**
+ * Marks an expression as being Materializable as per the
+ * Materialization query execution model.
+ *
+ * @author Adam Retter
+ */
+public interface Materializable {
+
+ /**
+ * Materialize the result.
+ *
+ * Depending on the context in which this expression is executed,
+ * either the context sequence, the context item or both of them may
+ * be set. An implementing class should know how to handle this.
+ *
+ * The general contract is as follows: if the {@link Dependency#CONTEXT_ITEM}
+ * bit is set in the bit field returned by {@link Expression#getDependencies()}, the eval method will
+ * be called once for every item in the context sequence. The contextItem
+ * parameter will be set to the current item. Otherwise, the eval method will only be called
+ * once for the whole context sequence and contextItem will be null.
+ *
+ * eXist-db tries to process the entire context set in one, single step whenever
+ * possible. Thus, most classes only expect context to contain a list of
+ * nodes which represents the current context of the expression.
+ *
+ * The position() function in XPath is an example for an expression,
+ * which requires both, context sequence and context item to be set.
+ *
+ * The context sequence might be a node set, a sequence of atomic values or a single
+ * node or atomic value.
+ *
+ * @param contextSequence the current context sequence, or null if there is no context sequence.
+ * @param contextItem a single item, taken from context, or null if there is no context item.
+ * This defines the item, the expression should work on.
+ *
+ * @return the result sequence.
+ *
+ * @throws XPathException if an error occurs during evaluation.
+ */
+ Sequence eval(@Nullable Sequence contextSequence, @Nullable Item contextItem) throws XPathException;
+}
diff --git a/exist-core/src/main/java/org/exist/xquery/OpSimpleMap.java b/exist-core/src/main/java/org/exist/xquery/OpSimpleMap.java
index 346085d6095..7a4e31e6ee0 100644
--- a/exist-core/src/main/java/org/exist/xquery/OpSimpleMap.java
+++ b/exist-core/src/main/java/org/exist/xquery/OpSimpleMap.java
@@ -51,7 +51,7 @@ public void analyze(AnalyzeContextInfo contextInfo) throws XPathException {
public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException {
if (contextItem != null)
{contextSequence = contextItem.toSequence();}
- final Sequence leftSeq = left.eval(contextSequence);
+ final Sequence leftSeq = left.eval(contextSequence, null);
if (leftSeq.isEmpty())
{return Sequence.EMPTY_SEQUENCE;}
@@ -59,7 +59,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
int pos = 0;
for (final SequenceIterator i = leftSeq.iterate(); i.hasNext(); pos++) {
context.setContextSequencePosition(pos, leftSeq);
- final Sequence rightSeq = right.eval(i.nextItem().toSequence());
+ final Sequence rightSeq = right.eval(i.nextItem().toSequence(), null);
result.addAll(rightSeq);
}
return result;
diff --git a/exist-core/src/main/java/org/exist/xquery/PathExpr.java b/exist-core/src/main/java/org/exist/xquery/PathExpr.java
index 8dee545bc37..818a30c5a29 100644
--- a/exist-core/src/main/java/org/exist/xquery/PathExpr.java
+++ b/exist-core/src/main/java/org/exist/xquery/PathExpr.java
@@ -277,7 +277,7 @@ public Sequence eval(Sequence contextSequence, final Item contextItem) throws XP
result = exprResult;
} else {
try {
- result = expr.eval(currentContext);
+ result = expr.eval(currentContext, null);
} catch (XPathException ex){
// enrich exception when information is available
if (ex.getLine() < 1 || ex.getColumn() < 1) {
diff --git a/exist-core/src/main/java/org/exist/xquery/Predicate.java b/exist-core/src/main/java/org/exist/xquery/Predicate.java
index e9d01318ea1..715e44b7caa 100644
--- a/exist-core/src/main/java/org/exist/xquery/Predicate.java
+++ b/exist-core/src/main/java/org/exist/xquery/Predicate.java
@@ -140,7 +140,7 @@ private AnalyzeContextInfo createContext(final AnalyzeContextInfo contextInfo) {
public Sequence preprocess() throws XPathException {
final Expression inner = steps.size() == 1 ? getSubExpression(0) : this;
- return inner.eval(null);
+ return inner.eval(null, null);
}
public Sequence evalPredicate(final Sequence outerSequence,
@@ -193,7 +193,7 @@ public Sequence evalPredicate(final Sequence outerSequence,
// if not, do not pass the context sequence to avoid cardinality errors
context.setContextSequencePosition(0, contextSequence);
innerSeq = inner.eval(Dependency.dependsOn(inner.getDependencies(), Dependency.CONTEXT_ITEM)
- ? contextSequence : null);
+ ? contextSequence : null, null);
}
// We must check for empty sequences here to avoid an NPE
@@ -239,7 +239,7 @@ private Tuple2 recomputeExecutionMode(final Sequence co
// computation should now be better
!((inner instanceof GeneralComparison) &&
((GeneralComparison) inner).invalidNodeEvaluation)) {
- innerSeq = inner.eval(contextSequence);
+ innerSeq = inner.eval(contextSequence, null);
// Only if we have an actual *singleton* of numeric items
if (innerSeq.hasOne()
&& Type.subTypeOfUnion(innerSeq.getItemType(), Type.NUMBER)) {
@@ -255,7 +255,7 @@ private Tuple2 recomputeExecutionMode(final Sequence co
* WARNING : this sequence will be evaluated with
* preloadable nodesets !
*/
- innerSeq = inner.eval(contextSequence);
+ innerSeq = inner.eval(contextSequence, null);
// Try to promote a boolean evaluation to a nodeset one
// We are now sure of the inner sequence return type
if (Type.subTypeOf(innerSeq.getItemType(), Type.NODE)
diff --git a/exist-core/src/main/java/org/exist/xquery/SimpleStep.java b/exist-core/src/main/java/org/exist/xquery/SimpleStep.java
index d5aad61e911..d8137ae68a3 100644
--- a/exist-core/src/main/java/org/exist/xquery/SimpleStep.java
+++ b/exist-core/src/main/java/org/exist/xquery/SimpleStep.java
@@ -74,7 +74,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
{contextSequence = contextItem.toSequence();}
Sequence result = Sequence.EMPTY_SEQUENCE;
- final Sequence set = expression.eval(contextSequence);
+ final Sequence set = expression.eval(contextSequence, null);
if (!set.isEmpty()) {
if (set.isPersistentSet()) {
diff --git a/exist-core/src/main/java/org/exist/xquery/StringConstructor.java b/exist-core/src/main/java/org/exist/xquery/StringConstructor.java
index d1d39431cd7..3d725e63c66 100644
--- a/exist-core/src/main/java/org/exist/xquery/StringConstructor.java
+++ b/exist-core/src/main/java/org/exist/xquery/StringConstructor.java
@@ -157,7 +157,7 @@ public void analyze(final AnalyzeContextInfo contextInfo) throws XPathException
@Override
public String eval(final Sequence contextSequence) throws XPathException {
- final Sequence result = expression.eval(contextSequence);
+ final Sequence result = expression.eval(contextSequence, null);
final StringBuilder out = new StringBuilder();
boolean gotOne = false;
diff --git a/exist-core/src/main/java/org/exist/xquery/SwitchExpression.java b/exist-core/src/main/java/org/exist/xquery/SwitchExpression.java
index d319f6ada9c..d75361bf784 100644
--- a/exist-core/src/main/java/org/exist/xquery/SwitchExpression.java
+++ b/exist-core/src/main/java/org/exist/xquery/SwitchExpression.java
@@ -88,10 +88,10 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
if (contextItem != null)
{contextSequence = contextItem.toSequence();}
- final Sequence opSeq = operand.eval(contextSequence);
+ final Sequence opSeq = operand.eval(contextSequence, null);
Sequence result = null;
if (opSeq.isEmpty()) {
- result = defaultClause.returnClause.eval(contextSequence);
+ result = defaultClause.returnClause.eval(contextSequence, null);
} else {
if (opSeq.hasMany()) {
throw new XPathException(this, ErrorCodes.XPTY0004, "Cardinality error in switch operand ", opSeq);
@@ -106,13 +106,13 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
}
final AtomicValue caseVal = caseSeq.isEmpty() ? AtomicValue.EMPTY_VALUE : caseSeq.itemAt(0).atomize();
if (FunDeepEqual.deepEquals(caseVal, opVal, defaultCollator)) {
- return next.returnClause.eval(contextSequence);
+ return next.returnClause.eval(contextSequence, null);
}
}
}
}
if (result == null) {
- result = defaultClause.returnClause.eval(contextSequence);
+ result = defaultClause.returnClause.eval(contextSequence, null);
}
return result;
diff --git a/exist-core/src/main/java/org/exist/xquery/TypeswitchExpression.java b/exist-core/src/main/java/org/exist/xquery/TypeswitchExpression.java
index 8bb04482d49..edfc79469db 100644
--- a/exist-core/src/main/java/org/exist/xquery/TypeswitchExpression.java
+++ b/exist-core/src/main/java/org/exist/xquery/TypeswitchExpression.java
@@ -89,7 +89,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem)
throws XPathException {
if (contextItem != null)
{contextSequence = contextItem.toSequence();}
- final Sequence opSeq = operand.eval(contextSequence);
+ final Sequence opSeq = operand.eval(contextSequence, null);
Sequence result = null;
final LocalVariable mark = context.markLocalVariables(false);
@@ -107,7 +107,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem)
context.declareVariableBinding(var);
}
- result = next.returnClause.eval(contextSequence);
+ result = next.returnClause.eval(contextSequence, null);
break;
}
}
@@ -121,7 +121,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem)
context.declareVariableBinding(var);
}
- result = defaultClause.returnClause.eval(contextSequence);
+ result = defaultClause.returnClause.eval(contextSequence, null);
}
} finally {
context.popLocalVariables(mark, result);
diff --git a/exist-core/src/main/java/org/exist/xquery/UnaryExpr.java b/exist-core/src/main/java/org/exist/xquery/UnaryExpr.java
index efa3f3b5bcb..25f24fce4b7 100644
--- a/exist-core/src/main/java/org/exist/xquery/UnaryExpr.java
+++ b/exist-core/src/main/java/org/exist/xquery/UnaryExpr.java
@@ -65,7 +65,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
Sequence result;
- final Sequence item = getExpression(0).eval(contextSequence);
+ final Sequence item = getExpression(0).eval(contextSequence, null);
if (item.isEmpty())
{return item;}
diff --git a/exist-core/src/main/java/org/exist/xquery/ValueComparison.java b/exist-core/src/main/java/org/exist/xquery/ValueComparison.java
index ee15b1b758a..c3de10aa93a 100644
--- a/exist-core/src/main/java/org/exist/xquery/ValueComparison.java
+++ b/exist-core/src/main/java/org/exist/xquery/ValueComparison.java
@@ -93,7 +93,7 @@ protected Sequence nodeSetCompare(NodeSet nodes, Sequence contextSequence) throw
}
do {
final AtomicValue lv = current.atomize();
- final Sequence rs = getRight().eval(context.getNode().toSequence());
+ final Sequence rs = getRight().eval(context.getNode().toSequence(), null);
if (!rs.hasOne()) {
throw new XPathException(this, ErrorCodes.XPTY0004,
"Type error: sequence with less or more than one item is not allowed here");
@@ -104,7 +104,7 @@ protected Sequence nodeSetCompare(NodeSet nodes, Sequence contextSequence) throw
} while ((context = context.getNextDirect()) != null);
}
} else {
- final Sequence rs = getRight().eval(null);
+ final Sequence rs = getRight().eval(null, null);
if (!rs.hasOne())
{throw new XPathException(this, ErrorCodes.XPTY0004,
"Type error: sequence with less or more than one item is not allowed here");}
diff --git a/exist-core/src/main/java/org/exist/xquery/WhereClause.java b/exist-core/src/main/java/org/exist/xquery/WhereClause.java
index ecb9d5aeaa0..031838963d6 100644
--- a/exist-core/src/main/java/org/exist/xquery/WhereClause.java
+++ b/exist-core/src/main/java/org/exist/xquery/WhereClause.java
@@ -75,7 +75,7 @@ public Sequence preEval(Sequence in) throws XPathException {
BindingExpression.setContext(getExpressionId(), in);
}
try {
- final Sequence seq = in.isEmpty() ? in : whereExpr.eval(in);
+ final Sequence seq = in.isEmpty() ? in : whereExpr.eval(in, null);
//But *now*, we are ;-)
if (Type.subTypeOf(whereExpr.returnsType(), Type.NODE)) {
final NodeSet nodes = seq.toNodeSet();
@@ -125,7 +125,7 @@ public Sequence preEval(Sequence in) throws XPathException {
@Override
public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException {
if (applyWhereExpression()) {
- return returnExpr.eval(null);
+ return returnExpr.eval(null, null);
}
return Sequence.EMPTY_SEQUENCE;
}
@@ -143,7 +143,7 @@ private boolean applyWhereExpression() throws XPathException {
if (fastTrack) {
return true;
}
- final Sequence innerSeq = whereExpr.eval(null);
+ final Sequence innerSeq = whereExpr.eval(null, null);
return innerSeq.effectiveBooleanValue();
}
diff --git a/exist-core/src/main/java/org/exist/xquery/XQuery.java b/exist-core/src/main/java/org/exist/xquery/XQuery.java
index c87f18ad35c..2009777436e 100644
--- a/exist-core/src/main/java/org/exist/xquery/XQuery.java
+++ b/exist-core/src/main/java/org/exist/xquery/XQuery.java
@@ -439,10 +439,10 @@ public Sequence execute(final DBBroker broker, final CompiledXQuery expression,
call.setArguments(functionArgs);
call.analyze(new AnalyzeContextInfo());
- result = call.eval(contextSequence);
+ result = call.eval(contextSequence, null);
} else {
- result = expression.eval(contextSequence);
+ result = expression.eval(contextSequence, null);
}
if(LOG.isDebugEnabled()) {
diff --git a/exist-core/src/main/java/org/exist/xquery/XQueryContext.java b/exist-core/src/main/java/org/exist/xquery/XQueryContext.java
index e1c397daa46..d3999e3b62e 100644
--- a/exist-core/src/main/java/org/exist/xquery/XQueryContext.java
+++ b/exist-core/src/main/java/org/exist/xquery/XQueryContext.java
@@ -68,7 +68,6 @@
import org.exist.dom.persistent.*;
import org.exist.dom.QName;
import org.exist.http.servlets.*;
-import org.exist.interpreter.Context;
import org.exist.dom.memtree.InMemoryXMLStreamReader;
import org.exist.dom.memtree.MemTreeBuilder;
import org.exist.dom.memtree.NodeImpl;
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/array/ArrayType.java b/exist-core/src/main/java/org/exist/xquery/functions/array/ArrayType.java
index df96af697fa..f21c21a52a7 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/array/ArrayType.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/array/ArrayType.java
@@ -223,7 +223,7 @@ public void analyze(AnalyzeContextInfo contextInfo) throws XPathException {
@Override
public Sequence eval(Sequence contextSequence) throws XPathException {
- return accessorFunc.eval(contextSequence);
+ return accessorFunc.eval(contextSequence, null);
}
@Override
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/fn/FnRandomNumberGenerator.java b/exist-core/src/main/java/org/exist/xquery/functions/fn/FnRandomNumberGenerator.java
index e866dfd5c61..0b10f6d51b9 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/fn/FnRandomNumberGenerator.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/fn/FnRandomNumberGenerator.java
@@ -72,7 +72,7 @@ public Sequence eval(final Sequence[] args, final Sequence contextSequence) thro
if (args.length < 1) {
seed = Optional.empty();
} else {
- final Sequence seedArg = getArgument(0).eval(contextSequence);
+ final Sequence seedArg = getArgument(0).eval(contextSequence, null);
if (seedArg.isEmpty()) {
seed = Optional.empty();
} else {
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunCodepointEqual.java b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunCodepointEqual.java
index c49ff6093c6..bcb55625a53 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunCodepointEqual.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunCodepointEqual.java
@@ -83,8 +83,8 @@ else if (args[1].isEmpty())
result = new BooleanValue(this, Collations.compare(
//TODO : how ugly ! We should be able to use Collations.UNICODE_CODEPOINT_COLLATION_URI here ! -pb
context.getDefaultCollator(),
- getArgument(0).eval(contextSequence).getStringValue(),
- getArgument(1).eval(contextSequence).getStringValue())
+ getArgument(0).eval(contextSequence, null).getStringValue(),
+ getArgument(1).eval(contextSequence, null).getStringValue())
== Constants.EQUAL);
}
if (context.getProfiler().isEnabled())
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunCount.java b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunCount.java
index 9b4e6d08b42..3e9e3440b38 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunCount.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunCount.java
@@ -92,7 +92,7 @@ public Sequence eval(Sequence contextSequence, final Item contextItem) throws XP
if (getArgumentCount() == 0) {
result = IntegerValue.ZERO;
} else {
- final Sequence seq = getArgument(0).eval(contextSequence);
+ final Sequence seq = getArgument(0).eval(contextSequence, null);
result = new IntegerValue(this, seq.getItemCountLong());
}
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunElementWithId.java b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunElementWithId.java
index 206cc011ad6..dd289251062 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunElementWithId.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunElementWithId.java
@@ -68,7 +68,7 @@ public Sequence eval(final Sequence[] args, Sequence contextSequence) throws XPa
final Sequence result;
boolean processInMem = false;
final Expression arg = getArgument(0);
- final Sequence idval = arg.eval(contextSequence);
+ final Sequence idval = arg.eval(contextSequence, null);
if (idval.isEmpty() || (getArgumentCount() == 1 && contextSequence != null && contextSequence.isEmpty())) {
result = Sequence.EMPTY_SEQUENCE;
@@ -76,7 +76,7 @@ public Sequence eval(final Sequence[] args, Sequence contextSequence) throws XPa
String nextId;
DocumentSet docs = null;
if (getArgumentCount() == 2) {
- final Sequence nodes = getArgument(1).eval(contextSequence);
+ final Sequence nodes = getArgument(1).eval(contextSequence, null);
if (nodes.isEmpty()) {
throw new XPathException(this, ErrorCodes.XPDY0002, "XPDY0002: no node or context item for fn:id", nodes);
} else if (!Type.subTypeOf(nodes.itemAt(0).getType(), Type.NODE)) {
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunIRIToURI.java b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunIRIToURI.java
index 8b326b1cc9d..bb94db1500a 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunIRIToURI.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunIRIToURI.java
@@ -101,7 +101,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
{contextSequence = contextItem.toSequence();}
Sequence result;
- final Sequence seq = getArgument(0).eval(contextSequence);
+ final Sequence seq = getArgument(0).eval(contextSequence, null);
if(seq.isEmpty())
{result = StringValue.EMPTY_STRING;}
else {
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunId.java b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunId.java
index fc79e5eeb3f..ba330cfb4c4 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunId.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunId.java
@@ -94,7 +94,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
Sequence result;
boolean processInMem = false;
final Expression arg = getArgument(0);
- final Sequence idval = arg.eval(contextSequence);
+ final Sequence idval = arg.eval(contextSequence, null);
if(idval.isEmpty() || (getArgumentCount() == 1 && contextSequence != null && contextSequence.isEmpty()))
{result = Sequence.EMPTY_SEQUENCE;}
@@ -104,7 +104,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
if (getArgumentCount() == 2) {
// second argument should be a node, whose owner document will be
// searched for the id
- final Sequence nodes = getArgument(1).eval(contextSequence);
+ final Sequence nodes = getArgument(1).eval(contextSequence, null);
if (nodes.isEmpty()) {
logger.error("{} No node or context item for fn:id", ErrorCodes.XPDY0002);
throw new XPathException(this, ErrorCodes.XPDY0002, "XPDY0002: no node or context item for fn:id", nodes);
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunIdRef.java b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunIdRef.java
index 0d5796f51fa..19637562f7e 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunIdRef.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunIdRef.java
@@ -114,7 +114,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
Sequence result;
boolean processInMem = false;
final Expression arg = getArgument(0);
- final Sequence idrefval = arg.eval(contextSequence);
+ final Sequence idrefval = arg.eval(contextSequence, null);
if(idrefval.isEmpty())
{result = Sequence.EMPTY_SEQUENCE;}
else {
@@ -123,7 +123,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
if (getArgumentCount() == 2) {
// second argument should be a node, whose owner document will be
// searched for the id
- final Sequence nodes = getArgument(1).eval(contextSequence);
+ final Sequence nodes = getArgument(1).eval(contextSequence, null);
if (nodes.isEmpty())
{throw new XPathException(this, ErrorCodes.XPDY0002,
"no node or context item for fn:idref");}
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunLang.java b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunLang.java
index d9c9765fcc3..49ad0f49061 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunLang.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunLang.java
@@ -119,7 +119,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
{contextSequence = contextItem.toSequence();}
if (getArgumentCount() == 2)
- {contextSequence = getArgument(1).eval(contextSequence);}
+ {contextSequence = getArgument(1).eval(contextSequence, null);}
if (contextSequence == null)
{throw new XPathException(this, ErrorCodes.XPDY0002, "Undefined context item");}
@@ -128,9 +128,9 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
if (!(Type.subTypeOf(contextSequence.getItemType(), Type.NODE)))
{throw new XPathException(this, ErrorCodes.XPTY0004, "Context item is not a node");}
else {
- final String lang = getArgument(0).eval(contextSequence).getStringValue();
+ final String lang = getArgument(0).eval(contextSequence, null).getStringValue();
- Sequence seq = query.eval(contextSequence);
+ Sequence seq = query.eval(contextSequence, null);
if (seq.isEmpty()) {
result = BooleanValue.FALSE ;
} else if (seq.hasOne()) {
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunLocalName.java b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunLocalName.java
index e7244341f36..a9c0392cbf5 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunLocalName.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunLocalName.java
@@ -105,7 +105,7 @@ public Sequence eval(Sequence contextSequence, final Item contextItem) throws XP
// check if the node is passed as an argument or should be taken from
// the context sequence
if (getArgumentCount() > 0) {
- final Sequence seq = getArgument(0).eval(contextSequence);
+ final Sequence seq = getArgument(0).eval(contextSequence, null);
if (!seq.isEmpty()) {
item = seq.itemAt(0);
} else {
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunMatches.java b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunMatches.java
index e35cfb49cc7..6c3e3b168e3 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunMatches.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunMatches.java
@@ -211,7 +211,7 @@ public NodeSet preSelect(final Sequence contextSequence, final boolean useContex
final int flags;
if (getSignature().getArgumentCount() == 3) {
- final String flagsArg = getArgument(2).eval(contextSequence).getStringValue();
+ final String flagsArg = getArgument(2).eval(contextSequence, null).getStringValue();
flags = parseFlags(this, flagsArg);
} else {
flags = 0;
@@ -223,11 +223,11 @@ public NodeSet preSelect(final Sequence contextSequence, final boolean useContex
final boolean literal = hasLiteral(flags);
if (literal) {
// no need to change anything
- pattern = getArgument(1).eval(contextSequence).getStringValue();
+ pattern = getArgument(1).eval(contextSequence, null).getStringValue();
} else {
final boolean ignoreWhitespace = hasIgnoreWhitespace(flags);
final boolean caseBlind = !caseSensitive;
- pattern = translateRegexp(this, getArgument(1).eval(contextSequence).getStringValue(), ignoreWhitespace, caseBlind);
+ pattern = translateRegexp(this, getArgument(1).eval(contextSequence, null).getStringValue(), ignoreWhitespace, caseBlind);
}
try {
@@ -350,7 +350,7 @@ public Sequence eval(Sequence contextSequence, final Item contextItem) throws XP
}
} else {
contextStep.setPreloadedData(contextSequence.getDocumentSet(), preselectResult);
- result = getArgument(0).eval(contextSequence).toNodeSet();
+ result = getArgument(0).eval(contextSequence, null).toNodeSet();
}
if (context.getProfiler().isEnabled()) {
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunNormalizeSpace.java b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunNormalizeSpace.java
index 7aa703b0776..8f4fb5e7808 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunNormalizeSpace.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunNormalizeSpace.java
@@ -116,7 +116,7 @@ public Sequence eval(Sequence contextSequence, final Item contextItem) throws XP
}
value = !contextSequence.isEmpty() ? contextSequence.itemAt(0).getStringValue() : "";
} else {
- final Sequence seq = getArgument(0).eval(contextSequence);
+ final Sequence seq = getArgument(0).eval(contextSequence, null);
if (seq == null) {
throw new XPathException(this, ErrorCodes.XPDY0002, "Undefined context item");
}
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunNormalizeUnicode.java b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunNormalizeUnicode.java
index fc711b49369..5a6038037d2 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunNormalizeUnicode.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunNormalizeUnicode.java
@@ -122,13 +122,13 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
Sequence result;
- final Sequence s1 = getArgument(0).eval(contextSequence);
+ final Sequence s1 = getArgument(0).eval(contextSequence, null);
if (s1.isEmpty())
{result = StringValue.EMPTY_STRING;}
else {
String newNormalizationForm = "NFC";
if (getArgumentCount() > 1)
- {newNormalizationForm = getArgument(1).eval(contextSequence).getStringValue().toUpperCase().trim();}
+ {newNormalizationForm = getArgument(1).eval(contextSequence, null).getStringValue().toUpperCase().trim();}
//TODO : handle the "FULLY-NORMALIZED" string...
if (newNormalizationForm.isEmpty())
{result = new StringValue(this, s1.getStringValue());}
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunNot.java b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunNot.java
index 430b61ee7f6..64c1389563f 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunNot.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunNot.java
@@ -128,7 +128,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
}
// evaluate argument expression
- final Sequence argSeq = arg.eval(result);
+ final Sequence argSeq = arg.eval(result, null);
NodeSet argSet;
if (contextId != Expression.NO_CONTEXT_ID) {
argSet = argSeq.toNodeSet().getContextNodes(contextId);
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunNumber.java b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunNumber.java
index 57d2b26607e..dda17da0726 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunNumber.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunNumber.java
@@ -111,7 +111,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
if(getSignature().getArgumentCount() == 1) {
//value is from $arg
- arg = getArgument(0).eval(contextSequence);
+ arg = getArgument(0).eval(contextSequence, null);
if(arg.isEmpty()) {
result = DoubleValue.NaN;
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunResolveURI.java b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunResolveURI.java
index 46a50aa77ab..150963daad2 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunResolveURI.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunResolveURI.java
@@ -112,7 +112,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
base = context.getBaseURI();
} else {
try {
- final Item item = getArgument(1).eval(contextSequence).itemAt(0).convertTo(Type.ANY_URI);
+ final Item item = getArgument(1).eval(contextSequence, null).itemAt(0).convertTo(Type.ANY_URI);
base = (AnyURIValue)item;
} catch (final XPathException e) {
throw new XPathException(this, ErrorCodes.FORG0002, "invalid argument to fn:resolve-uri(): " + e.getMessage(), null, e);
@@ -121,7 +121,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
Sequence result;
- final Sequence seq = getArgument(0).eval(contextSequence);
+ final Sequence seq = getArgument(0).eval(contextSequence, null);
if (seq.isEmpty()) {
result = Sequence.EMPTY_SEQUENCE;
} else {
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunStartsWith.java b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunStartsWith.java
index fac3ca0136d..beddb98cdbe 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunStartsWith.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunStartsWith.java
@@ -96,8 +96,8 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
{contextSequence = contextItem.toSequence();}
Sequence result;
- final String s1 = getArgument(0).eval(contextSequence).getStringValue();
- final String s2 = getArgument(1).eval(contextSequence).getStringValue();
+ final String s1 = getArgument(0).eval(contextSequence, null).getStringValue();
+ final String s2 = getArgument(1).eval(contextSequence, null).getStringValue();
if(s1.isEmpty() || s2.isEmpty())
{result = Sequence.EMPTY_SEQUENCE;}
else {
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunStrLength.java b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunStrLength.java
index af3d3b53524..dbc3eac6b3e 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunStrLength.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunStrLength.java
@@ -102,7 +102,7 @@ public Sequence eval(Sequence contextSequence, final Item contextItem) throws XP
if (getSignature().getArgumentCount() == 1) {
- contextSequence = getArgument(0).eval(contextSequence);
+ contextSequence = getArgument(0).eval(contextSequence, null);
}
if (contextSequence == null) {
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunString.java b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunString.java
index a3f8d9de6b9..ee52dc11400 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunString.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunString.java
@@ -87,7 +87,7 @@ public Sequence eval(Sequence contextSequence, final Item contextItem) throws XP
// if the function is called with an argument and it is empty,
// return the empty string
if(getArgumentCount() == 1) {
- contextSequence = getArgument(0).eval(contextSequence);
+ contextSequence = getArgument(0).eval(contextSequence, null);
if (contextSequence.isEmpty()) {
return StringValue.EMPTY_STRING;
}
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunSubstring.java b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunSubstring.java
index b05b6df7612..3474790cb4f 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunSubstring.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunSubstring.java
@@ -107,7 +107,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
if(contextItem != null)
{contextSequence = contextItem.toSequence();}
Sequence result;
- final Sequence seqSourceString = argSourceString.eval(contextSequence);
+ final Sequence seqSourceString = argSourceString.eval(contextSequence, null);
//If the value of $sourceString is the empty sequence return EMPTY_STRING, there must be a string to operate on!
if(seqSourceString.isEmpty()) {
@@ -117,7 +117,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
final String sourceString = seqSourceString.getStringValue();
//check for a valid start position for the substring
- final NumericValue startingLoc = ((NumericValue)(argStartingLoc.eval(contextSequence).itemAt(0).convertTo(Type.NUMBER))).round();
+ final NumericValue startingLoc = ((NumericValue)(argStartingLoc.eval(contextSequence, null).itemAt(0).convertTo(Type.NUMBER))).round();
if(!validStartPosition(startingLoc, sourceString.length())) {
//invalid start position
result = StringValue.EMPTY_STRING;
@@ -125,7 +125,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
//are there 2 or 3 arguments to this function?
if(getArgumentCount() > 2) {
argLength = getArgument(2);
- final NumericValue length = ((NumericValue)(argLength.eval(contextSequence).itemAt(0).convertTo(Type.NUMBER))).round();
+ final NumericValue length = ((NumericValue)(argLength.eval(contextSequence, null).itemAt(0).convertTo(Type.NUMBER))).round();
// Relocate length to position according to spec:
// fn:round($startingLoc) <=
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunSubstringAfter.java b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunSubstringAfter.java
index dc25cca9ac9..84faa6d2a10 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunSubstringAfter.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunSubstringAfter.java
@@ -105,8 +105,8 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
if (contextItem != null)
{contextSequence = contextItem.toSequence();}
- final Sequence seq1 = arg0.eval(contextSequence);
- final Sequence seq2 = arg1.eval(contextSequence);
+ final Sequence seq1 = arg0.eval(contextSequence, null);
+ final Sequence seq2 = arg1.eval(contextSequence, null);
String value;
String cmp;
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunSubstringBefore.java b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunSubstringBefore.java
index d28192435e9..914a1c6953a 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunSubstringBefore.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunSubstringBefore.java
@@ -105,8 +105,8 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
if (contextItem != null)
{contextSequence = contextItem.toSequence();}
- final Sequence seq1 = arg0.eval(contextSequence);
- final Sequence seq2 = arg1.eval(contextSequence);
+ final Sequence seq1 = arg0.eval(contextSequence, null);
+ final Sequence seq2 = arg1.eval(contextSequence, null);
String value;
String cmp;
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunTranslate.java b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunTranslate.java
index c07fb6d8349..c13a449b0e5 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunTranslate.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunTranslate.java
@@ -85,13 +85,13 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
{contextSequence = contextItem.toSequence();}
Sequence result;
- final Sequence seq = getArgument(0).eval(contextSequence);
+ final Sequence seq = getArgument(0).eval(contextSequence, null);
if(seq.isEmpty())
{result = StringValue.EMPTY_STRING;}
else {
final ValueSequence arg = FunStringToCodepoints.getCodePoints(this, seq.getStringValue());
- final ValueSequence mapStr = FunStringToCodepoints.getCodePoints(this, getArgument(1).eval(contextSequence).getStringValue());
- final ValueSequence transStr = FunStringToCodepoints.getCodePoints(this, getArgument(2).eval(contextSequence).getStringValue());
+ final ValueSequence mapStr = FunStringToCodepoints.getCodePoints(this, getArgument(1).eval(contextSequence, null).getStringValue());
+ final ValueSequence transStr = FunStringToCodepoints.getCodePoints(this, getArgument(2).eval(contextSequence, null).getStringValue());
int p;
IntegerValue ch;
final StringBuilder buf = new StringBuilder(arg.getItemCount());
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunUpperOrLowerCase.java b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunUpperOrLowerCase.java
index ce63ebdf0c2..6a5f576a98a 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/fn/FunUpperOrLowerCase.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/fn/FunUpperOrLowerCase.java
@@ -77,7 +77,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
{contextSequence = contextItem.toSequence();}
Sequence result;
- final Sequence seq = getArgument(0).eval(contextSequence);
+ final Sequence seq = getArgument(0).eval(contextSequence, null);
if (seq.isEmpty())
{result = StringValue.EMPTY_STRING;}
else {
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/map/AbstractMapType.java b/exist-core/src/main/java/org/exist/xquery/functions/map/AbstractMapType.java
index 33d3a4d9785..a4397ecbd8d 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/map/AbstractMapType.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/map/AbstractMapType.java
@@ -116,7 +116,7 @@ public void analyze(final AnalyzeContextInfo contextInfo) throws XPathException
@Override
public Sequence eval(final Sequence contextSequence) throws XPathException {
- return getAccessorFunc().eval(contextSequence);
+ return getAccessorFunc().eval(contextSequence, null);
}
@Override
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/map/MapExpr.java b/exist-core/src/main/java/org/exist/xquery/functions/map/MapExpr.java
index de04e2af25b..151bc69c3d7 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/map/MapExpr.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/map/MapExpr.java
@@ -74,12 +74,12 @@ public Sequence eval(Sequence contextSequence, final Item contextItem) throws XP
int prevType = AbstractMapType.UNKNOWN_KEY_TYPE;
for (final Mapping mapping : this.mappings) {
- final Sequence key = mapping.key.eval(contextSequence);
+ final Sequence key = mapping.key.eval(contextSequence, null);
if (key.getItemCount() != 1) {
throw new XPathException(this, MapErrorCode.EXMPDY001, "Expected single value for key, got " + key.getItemCount());
}
final AtomicValue atomic = key.itemAt(0).atomize();
- final Sequence value = mapping.value.eval(contextSequence);
+ final Sequence value = mapping.value.eval(contextSequence, null);
if (map.contains(atomic)) {
throw new XPathException(this, ErrorCodes.XQDY0137, "Key \"" + atomic.getStringValue() + "\" already exists in map.");
}
diff --git a/exist-core/src/main/java/org/exist/xquery/functions/util/FunctionFunction.java b/exist-core/src/main/java/org/exist/xquery/functions/util/FunctionFunction.java
index 75b17dd406b..929a2947f97 100644
--- a/exist-core/src/main/java/org/exist/xquery/functions/util/FunctionFunction.java
+++ b/exist-core/src/main/java/org/exist/xquery/functions/util/FunctionFunction.java
@@ -66,8 +66,8 @@ public FunctionFunction(XQueryContext context) {
public void analyze(AnalyzeContextInfo contextInfo) throws XPathException {
super.analyze(contextInfo);
- final String funcName = getArgument(0).eval(null).getStringValue();
- final int arity = ((NumericValue)getArgument(1).eval(null).itemAt(0)).getInt();
+ final String funcName = getArgument(0).eval(null, null).getStringValue();
+ final int arity = ((NumericValue)getArgument(1).eval(null, null).itemAt(0)).getInt();
final FunctionCall funcCall = lookupFunction(funcName, arity);
contextInfo.addFlag(SINGLE_STEP_EXECUTION);
funcCall.analyze(contextInfo);
diff --git a/exist-core/src/main/java/org/exist/xquery/pragmas/Optimize.java b/exist-core/src/main/java/org/exist/xquery/pragmas/Optimize.java
index a499c1e3b74..4a65d795ec0 100644
--- a/exist-core/src/main/java/org/exist/xquery/pragmas/Optimize.java
+++ b/exist-core/src/main/java/org/exist/xquery/pragmas/Optimize.java
@@ -94,7 +94,7 @@ public Sequence eval(Sequence contextSequence, final Item contextItem) throws XP
useCached = !originalContext.hasChanged(cachedTimestamp);
}
if (contextVar != null) {
- contextSequence = contextVar.eval(contextSequence);
+ contextSequence = contextVar.eval(contextSequence, null);
}
// check if all Optimizable expressions signal that they can indeed optimize
// in the current context
@@ -154,7 +154,7 @@ public Sequence eval(Sequence contextSequence, final Item contextItem) throws XP
contextSequence = result;
}
if (contextStep == null) {
- return innerExpr.eval(result);
+ return innerExpr.eval(result, null);
} else {
contextStep.setPreloadedData(result.getDocumentSet(), result);
if (LOG.isTraceEnabled()) {
@@ -166,7 +166,7 @@ public Sequence eval(Sequence contextSequence, final Item contextItem) throws XP
} else {
contextSequence = null;
}
- final Sequence seq = innerExpr.eval(contextSequence);
+ final Sequence seq = innerExpr.eval(contextSequence, null);
if (LOG.isTraceEnabled()) {
LOG.trace("exist:optimize: inner expr took {}; found: {}", System.currentTimeMillis() - start, seq.getItemCount());
}
@@ -342,4 +342,4 @@ public static int getQNameIndexType(final XQueryContext context, final Sequence
}
return indexType;
}
-}
\ No newline at end of file
+}
diff --git a/exist-core/src/main/java/org/exist/xquery/update/Delete.java b/exist-core/src/main/java/org/exist/xquery/update/Delete.java
index b6d19596785..a90d59af598 100644
--- a/exist-core/src/main/java/org/exist/xquery/update/Delete.java
+++ b/exist-core/src/main/java/org/exist/xquery/update/Delete.java
@@ -78,7 +78,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
contextSequence = contextItem.toSequence();
}
- final Sequence inSeq = select.eval(contextSequence);
+ final Sequence inSeq = select.eval(contextSequence, null);
//START trap Delete failure
/* If we try and Delete a node at an invalid location,
diff --git a/exist-core/src/main/java/org/exist/xquery/update/Insert.java b/exist-core/src/main/java/org/exist/xquery/update/Insert.java
index 9d5f4e04e61..ccf6d62846b 100644
--- a/exist-core/src/main/java/org/exist/xquery/update/Insert.java
+++ b/exist-core/src/main/java/org/exist/xquery/update/Insert.java
@@ -85,12 +85,12 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
contextSequence = contextItem.toSequence();
}
- Sequence contentSeq = value.eval(contextSequence);
+ Sequence contentSeq = value.eval(contextSequence, null);
if (contentSeq.isEmpty()) {
throw new XPathException(this, Messages.getMessage(Error.UPDATE_EMPTY_CONTENT));
}
- final Sequence inSeq = select.eval(contextSequence);
+ final Sequence inSeq = select.eval(contextSequence, null);
//START trap Insert failure
/* If we try and Insert a node at an invalid location,
diff --git a/exist-core/src/main/java/org/exist/xquery/update/Rename.java b/exist-core/src/main/java/org/exist/xquery/update/Rename.java
index d5c7a77744a..69aed9a7fb0 100644
--- a/exist-core/src/main/java/org/exist/xquery/update/Rename.java
+++ b/exist-core/src/main/java/org/exist/xquery/update/Rename.java
@@ -70,12 +70,12 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
contextSequence = contextItem.toSequence();
}
- final Sequence contentSeq = value.eval(contextSequence);
+ final Sequence contentSeq = value.eval(contextSequence, null);
if (contentSeq.isEmpty()) {
throw new XPathException(this, Messages.getMessage(Error.UPDATE_EMPTY_CONTENT));
}
- final Sequence inSeq = select.eval(contextSequence);
+ final Sequence inSeq = select.eval(contextSequence, null);
//START trap Rename failure
/* If we try and Rename a node at an invalid location,
diff --git a/exist-core/src/main/java/org/exist/xquery/update/Replace.java b/exist-core/src/main/java/org/exist/xquery/update/Replace.java
index 755b400af96..a95259ef9cd 100644
--- a/exist-core/src/main/java/org/exist/xquery/update/Replace.java
+++ b/exist-core/src/main/java/org/exist/xquery/update/Replace.java
@@ -79,7 +79,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
if (contextItem != null) {
contextSequence = contextItem.toSequence();
}
- final Sequence inSeq = select.eval(contextSequence);
+ final Sequence inSeq = select.eval(contextSequence, null);
if (inSeq.isEmpty()) {
return Sequence.EMPTY_SEQUENCE;
}
@@ -116,7 +116,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
}
//END trap Replace failure
- Sequence contentSeq = value.eval(contextSequence);
+ Sequence contentSeq = value.eval(contextSequence, null);
if (contentSeq.isEmpty()) {
throw new XPathException(this, Messages.getMessage(Error.UPDATE_EMPTY_CONTENT));
}
diff --git a/exist-core/src/main/java/org/exist/xquery/update/Update.java b/exist-core/src/main/java/org/exist/xquery/update/Update.java
index cc44a0a5b24..befcb69967f 100644
--- a/exist-core/src/main/java/org/exist/xquery/update/Update.java
+++ b/exist-core/src/main/java/org/exist/xquery/update/Update.java
@@ -87,12 +87,12 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
contextSequence = contextItem.toSequence();
}
- final Sequence contentSeq = value.eval(contextSequence);
+ final Sequence contentSeq = value.eval(contextSequence, null);
if (contentSeq.isEmpty()) {
throw new XPathException(this, Messages.getMessage(Error.UPDATE_EMPTY_CONTENT));
}
- final Sequence inSeq = select.eval(contextSequence);
+ final Sequence inSeq = select.eval(contextSequence, null);
//START trap Update failure
/* If we try and Update a node at an invalid location,
diff --git a/exist-core/src/main/java/org/exist/xquery/value/FunctionReference.java b/exist-core/src/main/java/org/exist/xquery/value/FunctionReference.java
index 3d938060a89..48c244a6575 100644
--- a/exist-core/src/main/java/org/exist/xquery/value/FunctionReference.java
+++ b/exist-core/src/main/java/org/exist/xquery/value/FunctionReference.java
@@ -103,18 +103,18 @@ public void analyze(AnalyzeContextInfo contextInfo) throws XPathException {
}
/**
- * Calls {@link FunctionCall#eval(Sequence)}.
+ * Evaluates the referenced function.
*
* @param contextSequence the input sequence
* @return evaluation result of the function call
* @throws XPathException in case of dynamic error
*/
public Sequence eval(Sequence contextSequence) throws XPathException {
- return functionCall.eval(contextSequence);
+ return functionCall.eval(contextSequence, null);
}
/**
- * Calls {@link FunctionCall#eval(Sequence, Item)}.
+ * Evaluates the referenced function.
*
* @param contextSequence the input sequence
* @param contextItem optional: the current context item
@@ -126,7 +126,7 @@ public Sequence eval(final Sequence contextSequence, final Item contextItem) thr
}
/**
- * Calls {@link FunctionCall#evalFunction(Sequence, Item, Sequence[])}.
+ * Evaluates the referenced function.
*
* @param contextSequence the input sequence
* @param contextItem optional: the current context item
diff --git a/exist-core/src/main/java/org/exist/xquery/value/OrderedValueSequence.java b/exist-core/src/main/java/org/exist/xquery/value/OrderedValueSequence.java
index d3e6c90db1f..1d41cc57e8b 100644
--- a/exist-core/src/main/java/org/exist/xquery/value/OrderedValueSequence.java
+++ b/exist-core/src/main/java/org/exist/xquery/value/OrderedValueSequence.java
@@ -328,7 +328,7 @@ public Entry(final Item item, final int position) throws XPathException {
this.pos = position;
values = new AtomicValue[orderSpecs.length];
for (int i = 0; i < orderSpecs.length; i++) {
- final Sequence seq = orderSpecs[i].getSortExpression().eval(null);
+ final Sequence seq = orderSpecs[i].getSortExpression().eval(null, null);
values[i] = AtomicValue.EMPTY_VALUE;
if (seq.hasOne()) {
values[i] = seq.itemAt(0).atomize();
diff --git a/exist-core/src/main/java/org/exist/xquery/value/PreorderedValueSequence.java b/exist-core/src/main/java/org/exist/xquery/value/PreorderedValueSequence.java
index a7edfe5e8c7..0969de9f238 100644
--- a/exist-core/src/main/java/org/exist/xquery/value/PreorderedValueSequence.java
+++ b/exist-core/src/main/java/org/exist/xquery/value/PreorderedValueSequence.java
@@ -62,7 +62,7 @@ public PreorderedValueSequence(final OrderSpec specs[], final Sequence input, fi
private void processAll() throws XPathException {
for (int i = 0; i < orderSpecs.length; i++) {
final Expression expr = orderSpecs[i].getSortExpression();
- final NodeSet result = expr.eval(null).toNodeSet();
+ final NodeSet result = expr.eval(null, null).toNodeSet();
for (final NodeProxy p : result) {
ContextItem context = p.getContext();
//TODO : review to consider transverse context
diff --git a/exist-core/src/test/java/org/exist/xquery/OpNumericTest.java b/exist-core/src/test/java/org/exist/xquery/OpNumericTest.java
index 7c72a4abbe9..e028a7fe917 100644
--- a/exist-core/src/test/java/org/exist/xquery/OpNumericTest.java
+++ b/exist-core/src/test/java/org/exist/xquery/OpNumericTest.java
@@ -82,7 +82,7 @@ private OpNumeric buildOp(ArithmeticOperator op, AtomicValue a, AtomicValue b) {
}
private void assertOp(String result, ArithmeticOperator op, AtomicValue a, AtomicValue b) throws XPathException {
- Sequence r = buildOp(op, a, b).eval(Sequence.EMPTY_SEQUENCE);
+ Sequence r = buildOp(op, a, b).eval(Sequence.EMPTY_SEQUENCE, null);
assertEquals(result, r.itemAt(0).getStringValue());
}
diff --git a/exist-core/src/test/java/org/exist/xquery/value/OrderedValueSequenceTest.java b/exist-core/src/test/java/org/exist/xquery/value/OrderedValueSequenceTest.java
index a35ce7f9bf2..4aa43a53539 100644
--- a/exist-core/src/test/java/org/exist/xquery/value/OrderedValueSequenceTest.java
+++ b/exist-core/src/test/java/org/exist/xquery/value/OrderedValueSequenceTest.java
@@ -98,7 +98,7 @@ public void iterate_loop_skip_loop() throws XPathException {
private static OrderedValueSequence mockOrderedValueSequence(final int size) throws XPathException {
final Expression mockSortExpr = createMock(Expression.class);
- expect(mockSortExpr.eval(null)).andReturn(Sequence.EMPTY_SEQUENCE).anyTimes();
+ expect(mockSortExpr.eval(null, null)).andReturn(Sequence.EMPTY_SEQUENCE).anyTimes();
replay(mockSortExpr);
final OrderedValueSequence orderedValueSequence = new OrderedValueSequence(new OrderSpec[] { new OrderSpec(null, mockSortExpr) }, size);
diff --git a/extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/ResourceFunctionExecutorImpl.java b/extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/ResourceFunctionExecutorImpl.java
index c73040c42dd..bc17256f549 100644
--- a/extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/ResourceFunctionExecutorImpl.java
+++ b/extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/ResourceFunctionExecutorImpl.java
@@ -142,7 +142,7 @@ public Sequence execute(final ResourceFunction resourceFunction, final Iterable<
for(int i = 0; i < rootExpr.getSubExpressionCount(); i++) {
final Expression subExpr = rootExpr.getSubExpression(i);
if(subExpr instanceof VariableDeclaration) {
- subExpr.eval(null);
+ subExpr.eval(null, null);
}
}
//END workaround
diff --git a/extensions/indexes/lucene/src/main/java/org/exist/xquery/modules/lucene/Query.java b/extensions/indexes/lucene/src/main/java/org/exist/xquery/modules/lucene/Query.java
index aab37366954..6a95e276298 100644
--- a/extensions/indexes/lucene/src/main/java/org/exist/xquery/modules/lucene/Query.java
+++ b/extensions/indexes/lucene/src/main/java/org/exist/xquery/modules/lucene/Query.java
@@ -246,7 +246,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
NodeSet result;
if (preselectResult == null) {
long start = System.currentTimeMillis();
- Sequence input = getArgument(0).eval(contextSequence);
+ Sequence input = getArgument(0).eval(contextSequence, null);
if (!(input instanceof VirtualNodeSet) && input.isEmpty())
result = NodeSet.EMPTY_SET;
else {
@@ -281,7 +281,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
} else {
// DW: contextSequence can be null
contextStep.setPreloadedData(contextSequence.getDocumentSet(), preselectResult);
- result = getArgument(0).eval(contextSequence).toNodeSet();
+ result = getArgument(0).eval(contextSequence, null).toNodeSet();
}
return result;
}
diff --git a/extensions/indexes/lucene/src/main/java/org/exist/xquery/modules/lucene/QueryField.java b/extensions/indexes/lucene/src/main/java/org/exist/xquery/modules/lucene/QueryField.java
index 9ec58b303b3..7da0115334f 100644
--- a/extensions/indexes/lucene/src/main/java/org/exist/xquery/modules/lucene/QueryField.java
+++ b/extensions/indexes/lucene/src/main/java/org/exist/xquery/modules/lucene/QueryField.java
@@ -113,7 +113,7 @@ public NodeSet preSelect(Sequence contextSequence, boolean useContext) throws XP
preselectResult = null;
LuceneIndexWorker index = (LuceneIndexWorker)
context.getBroker().getIndexController().getWorkerByIndexId(LuceneIndex.ID);
- String field = getArgument(0).eval(contextSequence).getStringValue();
+ String field = getArgument(0).eval(contextSequence, null).getStringValue();
DocumentSet docs = contextSequence.getDocumentSet();
Item query = getKey(contextSequence, null);
QueryOptions options = parseOptions(this, contextSequence, null, 3);
@@ -142,7 +142,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
NodeSet result;
if (preselectResult == null) {
long start = System.currentTimeMillis();
- String field = getArgument(0).eval(contextSequence).getStringValue();
+ String field = getArgument(0).eval(contextSequence, null).getStringValue();
Item query = getKey(contextSequence, null);
diff --git a/extensions/indexes/ngram/src/main/java/org/exist/xquery/modules/ngram/NGramSearch.java b/extensions/indexes/ngram/src/main/java/org/exist/xquery/modules/ngram/NGramSearch.java
index 66d0fbd96e2..28624ed5319 100644
--- a/extensions/indexes/ngram/src/main/java/org/exist/xquery/modules/ngram/NGramSearch.java
+++ b/extensions/indexes/ngram/src/main/java/org/exist/xquery/modules/ngram/NGramSearch.java
@@ -221,7 +221,7 @@ public NodeSet preSelect(Sequence contextSequence, boolean useContext) throws XP
NGramIndexWorker index = (NGramIndexWorker) context.getBroker().getIndexController().getWorkerByIndexId(
NGramIndex.ID);
DocumentSet docs = contextSequence.getDocumentSet();
- String key = getArgument(1).eval(contextSequence).getStringValue();
+ String key = getArgument(1).eval(contextSequence, null).getStringValue();
List qnames = new ArrayList<>(1);
qnames.add(contextQName);
preselectResult = processMatches(index, docs, qnames, key, useContext ? contextSequence.toNodeSet() : null,
@@ -268,7 +268,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
}
} else {
contextStep.setPreloadedData(contextSequence.getDocumentSet(), preselectResult);
- result = getArgument(0).eval(contextSequence).toNodeSet();
+ result = getArgument(0).eval(contextSequence, null).toNodeSet();
}
return result;
}
diff --git a/extensions/indexes/range/src/main/java/org/exist/indexing/range/RangeIndexConfigAttributeCondition.java b/extensions/indexes/range/src/main/java/org/exist/indexing/range/RangeIndexConfigAttributeCondition.java
index 58648d85f72..a764ca531a8 100644
--- a/extensions/indexes/range/src/main/java/org/exist/indexing/range/RangeIndexConfigAttributeCondition.java
+++ b/extensions/indexes/range/src/main/java/org/exist/indexing/range/RangeIndexConfigAttributeCondition.java
@@ -387,11 +387,11 @@ else if (expr instanceof LiteralValue) {
final Sequence contextSequence;
final ContextItemDeclaration cid = expr.getContext().getContextItemDeclartion();
if(cid != null) {
- contextSequence = cid.eval(null);
+ contextSequence = cid.eval(null, null);
} else {
contextSequence = null;
}
- final Sequence result = expr.eval(contextSequence);
+ final Sequence result = expr.eval(contextSequence, null);
if (result instanceof AtomicValue) {
return (AtomicValue) result;
}
diff --git a/extensions/indexes/range/src/main/java/org/exist/xquery/modules/range/FieldLookup.java b/extensions/indexes/range/src/main/java/org/exist/xquery/modules/range/FieldLookup.java
index 30a649badff..04bff0f8b5e 100644
--- a/extensions/indexes/range/src/main/java/org/exist/xquery/modules/range/FieldLookup.java
+++ b/extensions/indexes/range/src/main/java/org/exist/xquery/modules/range/FieldLookup.java
@@ -198,11 +198,11 @@ public NodeSet preSelect(Sequence contextSequence, boolean useContext) throws XP
// the expression can be called multiple times, so we need to clear the previous preselectResult
preselectResult = null;
- Sequence fieldSeq = getArgument(0).eval(contextSequence);
+ Sequence fieldSeq = getArgument(0).eval(contextSequence, null);
RangeIndex.Operator[] operators = null;
int j = 1;
if (isCalledAs("field")) {
- Sequence operatorSeq = getArgument(1).eval(contextSequence);
+ Sequence operatorSeq = getArgument(1).eval(contextSequence, null);
operators = new RangeIndex.Operator[operatorSeq.getItemCount()];
int i = 0;
for (SequenceIterator si = operatorSeq.iterate(); si.hasNext(); i++) {
@@ -217,7 +217,7 @@ public NodeSet preSelect(Sequence contextSequence, boolean useContext) throws XP
Sequence[] keys = new Sequence[getArgumentCount() - j];
for (int i = j; i < getArgumentCount(); i++) {
- keys[i - j] = Atomize.atomize(getArgument(i).eval(contextSequence));
+ keys[i - j] = Atomize.atomize(getArgument(i).eval(contextSequence, null));
}
DocumentSet docs = contextSequence.getDocumentSet();
@@ -261,11 +261,11 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
if (contextSequence != null)
contextSet = contextSequence.toNodeSet();
- Sequence fields = getArgument(0).eval(contextSequence);
+ Sequence fields = getArgument(0).eval(contextSequence, null);
RangeIndex.Operator[] operators = null;
int j = 1;
if (isCalledAs("field")) {
- Sequence operatorSeq = getArgument(1).eval(contextSequence);
+ Sequence operatorSeq = getArgument(1).eval(contextSequence, null);
operators = new RangeIndex.Operator[operatorSeq.getItemCount()];
int i = 0;
for (SequenceIterator si = operatorSeq.iterate(); si.hasNext(); i++) {
@@ -283,7 +283,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
Sequence[] keys = new Sequence[getArgumentCount() - j];
SequenceIterator fieldIter = fields.unorderedIterator();
for (int i = j; i < getArgumentCount(); i++) {
- keys[i - j] = getArgument(i).eval(contextSequence);
+ keys[i - j] = getArgument(i).eval(contextSequence, null);
int targetType = Type.ITEM;
if (fieldIter.hasNext()) {
String field = fieldIter.nextItem().getStringValue();
diff --git a/extensions/indexes/range/src/main/java/org/exist/xquery/modules/range/Lookup.java b/extensions/indexes/range/src/main/java/org/exist/xquery/modules/range/Lookup.java
index 22244705356..00b9cfdad19 100644
--- a/extensions/indexes/range/src/main/java/org/exist/xquery/modules/range/Lookup.java
+++ b/extensions/indexes/range/src/main/java/org/exist/xquery/modules/range/Lookup.java
@@ -299,7 +299,7 @@ private RangeIndex.Operator getOperator() {
private AtomicValue[] getKeys(Sequence contextSequence) throws XPathException {
RangeIndexConfigElement config = findConfiguration(contextSequence);
int targetType = config != null ? config.getType() : Type.ITEM;
- Sequence keySeq = Atomize.atomize(getArgument(1).eval(contextSequence));
+ Sequence keySeq = Atomize.atomize(getArgument(1).eval(contextSequence, null));
AtomicValue[] keys = new AtomicValue[keySeq.getItemCount()];
for (int i = 0; i < keys.length; i++) {
if (targetType == Type.ITEM) {
@@ -330,7 +330,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
NodeSet result;
if (preselectResult == null) {
long start = System.currentTimeMillis();
- Sequence input = getArgument(0).eval(contextSequence);
+ Sequence input = getArgument(0).eval(contextSequence, null);
if (!(input instanceof VirtualNodeSet) && input.isEmpty())
result = NodeSet.EMPTY_SET;
else {
@@ -367,7 +367,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
} else {
// long start = System.currentTimeMillis();
contextStep.setPreloadedData(preselectResult.getDocumentSet(), preselectResult);
- result = getArgument(0).eval(contextSequence).toNodeSet();
+ result = getArgument(0).eval(contextSequence, null).toNodeSet();
//LOG.info("eval took " + (System.currentTimeMillis() - start));
}
return result;
diff --git a/extensions/modules/sql/src/test/java/org/exist/xquery/modules/sql/ImplicitConnectionCloseIT.java b/extensions/modules/sql/src/test/java/org/exist/xquery/modules/sql/ImplicitConnectionCloseIT.java
index 8ff8e8f5bcd..f5ec125d127 100644
--- a/extensions/modules/sql/src/test/java/org/exist/xquery/modules/sql/ImplicitConnectionCloseIT.java
+++ b/extensions/modules/sql/src/test/java/org/exist/xquery/modules/sql/ImplicitConnectionCloseIT.java
@@ -47,7 +47,12 @@
import org.exist.util.MimeType;
import org.exist.util.StringInputSource;
import org.exist.xmldb.XmldbURI;
-import org.exist.xquery.*;
+
+import org.exist.xquery.ExternalModule;
+import org.exist.xquery.Module;
+import org.exist.xquery.ModuleContext;
+import org.exist.xquery.XPathException;
+import org.exist.xquery.XQueryContext;
import org.exist.xquery.modules.ModuleUtils;
import org.exist.xquery.value.IntegerValue;
import org.exist.xquery.value.Sequence;