zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #15625
[Merge] lp:~zorba-coders/zorba/move-xqxq-core into lp:zorba
Chris Hillery has proposed merging lp:~zorba-coders/zorba/move-xqxq-core into lp:zorba.
Commit message:
Moved XQXQ into Zorba core.
Requested reviews:
Matthias Brantner (matthias-brantner)
Juan Zacarias (juan457)
Chris Hillery (ceejatec)
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/move-xqxq-core/+merge/131295
--
https://code.launchpad.net/~zorba-coders/zorba/move-xqxq-core/+merge/131295
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'modules/CMakeLists.txt'
--- modules/CMakeLists.txt 2012-09-19 21:16:15 +0000
+++ modules/CMakeLists.txt 2012-10-25 00:08:23 +0000
@@ -15,6 +15,7 @@
ADD_SUBDIRECTORY(com)
ADD_SUBDIRECTORY(org)
ADD_SUBDIRECTORY(functx)
+ADD_SUBDIRECTORY(xqxq)
ADD_SUBDIRECTORY(w3c)
# Add external module projects - any subdirectories of a directory
=== modified file 'modules/ExternalModules.conf'
--- modules/ExternalModules.conf 2012-10-23 21:21:20 +0000
+++ modules/ExternalModules.conf 2012-10-25 00:08:23 +0000
@@ -42,7 +42,6 @@
read-pdf bzr lp:zorba/read-pdf-module zorba-2.7
security bzr lp:zorba/security-module
system bzr lp:zorba/system-module zorba-2.7
-xqxq bzr lp:zorba/xqxq-module zorba-2.7
email bzr lp:zorba/email-module zorba-2.7
util-jvm bzr lp:zorba/util-jvm-module zorba-2.7
schema-tools bzr lp:zorba/schema-tools-module zorba-2.7
=== added directory 'modules/xqxq'
=== added file 'modules/xqxq/CMakeLists.txt'
--- modules/xqxq/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ modules/xqxq/CMakeLists.txt 2012-10-25 00:08:23 +0000
@@ -0,0 +1,15 @@
+# Copyright 2006-2012 The FLWOR Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+DECLARE_ZORBA_MODULE (URI "http://www.zorba-xquery.com/modules/xqxq"; VERSION 1.0 FILE "xqxq.xq")
\ No newline at end of file
=== added file 'modules/xqxq/xqxq.xq'
--- modules/xqxq/xqxq.xq 1970-01-01 00:00:00 +0000
+++ modules/xqxq/xqxq.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,381 @@
+xquery version "3.0";
+(:
+ : Copyright 2011 The FLWOR Foundation.
+ :
+ : Licensed under the Apache License, Version 2.0 (the "License");
+ : you may not use this file except in compliance with the License.
+ : You may obtain a copy of the License at
+ :
+ : http://www.apache.org/licenses/LICENSE-2.0
+ :
+ : Unless required by applicable law or agreed to in writing, software
+ : distributed under the License is distributed on an "AS IS" BASIS,
+ : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ : See the License for the specific language governing permissions and
+ : limitations under the License.
+:)
+
+(:~
+ : This module contains functions to compile and evaluate XQuery
+ : programs. Also, it contains function that allow to parameterize
+ : the static or dynamic evaluation phase.
+ :
+ : @author Juan Zacarias
+ : @project Zorba/Programming Languages/XQuery
+ :)
+module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+
+declare namespace an = "http://www.zorba-xquery.com/annotations";;
+declare namespace ver = "http://www.zorba-xquery.com/options/versioning";;
+declare namespace op = "http://www.zorba-xquery.com/options/features";;
+declare namespace f = "http://www.zorba-xquery.com/features";;
+
+declare option ver:module-version "1.0";
+declare option op:enable "f:hof";
+
+(:~
+ : The function prepares a given XQuery program for execution.
+ : If the program was successfully compiled, the function returns an
+ : identifier as xs:anyURI. This URI can be passed to other functions
+ : of this module (e.g. to actually evaluate the program). The URI
+ : is opaque and its lilfetime is bound by the lifetime of the XQuery
+ : program that invoked this function. Further reference or uses
+ : of the identifier lead to unexpected results.
+ :
+ : Successfully prepared queries need to be deleted by passing the resulting
+ : identifier to the xqxq:delete-query function of this module.
+ :
+ : @param $main-module-text the XQuery program that should be prepared.
+ : The program needs to be a XQuery main module.
+ :
+ : @return an identifier for the compiled program that can be passed
+ : as arguments to other functions of this module.
+ :
+ : @error any (static or type) error that may be raised during the compilation
+ : of the query. For example, err:XPST0003 if the given XQuery program could
+ : not be parsed.
+ :)
+declare %an:sequential function xqxq:prepare-main-module($main-module-text as xs:string) as
+ xs:anyURI external;
+
+(:~
+ : The function prepares a given XQuery program for execution.
+ : If the program was successfully compiled, the function returns an
+ : identifier as xs:anyURI. This URI can be passed to other functions
+ : of this module (e.g. to actually evaluate the program). The URI
+ : is opaque and its lilfetime is bound by the lifetime of the XQuery
+ : program that invoked this function. Further reference or uses
+ : of the identifier lead to unexpected results.
+ :
+ : Important notes regarding the second and third parameters of the function:
+ : --------------------------------------------------------------------------
+ :
+ : These parameters allow you to specify a URL resolver and a URI mapper
+ : for Zorba to use when executing this query. See
+ : http://www.zorba-xquery.com/html/documentation/2.7.0/zorba/uriresolvers
+ :
+ : The second parameter is a function item for a URL
+ : resolver. The URL resolver function must recive 2 parameters:
+ : A $namespace as xs:string that will contain the url to be resolved.
+ : A $entity as xs:string that will contain the type of resolving needed;
+ : this can be 2 values "module" and "schema".
+ : The function must return an empty sequence when the specified $namespace
+ : or $entity are not the ones to be resolved.
+ :
+ : Example:
+ :
+ : declare function mymod:url-resolver($namespace as xs:string, $entity as xs:string)
+ : {
+ : if($namespace = 'http://test.xq')
+ : then "module namespace test = 'http://test'; declare function test:foo(){'foo'};"
+ : else ()
+ : };
+ :
+ : The URL resolver function's namespace, name, and parameter naming are
+ : not restricted by XQXQ.
+ :
+ : The URL resolver function's return type is not restricted, it could be a string, a sequence,
+ : a node, etc. All the outputs types are to be serialized as a string.
+ :
+ : The third parameter is a function item for a URI mapper.
+ : The URI mapper function, just like the URL resolver, receives 2 parameters:
+ : A $namespace as xs:string that will contain the URI to be mapped.
+ : A $entity as xs:string that will contain the type of resolving needed;
+ : this can be 2 values "module" and "schema".
+ : The URI mapper must return an empty sequence when the specified $namesapce or $entity
+ : are not to be mapped. Unlike the URL resolver this function must return a sequence of strings.
+ :
+ : Example:
+ :
+ : declare function mymod:uri-mapper($namespace as xs:string, $entity as xs:string)
+ : {
+ : if($namespace = 'http://test')
+ : then ("http://www.zorba-xquery.com/test";, "http://foo.com/schema/test";)
+ : else ()
+ : };
+ :
+ : The URI mapper function's namespace, name, and parameter naming are
+ : not restricted by XQXQ.
+ :
+ : In order to pass the above URL resolver and URI mapper to this function,
+ : use the following syntax:
+ :
+ : variable $queryID := xqxq:prepare-main-module("..query text..",
+ : mymod:url-resolver#2, mymod:uri-mapper#2);
+ :
+ : That is, the QName of the function followed by "#2". This is XQuery
+ : "higher-order function" syntax, meaning the function with the specified
+ : QName which takes two arguments. Since URL resolvers and URI mappers
+ : must take two arguments, both will always be specified with "#2".
+ :
+ : Note that parameters 2 and 3 should be declared as follows:
+ : as function($url as xs:string, $entity as xs:string) as item()
+ : as function($uri as xs:string, $entity as xs:string) as xs:string*
+ : However Zorba's implementation of higher-order functions (HOF) is not
+ : yet complete enough to allow for this. When Zorba's HOF implementation
+ : is complete this function signature will be changed.
+ :
+ : Both the URL resolver and URI mapper functions are optional, meaning you
+ : may pass the empty-sequence () for either.
+ :
+ : Successfully prepared queries need to be deleted by passing the resulting
+ : identifier to the xqxq:delete-query function of this module.
+ :
+ : @param $main-module-text the XQuery program that should be prepared.
+ : The program needs to be a XQuery main module.
+ :
+ : @param $resolver the URL resolver function.
+ :
+ : @param $mapper the URI mapper function.
+ :
+ : @return an identifier for the compiled program that can be passed
+ : as arguments to other functions of this module.
+ :
+ : @error any (static or type) error that may be raised during the compilation
+ : of the query. For example, err:XPST0003 if the given XQuery program could
+ : not be parsed.
+ :)
+declare %an:sequential function xqxq:prepare-main-module($main-module-text as xs:string, $resolver as item()?, $mapper as item()?) as
+ xs:anyURI external;
+
+(:~
+ : This function compiles a given XQuery library module. It can be used
+ : to compile-check a module.
+ :
+ : @param $library-module-text the XQuery library module that should
+ : be prepared.
+ :
+ : @return the function is declared as sequential.It returns the
+ : empty-sequence.
+ :
+ : @error any (static or type) error that may be raised during the compilation
+ : of the library module. For example, err:XPST0003 if the given XQuery library
+ : module could not be parsed.
+ :)
+declare %an:sequential function xqxq:prepare-library-module($library-module-text as xs:string) as
+ empty-sequence() external ;
+
+(:~
+ : The function tests if the context-item is bound for the
+ : execution of the query referred to by the given query identifier.
+ :
+ : @param $query-key the identifier for a compiled query
+ :
+ : @return true if the context-item is bound, false otherwise.
+ :
+ : @error xqxq:NoQueryMatch if no query with the given identifier
+ : was prepared.
+ :)
+declare function xqxq:is-bound-context-item($query-key as xs:anyURI)
+ as xs:boolean external;
+
+
+(:~
+ : The function tests if the given variable is bound for the
+ : execution of the query referred to by the given query identifier.
+ :
+ : @param $query-key the identifier for a compiled query
+ : @param $var-name the name of the variable
+ :
+ : @return true if the variable is bound, false otherwise.
+ :
+ : @error xqxq:NoQueryMatch if no query with the given identifier
+ : was prepared.
+ : @error xqxq:UndeclaredVariable if the given variable is not declared
+ : in the query.
+ :)
+declare function xqxq:is-bound-variable($query-key as xs:anyURI, $var-name as
+ xs:QName) as xs:boolean external;
+
+(:~
+ : The function returns the names of the external variables that
+ : are declared in the given query (either in the main module or
+ : in any of the imported library modules).
+ :
+ : @param $query-key the identifier for a compiled query
+ :
+ : @return the sequence of names of the said external variables.
+ :
+ : @error xqxq:NoQueryMatch if no query with the given identifier
+ : was prepared.
+ :)
+declare function xqxq:external-variables($query-key as xs:anyURI) as
+ xs:QName* external ;
+
+(:~
+ : The function tests if the query identified by the given key
+ : is an updating query.
+ :
+ : @param $query-key the identifier for a compiled query
+ :
+ : @return true if the query is an updating query, false otherwise.
+ :
+ : @error xqxq:NoQueryMatch if no query with the given identifier
+ : was prepared.
+ :)
+declare function xqxq:is-updating($query-key as xs:anyURI) as
+ xs:boolean external;
+
+(:~
+ : The function tests if the query identified by the given key
+ : is sequential query.
+ :
+ : @param $query-key the identifier for a compiled query
+ :
+ : @return true if the query is a sequential, false otherwise.
+ :
+ : @error xqxq:NoQueryMatch if no query with the given identifier
+ : was prepared.
+ :)
+declare function xqxq:is-sequential($query-key as xs:anyURI) as
+ xs:boolean external;
+
+(:~
+ : This function binds the context-item of the prepared query
+ : identified by the given key to the $dot argument.
+ :
+ : @param $query-key the identifier for a compiled query
+ : @param $dot the context item to bind
+ :
+ : @return the function has side effects and returns the empty
+ : sequence.
+ :
+ : @error xqxq:NoQueryMatch if no query with the given identifier
+ : was prepared.
+ :)
+declare %an:sequential function xqxq:bind-context-item($query-key as xs:anyURI,
+ $dot as item()) as empty-sequence() external ;
+
+(:~
+ : This function binds the variable with name $name of
+ : the prepared query identified by $query-key to the given sequence.
+ :
+ : @param $query-key the identifier for a compiled query
+ : @param $name the name of the external variable to bind
+ : @param $value the sequence to which the external variable $name
+ : should be bound
+ :
+ : @return the function has side effects and returns the empty
+ : sequence.
+ :
+ : @error xqxq:NoQueryMatch if no query with the given identifier
+ : was prepared.
+ : @error xqxq:UndeclaredVariable if the given variable is not declared
+ : in the query.
+ :)
+declare %an:sequential function xqxq:bind-variable($query-key as xs:anyURI,
+ $var as xs:QName, $value as item()*) as empty-sequence() external ;
+
+
+(:~
+ : Evaluates the given prepared query and returns the result
+ : of the evaluation. The query must not be sequential or
+ : updating.
+ :
+ : @param $query-key the identifier for a compiled query
+ :
+ : @return the result of evaluating the given query
+ :
+ : @error xqxq:NoQueryMatch if no query with the given identifier
+ : was prepared.
+ :
+ : @error xqxq:QueryIsUpdating if the query is an updating query.
+ :
+ : @error xqxq:QueryIsSequential if the query is sequential.
+ :
+ : @error any dynamic error that is raised by evaluating the
+ : given query.
+ :
+ :)
+declare function xqxq:evaluate($query-key as xs:anyURI) as item()* external;
+
+(:~
+ : Evaluates the given prepared query and applies the updates
+ : computed by this query. The query must be an updating query.
+ :
+ : @param $query-key the identifier for a compiled query
+ :
+ : @return the function has side effects because it applies
+ : the updates of the query. It returns the empty sequence.
+ :
+ : @error xqxq:NoQueryMatch if no query with the given identifier
+ : was prepared.
+ :
+ : @error xqxq:QueryNotUpdating if the query is not an updating query.
+ :
+ : @error xqxq:QueryIsSequential if the query is sequential.
+ :
+ : @error any dynamic error that is raised by evaluating the
+ : given query or applying its updates.
+ :
+ :)
+declare updating function xqxq:evaluate-updating($query-key as xs:anyURI) external;
+
+(:~
+ : Evaluates the given prepared query and returns the result
+ : of the evaluation. The query must be sequential.
+ :
+ : @param $query-key the identifier for a compiled query
+ :
+ : @return the result of evaluating the query.
+ :
+ : @error xqxq:NoQueryMatch if no query with the given identifier
+ : was prepared.
+ :
+ : @error xqxq:QueryNotSequential if the query is not sequential.
+ :
+ : @error xqxq:QueryIsUpdating if the query is an updating query.
+ :
+ : @error any dynamic error that is raised by evaluating the
+ : given query.
+ :
+ :)
+declare %an:sequential function xqxq:evaluate-sequential($query-key as
+ xs:string) as item()* external;
+
+(:~
+ : Deletes the prepared query associated with the given identifier.
+ : After the query is deleted, the corresponding identifier should
+ : not be used as argument to any of the functions of this module.
+ :
+ : @param $query-key the identifier for a compiled query
+ :
+ : @return the function has side effects and returns the empty sequence.
+ :
+ : @error xqxq:NoQueryMatch if no query with the given identifier
+ : was prepared.
+ :
+ :)
+declare %an:sequential function xqxq:delete-query($query-key as xs:anyURI) as
+ empty-sequence() external;
+
+
+(:~
+ : Internal helper function. Only necessary because of incomplete HOF
+ : support in Zorba.
+ :)
+declare %private function xqxq:hof-invoker($hof as item(),
+ $ns as xs:string, $entity as xs:string) as item()*
+{
+ $hof($ns, $entity)
+};
=== added directory 'modules/xqxq/xqxq.xq.src'
=== added file 'modules/xqxq/xqxq.xq.src/xqxq.cpp'
--- modules/xqxq/xqxq.xq.src/xqxq.cpp 1970-01-01 00:00:00 +0000
+++ modules/xqxq/xqxq.xq.src/xqxq.cpp 2012-10-25 00:08:23 +0000
@@ -0,0 +1,817 @@
+#include <zorba/item_factory.h>
+#include <zorba/singleton_item_sequence.h>
+#include <zorba/diagnostic_list.h>
+#include <zorba/empty_sequence.h>
+#include <zorba/store_manager.h>
+#include <zorba/user_exception.h>
+#include <zorba/uri_resolvers.h>
+#include <zorba/vector_item_sequence.h>
+#include <zorba/serializer.h>
+#include <zorba/xquery.h>
+#include <time.h>
+#include <stdio.h>
+#include <zorba/util/uuid.h>
+#include <vector>
+
+#include "xqxq.h"
+
+namespace zorba { namespace xqxq {
+
+ /*******************************************************************************************
+ *******************************************************************************************/
+
+ zorba::ExternalFunction*
+ XQXQModule::getExternalFunction(const zorba::String& localName)
+ {
+
+ FuncMap_t::iterator lIte = theFunctions.find(localName);
+
+ ExternalFunction*& lFunc = theFunctions[localName];
+
+ if (lIte == theFunctions.end())
+ {
+ if (localName == "prepare-main-module")
+ {
+ lFunc = new PrepareMainModuleFunction(this);
+ }
+ if (localName == "prepare-library-module")
+ {
+ lFunc = new PrepareLibraryModuleFunction(this);
+ }
+ else if (localName == "is-bound-context-item")
+ {
+ lFunc = new IsBoundContextItemFunction(this);
+ }
+ else if (localName == "is-bound-variable")
+ {
+ lFunc = new IsBoundVariableFunction(this);
+ }
+ else if (localName == "external-variables")
+ {
+ lFunc = new GetExternalVariablesFunction(this);
+ }
+ else if (localName == "is-updating")
+ {
+ lFunc = new IsUpdatingFunction(this);
+ }
+ else if (localName == "is-sequential")
+ {
+ lFunc = new IsSequentialFunction(this);
+ }
+ else if (localName == "bind-context-item")
+ {
+ lFunc = new BindContextItemFunction(this);
+ }
+ else if (localName == "bind-variable")
+ {
+ lFunc = new BindVariableFunction(this);
+ }
+ else if (localName == "evaluate")
+ {
+ lFunc = new EvaluateFunction(this);
+ }
+ else if (localName == "evaluate-updating")
+ {
+ lFunc = new EvaluateUpdatingFunction(this);
+ }
+ else if (localName == "evaluate-sequential")
+ {
+ lFunc = new EvaluateSequentialFunction(this);
+ }
+ else if (localName == "delete-query")
+ {
+ lFunc = new DeleteQueryFunction(this);
+ }
+ }
+
+ return lFunc;
+ }
+
+ void XQXQModule::destroy()
+ {
+ delete this;
+ }
+
+ XQXQModule::~XQXQModule()
+ {
+ for (FuncMap_t::const_iterator lIter = theFunctions.begin();
+ lIter != theFunctions.end(); ++lIter)
+ {
+ delete lIter->second;
+ }
+ theFunctions.clear();
+ }
+
+ /*******************************************************************************************
+ *******************************************************************************************/
+ XQXQFunction::XQXQFunction(const XQXQModule* aModule)
+ : theModule(aModule)
+ {
+ srand(time(NULL));
+ }
+
+ XQXQFunction::~XQXQFunction()
+ {
+
+ }
+
+ String XQXQFunction::getURI() const
+ {
+ return theModule->getURI();
+ }
+
+ String
+ XQXQFunction::getOneStringArgument(const Arguments_t& aArgs, int aPos) const
+ {
+ Item lItem;
+ Iterator_t args_iter = aArgs[aPos]->getIterator();
+ args_iter->open();
+ args_iter->next(lItem);
+ String lTmpString = lItem.getStringValue();
+ args_iter->close();
+ return lTmpString;
+ }
+
+
+ Item
+ XQXQFunction::getItemArgument(const Arguments_t& aArgs, int aPos) const
+ {
+ Item lItem;
+ Iterator_t args_iter = aArgs[aPos]->getIterator();
+ args_iter->open();
+ args_iter->next(lItem);
+ args_iter->close();
+
+ return lItem;
+ }
+
+ Iterator_t
+ XQXQFunction::getIterArgument(const Arguments_t& aArgs, int aPos) const
+ {
+ Iterator_t args_iter = aArgs[aPos]->getIterator();
+ return args_iter;
+ }
+
+ XQuery_t
+ XQXQFunction::getQuery(
+ const zorba::DynamicContext* aDctx,
+ const zorba::String& aIdent) const
+ {
+ QueryMap* lQueryMap;
+ if (!(lQueryMap= dynamic_cast<QueryMap*>(aDctx->getExternalFunctionParameter("xqxqQueryMap"))))
+ {
+ throwError("NoQueryMatch", "No query with the given identifier was found");
+ }
+
+ XQuery_t lQuery;
+ if (!(lQuery = lQueryMap->getQuery(aIdent)))
+ throwError("NoQueryMatch", "No query with the given identifier was found");
+
+ return lQuery;
+ }
+
+ void
+ XQXQFunction::throwError(const char *err_localname, const std::string aErrorMessage)
+ {
+ String errNS(XQXQ_MODULE_NAMESPACE);
+ String errName(err_localname);
+ Item errQName = XQXQModule::getItemFactory()->createQName(errNS, errName);
+ String errDescription(aErrorMessage);
+ throw USER_EXCEPTION(errQName, errDescription);
+ }
+
+ /*******************************************************************************************
+ *******************************************************************************************/
+
+ QueryData::QueryData(XQuery_t aQuery, URIMapper *aMapper, URLResolver *aResolver)
+ : theQuery(aQuery),
+ theURIMapper(aMapper),
+ theURLResolver(aResolver)
+ {
+ }
+
+ QueryData::~QueryData()
+ {
+ theQuery->close();
+ delete theURIMapper;
+ delete theURLResolver;
+ }
+
+ /*******************************************************************************************
+ *******************************************************************************************/
+
+ QueryMap::QueryMap()
+ {
+ QueryMap::queryMap = new QueryMap_t();
+ }
+
+ bool
+ QueryMap::storeQuery(const String& aKeyName, XQuery_t aQuery,
+ URIMapper* aMapper, URLResolver* aResolver)
+ {
+ QueryData_t lQueryData(new QueryData(aQuery, aMapper, aResolver));
+ std::pair<QueryMap_t::iterator,bool> ret;
+ ret = queryMap->insert(std::pair<String, QueryData_t>(aKeyName, lQueryData));
+ return ret.second;
+ }
+
+ XQuery_t
+ QueryMap::getQuery(const String& aKeyName)
+ {
+ QueryMap::QueryMap_t::iterator lIter = queryMap->find(aKeyName);
+
+ if(lIter == queryMap->end())
+ return NULL;
+
+ XQuery_t lQuery = lIter->second->getQuery();
+
+ return lQuery;
+ }
+
+ bool
+ QueryMap::deleteQuery(const String& aKeyName)
+ {
+ QueryMap::QueryMap_t::iterator lIter = queryMap->find(aKeyName);
+
+ if(lIter == queryMap->end())
+ return false;
+
+ queryMap->erase(lIter);
+ return true;
+ }
+
+ void
+ QueryMap::destroy() throw()
+ {
+ if(queryMap)
+ {
+ for (QueryMap_t::const_iterator lIter = queryMap->begin();
+ lIter != queryMap->end(); ++lIter)
+ {
+ deleteQuery(lIter->first);
+ }
+ queryMap->clear();
+ delete queryMap;
+ }
+ delete this;
+ }
+
+ /*******************************************************************************************
+ *******************************************************************************************/
+ static void streamReleaser(std::istream* aStream)
+ {
+ delete aStream;
+ }
+
+ void
+ PrepareMainModuleFunction::XQXQURIMapper::mapURI(
+ String aUri,
+ EntityData const* aEntityData,
+ std::vector<String>& oUris)
+ {
+ //Create entityData string to send to the new url resolver
+ String lDataKind;
+ switch (aEntityData->getKind())
+ {
+ case EntityData::SCHEMA:
+ lDataKind = "schema";
+ break;
+ case EntityData::MODULE:
+ lDataKind = "module";
+ break;
+ default:
+ break;
+ }
+
+ //construct the arguments for the url resolver
+ std::vector<ItemSequence_t> lArgs;
+ ItemSequence_t lSeq0 = new SingletonItemSequence(theFunction);
+ ItemSequence_t lSeq1 = new SingletonItemSequence(XQXQModule::getItemFactory()->createString(aUri));
+ ItemSequence_t lSeq2 = new SingletonItemSequence(XQXQModule::getItemFactory()->createString(lDataKind));
+ lArgs.push_back(lSeq0);
+ lArgs.push_back(lSeq1);
+ lArgs.push_back(lSeq2);
+
+ //invoke the HOF helper function using the arguments generated
+ Item lHofHelper = XQXQModule::getItemFactory()->createQName("http://www.zorba-xquery.com/modules/xqxq";, "xqxq", "hof-invoker");
+ ItemSequence_t lResult = theCtx->invoke(lHofHelper, lArgs);
+
+ //Check if the result is an empty sequence by creating an Iterator, this is cheaper than serializing the result
+ //and then checking if it was empty.
+ Iterator_t lIter = lResult->getIterator();
+ Item lItem;
+ lIter->open();
+ while (lIter->next(lItem))
+ {
+ std::cout << lItem.getStringValue() << std::endl;
+ oUris.push_back(lItem.getStringValue());
+ }
+ lIter->close();
+
+ }
+
+
+ Resource*
+ PrepareMainModuleFunction::XQXQURLResolver::resolveURL(
+ const String& aUrl,
+ EntityData const* aEntityData)
+ {
+ //Create entityData string to send to the new url resolver
+ String lDataKind;
+ switch (aEntityData->getKind())
+ {
+ case EntityData::SCHEMA:
+ lDataKind = "schema";
+ break;
+ case EntityData::MODULE:
+ lDataKind = "module";
+ break;
+ default:
+ break;
+ }
+
+ //construct the arguments for the url resolver
+ std::vector<ItemSequence_t> lArgs;
+ ItemSequence_t lSeq0 = new SingletonItemSequence(theFunction);
+ ItemSequence_t lSeq1 = new SingletonItemSequence(XQXQModule::getItemFactory()->createString(aUrl));
+ ItemSequence_t lSeq2 = new SingletonItemSequence(XQXQModule::getItemFactory()->createString(lDataKind));
+ lArgs.push_back(lSeq0);
+ lArgs.push_back(lSeq1);
+ lArgs.push_back(lSeq2);
+
+ //invoke the HOF helper function using the arguments generated
+ Item lHofHelper = XQXQModule::getItemFactory()->createQName("http://www.zorba-xquery.com/modules/xqxq";, "xqxq", "hof-invoker");
+ ItemSequence_t lResult = theCtx->invoke(lHofHelper, lArgs);
+
+ //Check if the result is an empty sequence by creating an Iterator, this is cheaper than serializing the result
+ //and then checking if it was empty.
+ Iterator_t lIter = lResult->getIterator();
+ Item lItem;
+ lIter->open();
+ lIter->next(lItem);
+ lIter->close();
+ if (lItem.isNull())
+ return NULL;
+
+ //Serialize resulting sequence of the resolver
+ Zorba_SerializerOptions_t lOpt;
+ if (lItem.isNode())
+ lOpt.ser_method = ZORBA_SERIALIZATION_METHOD_XML;
+ else
+ lOpt.ser_method = ZORBA_SERIALIZATION_METHOD_TEXT;
+ lOpt.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;
+ Serializer_t lSer = Serializer::createSerializer(lOpt);
+ std::stringstream lSerResult;
+ lSer->serialize(lResult, lSerResult);
+
+ //return resource
+ return StreamResource::create(new std::istringstream(lSerResult.str()), &streamReleaser);
+ }
+
+ zorba::ItemSequence_t
+ PrepareMainModuleFunction::evaluate(
+ const Arguments_t& aArgs,
+ const zorba::StaticContext* aSctx,
+ const zorba::DynamicContext* aDctx) const
+ {
+ DynamicContext* lDynCtx = const_cast<DynamicContext*>(aDctx);
+ StaticContext_t lSctxChild = aSctx->createChildContext();
+
+ QueryMap* lQueryMap;
+ if(!(lQueryMap = dynamic_cast<QueryMap*>(lDynCtx->getExternalFunctionParameter("xqxqQueryMap"))))
+ {
+ lQueryMap = new QueryMap();
+ lDynCtx->addExternalFunctionParameter("xqxqQueryMap", lQueryMap);
+ }
+
+ Zorba *lZorba = Zorba::getInstance(0);
+
+ String lQueryString = getOneStringArgument(aArgs, 0);
+
+ XQuery_t lQuery;
+
+ StaticContext_t ltempSctx = lZorba->createStaticContext();
+ std::auto_ptr<XQXQURLResolver> lResolver;
+ std::auto_ptr<XQXQURIMapper> lMapper;
+
+ if ( aArgs.size() > 2 )
+ {
+ Item lMapperFunctionItem = getItemArgument(aArgs, 2);
+ if (!lMapperFunctionItem.isNull())
+ {
+ lMapper.reset(new XQXQURIMapper(lMapperFunctionItem, lSctxChild));
+ ltempSctx->registerURIMapper(lMapper.get());
+ }
+ }
+
+ if ( aArgs.size() > 1 )
+ {
+ Item lResolverFunctionItem = getItemArgument(aArgs, 1);
+ if (!lResolverFunctionItem.isNull())
+ {
+ lResolver.reset(new XQXQURLResolver(lResolverFunctionItem, lSctxChild));
+ ltempSctx->registerURLResolver(lResolver.get());
+ }
+
+ }
+
+ try
+ {
+ lQuery = lZorba->compileQuery(lQueryString, ltempSctx);
+ }
+ catch (XQueryException& xe)
+ {
+ lQuery = NULL;
+ std::ostringstream err;
+ err << "The query compiled using xqxq:prepare-main-module raised an error at"
+ << " line " << xe.source_line() << " column " << xe.source_column() << ": " << xe.what();
+ Item errQName = XQXQModule::getItemFactory()->createQName(
+ xe.diagnostic().qname().ns(), xe.diagnostic().qname().localname());
+ throw USER_EXCEPTION(errQName, err.str());
+ }
+ catch (ZorbaException& e)
+ {
+ lQuery = NULL;
+ std::ostringstream err;
+ err << "The query compiled using xqxq:prepare-main-module raised an error: "
+ << e.what();
+ Item errQName = XQXQModule::getItemFactory()->createQName(
+ e.diagnostic().qname().ns(), e.diagnostic().qname().localname());
+ throw USER_EXCEPTION(errQName, err.str());
+ }
+
+ uuid lUUID;
+ uuid::create(&lUUID);
+
+ std::stringstream lStream;
+ lStream << lUUID;
+
+ String lStrUUID = lStream.str();
+
+ lQueryMap->storeQuery(lStrUUID, lQuery, lMapper.release(), lResolver.release());
+
+ return ItemSequence_t(new SingletonItemSequence(XQXQModule::getItemFactory()->createAnyURI(lStrUUID)));
+ }
+
+
+ /*******************************************************************************************
+ *******************************************************************************************/
+ zorba::ItemSequence_t
+ PrepareLibraryModuleFunction::evaluate(
+ const Arguments_t& aArgs,
+ const zorba::StaticContext* aSctx,
+ const zorba::DynamicContext* aDctx) const
+ {
+ Zorba *lZorba = Zorba::getInstance(0);
+ String lQueryString = getOneStringArgument(aArgs, 0);
+
+ Zorba_CompilerHints_t hints;
+ hints.lib_module = true;
+
+ try
+ {
+ lZorba->compileQuery(lQueryString, hints);
+ }
+ catch (XQueryException& xe)
+ {
+ std::ostringstream err;
+ err << "The query compiled using xqxq:prepare-library-module raised an error at"
+ << " line " << xe.source_line() << " column " << xe.source_column() << ": " << xe.what();
+ Item errQName = XQXQModule::getItemFactory()->createQName(
+ xe.diagnostic().qname().ns(), xe.diagnostic().qname().localname());
+ throw USER_EXCEPTION(errQName, err.str());
+ }
+ catch (ZorbaException& e)
+ {
+ std::ostringstream err;
+ err << "The query compiled using xqxq:prepare-main-query raised an error: "
+ << e.what();
+ Item errQName = XQXQModule::getItemFactory()->createQName(
+ e.diagnostic().qname().ns(), e.diagnostic().qname().localname());
+ throw USER_EXCEPTION(errQName, err.str());
+ }
+ return ItemSequence_t(new EmptySequence());
+ }
+
+ /*******************************************************************************************
+ *******************************************************************************************/
+ zorba::ItemSequence_t
+ IsBoundContextItemFunction::evaluate(
+ const Arguments_t& aArgs,
+ const zorba::StaticContext* aSctx,
+ const zorba::DynamicContext* aDctx) const
+ {
+
+ String lQueryID = XQXQFunction::getOneStringArgument(aArgs, 0);
+
+ XQuery_t lQuery = getQuery(aDctx, lQueryID);
+
+ bool lIsContextItemBound = lQuery->getDynamicContext()->isBoundContextItem();
+
+ return ItemSequence_t(new SingletonItemSequence(
+ XQXQModule::getItemFactory()->createBoolean(lIsContextItemBound)));
+ }
+
+ /*******************************************************************************************
+ *******************************************************************************************/
+ zorba::ItemSequence_t
+ IsBoundVariableFunction::evaluate(
+ const Arguments_t& aArgs,
+ const zorba::StaticContext* aSctx,
+ const zorba::DynamicContext* aDctx) const
+ {
+ String lQueryID = XQXQFunction::getOneStringArgument(aArgs, 0);
+
+ XQuery_t lQuery = getQuery(aDctx, lQueryID);
+
+ Item lVarQName = XQXQFunction::getItemArgument(aArgs, 1);
+ bool lIsBoundVariable = false;
+
+ try
+ {
+ lIsBoundVariable = lQuery->getDynamicContext()->isBoundExternalVariable(lVarQName.getNamespace(),lVarQName.getLocalName());
+ }
+ catch (ZorbaException& ze)
+ {
+ if (ze.diagnostic() == zerr::ZAPI0011_ELEMENT_NOT_DECLARED)
+ XQXQFunction::throwError("UndeclaredVariable", ze.what());
+ throw; // should not happen
+ }
+ return ItemSequence_t(new SingletonItemSequence(XQXQModule::getItemFactory()->createBoolean(lIsBoundVariable)));
+
+ }
+
+ /*******************************************************************************************
+ *******************************************************************************************/
+ zorba::ItemSequence_t
+ GetExternalVariablesFunction::evaluate(
+ const Arguments_t& aArgs,
+ const zorba::StaticContext* aSctx,
+ const zorba::DynamicContext* aDctx) const
+ {
+
+ String lQueryID = XQXQFunction::getOneStringArgument(aArgs, 0);
+
+ XQuery_t lQuery = getQuery(aDctx, lQueryID);
+
+ std::vector<Item> lVars;
+ Iterator_t lVarsIterator;
+ lQuery->getExternalVariables(lVarsIterator);
+
+ Item lVar;
+ lVarsIterator->open();
+ while(lVarsIterator->next(lVar))
+ lVars.push_back(lVar);
+ lVarsIterator->close();
+
+ return ItemSequence_t(new VectorItemSequence(lVars));
+ }
+ /*******************************************************************************************
+ *******************************************************************************************/
+ zorba::ItemSequence_t
+ IsUpdatingFunction::evaluate(
+ const Arguments_t& aArgs,
+ const zorba::StaticContext* aSctx,
+ const zorba::DynamicContext* aDctx) const
+ {
+ String lQueryID = XQXQFunction::getOneStringArgument(aArgs, 0);
+
+ XQuery_t lQuery = getQuery(aDctx, lQueryID);
+
+ return ItemSequence_t(new SingletonItemSequence(XQXQModule::getItemFactory()->createBoolean(lQuery->isUpdating())));
+ }
+
+ /*******************************************************************************************
+ *******************************************************************************************/
+ zorba::ItemSequence_t
+ IsSequentialFunction::evaluate(
+ const Arguments_t& aArgs,
+ const zorba::StaticContext* aSctx,
+ const zorba::DynamicContext* aDctx) const
+ {
+ String lQueryID = XQXQFunction::getOneStringArgument(aArgs, 0);
+
+ XQuery_t lQuery = getQuery(aDctx, lQueryID);
+
+ return ItemSequence_t(new SingletonItemSequence(XQXQModule::getItemFactory()->createBoolean(lQuery->isSequential())));
+ }
+
+ /*******************************************************************************************
+ *******************************************************************************************/
+ zorba::ItemSequence_t
+ BindContextItemFunction::evaluate(
+ const Arguments_t& aArgs,
+ const zorba::StaticContext* aSctx,
+ const zorba::DynamicContext* aDctx) const
+ {
+ String lQueryID = XQXQFunction::getOneStringArgument(aArgs,0);
+
+ XQuery_t lQuery = getQuery(aDctx, lQueryID);
+
+ // shouldn't raise errors
+ Item lItemContext = XQXQFunction::getItemArgument(aArgs, 1);
+ lQuery->getDynamicContext()->setContextItem(lItemContext);
+
+ return ItemSequence_t(new EmptySequence());
+ }
+
+ /*******************************************************************************************
+ *******************************************************************************************/
+ zorba::ItemSequence_t
+ BindContextPositionFunction::evaluate(
+ const Arguments_t& aArgs,
+ const zorba::StaticContext* aSctx,
+ const zorba::DynamicContext* aDctx) const
+ {
+
+ XQXQFunction::throwError("ImplementationError", "This function is not implemented yet");
+
+ return ItemSequence_t(new EmptySequence());
+ }
+
+ /*******************************************************************************************
+ *******************************************************************************************/
+ zorba::ItemSequence_t
+ BindContextSizeFunction::evaluate(
+ const Arguments_t& aArgs,
+ const zorba::StaticContext* aSctx,
+ const zorba::DynamicContext* aDctx) const
+ {
+
+ XQXQFunction::throwError("ImplementationError", "This function is not implemented yet");
+
+ return ItemSequence_t(new EmptySequence());
+ }
+
+ /*******************************************************************************************
+ *******************************************************************************************/
+ zorba::ItemSequence_t
+ BindVariableFunction::evaluate(
+ const Arguments_t& aArgs,
+ const zorba::StaticContext* aSctx,
+ const zorba::DynamicContext* aDctx) const
+ {
+ String lQueryID = XQXQFunction::getOneStringArgument(aArgs,0);
+
+ XQuery_t lQuery = getQuery(aDctx, lQueryID);
+
+ Item lVarQName = XQXQFunction::getItemArgument(aArgs, 1);
+
+ Iterator_t lVarValue = XQXQFunction::getIterArgument(aArgs, 2);
+
+ if (!lQuery->getDynamicContext()->setVariable(
+ lVarQName.getNamespace(), lVarQName.getLocalName() , lVarValue))
+ {
+ std::ostringstream lMsg;
+ lMsg << "{" << lVarQName.getNamespace() << "}" << lVarQName.getLocalName()
+ << ": undefined variable";
+ throwError("UndeclaredVariable", lMsg.str());
+ }
+
+ return ItemSequence_t(new EmptySequence());
+ }
+
+ /*******************************************************************************************
+ *******************************************************************************************/
+ bool
+ EvaluateItemSequence::EvaluateIterator::next(Item& aItem)
+ {
+ try
+ {
+ return theIterator->next(aItem);
+ }
+ catch (XQueryException& xe)
+ {
+ std::ostringstream err;
+ err << "The query " << "(" << theQueryID << ") evaluated using xqxq:evaluate raised an error at"
+ << " line " << xe.source_line() << " column " << xe.source_column() << ": " << xe.what();
+ Item errQName = XQXQModule::getItemFactory()->createQName(
+ xe.diagnostic().qname().ns(), xe.diagnostic().qname().localname());
+ throw USER_EXCEPTION(errQName, err.str());
+ }
+ catch (ZorbaException& e)
+ {
+ std::ostringstream err;
+ err << "The query " << "(" << theQueryID << ") evaluated using xqxq:evaluate raised an error at"
+ << e.what();
+ Item errQName = XQXQModule::getItemFactory()->createQName(
+ e.diagnostic().qname().ns(), e.diagnostic().qname().localname());
+ throw USER_EXCEPTION(errQName, err.str());
+ }
+ }
+
+ /*******************************************************************************************
+ *******************************************************************************************/
+ zorba::ItemSequence_t
+ EvaluateFunction::evaluate(
+ const Arguments_t& aArgs,
+ const zorba::StaticContext* aSctx,
+ const zorba::DynamicContext* aDctx) const
+ {
+ String lQueryID = XQXQFunction::getOneStringArgument(aArgs,0);
+
+ XQuery_t lQuery = getQuery(aDctx, lQueryID);
+
+ if(lQuery->isUpdating())
+ {
+ throwError("QueryIsUpdating", "Executing Query shouldn't be updating.");
+ }
+
+
+ if(lQuery->isSequential())
+ {
+ throwError("QueryIsSequential", "Executing Query shouldn't be sequential.");
+ }
+
+ Iterator_t lIterQuery = lQuery->iterator();
+
+ return ItemSequence_t(new EvaluateItemSequence(lIterQuery, lQueryID));
+ }
+
+ /*******************************************************************************************
+ *******************************************************************************************/
+ zorba::ItemSequence_t
+ EvaluateUpdatingFunction::evaluate(
+ const Arguments_t& aArgs,
+ const zorba::StaticContext* aSctx,
+ const zorba::DynamicContext* aDctx) const
+ {
+ String lQueryID = XQXQFunction::getOneStringArgument(aArgs,0);
+
+ XQuery_t lQuery = getQuery(aDctx, lQueryID);
+
+ if(lQuery->isSequential())
+ {
+ throwError("QueryIsSequential", "Executing Query shouldn't be sequential.");
+ }
+
+ if(!lQuery->isUpdating())
+ {
+ throwError("QueryNotUpdating", "Executing Query should be updating.") ;
+ }
+
+ Iterator_t lIterQuery = lQuery->iterator();
+ return ItemSequence_t(new EvaluateItemSequence(lIterQuery, lQueryID));
+}
+
+ /*******************************************************************************************
+ *******************************************************************************************/
+ zorba::ItemSequence_t
+ EvaluateSequentialFunction::evaluate(
+ const Arguments_t& aArgs,
+ const zorba::StaticContext* aSctx,
+ const zorba::DynamicContext* aDctx) const
+ {
+ String lQueryID = XQXQFunction::getOneStringArgument(aArgs, 0);
+
+ XQuery_t lQuery = getQuery(aDctx, lQueryID);
+
+ if(lQuery->isUpdating())
+ {
+ throwError("QueryIsUpdating", "Executing Query shouldn't be updating.");
+ }
+
+ if(!lQuery->isSequential())
+ {
+ throwError("QueryNotSequential", "Executing Query should be sequential.");
+ }
+
+ Iterator_t lIterQuery = lQuery->iterator();
+ return ItemSequence_t(new EvaluateItemSequence(lIterQuery, lQueryID));
+ }
+
+ /*******************************************************************************************
+ *******************************************************************************************/
+ zorba::ItemSequence_t
+ DeleteQueryFunction::evaluate(
+ const Arguments_t& aArgs,
+ const zorba::StaticContext* aSctx,
+ const zorba::DynamicContext* aDctx) const
+ {
+ String lQueryID = XQXQFunction::getOneStringArgument(aArgs,0);
+
+ QueryMap* lQueryMap;
+ if (!(lQueryMap= dynamic_cast<QueryMap*>(aDctx->getExternalFunctionParameter("xqxqQueryMap"))))
+ {
+ throwError("NoQueryMatch", "String identifying query does not exists.");
+ }
+
+ if (!lQueryMap->deleteQuery(lQueryID))
+ {
+ throwError("NoQueryMatch","String identifying query does not exists.");
+ }
+
+ return ItemSequence_t(new EmptySequence());
+ }
+
+}/*namespace xqxq*/ }/*namespace zorba*/
+
+#ifdef WIN32
+# define DLL_EXPORT __declspec(dllexport)
+#else
+# define DLL_EXPORT __attribute__ ((visibility("default")))
+#endif
+
+extern "C" DLL_EXPORT zorba::ExternalModule* createModule() {
+ return new zorba::xqxq::XQXQModule();
+}
=== added file 'modules/xqxq/xqxq.xq.src/xqxq.h'
--- modules/xqxq/xqxq.xq.src/xqxq.h 1970-01-01 00:00:00 +0000
+++ modules/xqxq/xqxq.xq.src/xqxq.h 2012-10-25 00:08:23 +0000
@@ -0,0 +1,456 @@
+#ifndef __COM_ZORBA_WWW_MODULES_XQXQ_H__
+#define __COM_ZORBA_WWW_MODULES_XQXQ_H__
+
+#include <map>
+
+#include <zorba/zorba.h>
+#include <zorba/external_module.h>
+#include <zorba/function.h>
+#include <zorba/dynamic_context.h>
+
+#define XQXQ_MODULE_NAMESPACE "http://www.zorba-xquery.com/modules/xqxq";
+
+namespace zorba { namespace xqxq {
+
+
+
+ class XQXQModule : public ExternalModule {
+ protected:
+ class ltstr
+ {
+ public:
+ bool operator()(const String& s1, const String& s2) const
+ {
+ return s1.compare(s2) < 0;
+ }
+ };
+
+ typedef std::map<String, ExternalFunction*, ltstr> FuncMap_t;
+
+ FuncMap_t theFunctions;
+
+ public:
+
+ virtual ~XQXQModule();
+
+ virtual zorba::String
+ getURI() const {return XQXQ_MODULE_NAMESPACE;}
+
+ virtual zorba::ExternalFunction*
+ getExternalFunction(const String& localName);
+
+ virtual void destroy();
+
+ static ItemFactory*
+ getItemFactory()
+ {
+ return Zorba::getInstance(0)->getItemFactory();
+ }
+
+ };
+
+ /**
+ * @brief Bag class for objects associated with a prepared query
+ */
+ class QueryData : public SmartObject
+ {
+ private:
+ XQuery_t theQuery;
+ URIMapper* theURIMapper;
+ URLResolver* theURLResolver;
+
+ public:
+ QueryData(XQuery_t aQuery, URIMapper* aMapper, URLResolver* aResolver);
+ virtual ~QueryData();
+ XQuery_t getQuery() { return theQuery; }
+ };
+ typedef SmartPtr<QueryData> QueryData_t;
+
+ class QueryMap : public ExternalFunctionParameter
+ {
+ private:
+ typedef std::map<String, QueryData_t> QueryMap_t;
+ QueryMap_t* queryMap;
+
+ public:
+ QueryMap();
+ bool
+ storeQuery(const String&, XQuery_t, URIMapper*, URLResolver*);
+ XQuery_t
+ getQuery(const String&);
+ bool
+ deleteQuery(const String&);
+ virtual void
+ destroy() throw();
+ };
+
+ class XQXQFunction : public ContextualExternalFunction
+ {
+ protected:
+ const XQXQModule* theModule;
+
+ String
+ getOneStringArgument(const Arguments_t&, int) const;
+
+ Item
+ getItemArgument(const Arguments_t&, int) const;
+
+ Iterator_t
+ getIterArgument(const Arguments_t&, int) const;
+
+ static void
+ throwError(const char*, const std::string);
+
+ XQuery_t
+ getQuery(
+ const zorba::DynamicContext* dctx,
+ const zorba::String& aIdent) const;
+
+ public:
+
+ XQXQFunction(const XQXQModule* module);
+
+ virtual ~XQXQFunction();
+
+ virtual String
+ getURI() const;
+ };
+
+
+
+ class PrepareMainModuleFunction : public XQXQFunction{
+ public:
+ PrepareMainModuleFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
+
+ virtual ~PrepareMainModuleFunction(){ }
+
+ virtual zorba::String
+ getLocalName() const { return "prepare-main-module"; }
+
+ virtual zorba::ItemSequence_t
+ evaluate(const Arguments_t&,
+ const zorba::StaticContext*,
+ const zorba::DynamicContext*) const;
+
+ protected:
+
+ class XQXQURLResolver : public URLResolver
+ {
+ protected:
+ Item theFunction;
+ StaticContext_t theCtx;
+
+ public:
+ XQXQURLResolver(Item& aFunction, StaticContext_t& aSctx) : URLResolver(), theFunction(aFunction), theCtx(aSctx) {}
+
+ virtual ~XQXQURLResolver(){ }
+
+ virtual Resource* resolveURL(const String& aUrl,
+ EntityData const* aEntityData);
+
+ };
+
+ class XQXQURIMapper : public URIMapper
+ {
+ protected:
+ Item theFunction;
+ StaticContext_t theCtx;
+
+ public:
+ XQXQURIMapper(Item& aFunction, StaticContext_t& aSctx) : URIMapper(), theFunction(aFunction), theCtx(aSctx) {}
+
+ virtual ~XQXQURIMapper(){ }
+
+ virtual void mapURI(
+ const zorba::String aUri,
+ EntityData const* aEntityData,
+ std::vector<zorba::String>& oUris);
+
+ };
+
+ };
+
+ class PrepareLibraryModuleFunction : public XQXQFunction{
+ public:
+ PrepareLibraryModuleFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
+
+ virtual ~PrepareLibraryModuleFunction(){}
+
+ virtual zorba::String
+ getLocalName() const { return "prepare-library-module"; }
+
+ virtual zorba::ItemSequence_t
+ evaluate(const Arguments_t&,
+ const zorba::StaticContext*,
+ const zorba::DynamicContext*) const;
+ };
+
+ class IsBoundContextItemFunction : public XQXQFunction{
+ public:
+ IsBoundContextItemFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
+
+ virtual ~IsBoundContextItemFunction(){}
+
+ virtual zorba::String
+ getLocalName() const { return "is-bound-context-item"; }
+
+ virtual zorba::ItemSequence_t
+ evaluate(const Arguments_t&,
+ const zorba::StaticContext*,
+ const zorba::DynamicContext*) const;
+ };
+
+ class IsBoundVariableFunction : public XQXQFunction{
+ public:
+ IsBoundVariableFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
+
+ virtual ~IsBoundVariableFunction(){}
+
+ virtual zorba::String
+ getLocalName() const { return "is-bound-variable"; }
+
+ virtual zorba::ItemSequence_t
+ evaluate(const Arguments_t&,
+ const zorba::StaticContext*,
+ const zorba::DynamicContext*) const;
+ };
+
+ class GetExternalVariablesFunction : public XQXQFunction{
+ public:
+ GetExternalVariablesFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
+
+ virtual ~GetExternalVariablesFunction() {}
+
+ virtual zorba::String
+ getLocalName() const {return "external-variables"; }
+
+ virtual zorba::ItemSequence_t
+ evaluate(const Arguments_t&,
+ const zorba::StaticContext*,
+ const zorba::DynamicContext*) const;
+ };
+
+ class IsUpdatingFunction : public XQXQFunction{
+ public:
+ IsUpdatingFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
+
+ virtual ~IsUpdatingFunction() {}
+
+ virtual zorba::String
+ getLocalName() const {return "is-updating"; }
+
+ virtual zorba::ItemSequence_t
+ evaluate(const Arguments_t&,
+ const zorba::StaticContext*,
+ const zorba::DynamicContext*) const;
+
+ };
+
+ class IsSequentialFunction : public XQXQFunction{
+ public:
+ IsSequentialFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
+
+ virtual ~IsSequentialFunction() {}
+
+ virtual zorba::String
+ getLocalName() const {return "is-sequential"; }
+
+ virtual zorba::ItemSequence_t
+ evaluate(const Arguments_t&,
+ const zorba::StaticContext*,
+ const zorba::DynamicContext*) const;
+ };
+
+ class BindContextItemFunction : public XQXQFunction{
+ public:
+ BindContextItemFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
+
+ virtual ~BindContextItemFunction() {}
+
+ virtual zorba::String
+ getLocalName() const {return "bind-context-item"; }
+
+ virtual zorba::ItemSequence_t
+ evaluate(const Arguments_t&,
+ const zorba::StaticContext*,
+ const zorba::DynamicContext*) const;
+ };
+
+ class BindContextPositionFunction : public XQXQFunction{
+ public:
+ BindContextPositionFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
+
+ virtual ~BindContextPositionFunction() {}
+
+ virtual zorba::String
+ getLocalName() const {return "bind-context-position"; }
+
+ virtual zorba::ItemSequence_t
+ evaluate(const Arguments_t&,
+ const zorba::StaticContext*,
+ const zorba::DynamicContext*) const;
+ };
+
+ class BindContextSizeFunction : public XQXQFunction{
+ public:
+ BindContextSizeFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
+
+ virtual ~BindContextSizeFunction() {}
+
+ virtual zorba::String
+ getLocalName() const {return "bind-context-size"; }
+
+ virtual zorba::ItemSequence_t
+ evaluate(const Arguments_t&,
+ const zorba::StaticContext*,
+ const zorba::DynamicContext*) const;
+ };
+
+ class BindVariableFunction : public XQXQFunction{
+ public:
+ BindVariableFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
+
+ virtual ~BindVariableFunction() {}
+
+ virtual zorba::String
+ getLocalName() const {return "bind-variable"; }
+
+ virtual zorba::ItemSequence_t
+ evaluate(const Arguments_t&,
+ const zorba::StaticContext*,
+ const zorba::DynamicContext*) const;
+ };
+
+ /*******************************************************************************************
+ *******************************************************************************************/
+ class EvaluateItemSequence : public ItemSequence
+ {
+ protected:
+
+ class EvaluateIterator : public Iterator
+ {
+ protected:
+ Iterator_t theIterator;
+
+ String theQueryID;
+
+ public:
+ EvaluateIterator(Iterator_t& aIter, String aQueryID)
+ : theIterator(aIter), theQueryID(aQueryID)
+ {
+ }
+
+ virtual ~EvaluateIterator(){}
+
+ virtual void
+ open()
+ {
+ theIterator->open();
+ }
+
+ virtual bool
+ next(Item& aItem);
+
+ virtual void
+ close()
+ {
+ theIterator->close();
+ }
+
+ virtual bool
+ isOpen() const
+ {
+ return theIterator->isOpen();
+ }
+
+ };
+
+ typedef zorba::SmartPtr<EvaluateIterator> EvaluateIterator_t;
+ EvaluateIterator_t theIter;
+
+ public:
+ EvaluateItemSequence(Iterator_t& aIter, String& aQueryID)
+ :theIter (new EvaluateIterator(aIter, aQueryID))
+ {
+
+ }
+
+ virtual ~EvaluateItemSequence() {}
+
+ Iterator_t
+ getIterator() { return theIter.get(); }
+ };
+
+ class EvaluateFunction : public XQXQFunction{
+ public:
+ EvaluateFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
+
+ virtual ~EvaluateFunction() {}
+
+ virtual zorba::String
+ getLocalName() const {return "evaluate"; }
+
+ virtual zorba::ItemSequence_t
+ evaluate(const Arguments_t&,
+ const zorba::StaticContext*,
+ const zorba::DynamicContext*) const;
+ };
+
+ class EvaluateUpdatingFunction : public XQXQFunction{
+ public:
+ EvaluateUpdatingFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
+
+ virtual ~EvaluateUpdatingFunction() {}
+
+ virtual zorba::String
+ getLocalName() const {return "evaluate-updating"; }
+
+ virtual zorba::ItemSequence_t
+ evaluate(const Arguments_t&,
+ const zorba::StaticContext*,
+ const zorba::DynamicContext*) const;
+ };
+
+ class EvaluateSequentialFunction : public XQXQFunction{
+ public:
+ EvaluateSequentialFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
+
+ virtual ~EvaluateSequentialFunction() {}
+
+ virtual zorba::String
+ getLocalName() const {return "evaluate-sequential"; }
+
+ virtual zorba::ItemSequence_t
+ evaluate(const Arguments_t&,
+ const zorba::StaticContext*,
+ const zorba::DynamicContext*) const;
+
+ virtual String getURI() const {
+ return theModule->getURI();
+ }
+
+ protected:
+ const XQXQModule* theModule;
+ };
+
+ class DeleteQueryFunction : public XQXQFunction{
+ public:
+ DeleteQueryFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
+
+ virtual ~DeleteQueryFunction() {}
+
+ virtual zorba::String
+ getLocalName() const {return "delete-query"; }
+
+ virtual zorba::ItemSequence_t
+ evaluate(const Arguments_t&,
+ const zorba::StaticContext*,
+ const zorba::DynamicContext*) const;
+ };
+
+
+
+}/*xqxq namespace*/}/*zorba namespace*/
+
+
+#endif //_COM_ZORBA_WWW_MODULES_XQXQ_H_
=== added directory 'test/rbkt/ExpQueryResults/zorba/xqxq'
=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/bind-context-item.xml.res'
--- test/rbkt/ExpQueryResults/zorba/xqxq/bind-context-item.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/xqxq/bind-context-item.xml.res 2012-10-25 00:08:23 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+true
\ No newline at end of file
=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/bind-variable.xml.res'
--- test/rbkt/ExpQueryResults/zorba/xqxq/bind-variable.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/xqxq/bind-variable.xml.res 2012-10-25 00:08:23 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+true
\ No newline at end of file
=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/evaluate-sequential.xml.res'
--- test/rbkt/ExpQueryResults/zorba/xqxq/evaluate-sequential.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/xqxq/evaluate-sequential.xml.res 2012-10-25 00:08:23 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+true
\ No newline at end of file
=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/evaluate-updating.xml.res'
--- test/rbkt/ExpQueryResults/zorba/xqxq/evaluate-updating.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/xqxq/evaluate-updating.xml.res 2012-10-25 00:08:23 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<parent><child>Content</child></parent>
\ No newline at end of file
=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/evaluate.xml.res'
--- test/rbkt/ExpQueryResults/zorba/xqxq/evaluate.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/xqxq/evaluate.xml.res 2012-10-25 00:08:23 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+2
\ No newline at end of file
=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/evaluate2.xml.res'
--- test/rbkt/ExpQueryResults/zorba/xqxq/evaluate2.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/xqxq/evaluate2.xml.res 2012-10-25 00:08:23 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+2
\ No newline at end of file
=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/external-module.xml.res'
--- test/rbkt/ExpQueryResults/zorba/xqxq/external-module.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/xqxq/external-module.xml.res 2012-10-25 00:08:23 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+true
\ No newline at end of file
=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/get-external-variables.xml.res'
--- test/rbkt/ExpQueryResults/zorba/xqxq/get-external-variables.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/xqxq/get-external-variables.xml.res 2012-10-25 00:08:23 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+a
\ No newline at end of file
=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/is-bound-context-item.xml.res'
--- test/rbkt/ExpQueryResults/zorba/xqxq/is-bound-context-item.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/xqxq/is-bound-context-item.xml.res 2012-10-25 00:08:23 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+false
\ No newline at end of file
=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/is-bound-variable.xml.res'
--- test/rbkt/ExpQueryResults/zorba/xqxq/is-bound-variable.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/xqxq/is-bound-variable.xml.res 2012-10-25 00:08:23 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+true true false
\ No newline at end of file
=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/is-sequential.xml.res'
--- test/rbkt/ExpQueryResults/zorba/xqxq/is-sequential.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/xqxq/is-sequential.xml.res 2012-10-25 00:08:23 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+true false
\ No newline at end of file
=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/is-updating.xml.res'
--- test/rbkt/ExpQueryResults/zorba/xqxq/is-updating.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/xqxq/is-updating.xml.res 2012-10-25 00:08:23 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+true false
\ No newline at end of file
=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/multiple-queries.xml.res'
--- test/rbkt/ExpQueryResults/zorba/xqxq/multiple-queries.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/xqxq/multiple-queries.xml.res 2012-10-25 00:08:23 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+2 3
\ No newline at end of file
=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/uri-mapper.xml.res'
--- test/rbkt/ExpQueryResults/zorba/xqxq/uri-mapper.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/xqxq/uri-mapper.xml.res 2012-10-25 00:08:23 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+foo
=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/uri-mapper2.xml.res'
--- test/rbkt/ExpQueryResults/zorba/xqxq/uri-mapper2.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/xqxq/uri-mapper2.xml.res 2012-10-25 00:08:23 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<test:test xmlns:test="http://test";><test:subtest>a</test:subtest><test:subtest2>a</test:subtest2></test:test>
=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/url-module-resolver.xml.res'
--- test/rbkt/ExpQueryResults/zorba/xqxq/url-module-resolver.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/xqxq/url-module-resolver.xml.res 2012-10-25 00:08:23 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+foo
=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/url-schema-resolver.xml.res'
--- test/rbkt/ExpQueryResults/zorba/xqxq/url-schema-resolver.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/xqxq/url-schema-resolver.xml.res 2012-10-25 00:08:23 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<test:test xmlns:test="http://test";><test:subtest>a</test:subtest><test:subtest2>a</test:subtest2></test:test>
=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/url-schema-resolver2.xml.res'
--- test/rbkt/ExpQueryResults/zorba/xqxq/url-schema-resolver2.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/xqxq/url-schema-resolver2.xml.res 2012-10-25 00:08:23 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<test:test xmlns:test="http://test";><test:subtest>a</test:subtest><test:subtest2>a</test:subtest2></test:test>
=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/url-schema-resolver3.xml.res'
--- test/rbkt/ExpQueryResults/zorba/xqxq/url-schema-resolver3.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/xqxq/url-schema-resolver3.xml.res 2012-10-25 00:08:23 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<test:test xmlns:test="http://test";><test:subtest>a</test:subtest><test:subtest2>a</test:subtest2></test:test>
=== added directory 'test/rbkt/Queries/zorba/xqxq'
=== added file 'test/rbkt/Queries/zorba/xqxq/bind-context-item.xq'
--- test/rbkt/Queries/zorba/xqxq/bind-context-item.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/bind-context-item.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,6 @@
+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+
+variable $query-key := xqxq:prepare-main-module("insert node <child>Content</child> into /parent");
+variable $xml := doc("context-item.xml");
+xqxq:bind-context-item($query-key, $xml);
+xqxq:is-bound-context-item($query-key)
=== added file 'test/rbkt/Queries/zorba/xqxq/bind-variable.xq'
--- test/rbkt/Queries/zorba/xqxq/bind-variable.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/bind-variable.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,4 @@
+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+variable $query-key := xqxq:prepare-main-module('declare variable $a external; $a');
+xqxq:bind-variable($query-key,xs:QName('a'),"foo");
+xqxq:is-bound-variable($query-key, xs:QName('a'))
\ No newline at end of file
=== added file 'test/rbkt/Queries/zorba/xqxq/context-item.xml'
--- test/rbkt/Queries/zorba/xqxq/context-item.xml 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/context-item.xml 2012-10-25 00:08:23 +0000
@@ -0,0 +1,1 @@
+<parent></parent>
\ No newline at end of file
=== added file 'test/rbkt/Queries/zorba/xqxq/delete.spec'
--- test/rbkt/Queries/zorba/xqxq/delete.spec 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/delete.spec 2012-10-25 00:08:23 +0000
@@ -0,0 +1,1 @@
+Error: http://www.zorba-xquery.com/modules/xqxq:NoQueryMatch
\ No newline at end of file
=== added file 'test/rbkt/Queries/zorba/xqxq/delete.xq'
--- test/rbkt/Queries/zorba/xqxq/delete.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/delete.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,5 @@
+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+
+variable $query-key := xqxq:prepare-main-module("1+1");
+xqxq:delete-query($query-key);
+xqxq:evaluate($query-key)
=== added file 'test/rbkt/Queries/zorba/xqxq/error-in-query.spec'
--- test/rbkt/Queries/zorba/xqxq/error-in-query.spec 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/error-in-query.spec 2012-10-25 00:08:23 +0000
@@ -0,0 +1,2 @@
+Error: http://www.w3.org/2005/xqt-errors:XQST0033
+
=== added file 'test/rbkt/Queries/zorba/xqxq/error-in-query.xq'
--- test/rbkt/Queries/zorba/xqxq/error-in-query.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/error-in-query.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,21 @@
+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+
+declare namespace op = 'http://www.zorba-xquery.com/options/features';
+declare namespace f = 'http://www.zorba-xquery.com/features';
+declare option op:enable 'f:hof';
+
+declare function local:url-resolver($namespace as xs:string, $entity as xs:string) {
+switch($entity)
+case 'schema'
+ return switch($namespace)
+ case 'http://www.w3.org/XQueryTest' return doc('/tmp/atomic.xsd')
+ default return ()
+default return ()
+};
+
+variable $queryID := xqxq:prepare-main-module(
+ "declare namespace foo='http://test';
+ declare namespace foo='http://test';
+ 1",
+ local:url-resolver#2, ());
+xqxq:evaluate($queryID)
=== added file 'test/rbkt/Queries/zorba/xqxq/evaluate-sequential.xq'
--- test/rbkt/Queries/zorba/xqxq/evaluate-sequential.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/evaluate-sequential.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,17 @@
+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+
+variable $query-key := xqxq:prepare-main-module('
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+declare namespace an = "http://www.zorba-xquery.com/annotations";;
+declare %an:sequential function local:foo() {
+ ddl:create(xs:QName("hola"),(<a/>,<b/>));
+
+ exit returning true();
+};
+
+local:foo()
+');
+variable $xml := doc("context-item.xml");
+xqxq:bind-context-item($query-key, $xml);
+xqxq:evaluate-sequential($query-key)
+
=== added file 'test/rbkt/Queries/zorba/xqxq/evaluate-sequential2.spec'
--- test/rbkt/Queries/zorba/xqxq/evaluate-sequential2.spec 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/evaluate-sequential2.spec 2012-10-25 00:08:23 +0000
@@ -0,0 +1,1 @@
+Error: http://www.zorba-xquery.com/modules/xqxq:QueryIsUpdating
\ No newline at end of file
=== added file 'test/rbkt/Queries/zorba/xqxq/evaluate-sequential2.xq'
--- test/rbkt/Queries/zorba/xqxq/evaluate-sequential2.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/evaluate-sequential2.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,6 @@
+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+
+variable $query-key := xqxq:prepare-main-module("insert node <child>Content</child> into /parent");
+variable $xml := doc("context-item.xml");
+xqxq:bind-context-item($query-key, $xml);
+xqxq:evaluate-sequential($query-key)
\ No newline at end of file
=== added file 'test/rbkt/Queries/zorba/xqxq/evaluate-updating.xq'
--- test/rbkt/Queries/zorba/xqxq/evaluate-updating.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/evaluate-updating.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,7 @@
+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+
+variable $query-key := xqxq:prepare-main-module("insert node <child>Content</child> into /parent");
+variable $xml := doc("context-item.xml");
+xqxq:bind-context-item($query-key, $xml);
+xqxq:evaluate-updating($query-key);
+$xml
\ No newline at end of file
=== added file 'test/rbkt/Queries/zorba/xqxq/evaluate-updating2.spec'
--- test/rbkt/Queries/zorba/xqxq/evaluate-updating2.spec 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/evaluate-updating2.spec 2012-10-25 00:08:23 +0000
@@ -0,0 +1,1 @@
+Error: http://www.zorba-xquery.com/modules/xqxq:QueryIsSequential
\ No newline at end of file
=== added file 'test/rbkt/Queries/zorba/xqxq/evaluate-updating2.xq'
--- test/rbkt/Queries/zorba/xqxq/evaluate-updating2.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/evaluate-updating2.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,15 @@
+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+
+variable $query-key := xqxq:prepare-main-module('
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+declare namespace an = "http://www.zorba-xquery.com/annotations";;
+declare %an:sequential function local:foo() {
+ ddl:create(xs:QName("hola"),(<a/>,<b/>));
+
+ exit returning ();
+};
+
+local:foo()
+');
+xqxq:evaluate-updating($query-key);
+
=== added file 'test/rbkt/Queries/zorba/xqxq/evaluate.xq'
--- test/rbkt/Queries/zorba/xqxq/evaluate.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/evaluate.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,5 @@
+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+
+variable $query-key := xqxq:prepare-main-module("1+1");
+variable $a := xqxq:evaluate($query-key);
+$a
=== added file 'test/rbkt/Queries/zorba/xqxq/evaluate2.xq'
--- test/rbkt/Queries/zorba/xqxq/evaluate2.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/evaluate2.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,6 @@
+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+
+variable $query-key := xqxq:prepare-main-module("declare variable $a external; $a+1");
+xqxq:bind-variable($query-key, xs:QName("a"), 1);
+variable $b := xqxq:evaluate($query-key);
+$b
=== added file 'test/rbkt/Queries/zorba/xqxq/evaluate3.spec'
--- test/rbkt/Queries/zorba/xqxq/evaluate3.spec 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/evaluate3.spec 2012-10-25 00:08:23 +0000
@@ -0,0 +1,1 @@
+Error: http://www.zorba-xquery.com/modules/xqxq:QueryIsSequential
\ No newline at end of file
=== added file 'test/rbkt/Queries/zorba/xqxq/evaluate3.xq'
--- test/rbkt/Queries/zorba/xqxq/evaluate3.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/evaluate3.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,15 @@
+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+
+variable $query-key := xqxq:prepare-main-module('
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+declare namespace an = "http://www.zorba-xquery.com/annotations";;
+declare %an:sequential function local:foo() {
+ ddl:create(xs:QName("hola"),(<a/>,<b/>));
+
+ exit returning ();
+};
+
+local:foo()
+');
+variable $a := xqxq:evaluate($query-key);
+$a
=== added file 'test/rbkt/Queries/zorba/xqxq/external-module.xq'
--- test/rbkt/Queries/zorba/xqxq/external-module.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/external-module.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,8 @@
+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+
+variable $query-key := xqxq:prepare-main-module('
+ import module namespace r = "http://www.zorba-xquery.com/modules/random";;
+
+ count((for $i in 1 to 10 return r:random(10), r:random())) eq 101
+ ');
+xqxq:evaluate($query-key)
\ No newline at end of file
=== added file 'test/rbkt/Queries/zorba/xqxq/get-external-variables.xq'
--- test/rbkt/Queries/zorba/xqxq/get-external-variables.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/get-external-variables.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,4 @@
+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+variable $query-key2 := xqxq:prepare-main-module('declare variable $c external; $c');
+variable $query-key := xqxq:prepare-main-module('declare variable $a external;declare variable $d := "hi"; $a');
+xqxq:external-variables($query-key)
\ No newline at end of file
=== added file 'test/rbkt/Queries/zorba/xqxq/is-bound-context-item.xq'
--- test/rbkt/Queries/zorba/xqxq/is-bound-context-item.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/is-bound-context-item.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,4 @@
+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+
+variable $query-key := xqxq:prepare-main-module("insert node <child/> into /parent");
+xqxq:is-bound-context-item($query-key)
=== added file 'test/rbkt/Queries/zorba/xqxq/is-bound-variable.xq'
--- test/rbkt/Queries/zorba/xqxq/is-bound-variable.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/is-bound-variable.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,10 @@
+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+variable $query-key := xqxq:prepare-main-module('
+ declare variable $a external;
+ declare variable $b external := 2;
+ declare variable $c external;
+ $a');
+xqxq:bind-variable($query-key, xs:QName('a'), "foo");
+xqxq:is-bound-variable($query-key, xs:QName('a')),
+xqxq:is-bound-variable($query-key, xs:QName('b')),
+xqxq:is-bound-variable($query-key, xs:QName('c'))
\ No newline at end of file
=== added file 'test/rbkt/Queries/zorba/xqxq/is-bound-variable2.spec'
--- test/rbkt/Queries/zorba/xqxq/is-bound-variable2.spec 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/is-bound-variable2.spec 2012-10-25 00:08:23 +0000
@@ -0,0 +1,1 @@
+Error: http://www.zorba-xquery.com/modules/xqxq:UndeclaredVariable
\ No newline at end of file
=== added file 'test/rbkt/Queries/zorba/xqxq/is-bound-variable2.xq'
--- test/rbkt/Queries/zorba/xqxq/is-bound-variable2.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/is-bound-variable2.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,7 @@
+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+variable $query-key := xqxq:prepare-main-module('
+ declare variable $a external;
+ declare variable $b external := 2;
+ declare variable $c external;
+ $a');
+xqxq:is-bound-variable($query-key, xs:QName('x'))
\ No newline at end of file
=== added file 'test/rbkt/Queries/zorba/xqxq/is-sequential.xq'
--- test/rbkt/Queries/zorba/xqxq/is-sequential.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/is-sequential.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,18 @@
+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+
+variable $query-key1 := xqxq:prepare-main-module('
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+declare namespace an = "http://www.zorba-xquery.com/annotations";;
+declare %an:sequential function local:foo() {
+ ddl:create(xs:QName("hola"),(<a/>,<b/>));
+
+ exit returning ();
+};
+
+local:foo()
+');
+variable $query-key2 := xqxq:prepare-main-module("insert node <child/> into /parent");
+variable $is-sequential := xqxq:is-sequential($query-key1);
+variable $is-not-sequential := xqxq:is-sequential($query-key2);
+$is-sequential, $is-not-sequential
+
=== added file 'test/rbkt/Queries/zorba/xqxq/is-updating.xq'
--- test/rbkt/Queries/zorba/xqxq/is-updating.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/is-updating.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,20 @@
+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+
+variable $query-key1 := xqxq:prepare-main-module('
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+declare namespace an = "http://www.zorba-xquery.com/annotations";;
+declare %an:sequential function local:foo() {
+ ddl:create(xs:QName("hola"),(<a/>,<b/>));
+
+ exit returning ();
+};
+
+local:foo()
+');
+variable $query-key2 := xqxq:prepare-main-module("insert node <child/> into /parent");
+variable $is-updating := xqxq:is-updating($query-key2);
+variable $is-not-updating := xqxq:is-updating($query-key1);
+xqxq:delete-query($query-key1);
+xqxq:delete-query($query-key2);
+$is-updating, $is-not-updating
+
=== added file 'test/rbkt/Queries/zorba/xqxq/multiple-queries.xq'
--- test/rbkt/Queries/zorba/xqxq/multiple-queries.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/multiple-queries.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,9 @@
+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+
+variable $query-key1 := xqxq:prepare-main-module("1+1");
+variable $query-key2 := xqxq:prepare-main-module("1+2");
+variable $a := xqxq:evaluate($query-key1);
+variable $b := xqxq:evaluate($query-key2);
+xqxq:delete-query($query-key1);
+xqxq:delete-query($query-key2);
+$a, $b
=== added file 'test/rbkt/Queries/zorba/xqxq/prepare-library-module.spec'
--- test/rbkt/Queries/zorba/xqxq/prepare-library-module.spec 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/prepare-library-module.spec 2012-10-25 00:08:23 +0000
@@ -0,0 +1,1 @@
+Error: http://www.w3.org/2005/xqt-errors:XPST0003
=== added file 'test/rbkt/Queries/zorba/xqxq/prepare-library-module.xq'
--- test/rbkt/Queries/zorba/xqxq/prepare-library-module.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/prepare-library-module.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,3 @@
+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+
+xqxq:prepare-library-module('module namespace foo = "foo:bar"; declare function foo:bar() { 1 }')
=== added file 'test/rbkt/Queries/zorba/xqxq/test.xml'
--- test/rbkt/Queries/zorba/xqxq/test.xml 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/test.xml 2012-10-25 00:08:23 +0000
@@ -0,0 +1,1 @@
+<test:test xmlns:test="http://test";><test:subtest>a</test:subtest><test:subtest2>a</test:subtest2></test:test>
\ No newline at end of file
=== added file 'test/rbkt/Queries/zorba/xqxq/test.xsd'
--- test/rbkt/Queries/zorba/xqxq/test.xsd 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/test.xsd 2012-10-25 00:08:23 +0000
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
+ targetNamespace="http://test";
+ xmlns="http://test";
+ elementFormDefault="qualified">
+ <xs:element name="test">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="subtest" type="xs:string"/>
+ <xs:element name="subtest2" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
\ No newline at end of file
=== added file 'test/rbkt/Queries/zorba/xqxq/uri-mapper.xq'
--- test/rbkt/Queries/zorba/xqxq/uri-mapper.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/uri-mapper.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,27 @@
+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+
+declare namespace resolver = 'http://www.zorba-xquery.com/modules/xqxq/url-resolver';
+declare namespace mapper = 'http://www.zorba-xquery.com/modules/xqxq/uri-mapper';
+declare namespace op = "http://www.zorba-xquery.com/options/features";;
+declare namespace f = "http://www.zorba-xquery.com/features";;
+declare option op:enable "f:hof";
+
+declare function resolver:url-resolver($namespace as xs:string, $entity as xs:string) {
+ if($namespace = 'http://foo')
+ then "module namespace test = 'http://test'; declare function test:foo(){'foo'};"
+ else ()
+};
+
+declare function mapper:uri-mapper($namespace as xs:string, $entity as xs:string)
+{
+ if($namespace = 'http://test')
+ then 'http://foo'
+ else ()
+};
+
+variable $queryID := xqxq:prepare-main-module
+(
+ "import module namespace test = 'http://test'; test:foo()",
+ resolver:url-resolver#2, mapper:uri-mapper#2
+);
+xqxq:evaluate($queryID)
=== added file 'test/rbkt/Queries/zorba/xqxq/uri-mapper2.xq'
--- test/rbkt/Queries/zorba/xqxq/uri-mapper2.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/uri-mapper2.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,22 @@
+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+
+declare namespace resolver = 'http://www.zorba-xquery.com/modules/xqxq/url-resolver';
+declare namespace mapper = 'http://www.zorba-xquery.com/modules/xqxq/uri-mapper';
+declare namespace op = "http://www.zorba-xquery.com/options/features";;
+declare namespace f = "http://www.zorba-xquery.com/features";;
+declare option op:enable "f:hof";
+
+declare function mapper:uri-mapper($namespace as xs:string, $entity as xs:string)
+{
+ if ($namespace = 'http://test' and $entity = 'schema')
+ then resolve-uri('test.xsd')
+ else ()
+};
+
+variable $queryID := xqxq:prepare-main-module
+(
+ "import schema namespace test = 'http://test'; validate{<test:test><test:subtest>a</test:subtest><test:subtest2>a</test:subtest2></test:test>}",
+ (),
+ mapper:uri-mapper#2
+);
+xqxq:evaluate($queryID)
=== added file 'test/rbkt/Queries/zorba/xqxq/url-module-resolver.xq'
--- test/rbkt/Queries/zorba/xqxq/url-module-resolver.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/url-module-resolver.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,17 @@
+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+
+declare namespace resolver = 'http://www.zorba-xquery.com/modules/xqxq/url-resolver';
+declare namespace op = "http://www.zorba-xquery.com/options/features";;
+declare namespace f = "http://www.zorba-xquery.com/features";;
+declare option op:enable "f:hof";
+
+declare function resolver:url-resolver($namespace as xs:string, $entity as xs:string) {
+ if($namespace = 'http://test.xq')
+ then "module namespace test = 'http://test'; declare function test:foo(){'foo'};"
+ else ()
+};
+
+variable $queryID := xqxq:prepare-main-module(
+ "import module namespace test = 'http://test'; test:foo()",
+ resolver:url-resolver#2, ());
+xqxq:evaluate($queryID)
=== added file 'test/rbkt/Queries/zorba/xqxq/url-schema-resolver.xq'
--- test/rbkt/Queries/zorba/xqxq/url-schema-resolver.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/url-schema-resolver.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,20 @@
+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+
+declare namespace resolver = 'http://www.zorba-xquery.com/modules/xqxq/url-resolver';
+
+declare namespace op = "http://www.zorba-xquery.com/options/features";;
+declare namespace f = "http://www.zorba-xquery.com/features";;
+declare option op:enable "f:hof";
+
+declare function resolver:url-resolver($namespace as xs:string, $entity as xs:string) {
+ if($namespace = 'http://test' and $entity = 'schema')
+ then
+ doc('test.xsd')
+ else
+ ()
+};
+
+variable $queryID := xqxq:prepare-main-module(
+ "import schema namespace test = 'http://test'; validate {<test:test><test:subtest>a</test:subtest><test:subtest2>a</test:subtest2></test:test>}",
+ resolver:url-resolver#2, ());
+xqxq:evaluate($queryID)
=== added file 'test/rbkt/Queries/zorba/xqxq/url-schema-resolver2.xq'
--- test/rbkt/Queries/zorba/xqxq/url-schema-resolver2.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/url-schema-resolver2.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,29 @@
+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+
+import module namespace ddl =
+ "http://www.zorba-xquery.com/modules/store/dynamic/collections/w3c/ddl";;
+import module namespace dml =
+ "http://www.zorba-xquery.com/modules/store/dynamic/collections/w3c/dml";;
+
+declare namespace resolver = 'http://www.zorba-xquery.com/modules/xqxq/url-resolver';
+declare namespace op = "http://www.zorba-xquery.com/options/features";;
+declare namespace f = "http://www.zorba-xquery.com/features";;
+declare option op:enable "f:hof";
+
+declare function resolver:url-resolver($namespace as xs:string, $entity as xs:string) {
+ if ($entity = 'schema')
+ then
+ dml:collection("http://www.zorba-xquery.com/modules/xqxq";)//xs:schema[@targetNamespace=$namespace]
+ else
+ ()
+};
+
+declare variable $coll := "http://www.zorba-xquery.com/modules/xqxq";;
+declare variable $schema := doc("test.xsd");
+ddl:create($coll);
+
+dml:apply-insert-nodes-first($coll, $schema);
+variable $query-key := xqxq:prepare-main-module(
+ "import schema namespace test = 'http://test'; validate {<test:test><test:subtest>a</test:subtest><test:subtest2>a</test:subtest2></test:test>}",
+ resolver:url-resolver#2, ());
+xqxq:evaluate($query-key)
=== added file 'test/rbkt/Queries/zorba/xqxq/url-schema-resolver3.xq'
--- test/rbkt/Queries/zorba/xqxq/url-schema-resolver3.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/xqxq/url-schema-resolver3.xq 2012-10-25 00:08:23 +0000
@@ -0,0 +1,29 @@
+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
+
+declare namespace resolver = 'http://www.zorba-xquery.com/modules/xqxq/url-resolver';
+
+declare namespace op = "http://www.zorba-xquery.com/options/features";;
+declare namespace f = "http://www.zorba-xquery.com/features";;
+declare option op:enable "f:hof";
+
+declare function resolver:url-resolver($namespace as xs:string, $entity as xs:string) {
+ if($namespace = 'http://test' and $entity = 'schema')
+ then
+ doc('test.xsd')
+ else
+ ()
+};
+
+variable $contextQueryID := xqxq:prepare-main-module(
+ "import schema namespace test = 'http://test';
+ declare variable $cwd as xs:anyURI external;
+ validate { doc(resolve-uri('test.xml', $cwd)) }",
+ resolver:url-resolver#2, ());
+xqxq:bind-variable($contextQueryID, fn:QName("", "cwd"), resolve-uri("."));
+variable $contextItem := xqxq:evaluate($contextQueryID);
+
+variable $queryID := xqxq:prepare-main-module(
+ "import schema namespace test = 'http://test'; //*:test",
+ resolver:url-resolver#2, ());
+xqxq:bind-context-item($queryID, $contextItem);
+xqxq:evaluate($queryID)
Follow ups