Merge lp:~zorba-coders/zorba/move-xqxq-core into lp:zorba

Proposed by Chris Hillery
Status: Merged
Approved by: Juan Zacarias
Approved revision: 11112
Merged at revision: 11112
Proposed branch: lp:~zorba-coders/zorba/move-xqxq-core
Merge into: lp:zorba
Diff against target: 2428 lines (+2067/-1)
62 files modified
ChangeLog (+1/-0)
modules/CMakeLists.txt (+1/-0)
modules/ExternalModules.conf (+0/-1)
modules/xqxq/CMakeLists.txt (+15/-0)
modules/xqxq/xqxq.xq (+381/-0)
modules/xqxq/xqxq.xq.src/xqxq.cpp (+817/-0)
modules/xqxq/xqxq.xq.src/xqxq.h (+456/-0)
test/rbkt/ExpQueryResults/zorba/xqxq/bind-context-item.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/xqxq/bind-variable.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/xqxq/evaluate-sequential.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/xqxq/evaluate-updating.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/xqxq/evaluate.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/xqxq/evaluate2.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/xqxq/external-module.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/xqxq/get-external-variables.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/xqxq/is-bound-context-item.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/xqxq/is-bound-variable.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/xqxq/is-sequential.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/xqxq/is-updating.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/xqxq/multiple-queries.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/xqxq/uri-mapper.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/xqxq/uri-mapper2.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/xqxq/url-module-resolver.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/xqxq/url-schema-resolver.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/xqxq/url-schema-resolver2.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/xqxq/url-schema-resolver3.xml.res (+2/-0)
test/rbkt/Queries/zorba/xqxq/bind-context-item.xq (+6/-0)
test/rbkt/Queries/zorba/xqxq/bind-variable.xq (+4/-0)
test/rbkt/Queries/zorba/xqxq/context-item.xml (+1/-0)
test/rbkt/Queries/zorba/xqxq/delete.spec (+1/-0)
test/rbkt/Queries/zorba/xqxq/delete.xq (+5/-0)
test/rbkt/Queries/zorba/xqxq/error-in-query.spec (+2/-0)
test/rbkt/Queries/zorba/xqxq/error-in-query.xq (+21/-0)
test/rbkt/Queries/zorba/xqxq/evaluate-sequential.xq (+17/-0)
test/rbkt/Queries/zorba/xqxq/evaluate-sequential2.spec (+1/-0)
test/rbkt/Queries/zorba/xqxq/evaluate-sequential2.xq (+6/-0)
test/rbkt/Queries/zorba/xqxq/evaluate-updating.xq (+7/-0)
test/rbkt/Queries/zorba/xqxq/evaluate-updating2.spec (+1/-0)
test/rbkt/Queries/zorba/xqxq/evaluate-updating2.xq (+15/-0)
test/rbkt/Queries/zorba/xqxq/evaluate.xq (+5/-0)
test/rbkt/Queries/zorba/xqxq/evaluate2.xq (+6/-0)
test/rbkt/Queries/zorba/xqxq/evaluate3.spec (+1/-0)
test/rbkt/Queries/zorba/xqxq/evaluate3.xq (+15/-0)
test/rbkt/Queries/zorba/xqxq/external-module.xq (+8/-0)
test/rbkt/Queries/zorba/xqxq/get-external-variables.xq (+4/-0)
test/rbkt/Queries/zorba/xqxq/is-bound-context-item.xq (+4/-0)
test/rbkt/Queries/zorba/xqxq/is-bound-variable.xq (+10/-0)
test/rbkt/Queries/zorba/xqxq/is-bound-variable2.spec (+1/-0)
test/rbkt/Queries/zorba/xqxq/is-bound-variable2.xq (+7/-0)
test/rbkt/Queries/zorba/xqxq/is-sequential.xq (+18/-0)
test/rbkt/Queries/zorba/xqxq/is-updating.xq (+20/-0)
test/rbkt/Queries/zorba/xqxq/multiple-queries.xq (+9/-0)
test/rbkt/Queries/zorba/xqxq/prepare-library-module.spec (+1/-0)
test/rbkt/Queries/zorba/xqxq/prepare-library-module.xq (+3/-0)
test/rbkt/Queries/zorba/xqxq/test.xml (+1/-0)
test/rbkt/Queries/zorba/xqxq/test.xsd (+14/-0)
test/rbkt/Queries/zorba/xqxq/uri-mapper.xq (+27/-0)
test/rbkt/Queries/zorba/xqxq/uri-mapper2.xq (+22/-0)
test/rbkt/Queries/zorba/xqxq/url-module-resolver.xq (+17/-0)
test/rbkt/Queries/zorba/xqxq/url-schema-resolver.xq (+20/-0)
test/rbkt/Queries/zorba/xqxq/url-schema-resolver2.xq (+29/-0)
test/rbkt/Queries/zorba/xqxq/url-schema-resolver3.xq (+29/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/move-xqxq-core
Reviewer Review Type Date Requested Status
Juan Zacarias Approve
Matthias Brantner Approve
Chris Hillery Approve
Review via email: mp+131295@code.launchpad.net

Commit message

Moved XQXQ into Zorba core.

To post a comment you must log in.
Revision history for this message
Chris Hillery (ceejatec) :
review: Approve
Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

Conditional approval because everything seems to work.

However, the ChangeLog should be updated and an email should be sent to the list letting everybody know that they have to remove xqxq from their zorba_modules directories.

review: Approve
11112. By Chris Hillery

Updated ChangeLog.

Revision history for this message
Chris Hillery (ceejatec) wrote :

I have pushed a ChangeLog change.

Tested locally: If I bump the XQXQ version number to 1.1, it can actually co-exist with the non-core module. Should I do this for convenience, or is it better to force people to remove the old one?

Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

> I have pushed a ChangeLog change.
>
> Tested locally: If I bump the XQXQ version number to 1.1, it can actually co-
> exist with the non-core module. Should I do this for convenience, or is it
> better to force people to remove the old one?
Good question. My feeling is that the old one should be removed because both of the modules provide exactly the same functionality.

Revision history for this message
Chris Hillery (ceejatec) wrote :

> My feeling is that the old one should be removed because both
> of the modules provide exactly the same functionality.

I tend to agree. Ok, I won't push that change, and I'll send out an email.

Juan, please review soon; thanks!

Revision history for this message
Juan Zacarias (juan457) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job move-xqxq-core-2012-10-26T14-50-00.735Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2012-10-24 12:49:43 +0000
3+++ ChangeLog 2012-10-25 00:20:28 +0000
4@@ -11,6 +11,7 @@
5 * Optimized the MarkFreeVars optimizer rule
6
7 Bug Fixes/Other Changes:
8+ * Change XQXQ (XQuery-for-XQuery) module now part of Zorba core
9 * Fixed mustCopyInputNodes() method of no-copy, and jsoniq functions.
10 * Fixed bug #868640 (Node lifetime is shorter than expected due to let
11 variable inlining)
12
13=== modified file 'modules/CMakeLists.txt'
14--- modules/CMakeLists.txt 2012-09-19 21:16:15 +0000
15+++ modules/CMakeLists.txt 2012-10-25 00:20:28 +0000
16@@ -15,6 +15,7 @@
17 ADD_SUBDIRECTORY(com)
18 ADD_SUBDIRECTORY(org)
19 ADD_SUBDIRECTORY(functx)
20+ADD_SUBDIRECTORY(xqxq)
21 ADD_SUBDIRECTORY(w3c)
22
23 # Add external module projects - any subdirectories of a directory
24
25=== modified file 'modules/ExternalModules.conf'
26--- modules/ExternalModules.conf 2012-10-23 21:21:20 +0000
27+++ modules/ExternalModules.conf 2012-10-25 00:20:28 +0000
28@@ -42,7 +42,6 @@
29 read-pdf bzr lp:zorba/read-pdf-module zorba-2.7
30 security bzr lp:zorba/security-module
31 system bzr lp:zorba/system-module zorba-2.7
32-xqxq bzr lp:zorba/xqxq-module zorba-2.7
33 email bzr lp:zorba/email-module zorba-2.7
34 util-jvm bzr lp:zorba/util-jvm-module zorba-2.7
35 schema-tools bzr lp:zorba/schema-tools-module zorba-2.7
36
37=== added directory 'modules/xqxq'
38=== added file 'modules/xqxq/CMakeLists.txt'
39--- modules/xqxq/CMakeLists.txt 1970-01-01 00:00:00 +0000
40+++ modules/xqxq/CMakeLists.txt 2012-10-25 00:20:28 +0000
41@@ -0,0 +1,15 @@
42+# Copyright 2006-2012 The FLWOR Foundation.
43+#
44+# Licensed under the Apache License, Version 2.0 (the "License");
45+# you may not use this file except in compliance with the License.
46+# You may obtain a copy of the License at
47+#
48+# http://www.apache.org/licenses/LICENSE-2.0
49+#
50+# Unless required by applicable law or agreed to in writing, software
51+# distributed under the License is distributed on an "AS IS" BASIS,
52+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
53+# See the License for the specific language governing permissions and
54+# limitations under the License.
55+
56+DECLARE_ZORBA_MODULE (URI "http://www.zorba-xquery.com/modules/xqxq" VERSION 1.0 FILE "xqxq.xq")
57\ No newline at end of file
58
59=== added file 'modules/xqxq/xqxq.xq'
60--- modules/xqxq/xqxq.xq 1970-01-01 00:00:00 +0000
61+++ modules/xqxq/xqxq.xq 2012-10-25 00:20:28 +0000
62@@ -0,0 +1,381 @@
63+xquery version "3.0";
64+(:
65+ : Copyright 2011 The FLWOR Foundation.
66+ :
67+ : Licensed under the Apache License, Version 2.0 (the "License");
68+ : you may not use this file except in compliance with the License.
69+ : You may obtain a copy of the License at
70+ :
71+ : http://www.apache.org/licenses/LICENSE-2.0
72+ :
73+ : Unless required by applicable law or agreed to in writing, software
74+ : distributed under the License is distributed on an "AS IS" BASIS,
75+ : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
76+ : See the License for the specific language governing permissions and
77+ : limitations under the License.
78+:)
79+
80+(:~
81+ : This module contains functions to compile and evaluate XQuery
82+ : programs. Also, it contains function that allow to parameterize
83+ : the static or dynamic evaluation phase.
84+ :
85+ : @author Juan Zacarias
86+ : @project Zorba/Programming Languages/XQuery
87+ :)
88+module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
89+
90+declare namespace an = "http://www.zorba-xquery.com/annotations";
91+declare namespace ver = "http://www.zorba-xquery.com/options/versioning";
92+declare namespace op = "http://www.zorba-xquery.com/options/features";
93+declare namespace f = "http://www.zorba-xquery.com/features";
94+
95+declare option ver:module-version "1.0";
96+declare option op:enable "f:hof";
97+
98+(:~
99+ : The function prepares a given XQuery program for execution.
100+ : If the program was successfully compiled, the function returns an
101+ : identifier as xs:anyURI. This URI can be passed to other functions
102+ : of this module (e.g. to actually evaluate the program). The URI
103+ : is opaque and its lilfetime is bound by the lifetime of the XQuery
104+ : program that invoked this function. Further reference or uses
105+ : of the identifier lead to unexpected results.
106+ :
107+ : Successfully prepared queries need to be deleted by passing the resulting
108+ : identifier to the xqxq:delete-query function of this module.
109+ :
110+ : @param $main-module-text the XQuery program that should be prepared.
111+ : The program needs to be a XQuery main module.
112+ :
113+ : @return an identifier for the compiled program that can be passed
114+ : as arguments to other functions of this module.
115+ :
116+ : @error any (static or type) error that may be raised during the compilation
117+ : of the query. For example, err:XPST0003 if the given XQuery program could
118+ : not be parsed.
119+ :)
120+declare %an:sequential function xqxq:prepare-main-module($main-module-text as xs:string) as
121+ xs:anyURI external;
122+
123+(:~
124+ : The function prepares a given XQuery program for execution.
125+ : If the program was successfully compiled, the function returns an
126+ : identifier as xs:anyURI. This URI can be passed to other functions
127+ : of this module (e.g. to actually evaluate the program). The URI
128+ : is opaque and its lilfetime is bound by the lifetime of the XQuery
129+ : program that invoked this function. Further reference or uses
130+ : of the identifier lead to unexpected results.
131+ :
132+ : Important notes regarding the second and third parameters of the function:
133+ : --------------------------------------------------------------------------
134+ :
135+ : These parameters allow you to specify a URL resolver and a URI mapper
136+ : for Zorba to use when executing this query. See
137+ : http://www.zorba-xquery.com/html/documentation/2.7.0/zorba/uriresolvers
138+ :
139+ : The second parameter is a function item for a URL
140+ : resolver. The URL resolver function must recive 2 parameters:
141+ : A $namespace as xs:string that will contain the url to be resolved.
142+ : A $entity as xs:string that will contain the type of resolving needed;
143+ : this can be 2 values "module" and "schema".
144+ : The function must return an empty sequence when the specified $namespace
145+ : or $entity are not the ones to be resolved.
146+ :
147+ : Example:
148+ :
149+ : declare function mymod:url-resolver($namespace as xs:string, $entity as xs:string)
150+ : {
151+ : if($namespace = 'http://test.xq')
152+ : then "module namespace test = 'http://test'; declare function test:foo(){'foo'};"
153+ : else ()
154+ : };
155+ :
156+ : The URL resolver function's namespace, name, and parameter naming are
157+ : not restricted by XQXQ.
158+ :
159+ : The URL resolver function's return type is not restricted, it could be a string, a sequence,
160+ : a node, etc. All the outputs types are to be serialized as a string.
161+ :
162+ : The third parameter is a function item for a URI mapper.
163+ : The URI mapper function, just like the URL resolver, receives 2 parameters:
164+ : A $namespace as xs:string that will contain the URI to be mapped.
165+ : A $entity as xs:string that will contain the type of resolving needed;
166+ : this can be 2 values "module" and "schema".
167+ : The URI mapper must return an empty sequence when the specified $namesapce or $entity
168+ : are not to be mapped. Unlike the URL resolver this function must return a sequence of strings.
169+ :
170+ : Example:
171+ :
172+ : declare function mymod:uri-mapper($namespace as xs:string, $entity as xs:string)
173+ : {
174+ : if($namespace = 'http://test')
175+ : then ("http://www.zorba-xquery.com/test", "http://foo.com/schema/test")
176+ : else ()
177+ : };
178+ :
179+ : The URI mapper function's namespace, name, and parameter naming are
180+ : not restricted by XQXQ.
181+ :
182+ : In order to pass the above URL resolver and URI mapper to this function,
183+ : use the following syntax:
184+ :
185+ : variable $queryID := xqxq:prepare-main-module("..query text..",
186+ : mymod:url-resolver#2, mymod:uri-mapper#2);
187+ :
188+ : That is, the QName of the function followed by "#2". This is XQuery
189+ : "higher-order function" syntax, meaning the function with the specified
190+ : QName which takes two arguments. Since URL resolvers and URI mappers
191+ : must take two arguments, both will always be specified with "#2".
192+ :
193+ : Note that parameters 2 and 3 should be declared as follows:
194+ : as function($url as xs:string, $entity as xs:string) as item()
195+ : as function($uri as xs:string, $entity as xs:string) as xs:string*
196+ : However Zorba's implementation of higher-order functions (HOF) is not
197+ : yet complete enough to allow for this. When Zorba's HOF implementation
198+ : is complete this function signature will be changed.
199+ :
200+ : Both the URL resolver and URI mapper functions are optional, meaning you
201+ : may pass the empty-sequence () for either.
202+ :
203+ : Successfully prepared queries need to be deleted by passing the resulting
204+ : identifier to the xqxq:delete-query function of this module.
205+ :
206+ : @param $main-module-text the XQuery program that should be prepared.
207+ : The program needs to be a XQuery main module.
208+ :
209+ : @param $resolver the URL resolver function.
210+ :
211+ : @param $mapper the URI mapper function.
212+ :
213+ : @return an identifier for the compiled program that can be passed
214+ : as arguments to other functions of this module.
215+ :
216+ : @error any (static or type) error that may be raised during the compilation
217+ : of the query. For example, err:XPST0003 if the given XQuery program could
218+ : not be parsed.
219+ :)
220+declare %an:sequential function xqxq:prepare-main-module($main-module-text as xs:string, $resolver as item()?, $mapper as item()?) as
221+ xs:anyURI external;
222+
223+(:~
224+ : This function compiles a given XQuery library module. It can be used
225+ : to compile-check a module.
226+ :
227+ : @param $library-module-text the XQuery library module that should
228+ : be prepared.
229+ :
230+ : @return the function is declared as sequential.It returns the
231+ : empty-sequence.
232+ :
233+ : @error any (static or type) error that may be raised during the compilation
234+ : of the library module. For example, err:XPST0003 if the given XQuery library
235+ : module could not be parsed.
236+ :)
237+declare %an:sequential function xqxq:prepare-library-module($library-module-text as xs:string) as
238+ empty-sequence() external ;
239+
240+(:~
241+ : The function tests if the context-item is bound for the
242+ : execution of the query referred to by the given query identifier.
243+ :
244+ : @param $query-key the identifier for a compiled query
245+ :
246+ : @return true if the context-item is bound, false otherwise.
247+ :
248+ : @error xqxq:NoQueryMatch if no query with the given identifier
249+ : was prepared.
250+ :)
251+declare function xqxq:is-bound-context-item($query-key as xs:anyURI)
252+ as xs:boolean external;
253+
254+
255+(:~
256+ : The function tests if the given variable is bound for the
257+ : execution of the query referred to by the given query identifier.
258+ :
259+ : @param $query-key the identifier for a compiled query
260+ : @param $var-name the name of the variable
261+ :
262+ : @return true if the variable is bound, false otherwise.
263+ :
264+ : @error xqxq:NoQueryMatch if no query with the given identifier
265+ : was prepared.
266+ : @error xqxq:UndeclaredVariable if the given variable is not declared
267+ : in the query.
268+ :)
269+declare function xqxq:is-bound-variable($query-key as xs:anyURI, $var-name as
270+ xs:QName) as xs:boolean external;
271+
272+(:~
273+ : The function returns the names of the external variables that
274+ : are declared in the given query (either in the main module or
275+ : in any of the imported library modules).
276+ :
277+ : @param $query-key the identifier for a compiled query
278+ :
279+ : @return the sequence of names of the said external variables.
280+ :
281+ : @error xqxq:NoQueryMatch if no query with the given identifier
282+ : was prepared.
283+ :)
284+declare function xqxq:external-variables($query-key as xs:anyURI) as
285+ xs:QName* external ;
286+
287+(:~
288+ : The function tests if the query identified by the given key
289+ : is an updating query.
290+ :
291+ : @param $query-key the identifier for a compiled query
292+ :
293+ : @return true if the query is an updating query, false otherwise.
294+ :
295+ : @error xqxq:NoQueryMatch if no query with the given identifier
296+ : was prepared.
297+ :)
298+declare function xqxq:is-updating($query-key as xs:anyURI) as
299+ xs:boolean external;
300+
301+(:~
302+ : The function tests if the query identified by the given key
303+ : is sequential query.
304+ :
305+ : @param $query-key the identifier for a compiled query
306+ :
307+ : @return true if the query is a sequential, false otherwise.
308+ :
309+ : @error xqxq:NoQueryMatch if no query with the given identifier
310+ : was prepared.
311+ :)
312+declare function xqxq:is-sequential($query-key as xs:anyURI) as
313+ xs:boolean external;
314+
315+(:~
316+ : This function binds the context-item of the prepared query
317+ : identified by the given key to the $dot argument.
318+ :
319+ : @param $query-key the identifier for a compiled query
320+ : @param $dot the context item to bind
321+ :
322+ : @return the function has side effects and returns the empty
323+ : sequence.
324+ :
325+ : @error xqxq:NoQueryMatch if no query with the given identifier
326+ : was prepared.
327+ :)
328+declare %an:sequential function xqxq:bind-context-item($query-key as xs:anyURI,
329+ $dot as item()) as empty-sequence() external ;
330+
331+(:~
332+ : This function binds the variable with name $name of
333+ : the prepared query identified by $query-key to the given sequence.
334+ :
335+ : @param $query-key the identifier for a compiled query
336+ : @param $name the name of the external variable to bind
337+ : @param $value the sequence to which the external variable $name
338+ : should be bound
339+ :
340+ : @return the function has side effects and returns the empty
341+ : sequence.
342+ :
343+ : @error xqxq:NoQueryMatch if no query with the given identifier
344+ : was prepared.
345+ : @error xqxq:UndeclaredVariable if the given variable is not declared
346+ : in the query.
347+ :)
348+declare %an:sequential function xqxq:bind-variable($query-key as xs:anyURI,
349+ $var as xs:QName, $value as item()*) as empty-sequence() external ;
350+
351+
352+(:~
353+ : Evaluates the given prepared query and returns the result
354+ : of the evaluation. The query must not be sequential or
355+ : updating.
356+ :
357+ : @param $query-key the identifier for a compiled query
358+ :
359+ : @return the result of evaluating the given query
360+ :
361+ : @error xqxq:NoQueryMatch if no query with the given identifier
362+ : was prepared.
363+ :
364+ : @error xqxq:QueryIsUpdating if the query is an updating query.
365+ :
366+ : @error xqxq:QueryIsSequential if the query is sequential.
367+ :
368+ : @error any dynamic error that is raised by evaluating the
369+ : given query.
370+ :
371+ :)
372+declare function xqxq:evaluate($query-key as xs:anyURI) as item()* external;
373+
374+(:~
375+ : Evaluates the given prepared query and applies the updates
376+ : computed by this query. The query must be an updating query.
377+ :
378+ : @param $query-key the identifier for a compiled query
379+ :
380+ : @return the function has side effects because it applies
381+ : the updates of the query. It returns the empty sequence.
382+ :
383+ : @error xqxq:NoQueryMatch if no query with the given identifier
384+ : was prepared.
385+ :
386+ : @error xqxq:QueryNotUpdating if the query is not an updating query.
387+ :
388+ : @error xqxq:QueryIsSequential if the query is sequential.
389+ :
390+ : @error any dynamic error that is raised by evaluating the
391+ : given query or applying its updates.
392+ :
393+ :)
394+declare updating function xqxq:evaluate-updating($query-key as xs:anyURI) external;
395+
396+(:~
397+ : Evaluates the given prepared query and returns the result
398+ : of the evaluation. The query must be sequential.
399+ :
400+ : @param $query-key the identifier for a compiled query
401+ :
402+ : @return the result of evaluating the query.
403+ :
404+ : @error xqxq:NoQueryMatch if no query with the given identifier
405+ : was prepared.
406+ :
407+ : @error xqxq:QueryNotSequential if the query is not sequential.
408+ :
409+ : @error xqxq:QueryIsUpdating if the query is an updating query.
410+ :
411+ : @error any dynamic error that is raised by evaluating the
412+ : given query.
413+ :
414+ :)
415+declare %an:sequential function xqxq:evaluate-sequential($query-key as
416+ xs:string) as item()* external;
417+
418+(:~
419+ : Deletes the prepared query associated with the given identifier.
420+ : After the query is deleted, the corresponding identifier should
421+ : not be used as argument to any of the functions of this module.
422+ :
423+ : @param $query-key the identifier for a compiled query
424+ :
425+ : @return the function has side effects and returns the empty sequence.
426+ :
427+ : @error xqxq:NoQueryMatch if no query with the given identifier
428+ : was prepared.
429+ :
430+ :)
431+declare %an:sequential function xqxq:delete-query($query-key as xs:anyURI) as
432+ empty-sequence() external;
433+
434+
435+(:~
436+ : Internal helper function. Only necessary because of incomplete HOF
437+ : support in Zorba.
438+ :)
439+declare %private function xqxq:hof-invoker($hof as item(),
440+ $ns as xs:string, $entity as xs:string) as item()*
441+{
442+ $hof($ns, $entity)
443+};
444
445=== added directory 'modules/xqxq/xqxq.xq.src'
446=== added file 'modules/xqxq/xqxq.xq.src/xqxq.cpp'
447--- modules/xqxq/xqxq.xq.src/xqxq.cpp 1970-01-01 00:00:00 +0000
448+++ modules/xqxq/xqxq.xq.src/xqxq.cpp 2012-10-25 00:20:28 +0000
449@@ -0,0 +1,817 @@
450+#include <zorba/item_factory.h>
451+#include <zorba/singleton_item_sequence.h>
452+#include <zorba/diagnostic_list.h>
453+#include <zorba/empty_sequence.h>
454+#include <zorba/store_manager.h>
455+#include <zorba/user_exception.h>
456+#include <zorba/uri_resolvers.h>
457+#include <zorba/vector_item_sequence.h>
458+#include <zorba/serializer.h>
459+#include <zorba/xquery.h>
460+#include <time.h>
461+#include <stdio.h>
462+#include <zorba/util/uuid.h>
463+#include <vector>
464+
465+#include "xqxq.h"
466+
467+namespace zorba { namespace xqxq {
468+
469+ /*******************************************************************************************
470+ *******************************************************************************************/
471+
472+ zorba::ExternalFunction*
473+ XQXQModule::getExternalFunction(const zorba::String& localName)
474+ {
475+
476+ FuncMap_t::iterator lIte = theFunctions.find(localName);
477+
478+ ExternalFunction*& lFunc = theFunctions[localName];
479+
480+ if (lIte == theFunctions.end())
481+ {
482+ if (localName == "prepare-main-module")
483+ {
484+ lFunc = new PrepareMainModuleFunction(this);
485+ }
486+ if (localName == "prepare-library-module")
487+ {
488+ lFunc = new PrepareLibraryModuleFunction(this);
489+ }
490+ else if (localName == "is-bound-context-item")
491+ {
492+ lFunc = new IsBoundContextItemFunction(this);
493+ }
494+ else if (localName == "is-bound-variable")
495+ {
496+ lFunc = new IsBoundVariableFunction(this);
497+ }
498+ else if (localName == "external-variables")
499+ {
500+ lFunc = new GetExternalVariablesFunction(this);
501+ }
502+ else if (localName == "is-updating")
503+ {
504+ lFunc = new IsUpdatingFunction(this);
505+ }
506+ else if (localName == "is-sequential")
507+ {
508+ lFunc = new IsSequentialFunction(this);
509+ }
510+ else if (localName == "bind-context-item")
511+ {
512+ lFunc = new BindContextItemFunction(this);
513+ }
514+ else if (localName == "bind-variable")
515+ {
516+ lFunc = new BindVariableFunction(this);
517+ }
518+ else if (localName == "evaluate")
519+ {
520+ lFunc = new EvaluateFunction(this);
521+ }
522+ else if (localName == "evaluate-updating")
523+ {
524+ lFunc = new EvaluateUpdatingFunction(this);
525+ }
526+ else if (localName == "evaluate-sequential")
527+ {
528+ lFunc = new EvaluateSequentialFunction(this);
529+ }
530+ else if (localName == "delete-query")
531+ {
532+ lFunc = new DeleteQueryFunction(this);
533+ }
534+ }
535+
536+ return lFunc;
537+ }
538+
539+ void XQXQModule::destroy()
540+ {
541+ delete this;
542+ }
543+
544+ XQXQModule::~XQXQModule()
545+ {
546+ for (FuncMap_t::const_iterator lIter = theFunctions.begin();
547+ lIter != theFunctions.end(); ++lIter)
548+ {
549+ delete lIter->second;
550+ }
551+ theFunctions.clear();
552+ }
553+
554+ /*******************************************************************************************
555+ *******************************************************************************************/
556+ XQXQFunction::XQXQFunction(const XQXQModule* aModule)
557+ : theModule(aModule)
558+ {
559+ srand(time(NULL));
560+ }
561+
562+ XQXQFunction::~XQXQFunction()
563+ {
564+
565+ }
566+
567+ String XQXQFunction::getURI() const
568+ {
569+ return theModule->getURI();
570+ }
571+
572+ String
573+ XQXQFunction::getOneStringArgument(const Arguments_t& aArgs, int aPos) const
574+ {
575+ Item lItem;
576+ Iterator_t args_iter = aArgs[aPos]->getIterator();
577+ args_iter->open();
578+ args_iter->next(lItem);
579+ String lTmpString = lItem.getStringValue();
580+ args_iter->close();
581+ return lTmpString;
582+ }
583+
584+
585+ Item
586+ XQXQFunction::getItemArgument(const Arguments_t& aArgs, int aPos) const
587+ {
588+ Item lItem;
589+ Iterator_t args_iter = aArgs[aPos]->getIterator();
590+ args_iter->open();
591+ args_iter->next(lItem);
592+ args_iter->close();
593+
594+ return lItem;
595+ }
596+
597+ Iterator_t
598+ XQXQFunction::getIterArgument(const Arguments_t& aArgs, int aPos) const
599+ {
600+ Iterator_t args_iter = aArgs[aPos]->getIterator();
601+ return args_iter;
602+ }
603+
604+ XQuery_t
605+ XQXQFunction::getQuery(
606+ const zorba::DynamicContext* aDctx,
607+ const zorba::String& aIdent) const
608+ {
609+ QueryMap* lQueryMap;
610+ if (!(lQueryMap= dynamic_cast<QueryMap*>(aDctx->getExternalFunctionParameter("xqxqQueryMap"))))
611+ {
612+ throwError("NoQueryMatch", "No query with the given identifier was found");
613+ }
614+
615+ XQuery_t lQuery;
616+ if (!(lQuery = lQueryMap->getQuery(aIdent)))
617+ throwError("NoQueryMatch", "No query with the given identifier was found");
618+
619+ return lQuery;
620+ }
621+
622+ void
623+ XQXQFunction::throwError(const char *err_localname, const std::string aErrorMessage)
624+ {
625+ String errNS(XQXQ_MODULE_NAMESPACE);
626+ String errName(err_localname);
627+ Item errQName = XQXQModule::getItemFactory()->createQName(errNS, errName);
628+ String errDescription(aErrorMessage);
629+ throw USER_EXCEPTION(errQName, errDescription);
630+ }
631+
632+ /*******************************************************************************************
633+ *******************************************************************************************/
634+
635+ QueryData::QueryData(XQuery_t aQuery, URIMapper *aMapper, URLResolver *aResolver)
636+ : theQuery(aQuery),
637+ theURIMapper(aMapper),
638+ theURLResolver(aResolver)
639+ {
640+ }
641+
642+ QueryData::~QueryData()
643+ {
644+ theQuery->close();
645+ delete theURIMapper;
646+ delete theURLResolver;
647+ }
648+
649+ /*******************************************************************************************
650+ *******************************************************************************************/
651+
652+ QueryMap::QueryMap()
653+ {
654+ QueryMap::queryMap = new QueryMap_t();
655+ }
656+
657+ bool
658+ QueryMap::storeQuery(const String& aKeyName, XQuery_t aQuery,
659+ URIMapper* aMapper, URLResolver* aResolver)
660+ {
661+ QueryData_t lQueryData(new QueryData(aQuery, aMapper, aResolver));
662+ std::pair<QueryMap_t::iterator,bool> ret;
663+ ret = queryMap->insert(std::pair<String, QueryData_t>(aKeyName, lQueryData));
664+ return ret.second;
665+ }
666+
667+ XQuery_t
668+ QueryMap::getQuery(const String& aKeyName)
669+ {
670+ QueryMap::QueryMap_t::iterator lIter = queryMap->find(aKeyName);
671+
672+ if(lIter == queryMap->end())
673+ return NULL;
674+
675+ XQuery_t lQuery = lIter->second->getQuery();
676+
677+ return lQuery;
678+ }
679+
680+ bool
681+ QueryMap::deleteQuery(const String& aKeyName)
682+ {
683+ QueryMap::QueryMap_t::iterator lIter = queryMap->find(aKeyName);
684+
685+ if(lIter == queryMap->end())
686+ return false;
687+
688+ queryMap->erase(lIter);
689+ return true;
690+ }
691+
692+ void
693+ QueryMap::destroy() throw()
694+ {
695+ if(queryMap)
696+ {
697+ for (QueryMap_t::const_iterator lIter = queryMap->begin();
698+ lIter != queryMap->end(); ++lIter)
699+ {
700+ deleteQuery(lIter->first);
701+ }
702+ queryMap->clear();
703+ delete queryMap;
704+ }
705+ delete this;
706+ }
707+
708+ /*******************************************************************************************
709+ *******************************************************************************************/
710+ static void streamReleaser(std::istream* aStream)
711+ {
712+ delete aStream;
713+ }
714+
715+ void
716+ PrepareMainModuleFunction::XQXQURIMapper::mapURI(
717+ String aUri,
718+ EntityData const* aEntityData,
719+ std::vector<String>& oUris)
720+ {
721+ //Create entityData string to send to the new url resolver
722+ String lDataKind;
723+ switch (aEntityData->getKind())
724+ {
725+ case EntityData::SCHEMA:
726+ lDataKind = "schema";
727+ break;
728+ case EntityData::MODULE:
729+ lDataKind = "module";
730+ break;
731+ default:
732+ break;
733+ }
734+
735+ //construct the arguments for the url resolver
736+ std::vector<ItemSequence_t> lArgs;
737+ ItemSequence_t lSeq0 = new SingletonItemSequence(theFunction);
738+ ItemSequence_t lSeq1 = new SingletonItemSequence(XQXQModule::getItemFactory()->createString(aUri));
739+ ItemSequence_t lSeq2 = new SingletonItemSequence(XQXQModule::getItemFactory()->createString(lDataKind));
740+ lArgs.push_back(lSeq0);
741+ lArgs.push_back(lSeq1);
742+ lArgs.push_back(lSeq2);
743+
744+ //invoke the HOF helper function using the arguments generated
745+ Item lHofHelper = XQXQModule::getItemFactory()->createQName("http://www.zorba-xquery.com/modules/xqxq", "xqxq", "hof-invoker");
746+ ItemSequence_t lResult = theCtx->invoke(lHofHelper, lArgs);
747+
748+ //Check if the result is an empty sequence by creating an Iterator, this is cheaper than serializing the result
749+ //and then checking if it was empty.
750+ Iterator_t lIter = lResult->getIterator();
751+ Item lItem;
752+ lIter->open();
753+ while (lIter->next(lItem))
754+ {
755+ std::cout << lItem.getStringValue() << std::endl;
756+ oUris.push_back(lItem.getStringValue());
757+ }
758+ lIter->close();
759+
760+ }
761+
762+
763+ Resource*
764+ PrepareMainModuleFunction::XQXQURLResolver::resolveURL(
765+ const String& aUrl,
766+ EntityData const* aEntityData)
767+ {
768+ //Create entityData string to send to the new url resolver
769+ String lDataKind;
770+ switch (aEntityData->getKind())
771+ {
772+ case EntityData::SCHEMA:
773+ lDataKind = "schema";
774+ break;
775+ case EntityData::MODULE:
776+ lDataKind = "module";
777+ break;
778+ default:
779+ break;
780+ }
781+
782+ //construct the arguments for the url resolver
783+ std::vector<ItemSequence_t> lArgs;
784+ ItemSequence_t lSeq0 = new SingletonItemSequence(theFunction);
785+ ItemSequence_t lSeq1 = new SingletonItemSequence(XQXQModule::getItemFactory()->createString(aUrl));
786+ ItemSequence_t lSeq2 = new SingletonItemSequence(XQXQModule::getItemFactory()->createString(lDataKind));
787+ lArgs.push_back(lSeq0);
788+ lArgs.push_back(lSeq1);
789+ lArgs.push_back(lSeq2);
790+
791+ //invoke the HOF helper function using the arguments generated
792+ Item lHofHelper = XQXQModule::getItemFactory()->createQName("http://www.zorba-xquery.com/modules/xqxq", "xqxq", "hof-invoker");
793+ ItemSequence_t lResult = theCtx->invoke(lHofHelper, lArgs);
794+
795+ //Check if the result is an empty sequence by creating an Iterator, this is cheaper than serializing the result
796+ //and then checking if it was empty.
797+ Iterator_t lIter = lResult->getIterator();
798+ Item lItem;
799+ lIter->open();
800+ lIter->next(lItem);
801+ lIter->close();
802+ if (lItem.isNull())
803+ return NULL;
804+
805+ //Serialize resulting sequence of the resolver
806+ Zorba_SerializerOptions_t lOpt;
807+ if (lItem.isNode())
808+ lOpt.ser_method = ZORBA_SERIALIZATION_METHOD_XML;
809+ else
810+ lOpt.ser_method = ZORBA_SERIALIZATION_METHOD_TEXT;
811+ lOpt.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;
812+ Serializer_t lSer = Serializer::createSerializer(lOpt);
813+ std::stringstream lSerResult;
814+ lSer->serialize(lResult, lSerResult);
815+
816+ //return resource
817+ return StreamResource::create(new std::istringstream(lSerResult.str()), &streamReleaser);
818+ }
819+
820+ zorba::ItemSequence_t
821+ PrepareMainModuleFunction::evaluate(
822+ const Arguments_t& aArgs,
823+ const zorba::StaticContext* aSctx,
824+ const zorba::DynamicContext* aDctx) const
825+ {
826+ DynamicContext* lDynCtx = const_cast<DynamicContext*>(aDctx);
827+ StaticContext_t lSctxChild = aSctx->createChildContext();
828+
829+ QueryMap* lQueryMap;
830+ if(!(lQueryMap = dynamic_cast<QueryMap*>(lDynCtx->getExternalFunctionParameter("xqxqQueryMap"))))
831+ {
832+ lQueryMap = new QueryMap();
833+ lDynCtx->addExternalFunctionParameter("xqxqQueryMap", lQueryMap);
834+ }
835+
836+ Zorba *lZorba = Zorba::getInstance(0);
837+
838+ String lQueryString = getOneStringArgument(aArgs, 0);
839+
840+ XQuery_t lQuery;
841+
842+ StaticContext_t ltempSctx = lZorba->createStaticContext();
843+ std::auto_ptr<XQXQURLResolver> lResolver;
844+ std::auto_ptr<XQXQURIMapper> lMapper;
845+
846+ if ( aArgs.size() > 2 )
847+ {
848+ Item lMapperFunctionItem = getItemArgument(aArgs, 2);
849+ if (!lMapperFunctionItem.isNull())
850+ {
851+ lMapper.reset(new XQXQURIMapper(lMapperFunctionItem, lSctxChild));
852+ ltempSctx->registerURIMapper(lMapper.get());
853+ }
854+ }
855+
856+ if ( aArgs.size() > 1 )
857+ {
858+ Item lResolverFunctionItem = getItemArgument(aArgs, 1);
859+ if (!lResolverFunctionItem.isNull())
860+ {
861+ lResolver.reset(new XQXQURLResolver(lResolverFunctionItem, lSctxChild));
862+ ltempSctx->registerURLResolver(lResolver.get());
863+ }
864+
865+ }
866+
867+ try
868+ {
869+ lQuery = lZorba->compileQuery(lQueryString, ltempSctx);
870+ }
871+ catch (XQueryException& xe)
872+ {
873+ lQuery = NULL;
874+ std::ostringstream err;
875+ err << "The query compiled using xqxq:prepare-main-module raised an error at"
876+ << " line " << xe.source_line() << " column " << xe.source_column() << ": " << xe.what();
877+ Item errQName = XQXQModule::getItemFactory()->createQName(
878+ xe.diagnostic().qname().ns(), xe.diagnostic().qname().localname());
879+ throw USER_EXCEPTION(errQName, err.str());
880+ }
881+ catch (ZorbaException& e)
882+ {
883+ lQuery = NULL;
884+ std::ostringstream err;
885+ err << "The query compiled using xqxq:prepare-main-module raised an error: "
886+ << e.what();
887+ Item errQName = XQXQModule::getItemFactory()->createQName(
888+ e.diagnostic().qname().ns(), e.diagnostic().qname().localname());
889+ throw USER_EXCEPTION(errQName, err.str());
890+ }
891+
892+ uuid lUUID;
893+ uuid::create(&lUUID);
894+
895+ std::stringstream lStream;
896+ lStream << lUUID;
897+
898+ String lStrUUID = lStream.str();
899+
900+ lQueryMap->storeQuery(lStrUUID, lQuery, lMapper.release(), lResolver.release());
901+
902+ return ItemSequence_t(new SingletonItemSequence(XQXQModule::getItemFactory()->createAnyURI(lStrUUID)));
903+ }
904+
905+
906+ /*******************************************************************************************
907+ *******************************************************************************************/
908+ zorba::ItemSequence_t
909+ PrepareLibraryModuleFunction::evaluate(
910+ const Arguments_t& aArgs,
911+ const zorba::StaticContext* aSctx,
912+ const zorba::DynamicContext* aDctx) const
913+ {
914+ Zorba *lZorba = Zorba::getInstance(0);
915+ String lQueryString = getOneStringArgument(aArgs, 0);
916+
917+ Zorba_CompilerHints_t hints;
918+ hints.lib_module = true;
919+
920+ try
921+ {
922+ lZorba->compileQuery(lQueryString, hints);
923+ }
924+ catch (XQueryException& xe)
925+ {
926+ std::ostringstream err;
927+ err << "The query compiled using xqxq:prepare-library-module raised an error at"
928+ << " line " << xe.source_line() << " column " << xe.source_column() << ": " << xe.what();
929+ Item errQName = XQXQModule::getItemFactory()->createQName(
930+ xe.diagnostic().qname().ns(), xe.diagnostic().qname().localname());
931+ throw USER_EXCEPTION(errQName, err.str());
932+ }
933+ catch (ZorbaException& e)
934+ {
935+ std::ostringstream err;
936+ err << "The query compiled using xqxq:prepare-main-query raised an error: "
937+ << e.what();
938+ Item errQName = XQXQModule::getItemFactory()->createQName(
939+ e.diagnostic().qname().ns(), e.diagnostic().qname().localname());
940+ throw USER_EXCEPTION(errQName, err.str());
941+ }
942+ return ItemSequence_t(new EmptySequence());
943+ }
944+
945+ /*******************************************************************************************
946+ *******************************************************************************************/
947+ zorba::ItemSequence_t
948+ IsBoundContextItemFunction::evaluate(
949+ const Arguments_t& aArgs,
950+ const zorba::StaticContext* aSctx,
951+ const zorba::DynamicContext* aDctx) const
952+ {
953+
954+ String lQueryID = XQXQFunction::getOneStringArgument(aArgs, 0);
955+
956+ XQuery_t lQuery = getQuery(aDctx, lQueryID);
957+
958+ bool lIsContextItemBound = lQuery->getDynamicContext()->isBoundContextItem();
959+
960+ return ItemSequence_t(new SingletonItemSequence(
961+ XQXQModule::getItemFactory()->createBoolean(lIsContextItemBound)));
962+ }
963+
964+ /*******************************************************************************************
965+ *******************************************************************************************/
966+ zorba::ItemSequence_t
967+ IsBoundVariableFunction::evaluate(
968+ const Arguments_t& aArgs,
969+ const zorba::StaticContext* aSctx,
970+ const zorba::DynamicContext* aDctx) const
971+ {
972+ String lQueryID = XQXQFunction::getOneStringArgument(aArgs, 0);
973+
974+ XQuery_t lQuery = getQuery(aDctx, lQueryID);
975+
976+ Item lVarQName = XQXQFunction::getItemArgument(aArgs, 1);
977+ bool lIsBoundVariable = false;
978+
979+ try
980+ {
981+ lIsBoundVariable = lQuery->getDynamicContext()->isBoundExternalVariable(lVarQName.getNamespace(),lVarQName.getLocalName());
982+ }
983+ catch (ZorbaException& ze)
984+ {
985+ if (ze.diagnostic() == zerr::ZAPI0011_ELEMENT_NOT_DECLARED)
986+ XQXQFunction::throwError("UndeclaredVariable", ze.what());
987+ throw; // should not happen
988+ }
989+ return ItemSequence_t(new SingletonItemSequence(XQXQModule::getItemFactory()->createBoolean(lIsBoundVariable)));
990+
991+ }
992+
993+ /*******************************************************************************************
994+ *******************************************************************************************/
995+ zorba::ItemSequence_t
996+ GetExternalVariablesFunction::evaluate(
997+ const Arguments_t& aArgs,
998+ const zorba::StaticContext* aSctx,
999+ const zorba::DynamicContext* aDctx) const
1000+ {
1001+
1002+ String lQueryID = XQXQFunction::getOneStringArgument(aArgs, 0);
1003+
1004+ XQuery_t lQuery = getQuery(aDctx, lQueryID);
1005+
1006+ std::vector<Item> lVars;
1007+ Iterator_t lVarsIterator;
1008+ lQuery->getExternalVariables(lVarsIterator);
1009+
1010+ Item lVar;
1011+ lVarsIterator->open();
1012+ while(lVarsIterator->next(lVar))
1013+ lVars.push_back(lVar);
1014+ lVarsIterator->close();
1015+
1016+ return ItemSequence_t(new VectorItemSequence(lVars));
1017+ }
1018+ /*******************************************************************************************
1019+ *******************************************************************************************/
1020+ zorba::ItemSequence_t
1021+ IsUpdatingFunction::evaluate(
1022+ const Arguments_t& aArgs,
1023+ const zorba::StaticContext* aSctx,
1024+ const zorba::DynamicContext* aDctx) const
1025+ {
1026+ String lQueryID = XQXQFunction::getOneStringArgument(aArgs, 0);
1027+
1028+ XQuery_t lQuery = getQuery(aDctx, lQueryID);
1029+
1030+ return ItemSequence_t(new SingletonItemSequence(XQXQModule::getItemFactory()->createBoolean(lQuery->isUpdating())));
1031+ }
1032+
1033+ /*******************************************************************************************
1034+ *******************************************************************************************/
1035+ zorba::ItemSequence_t
1036+ IsSequentialFunction::evaluate(
1037+ const Arguments_t& aArgs,
1038+ const zorba::StaticContext* aSctx,
1039+ const zorba::DynamicContext* aDctx) const
1040+ {
1041+ String lQueryID = XQXQFunction::getOneStringArgument(aArgs, 0);
1042+
1043+ XQuery_t lQuery = getQuery(aDctx, lQueryID);
1044+
1045+ return ItemSequence_t(new SingletonItemSequence(XQXQModule::getItemFactory()->createBoolean(lQuery->isSequential())));
1046+ }
1047+
1048+ /*******************************************************************************************
1049+ *******************************************************************************************/
1050+ zorba::ItemSequence_t
1051+ BindContextItemFunction::evaluate(
1052+ const Arguments_t& aArgs,
1053+ const zorba::StaticContext* aSctx,
1054+ const zorba::DynamicContext* aDctx) const
1055+ {
1056+ String lQueryID = XQXQFunction::getOneStringArgument(aArgs,0);
1057+
1058+ XQuery_t lQuery = getQuery(aDctx, lQueryID);
1059+
1060+ // shouldn't raise errors
1061+ Item lItemContext = XQXQFunction::getItemArgument(aArgs, 1);
1062+ lQuery->getDynamicContext()->setContextItem(lItemContext);
1063+
1064+ return ItemSequence_t(new EmptySequence());
1065+ }
1066+
1067+ /*******************************************************************************************
1068+ *******************************************************************************************/
1069+ zorba::ItemSequence_t
1070+ BindContextPositionFunction::evaluate(
1071+ const Arguments_t& aArgs,
1072+ const zorba::StaticContext* aSctx,
1073+ const zorba::DynamicContext* aDctx) const
1074+ {
1075+
1076+ XQXQFunction::throwError("ImplementationError", "This function is not implemented yet");
1077+
1078+ return ItemSequence_t(new EmptySequence());
1079+ }
1080+
1081+ /*******************************************************************************************
1082+ *******************************************************************************************/
1083+ zorba::ItemSequence_t
1084+ BindContextSizeFunction::evaluate(
1085+ const Arguments_t& aArgs,
1086+ const zorba::StaticContext* aSctx,
1087+ const zorba::DynamicContext* aDctx) const
1088+ {
1089+
1090+ XQXQFunction::throwError("ImplementationError", "This function is not implemented yet");
1091+
1092+ return ItemSequence_t(new EmptySequence());
1093+ }
1094+
1095+ /*******************************************************************************************
1096+ *******************************************************************************************/
1097+ zorba::ItemSequence_t
1098+ BindVariableFunction::evaluate(
1099+ const Arguments_t& aArgs,
1100+ const zorba::StaticContext* aSctx,
1101+ const zorba::DynamicContext* aDctx) const
1102+ {
1103+ String lQueryID = XQXQFunction::getOneStringArgument(aArgs,0);
1104+
1105+ XQuery_t lQuery = getQuery(aDctx, lQueryID);
1106+
1107+ Item lVarQName = XQXQFunction::getItemArgument(aArgs, 1);
1108+
1109+ Iterator_t lVarValue = XQXQFunction::getIterArgument(aArgs, 2);
1110+
1111+ if (!lQuery->getDynamicContext()->setVariable(
1112+ lVarQName.getNamespace(), lVarQName.getLocalName() , lVarValue))
1113+ {
1114+ std::ostringstream lMsg;
1115+ lMsg << "{" << lVarQName.getNamespace() << "}" << lVarQName.getLocalName()
1116+ << ": undefined variable";
1117+ throwError("UndeclaredVariable", lMsg.str());
1118+ }
1119+
1120+ return ItemSequence_t(new EmptySequence());
1121+ }
1122+
1123+ /*******************************************************************************************
1124+ *******************************************************************************************/
1125+ bool
1126+ EvaluateItemSequence::EvaluateIterator::next(Item& aItem)
1127+ {
1128+ try
1129+ {
1130+ return theIterator->next(aItem);
1131+ }
1132+ catch (XQueryException& xe)
1133+ {
1134+ std::ostringstream err;
1135+ err << "The query " << "(" << theQueryID << ") evaluated using xqxq:evaluate raised an error at"
1136+ << " line " << xe.source_line() << " column " << xe.source_column() << ": " << xe.what();
1137+ Item errQName = XQXQModule::getItemFactory()->createQName(
1138+ xe.diagnostic().qname().ns(), xe.diagnostic().qname().localname());
1139+ throw USER_EXCEPTION(errQName, err.str());
1140+ }
1141+ catch (ZorbaException& e)
1142+ {
1143+ std::ostringstream err;
1144+ err << "The query " << "(" << theQueryID << ") evaluated using xqxq:evaluate raised an error at"
1145+ << e.what();
1146+ Item errQName = XQXQModule::getItemFactory()->createQName(
1147+ e.diagnostic().qname().ns(), e.diagnostic().qname().localname());
1148+ throw USER_EXCEPTION(errQName, err.str());
1149+ }
1150+ }
1151+
1152+ /*******************************************************************************************
1153+ *******************************************************************************************/
1154+ zorba::ItemSequence_t
1155+ EvaluateFunction::evaluate(
1156+ const Arguments_t& aArgs,
1157+ const zorba::StaticContext* aSctx,
1158+ const zorba::DynamicContext* aDctx) const
1159+ {
1160+ String lQueryID = XQXQFunction::getOneStringArgument(aArgs,0);
1161+
1162+ XQuery_t lQuery = getQuery(aDctx, lQueryID);
1163+
1164+ if(lQuery->isUpdating())
1165+ {
1166+ throwError("QueryIsUpdating", "Executing Query shouldn't be updating.");
1167+ }
1168+
1169+
1170+ if(lQuery->isSequential())
1171+ {
1172+ throwError("QueryIsSequential", "Executing Query shouldn't be sequential.");
1173+ }
1174+
1175+ Iterator_t lIterQuery = lQuery->iterator();
1176+
1177+ return ItemSequence_t(new EvaluateItemSequence(lIterQuery, lQueryID));
1178+ }
1179+
1180+ /*******************************************************************************************
1181+ *******************************************************************************************/
1182+ zorba::ItemSequence_t
1183+ EvaluateUpdatingFunction::evaluate(
1184+ const Arguments_t& aArgs,
1185+ const zorba::StaticContext* aSctx,
1186+ const zorba::DynamicContext* aDctx) const
1187+ {
1188+ String lQueryID = XQXQFunction::getOneStringArgument(aArgs,0);
1189+
1190+ XQuery_t lQuery = getQuery(aDctx, lQueryID);
1191+
1192+ if(lQuery->isSequential())
1193+ {
1194+ throwError("QueryIsSequential", "Executing Query shouldn't be sequential.");
1195+ }
1196+
1197+ if(!lQuery->isUpdating())
1198+ {
1199+ throwError("QueryNotUpdating", "Executing Query should be updating.") ;
1200+ }
1201+
1202+ Iterator_t lIterQuery = lQuery->iterator();
1203+ return ItemSequence_t(new EvaluateItemSequence(lIterQuery, lQueryID));
1204+}
1205+
1206+ /*******************************************************************************************
1207+ *******************************************************************************************/
1208+ zorba::ItemSequence_t
1209+ EvaluateSequentialFunction::evaluate(
1210+ const Arguments_t& aArgs,
1211+ const zorba::StaticContext* aSctx,
1212+ const zorba::DynamicContext* aDctx) const
1213+ {
1214+ String lQueryID = XQXQFunction::getOneStringArgument(aArgs, 0);
1215+
1216+ XQuery_t lQuery = getQuery(aDctx, lQueryID);
1217+
1218+ if(lQuery->isUpdating())
1219+ {
1220+ throwError("QueryIsUpdating", "Executing Query shouldn't be updating.");
1221+ }
1222+
1223+ if(!lQuery->isSequential())
1224+ {
1225+ throwError("QueryNotSequential", "Executing Query should be sequential.");
1226+ }
1227+
1228+ Iterator_t lIterQuery = lQuery->iterator();
1229+ return ItemSequence_t(new EvaluateItemSequence(lIterQuery, lQueryID));
1230+ }
1231+
1232+ /*******************************************************************************************
1233+ *******************************************************************************************/
1234+ zorba::ItemSequence_t
1235+ DeleteQueryFunction::evaluate(
1236+ const Arguments_t& aArgs,
1237+ const zorba::StaticContext* aSctx,
1238+ const zorba::DynamicContext* aDctx) const
1239+ {
1240+ String lQueryID = XQXQFunction::getOneStringArgument(aArgs,0);
1241+
1242+ QueryMap* lQueryMap;
1243+ if (!(lQueryMap= dynamic_cast<QueryMap*>(aDctx->getExternalFunctionParameter("xqxqQueryMap"))))
1244+ {
1245+ throwError("NoQueryMatch", "String identifying query does not exists.");
1246+ }
1247+
1248+ if (!lQueryMap->deleteQuery(lQueryID))
1249+ {
1250+ throwError("NoQueryMatch","String identifying query does not exists.");
1251+ }
1252+
1253+ return ItemSequence_t(new EmptySequence());
1254+ }
1255+
1256+}/*namespace xqxq*/ }/*namespace zorba*/
1257+
1258+#ifdef WIN32
1259+# define DLL_EXPORT __declspec(dllexport)
1260+#else
1261+# define DLL_EXPORT __attribute__ ((visibility("default")))
1262+#endif
1263+
1264+extern "C" DLL_EXPORT zorba::ExternalModule* createModule() {
1265+ return new zorba::xqxq::XQXQModule();
1266+}
1267
1268=== added file 'modules/xqxq/xqxq.xq.src/xqxq.h'
1269--- modules/xqxq/xqxq.xq.src/xqxq.h 1970-01-01 00:00:00 +0000
1270+++ modules/xqxq/xqxq.xq.src/xqxq.h 2012-10-25 00:20:28 +0000
1271@@ -0,0 +1,456 @@
1272+#ifndef __COM_ZORBA_WWW_MODULES_XQXQ_H__
1273+#define __COM_ZORBA_WWW_MODULES_XQXQ_H__
1274+
1275+#include <map>
1276+
1277+#include <zorba/zorba.h>
1278+#include <zorba/external_module.h>
1279+#include <zorba/function.h>
1280+#include <zorba/dynamic_context.h>
1281+
1282+#define XQXQ_MODULE_NAMESPACE "http://www.zorba-xquery.com/modules/xqxq"
1283+
1284+namespace zorba { namespace xqxq {
1285+
1286+
1287+
1288+ class XQXQModule : public ExternalModule {
1289+ protected:
1290+ class ltstr
1291+ {
1292+ public:
1293+ bool operator()(const String& s1, const String& s2) const
1294+ {
1295+ return s1.compare(s2) < 0;
1296+ }
1297+ };
1298+
1299+ typedef std::map<String, ExternalFunction*, ltstr> FuncMap_t;
1300+
1301+ FuncMap_t theFunctions;
1302+
1303+ public:
1304+
1305+ virtual ~XQXQModule();
1306+
1307+ virtual zorba::String
1308+ getURI() const {return XQXQ_MODULE_NAMESPACE;}
1309+
1310+ virtual zorba::ExternalFunction*
1311+ getExternalFunction(const String& localName);
1312+
1313+ virtual void destroy();
1314+
1315+ static ItemFactory*
1316+ getItemFactory()
1317+ {
1318+ return Zorba::getInstance(0)->getItemFactory();
1319+ }
1320+
1321+ };
1322+
1323+ /**
1324+ * @brief Bag class for objects associated with a prepared query
1325+ */
1326+ class QueryData : public SmartObject
1327+ {
1328+ private:
1329+ XQuery_t theQuery;
1330+ URIMapper* theURIMapper;
1331+ URLResolver* theURLResolver;
1332+
1333+ public:
1334+ QueryData(XQuery_t aQuery, URIMapper* aMapper, URLResolver* aResolver);
1335+ virtual ~QueryData();
1336+ XQuery_t getQuery() { return theQuery; }
1337+ };
1338+ typedef SmartPtr<QueryData> QueryData_t;
1339+
1340+ class QueryMap : public ExternalFunctionParameter
1341+ {
1342+ private:
1343+ typedef std::map<String, QueryData_t> QueryMap_t;
1344+ QueryMap_t* queryMap;
1345+
1346+ public:
1347+ QueryMap();
1348+ bool
1349+ storeQuery(const String&, XQuery_t, URIMapper*, URLResolver*);
1350+ XQuery_t
1351+ getQuery(const String&);
1352+ bool
1353+ deleteQuery(const String&);
1354+ virtual void
1355+ destroy() throw();
1356+ };
1357+
1358+ class XQXQFunction : public ContextualExternalFunction
1359+ {
1360+ protected:
1361+ const XQXQModule* theModule;
1362+
1363+ String
1364+ getOneStringArgument(const Arguments_t&, int) const;
1365+
1366+ Item
1367+ getItemArgument(const Arguments_t&, int) const;
1368+
1369+ Iterator_t
1370+ getIterArgument(const Arguments_t&, int) const;
1371+
1372+ static void
1373+ throwError(const char*, const std::string);
1374+
1375+ XQuery_t
1376+ getQuery(
1377+ const zorba::DynamicContext* dctx,
1378+ const zorba::String& aIdent) const;
1379+
1380+ public:
1381+
1382+ XQXQFunction(const XQXQModule* module);
1383+
1384+ virtual ~XQXQFunction();
1385+
1386+ virtual String
1387+ getURI() const;
1388+ };
1389+
1390+
1391+
1392+ class PrepareMainModuleFunction : public XQXQFunction{
1393+ public:
1394+ PrepareMainModuleFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
1395+
1396+ virtual ~PrepareMainModuleFunction(){ }
1397+
1398+ virtual zorba::String
1399+ getLocalName() const { return "prepare-main-module"; }
1400+
1401+ virtual zorba::ItemSequence_t
1402+ evaluate(const Arguments_t&,
1403+ const zorba::StaticContext*,
1404+ const zorba::DynamicContext*) const;
1405+
1406+ protected:
1407+
1408+ class XQXQURLResolver : public URLResolver
1409+ {
1410+ protected:
1411+ Item theFunction;
1412+ StaticContext_t theCtx;
1413+
1414+ public:
1415+ XQXQURLResolver(Item& aFunction, StaticContext_t& aSctx) : URLResolver(), theFunction(aFunction), theCtx(aSctx) {}
1416+
1417+ virtual ~XQXQURLResolver(){ }
1418+
1419+ virtual Resource* resolveURL(const String& aUrl,
1420+ EntityData const* aEntityData);
1421+
1422+ };
1423+
1424+ class XQXQURIMapper : public URIMapper
1425+ {
1426+ protected:
1427+ Item theFunction;
1428+ StaticContext_t theCtx;
1429+
1430+ public:
1431+ XQXQURIMapper(Item& aFunction, StaticContext_t& aSctx) : URIMapper(), theFunction(aFunction), theCtx(aSctx) {}
1432+
1433+ virtual ~XQXQURIMapper(){ }
1434+
1435+ virtual void mapURI(
1436+ const zorba::String aUri,
1437+ EntityData const* aEntityData,
1438+ std::vector<zorba::String>& oUris);
1439+
1440+ };
1441+
1442+ };
1443+
1444+ class PrepareLibraryModuleFunction : public XQXQFunction{
1445+ public:
1446+ PrepareLibraryModuleFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
1447+
1448+ virtual ~PrepareLibraryModuleFunction(){}
1449+
1450+ virtual zorba::String
1451+ getLocalName() const { return "prepare-library-module"; }
1452+
1453+ virtual zorba::ItemSequence_t
1454+ evaluate(const Arguments_t&,
1455+ const zorba::StaticContext*,
1456+ const zorba::DynamicContext*) const;
1457+ };
1458+
1459+ class IsBoundContextItemFunction : public XQXQFunction{
1460+ public:
1461+ IsBoundContextItemFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
1462+
1463+ virtual ~IsBoundContextItemFunction(){}
1464+
1465+ virtual zorba::String
1466+ getLocalName() const { return "is-bound-context-item"; }
1467+
1468+ virtual zorba::ItemSequence_t
1469+ evaluate(const Arguments_t&,
1470+ const zorba::StaticContext*,
1471+ const zorba::DynamicContext*) const;
1472+ };
1473+
1474+ class IsBoundVariableFunction : public XQXQFunction{
1475+ public:
1476+ IsBoundVariableFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
1477+
1478+ virtual ~IsBoundVariableFunction(){}
1479+
1480+ virtual zorba::String
1481+ getLocalName() const { return "is-bound-variable"; }
1482+
1483+ virtual zorba::ItemSequence_t
1484+ evaluate(const Arguments_t&,
1485+ const zorba::StaticContext*,
1486+ const zorba::DynamicContext*) const;
1487+ };
1488+
1489+ class GetExternalVariablesFunction : public XQXQFunction{
1490+ public:
1491+ GetExternalVariablesFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
1492+
1493+ virtual ~GetExternalVariablesFunction() {}
1494+
1495+ virtual zorba::String
1496+ getLocalName() const {return "external-variables"; }
1497+
1498+ virtual zorba::ItemSequence_t
1499+ evaluate(const Arguments_t&,
1500+ const zorba::StaticContext*,
1501+ const zorba::DynamicContext*) const;
1502+ };
1503+
1504+ class IsUpdatingFunction : public XQXQFunction{
1505+ public:
1506+ IsUpdatingFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
1507+
1508+ virtual ~IsUpdatingFunction() {}
1509+
1510+ virtual zorba::String
1511+ getLocalName() const {return "is-updating"; }
1512+
1513+ virtual zorba::ItemSequence_t
1514+ evaluate(const Arguments_t&,
1515+ const zorba::StaticContext*,
1516+ const zorba::DynamicContext*) const;
1517+
1518+ };
1519+
1520+ class IsSequentialFunction : public XQXQFunction{
1521+ public:
1522+ IsSequentialFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
1523+
1524+ virtual ~IsSequentialFunction() {}
1525+
1526+ virtual zorba::String
1527+ getLocalName() const {return "is-sequential"; }
1528+
1529+ virtual zorba::ItemSequence_t
1530+ evaluate(const Arguments_t&,
1531+ const zorba::StaticContext*,
1532+ const zorba::DynamicContext*) const;
1533+ };
1534+
1535+ class BindContextItemFunction : public XQXQFunction{
1536+ public:
1537+ BindContextItemFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
1538+
1539+ virtual ~BindContextItemFunction() {}
1540+
1541+ virtual zorba::String
1542+ getLocalName() const {return "bind-context-item"; }
1543+
1544+ virtual zorba::ItemSequence_t
1545+ evaluate(const Arguments_t&,
1546+ const zorba::StaticContext*,
1547+ const zorba::DynamicContext*) const;
1548+ };
1549+
1550+ class BindContextPositionFunction : public XQXQFunction{
1551+ public:
1552+ BindContextPositionFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
1553+
1554+ virtual ~BindContextPositionFunction() {}
1555+
1556+ virtual zorba::String
1557+ getLocalName() const {return "bind-context-position"; }
1558+
1559+ virtual zorba::ItemSequence_t
1560+ evaluate(const Arguments_t&,
1561+ const zorba::StaticContext*,
1562+ const zorba::DynamicContext*) const;
1563+ };
1564+
1565+ class BindContextSizeFunction : public XQXQFunction{
1566+ public:
1567+ BindContextSizeFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
1568+
1569+ virtual ~BindContextSizeFunction() {}
1570+
1571+ virtual zorba::String
1572+ getLocalName() const {return "bind-context-size"; }
1573+
1574+ virtual zorba::ItemSequence_t
1575+ evaluate(const Arguments_t&,
1576+ const zorba::StaticContext*,
1577+ const zorba::DynamicContext*) const;
1578+ };
1579+
1580+ class BindVariableFunction : public XQXQFunction{
1581+ public:
1582+ BindVariableFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
1583+
1584+ virtual ~BindVariableFunction() {}
1585+
1586+ virtual zorba::String
1587+ getLocalName() const {return "bind-variable"; }
1588+
1589+ virtual zorba::ItemSequence_t
1590+ evaluate(const Arguments_t&,
1591+ const zorba::StaticContext*,
1592+ const zorba::DynamicContext*) const;
1593+ };
1594+
1595+ /*******************************************************************************************
1596+ *******************************************************************************************/
1597+ class EvaluateItemSequence : public ItemSequence
1598+ {
1599+ protected:
1600+
1601+ class EvaluateIterator : public Iterator
1602+ {
1603+ protected:
1604+ Iterator_t theIterator;
1605+
1606+ String theQueryID;
1607+
1608+ public:
1609+ EvaluateIterator(Iterator_t& aIter, String aQueryID)
1610+ : theIterator(aIter), theQueryID(aQueryID)
1611+ {
1612+ }
1613+
1614+ virtual ~EvaluateIterator(){}
1615+
1616+ virtual void
1617+ open()
1618+ {
1619+ theIterator->open();
1620+ }
1621+
1622+ virtual bool
1623+ next(Item& aItem);
1624+
1625+ virtual void
1626+ close()
1627+ {
1628+ theIterator->close();
1629+ }
1630+
1631+ virtual bool
1632+ isOpen() const
1633+ {
1634+ return theIterator->isOpen();
1635+ }
1636+
1637+ };
1638+
1639+ typedef zorba::SmartPtr<EvaluateIterator> EvaluateIterator_t;
1640+ EvaluateIterator_t theIter;
1641+
1642+ public:
1643+ EvaluateItemSequence(Iterator_t& aIter, String& aQueryID)
1644+ :theIter (new EvaluateIterator(aIter, aQueryID))
1645+ {
1646+
1647+ }
1648+
1649+ virtual ~EvaluateItemSequence() {}
1650+
1651+ Iterator_t
1652+ getIterator() { return theIter.get(); }
1653+ };
1654+
1655+ class EvaluateFunction : public XQXQFunction{
1656+ public:
1657+ EvaluateFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
1658+
1659+ virtual ~EvaluateFunction() {}
1660+
1661+ virtual zorba::String
1662+ getLocalName() const {return "evaluate"; }
1663+
1664+ virtual zorba::ItemSequence_t
1665+ evaluate(const Arguments_t&,
1666+ const zorba::StaticContext*,
1667+ const zorba::DynamicContext*) const;
1668+ };
1669+
1670+ class EvaluateUpdatingFunction : public XQXQFunction{
1671+ public:
1672+ EvaluateUpdatingFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
1673+
1674+ virtual ~EvaluateUpdatingFunction() {}
1675+
1676+ virtual zorba::String
1677+ getLocalName() const {return "evaluate-updating"; }
1678+
1679+ virtual zorba::ItemSequence_t
1680+ evaluate(const Arguments_t&,
1681+ const zorba::StaticContext*,
1682+ const zorba::DynamicContext*) const;
1683+ };
1684+
1685+ class EvaluateSequentialFunction : public XQXQFunction{
1686+ public:
1687+ EvaluateSequentialFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
1688+
1689+ virtual ~EvaluateSequentialFunction() {}
1690+
1691+ virtual zorba::String
1692+ getLocalName() const {return "evaluate-sequential"; }
1693+
1694+ virtual zorba::ItemSequence_t
1695+ evaluate(const Arguments_t&,
1696+ const zorba::StaticContext*,
1697+ const zorba::DynamicContext*) const;
1698+
1699+ virtual String getURI() const {
1700+ return theModule->getURI();
1701+ }
1702+
1703+ protected:
1704+ const XQXQModule* theModule;
1705+ };
1706+
1707+ class DeleteQueryFunction : public XQXQFunction{
1708+ public:
1709+ DeleteQueryFunction(const XQXQModule* aModule) : XQXQFunction(aModule) {}
1710+
1711+ virtual ~DeleteQueryFunction() {}
1712+
1713+ virtual zorba::String
1714+ getLocalName() const {return "delete-query"; }
1715+
1716+ virtual zorba::ItemSequence_t
1717+ evaluate(const Arguments_t&,
1718+ const zorba::StaticContext*,
1719+ const zorba::DynamicContext*) const;
1720+ };
1721+
1722+
1723+
1724+}/*xqxq namespace*/}/*zorba namespace*/
1725+
1726+
1727+#endif //_COM_ZORBA_WWW_MODULES_XQXQ_H_
1728
1729=== added directory 'test/rbkt/ExpQueryResults/zorba/xqxq'
1730=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/bind-context-item.xml.res'
1731--- test/rbkt/ExpQueryResults/zorba/xqxq/bind-context-item.xml.res 1970-01-01 00:00:00 +0000
1732+++ test/rbkt/ExpQueryResults/zorba/xqxq/bind-context-item.xml.res 2012-10-25 00:20:28 +0000
1733@@ -0,0 +1,2 @@
1734+<?xml version="1.0" encoding="UTF-8"?>
1735+true
1736\ No newline at end of file
1737
1738=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/bind-variable.xml.res'
1739--- test/rbkt/ExpQueryResults/zorba/xqxq/bind-variable.xml.res 1970-01-01 00:00:00 +0000
1740+++ test/rbkt/ExpQueryResults/zorba/xqxq/bind-variable.xml.res 2012-10-25 00:20:28 +0000
1741@@ -0,0 +1,2 @@
1742+<?xml version="1.0" encoding="UTF-8"?>
1743+true
1744\ No newline at end of file
1745
1746=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/evaluate-sequential.xml.res'
1747--- test/rbkt/ExpQueryResults/zorba/xqxq/evaluate-sequential.xml.res 1970-01-01 00:00:00 +0000
1748+++ test/rbkt/ExpQueryResults/zorba/xqxq/evaluate-sequential.xml.res 2012-10-25 00:20:28 +0000
1749@@ -0,0 +1,2 @@
1750+<?xml version="1.0" encoding="UTF-8"?>
1751+true
1752\ No newline at end of file
1753
1754=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/evaluate-updating.xml.res'
1755--- test/rbkt/ExpQueryResults/zorba/xqxq/evaluate-updating.xml.res 1970-01-01 00:00:00 +0000
1756+++ test/rbkt/ExpQueryResults/zorba/xqxq/evaluate-updating.xml.res 2012-10-25 00:20:28 +0000
1757@@ -0,0 +1,2 @@
1758+<?xml version="1.0" encoding="UTF-8"?>
1759+<parent><child>Content</child></parent>
1760\ No newline at end of file
1761
1762=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/evaluate.xml.res'
1763--- test/rbkt/ExpQueryResults/zorba/xqxq/evaluate.xml.res 1970-01-01 00:00:00 +0000
1764+++ test/rbkt/ExpQueryResults/zorba/xqxq/evaluate.xml.res 2012-10-25 00:20:28 +0000
1765@@ -0,0 +1,2 @@
1766+<?xml version="1.0" encoding="UTF-8"?>
1767+2
1768\ No newline at end of file
1769
1770=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/evaluate2.xml.res'
1771--- test/rbkt/ExpQueryResults/zorba/xqxq/evaluate2.xml.res 1970-01-01 00:00:00 +0000
1772+++ test/rbkt/ExpQueryResults/zorba/xqxq/evaluate2.xml.res 2012-10-25 00:20:28 +0000
1773@@ -0,0 +1,2 @@
1774+<?xml version="1.0" encoding="UTF-8"?>
1775+2
1776\ No newline at end of file
1777
1778=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/external-module.xml.res'
1779--- test/rbkt/ExpQueryResults/zorba/xqxq/external-module.xml.res 1970-01-01 00:00:00 +0000
1780+++ test/rbkt/ExpQueryResults/zorba/xqxq/external-module.xml.res 2012-10-25 00:20:28 +0000
1781@@ -0,0 +1,2 @@
1782+<?xml version="1.0" encoding="UTF-8"?>
1783+true
1784\ No newline at end of file
1785
1786=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/get-external-variables.xml.res'
1787--- test/rbkt/ExpQueryResults/zorba/xqxq/get-external-variables.xml.res 1970-01-01 00:00:00 +0000
1788+++ test/rbkt/ExpQueryResults/zorba/xqxq/get-external-variables.xml.res 2012-10-25 00:20:28 +0000
1789@@ -0,0 +1,2 @@
1790+<?xml version="1.0" encoding="UTF-8"?>
1791+a
1792\ No newline at end of file
1793
1794=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/is-bound-context-item.xml.res'
1795--- test/rbkt/ExpQueryResults/zorba/xqxq/is-bound-context-item.xml.res 1970-01-01 00:00:00 +0000
1796+++ test/rbkt/ExpQueryResults/zorba/xqxq/is-bound-context-item.xml.res 2012-10-25 00:20:28 +0000
1797@@ -0,0 +1,2 @@
1798+<?xml version="1.0" encoding="UTF-8"?>
1799+false
1800\ No newline at end of file
1801
1802=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/is-bound-variable.xml.res'
1803--- test/rbkt/ExpQueryResults/zorba/xqxq/is-bound-variable.xml.res 1970-01-01 00:00:00 +0000
1804+++ test/rbkt/ExpQueryResults/zorba/xqxq/is-bound-variable.xml.res 2012-10-25 00:20:28 +0000
1805@@ -0,0 +1,2 @@
1806+<?xml version="1.0" encoding="UTF-8"?>
1807+true true false
1808\ No newline at end of file
1809
1810=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/is-sequential.xml.res'
1811--- test/rbkt/ExpQueryResults/zorba/xqxq/is-sequential.xml.res 1970-01-01 00:00:00 +0000
1812+++ test/rbkt/ExpQueryResults/zorba/xqxq/is-sequential.xml.res 2012-10-25 00:20:28 +0000
1813@@ -0,0 +1,2 @@
1814+<?xml version="1.0" encoding="UTF-8"?>
1815+true false
1816\ No newline at end of file
1817
1818=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/is-updating.xml.res'
1819--- test/rbkt/ExpQueryResults/zorba/xqxq/is-updating.xml.res 1970-01-01 00:00:00 +0000
1820+++ test/rbkt/ExpQueryResults/zorba/xqxq/is-updating.xml.res 2012-10-25 00:20:28 +0000
1821@@ -0,0 +1,2 @@
1822+<?xml version="1.0" encoding="UTF-8"?>
1823+true false
1824\ No newline at end of file
1825
1826=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/multiple-queries.xml.res'
1827--- test/rbkt/ExpQueryResults/zorba/xqxq/multiple-queries.xml.res 1970-01-01 00:00:00 +0000
1828+++ test/rbkt/ExpQueryResults/zorba/xqxq/multiple-queries.xml.res 2012-10-25 00:20:28 +0000
1829@@ -0,0 +1,2 @@
1830+<?xml version="1.0" encoding="UTF-8"?>
1831+2 3
1832\ No newline at end of file
1833
1834=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/uri-mapper.xml.res'
1835--- test/rbkt/ExpQueryResults/zorba/xqxq/uri-mapper.xml.res 1970-01-01 00:00:00 +0000
1836+++ test/rbkt/ExpQueryResults/zorba/xqxq/uri-mapper.xml.res 2012-10-25 00:20:28 +0000
1837@@ -0,0 +1,2 @@
1838+<?xml version="1.0" encoding="UTF-8"?>
1839+foo
1840
1841=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/uri-mapper2.xml.res'
1842--- test/rbkt/ExpQueryResults/zorba/xqxq/uri-mapper2.xml.res 1970-01-01 00:00:00 +0000
1843+++ test/rbkt/ExpQueryResults/zorba/xqxq/uri-mapper2.xml.res 2012-10-25 00:20:28 +0000
1844@@ -0,0 +1,2 @@
1845+<?xml version="1.0" encoding="UTF-8"?>
1846+<test:test xmlns:test="http://test"><test:subtest>a</test:subtest><test:subtest2>a</test:subtest2></test:test>
1847
1848=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/url-module-resolver.xml.res'
1849--- test/rbkt/ExpQueryResults/zorba/xqxq/url-module-resolver.xml.res 1970-01-01 00:00:00 +0000
1850+++ test/rbkt/ExpQueryResults/zorba/xqxq/url-module-resolver.xml.res 2012-10-25 00:20:28 +0000
1851@@ -0,0 +1,2 @@
1852+<?xml version="1.0" encoding="UTF-8"?>
1853+foo
1854
1855=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/url-schema-resolver.xml.res'
1856--- test/rbkt/ExpQueryResults/zorba/xqxq/url-schema-resolver.xml.res 1970-01-01 00:00:00 +0000
1857+++ test/rbkt/ExpQueryResults/zorba/xqxq/url-schema-resolver.xml.res 2012-10-25 00:20:28 +0000
1858@@ -0,0 +1,2 @@
1859+<?xml version="1.0" encoding="UTF-8"?>
1860+<test:test xmlns:test="http://test"><test:subtest>a</test:subtest><test:subtest2>a</test:subtest2></test:test>
1861
1862=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/url-schema-resolver2.xml.res'
1863--- test/rbkt/ExpQueryResults/zorba/xqxq/url-schema-resolver2.xml.res 1970-01-01 00:00:00 +0000
1864+++ test/rbkt/ExpQueryResults/zorba/xqxq/url-schema-resolver2.xml.res 2012-10-25 00:20:28 +0000
1865@@ -0,0 +1,2 @@
1866+<?xml version="1.0" encoding="UTF-8"?>
1867+<test:test xmlns:test="http://test"><test:subtest>a</test:subtest><test:subtest2>a</test:subtest2></test:test>
1868
1869=== added file 'test/rbkt/ExpQueryResults/zorba/xqxq/url-schema-resolver3.xml.res'
1870--- test/rbkt/ExpQueryResults/zorba/xqxq/url-schema-resolver3.xml.res 1970-01-01 00:00:00 +0000
1871+++ test/rbkt/ExpQueryResults/zorba/xqxq/url-schema-resolver3.xml.res 2012-10-25 00:20:28 +0000
1872@@ -0,0 +1,2 @@
1873+<?xml version="1.0" encoding="UTF-8"?>
1874+<test:test xmlns:test="http://test"><test:subtest>a</test:subtest><test:subtest2>a</test:subtest2></test:test>
1875
1876=== added directory 'test/rbkt/Queries/zorba/xqxq'
1877=== added file 'test/rbkt/Queries/zorba/xqxq/bind-context-item.xq'
1878--- test/rbkt/Queries/zorba/xqxq/bind-context-item.xq 1970-01-01 00:00:00 +0000
1879+++ test/rbkt/Queries/zorba/xqxq/bind-context-item.xq 2012-10-25 00:20:28 +0000
1880@@ -0,0 +1,6 @@
1881+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
1882+
1883+variable $query-key := xqxq:prepare-main-module("insert node <child>Content</child> into /parent");
1884+variable $xml := doc("context-item.xml");
1885+xqxq:bind-context-item($query-key, $xml);
1886+xqxq:is-bound-context-item($query-key)
1887
1888=== added file 'test/rbkt/Queries/zorba/xqxq/bind-variable.xq'
1889--- test/rbkt/Queries/zorba/xqxq/bind-variable.xq 1970-01-01 00:00:00 +0000
1890+++ test/rbkt/Queries/zorba/xqxq/bind-variable.xq 2012-10-25 00:20:28 +0000
1891@@ -0,0 +1,4 @@
1892+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
1893+variable $query-key := xqxq:prepare-main-module('declare variable $a external; $a');
1894+xqxq:bind-variable($query-key,xs:QName('a'),"foo");
1895+xqxq:is-bound-variable($query-key, xs:QName('a'))
1896\ No newline at end of file
1897
1898=== added file 'test/rbkt/Queries/zorba/xqxq/context-item.xml'
1899--- test/rbkt/Queries/zorba/xqxq/context-item.xml 1970-01-01 00:00:00 +0000
1900+++ test/rbkt/Queries/zorba/xqxq/context-item.xml 2012-10-25 00:20:28 +0000
1901@@ -0,0 +1,1 @@
1902+<parent></parent>
1903\ No newline at end of file
1904
1905=== added file 'test/rbkt/Queries/zorba/xqxq/delete.spec'
1906--- test/rbkt/Queries/zorba/xqxq/delete.spec 1970-01-01 00:00:00 +0000
1907+++ test/rbkt/Queries/zorba/xqxq/delete.spec 2012-10-25 00:20:28 +0000
1908@@ -0,0 +1,1 @@
1909+Error: http://www.zorba-xquery.com/modules/xqxq:NoQueryMatch
1910\ No newline at end of file
1911
1912=== added file 'test/rbkt/Queries/zorba/xqxq/delete.xq'
1913--- test/rbkt/Queries/zorba/xqxq/delete.xq 1970-01-01 00:00:00 +0000
1914+++ test/rbkt/Queries/zorba/xqxq/delete.xq 2012-10-25 00:20:28 +0000
1915@@ -0,0 +1,5 @@
1916+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
1917+
1918+variable $query-key := xqxq:prepare-main-module("1+1");
1919+xqxq:delete-query($query-key);
1920+xqxq:evaluate($query-key)
1921
1922=== added file 'test/rbkt/Queries/zorba/xqxq/error-in-query.spec'
1923--- test/rbkt/Queries/zorba/xqxq/error-in-query.spec 1970-01-01 00:00:00 +0000
1924+++ test/rbkt/Queries/zorba/xqxq/error-in-query.spec 2012-10-25 00:20:28 +0000
1925@@ -0,0 +1,2 @@
1926+Error: http://www.w3.org/2005/xqt-errors:XQST0033
1927+
1928
1929=== added file 'test/rbkt/Queries/zorba/xqxq/error-in-query.xq'
1930--- test/rbkt/Queries/zorba/xqxq/error-in-query.xq 1970-01-01 00:00:00 +0000
1931+++ test/rbkt/Queries/zorba/xqxq/error-in-query.xq 2012-10-25 00:20:28 +0000
1932@@ -0,0 +1,21 @@
1933+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
1934+
1935+declare namespace op = 'http://www.zorba-xquery.com/options/features';
1936+declare namespace f = 'http://www.zorba-xquery.com/features';
1937+declare option op:enable 'f:hof';
1938+
1939+declare function local:url-resolver($namespace as xs:string, $entity as xs:string) {
1940+switch($entity)
1941+case 'schema'
1942+ return switch($namespace)
1943+ case 'http://www.w3.org/XQueryTest' return doc('/tmp/atomic.xsd')
1944+ default return ()
1945+default return ()
1946+};
1947+
1948+variable $queryID := xqxq:prepare-main-module(
1949+ "declare namespace foo='http://test';
1950+ declare namespace foo='http://test';
1951+ 1",
1952+ local:url-resolver#2, ());
1953+xqxq:evaluate($queryID)
1954
1955=== added file 'test/rbkt/Queries/zorba/xqxq/evaluate-sequential.xq'
1956--- test/rbkt/Queries/zorba/xqxq/evaluate-sequential.xq 1970-01-01 00:00:00 +0000
1957+++ test/rbkt/Queries/zorba/xqxq/evaluate-sequential.xq 2012-10-25 00:20:28 +0000
1958@@ -0,0 +1,17 @@
1959+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
1960+
1961+variable $query-key := xqxq:prepare-main-module('
1962+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";
1963+declare namespace an = "http://www.zorba-xquery.com/annotations";
1964+declare %an:sequential function local:foo() {
1965+ ddl:create(xs:QName("hola"),(<a/>,<b/>));
1966+
1967+ exit returning true();
1968+};
1969+
1970+local:foo()
1971+');
1972+variable $xml := doc("context-item.xml");
1973+xqxq:bind-context-item($query-key, $xml);
1974+xqxq:evaluate-sequential($query-key)
1975+
1976
1977=== added file 'test/rbkt/Queries/zorba/xqxq/evaluate-sequential2.spec'
1978--- test/rbkt/Queries/zorba/xqxq/evaluate-sequential2.spec 1970-01-01 00:00:00 +0000
1979+++ test/rbkt/Queries/zorba/xqxq/evaluate-sequential2.spec 2012-10-25 00:20:28 +0000
1980@@ -0,0 +1,1 @@
1981+Error: http://www.zorba-xquery.com/modules/xqxq:QueryIsUpdating
1982\ No newline at end of file
1983
1984=== added file 'test/rbkt/Queries/zorba/xqxq/evaluate-sequential2.xq'
1985--- test/rbkt/Queries/zorba/xqxq/evaluate-sequential2.xq 1970-01-01 00:00:00 +0000
1986+++ test/rbkt/Queries/zorba/xqxq/evaluate-sequential2.xq 2012-10-25 00:20:28 +0000
1987@@ -0,0 +1,6 @@
1988+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
1989+
1990+variable $query-key := xqxq:prepare-main-module("insert node <child>Content</child> into /parent");
1991+variable $xml := doc("context-item.xml");
1992+xqxq:bind-context-item($query-key, $xml);
1993+xqxq:evaluate-sequential($query-key)
1994\ No newline at end of file
1995
1996=== added file 'test/rbkt/Queries/zorba/xqxq/evaluate-updating.xq'
1997--- test/rbkt/Queries/zorba/xqxq/evaluate-updating.xq 1970-01-01 00:00:00 +0000
1998+++ test/rbkt/Queries/zorba/xqxq/evaluate-updating.xq 2012-10-25 00:20:28 +0000
1999@@ -0,0 +1,7 @@
2000+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
2001+
2002+variable $query-key := xqxq:prepare-main-module("insert node <child>Content</child> into /parent");
2003+variable $xml := doc("context-item.xml");
2004+xqxq:bind-context-item($query-key, $xml);
2005+xqxq:evaluate-updating($query-key);
2006+$xml
2007\ No newline at end of file
2008
2009=== added file 'test/rbkt/Queries/zorba/xqxq/evaluate-updating2.spec'
2010--- test/rbkt/Queries/zorba/xqxq/evaluate-updating2.spec 1970-01-01 00:00:00 +0000
2011+++ test/rbkt/Queries/zorba/xqxq/evaluate-updating2.spec 2012-10-25 00:20:28 +0000
2012@@ -0,0 +1,1 @@
2013+Error: http://www.zorba-xquery.com/modules/xqxq:QueryIsSequential
2014\ No newline at end of file
2015
2016=== added file 'test/rbkt/Queries/zorba/xqxq/evaluate-updating2.xq'
2017--- test/rbkt/Queries/zorba/xqxq/evaluate-updating2.xq 1970-01-01 00:00:00 +0000
2018+++ test/rbkt/Queries/zorba/xqxq/evaluate-updating2.xq 2012-10-25 00:20:28 +0000
2019@@ -0,0 +1,15 @@
2020+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
2021+
2022+variable $query-key := xqxq:prepare-main-module('
2023+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";
2024+declare namespace an = "http://www.zorba-xquery.com/annotations";
2025+declare %an:sequential function local:foo() {
2026+ ddl:create(xs:QName("hola"),(<a/>,<b/>));
2027+
2028+ exit returning ();
2029+};
2030+
2031+local:foo()
2032+');
2033+xqxq:evaluate-updating($query-key);
2034+
2035
2036=== added file 'test/rbkt/Queries/zorba/xqxq/evaluate.xq'
2037--- test/rbkt/Queries/zorba/xqxq/evaluate.xq 1970-01-01 00:00:00 +0000
2038+++ test/rbkt/Queries/zorba/xqxq/evaluate.xq 2012-10-25 00:20:28 +0000
2039@@ -0,0 +1,5 @@
2040+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
2041+
2042+variable $query-key := xqxq:prepare-main-module("1+1");
2043+variable $a := xqxq:evaluate($query-key);
2044+$a
2045
2046=== added file 'test/rbkt/Queries/zorba/xqxq/evaluate2.xq'
2047--- test/rbkt/Queries/zorba/xqxq/evaluate2.xq 1970-01-01 00:00:00 +0000
2048+++ test/rbkt/Queries/zorba/xqxq/evaluate2.xq 2012-10-25 00:20:28 +0000
2049@@ -0,0 +1,6 @@
2050+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
2051+
2052+variable $query-key := xqxq:prepare-main-module("declare variable $a external; $a+1");
2053+xqxq:bind-variable($query-key, xs:QName("a"), 1);
2054+variable $b := xqxq:evaluate($query-key);
2055+$b
2056
2057=== added file 'test/rbkt/Queries/zorba/xqxq/evaluate3.spec'
2058--- test/rbkt/Queries/zorba/xqxq/evaluate3.spec 1970-01-01 00:00:00 +0000
2059+++ test/rbkt/Queries/zorba/xqxq/evaluate3.spec 2012-10-25 00:20:28 +0000
2060@@ -0,0 +1,1 @@
2061+Error: http://www.zorba-xquery.com/modules/xqxq:QueryIsSequential
2062\ No newline at end of file
2063
2064=== added file 'test/rbkt/Queries/zorba/xqxq/evaluate3.xq'
2065--- test/rbkt/Queries/zorba/xqxq/evaluate3.xq 1970-01-01 00:00:00 +0000
2066+++ test/rbkt/Queries/zorba/xqxq/evaluate3.xq 2012-10-25 00:20:28 +0000
2067@@ -0,0 +1,15 @@
2068+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
2069+
2070+variable $query-key := xqxq:prepare-main-module('
2071+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";
2072+declare namespace an = "http://www.zorba-xquery.com/annotations";
2073+declare %an:sequential function local:foo() {
2074+ ddl:create(xs:QName("hola"),(<a/>,<b/>));
2075+
2076+ exit returning ();
2077+};
2078+
2079+local:foo()
2080+');
2081+variable $a := xqxq:evaluate($query-key);
2082+$a
2083
2084=== added file 'test/rbkt/Queries/zorba/xqxq/external-module.xq'
2085--- test/rbkt/Queries/zorba/xqxq/external-module.xq 1970-01-01 00:00:00 +0000
2086+++ test/rbkt/Queries/zorba/xqxq/external-module.xq 2012-10-25 00:20:28 +0000
2087@@ -0,0 +1,8 @@
2088+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
2089+
2090+variable $query-key := xqxq:prepare-main-module('
2091+ import module namespace r = "http://www.zorba-xquery.com/modules/random";
2092+
2093+ count((for $i in 1 to 10 return r:random(10), r:random())) eq 101
2094+ ');
2095+xqxq:evaluate($query-key)
2096\ No newline at end of file
2097
2098=== added file 'test/rbkt/Queries/zorba/xqxq/get-external-variables.xq'
2099--- test/rbkt/Queries/zorba/xqxq/get-external-variables.xq 1970-01-01 00:00:00 +0000
2100+++ test/rbkt/Queries/zorba/xqxq/get-external-variables.xq 2012-10-25 00:20:28 +0000
2101@@ -0,0 +1,4 @@
2102+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
2103+variable $query-key2 := xqxq:prepare-main-module('declare variable $c external; $c');
2104+variable $query-key := xqxq:prepare-main-module('declare variable $a external;declare variable $d := "hi"; $a');
2105+xqxq:external-variables($query-key)
2106\ No newline at end of file
2107
2108=== added file 'test/rbkt/Queries/zorba/xqxq/is-bound-context-item.xq'
2109--- test/rbkt/Queries/zorba/xqxq/is-bound-context-item.xq 1970-01-01 00:00:00 +0000
2110+++ test/rbkt/Queries/zorba/xqxq/is-bound-context-item.xq 2012-10-25 00:20:28 +0000
2111@@ -0,0 +1,4 @@
2112+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
2113+
2114+variable $query-key := xqxq:prepare-main-module("insert node <child/> into /parent");
2115+xqxq:is-bound-context-item($query-key)
2116
2117=== added file 'test/rbkt/Queries/zorba/xqxq/is-bound-variable.xq'
2118--- test/rbkt/Queries/zorba/xqxq/is-bound-variable.xq 1970-01-01 00:00:00 +0000
2119+++ test/rbkt/Queries/zorba/xqxq/is-bound-variable.xq 2012-10-25 00:20:28 +0000
2120@@ -0,0 +1,10 @@
2121+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
2122+variable $query-key := xqxq:prepare-main-module('
2123+ declare variable $a external;
2124+ declare variable $b external := 2;
2125+ declare variable $c external;
2126+ $a');
2127+xqxq:bind-variable($query-key, xs:QName('a'), "foo");
2128+xqxq:is-bound-variable($query-key, xs:QName('a')),
2129+xqxq:is-bound-variable($query-key, xs:QName('b')),
2130+xqxq:is-bound-variable($query-key, xs:QName('c'))
2131\ No newline at end of file
2132
2133=== added file 'test/rbkt/Queries/zorba/xqxq/is-bound-variable2.spec'
2134--- test/rbkt/Queries/zorba/xqxq/is-bound-variable2.spec 1970-01-01 00:00:00 +0000
2135+++ test/rbkt/Queries/zorba/xqxq/is-bound-variable2.spec 2012-10-25 00:20:28 +0000
2136@@ -0,0 +1,1 @@
2137+Error: http://www.zorba-xquery.com/modules/xqxq:UndeclaredVariable
2138\ No newline at end of file
2139
2140=== added file 'test/rbkt/Queries/zorba/xqxq/is-bound-variable2.xq'
2141--- test/rbkt/Queries/zorba/xqxq/is-bound-variable2.xq 1970-01-01 00:00:00 +0000
2142+++ test/rbkt/Queries/zorba/xqxq/is-bound-variable2.xq 2012-10-25 00:20:28 +0000
2143@@ -0,0 +1,7 @@
2144+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
2145+variable $query-key := xqxq:prepare-main-module('
2146+ declare variable $a external;
2147+ declare variable $b external := 2;
2148+ declare variable $c external;
2149+ $a');
2150+xqxq:is-bound-variable($query-key, xs:QName('x'))
2151\ No newline at end of file
2152
2153=== added file 'test/rbkt/Queries/zorba/xqxq/is-sequential.xq'
2154--- test/rbkt/Queries/zorba/xqxq/is-sequential.xq 1970-01-01 00:00:00 +0000
2155+++ test/rbkt/Queries/zorba/xqxq/is-sequential.xq 2012-10-25 00:20:28 +0000
2156@@ -0,0 +1,18 @@
2157+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
2158+
2159+variable $query-key1 := xqxq:prepare-main-module('
2160+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";
2161+declare namespace an = "http://www.zorba-xquery.com/annotations";
2162+declare %an:sequential function local:foo() {
2163+ ddl:create(xs:QName("hola"),(<a/>,<b/>));
2164+
2165+ exit returning ();
2166+};
2167+
2168+local:foo()
2169+');
2170+variable $query-key2 := xqxq:prepare-main-module("insert node <child/> into /parent");
2171+variable $is-sequential := xqxq:is-sequential($query-key1);
2172+variable $is-not-sequential := xqxq:is-sequential($query-key2);
2173+$is-sequential, $is-not-sequential
2174+
2175
2176=== added file 'test/rbkt/Queries/zorba/xqxq/is-updating.xq'
2177--- test/rbkt/Queries/zorba/xqxq/is-updating.xq 1970-01-01 00:00:00 +0000
2178+++ test/rbkt/Queries/zorba/xqxq/is-updating.xq 2012-10-25 00:20:28 +0000
2179@@ -0,0 +1,20 @@
2180+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
2181+
2182+variable $query-key1 := xqxq:prepare-main-module('
2183+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";
2184+declare namespace an = "http://www.zorba-xquery.com/annotations";
2185+declare %an:sequential function local:foo() {
2186+ ddl:create(xs:QName("hola"),(<a/>,<b/>));
2187+
2188+ exit returning ();
2189+};
2190+
2191+local:foo()
2192+');
2193+variable $query-key2 := xqxq:prepare-main-module("insert node <child/> into /parent");
2194+variable $is-updating := xqxq:is-updating($query-key2);
2195+variable $is-not-updating := xqxq:is-updating($query-key1);
2196+xqxq:delete-query($query-key1);
2197+xqxq:delete-query($query-key2);
2198+$is-updating, $is-not-updating
2199+
2200
2201=== added file 'test/rbkt/Queries/zorba/xqxq/multiple-queries.xq'
2202--- test/rbkt/Queries/zorba/xqxq/multiple-queries.xq 1970-01-01 00:00:00 +0000
2203+++ test/rbkt/Queries/zorba/xqxq/multiple-queries.xq 2012-10-25 00:20:28 +0000
2204@@ -0,0 +1,9 @@
2205+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
2206+
2207+variable $query-key1 := xqxq:prepare-main-module("1+1");
2208+variable $query-key2 := xqxq:prepare-main-module("1+2");
2209+variable $a := xqxq:evaluate($query-key1);
2210+variable $b := xqxq:evaluate($query-key2);
2211+xqxq:delete-query($query-key1);
2212+xqxq:delete-query($query-key2);
2213+$a, $b
2214
2215=== added file 'test/rbkt/Queries/zorba/xqxq/prepare-library-module.spec'
2216--- test/rbkt/Queries/zorba/xqxq/prepare-library-module.spec 1970-01-01 00:00:00 +0000
2217+++ test/rbkt/Queries/zorba/xqxq/prepare-library-module.spec 2012-10-25 00:20:28 +0000
2218@@ -0,0 +1,1 @@
2219+Error: http://www.w3.org/2005/xqt-errors:XPST0003
2220
2221=== added file 'test/rbkt/Queries/zorba/xqxq/prepare-library-module.xq'
2222--- test/rbkt/Queries/zorba/xqxq/prepare-library-module.xq 1970-01-01 00:00:00 +0000
2223+++ test/rbkt/Queries/zorba/xqxq/prepare-library-module.xq 2012-10-25 00:20:28 +0000
2224@@ -0,0 +1,3 @@
2225+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
2226+
2227+xqxq:prepare-library-module('module namespace foo = "foo:bar"; declare function foo:bar() { 1 }')
2228
2229=== added file 'test/rbkt/Queries/zorba/xqxq/test.xml'
2230--- test/rbkt/Queries/zorba/xqxq/test.xml 1970-01-01 00:00:00 +0000
2231+++ test/rbkt/Queries/zorba/xqxq/test.xml 2012-10-25 00:20:28 +0000
2232@@ -0,0 +1,1 @@
2233+<test:test xmlns:test="http://test"><test:subtest>a</test:subtest><test:subtest2>a</test:subtest2></test:test>
2234\ No newline at end of file
2235
2236=== added file 'test/rbkt/Queries/zorba/xqxq/test.xsd'
2237--- test/rbkt/Queries/zorba/xqxq/test.xsd 1970-01-01 00:00:00 +0000
2238+++ test/rbkt/Queries/zorba/xqxq/test.xsd 2012-10-25 00:20:28 +0000
2239@@ -0,0 +1,14 @@
2240+<?xml version="1.0"?>
2241+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
2242+ targetNamespace="http://test"
2243+ xmlns="http://test"
2244+ elementFormDefault="qualified">
2245+ <xs:element name="test">
2246+ <xs:complexType>
2247+ <xs:sequence>
2248+ <xs:element name="subtest" type="xs:string"/>
2249+ <xs:element name="subtest2" type="xs:string"/>
2250+ </xs:sequence>
2251+ </xs:complexType>
2252+ </xs:element>
2253+</xs:schema>
2254\ No newline at end of file
2255
2256=== added file 'test/rbkt/Queries/zorba/xqxq/uri-mapper.xq'
2257--- test/rbkt/Queries/zorba/xqxq/uri-mapper.xq 1970-01-01 00:00:00 +0000
2258+++ test/rbkt/Queries/zorba/xqxq/uri-mapper.xq 2012-10-25 00:20:28 +0000
2259@@ -0,0 +1,27 @@
2260+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
2261+
2262+declare namespace resolver = 'http://www.zorba-xquery.com/modules/xqxq/url-resolver';
2263+declare namespace mapper = 'http://www.zorba-xquery.com/modules/xqxq/uri-mapper';
2264+declare namespace op = "http://www.zorba-xquery.com/options/features";
2265+declare namespace f = "http://www.zorba-xquery.com/features";
2266+declare option op:enable "f:hof";
2267+
2268+declare function resolver:url-resolver($namespace as xs:string, $entity as xs:string) {
2269+ if($namespace = 'http://foo')
2270+ then "module namespace test = 'http://test'; declare function test:foo(){'foo'};"
2271+ else ()
2272+};
2273+
2274+declare function mapper:uri-mapper($namespace as xs:string, $entity as xs:string)
2275+{
2276+ if($namespace = 'http://test')
2277+ then 'http://foo'
2278+ else ()
2279+};
2280+
2281+variable $queryID := xqxq:prepare-main-module
2282+(
2283+ "import module namespace test = 'http://test'; test:foo()",
2284+ resolver:url-resolver#2, mapper:uri-mapper#2
2285+);
2286+xqxq:evaluate($queryID)
2287
2288=== added file 'test/rbkt/Queries/zorba/xqxq/uri-mapper2.xq'
2289--- test/rbkt/Queries/zorba/xqxq/uri-mapper2.xq 1970-01-01 00:00:00 +0000
2290+++ test/rbkt/Queries/zorba/xqxq/uri-mapper2.xq 2012-10-25 00:20:28 +0000
2291@@ -0,0 +1,22 @@
2292+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
2293+
2294+declare namespace resolver = 'http://www.zorba-xquery.com/modules/xqxq/url-resolver';
2295+declare namespace mapper = 'http://www.zorba-xquery.com/modules/xqxq/uri-mapper';
2296+declare namespace op = "http://www.zorba-xquery.com/options/features";
2297+declare namespace f = "http://www.zorba-xquery.com/features";
2298+declare option op:enable "f:hof";
2299+
2300+declare function mapper:uri-mapper($namespace as xs:string, $entity as xs:string)
2301+{
2302+ if ($namespace = 'http://test' and $entity = 'schema')
2303+ then resolve-uri('test.xsd')
2304+ else ()
2305+};
2306+
2307+variable $queryID := xqxq:prepare-main-module
2308+(
2309+ "import schema namespace test = 'http://test'; validate{<test:test><test:subtest>a</test:subtest><test:subtest2>a</test:subtest2></test:test>}",
2310+ (),
2311+ mapper:uri-mapper#2
2312+);
2313+xqxq:evaluate($queryID)
2314
2315=== added file 'test/rbkt/Queries/zorba/xqxq/url-module-resolver.xq'
2316--- test/rbkt/Queries/zorba/xqxq/url-module-resolver.xq 1970-01-01 00:00:00 +0000
2317+++ test/rbkt/Queries/zorba/xqxq/url-module-resolver.xq 2012-10-25 00:20:28 +0000
2318@@ -0,0 +1,17 @@
2319+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
2320+
2321+declare namespace resolver = 'http://www.zorba-xquery.com/modules/xqxq/url-resolver';
2322+declare namespace op = "http://www.zorba-xquery.com/options/features";
2323+declare namespace f = "http://www.zorba-xquery.com/features";
2324+declare option op:enable "f:hof";
2325+
2326+declare function resolver:url-resolver($namespace as xs:string, $entity as xs:string) {
2327+ if($namespace = 'http://test.xq')
2328+ then "module namespace test = 'http://test'; declare function test:foo(){'foo'};"
2329+ else ()
2330+};
2331+
2332+variable $queryID := xqxq:prepare-main-module(
2333+ "import module namespace test = 'http://test'; test:foo()",
2334+ resolver:url-resolver#2, ());
2335+xqxq:evaluate($queryID)
2336
2337=== added file 'test/rbkt/Queries/zorba/xqxq/url-schema-resolver.xq'
2338--- test/rbkt/Queries/zorba/xqxq/url-schema-resolver.xq 1970-01-01 00:00:00 +0000
2339+++ test/rbkt/Queries/zorba/xqxq/url-schema-resolver.xq 2012-10-25 00:20:28 +0000
2340@@ -0,0 +1,20 @@
2341+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
2342+
2343+declare namespace resolver = 'http://www.zorba-xquery.com/modules/xqxq/url-resolver';
2344+
2345+declare namespace op = "http://www.zorba-xquery.com/options/features";
2346+declare namespace f = "http://www.zorba-xquery.com/features";
2347+declare option op:enable "f:hof";
2348+
2349+declare function resolver:url-resolver($namespace as xs:string, $entity as xs:string) {
2350+ if($namespace = 'http://test' and $entity = 'schema')
2351+ then
2352+ doc('test.xsd')
2353+ else
2354+ ()
2355+};
2356+
2357+variable $queryID := xqxq:prepare-main-module(
2358+ "import schema namespace test = 'http://test'; validate {<test:test><test:subtest>a</test:subtest><test:subtest2>a</test:subtest2></test:test>}",
2359+ resolver:url-resolver#2, ());
2360+xqxq:evaluate($queryID)
2361
2362=== added file 'test/rbkt/Queries/zorba/xqxq/url-schema-resolver2.xq'
2363--- test/rbkt/Queries/zorba/xqxq/url-schema-resolver2.xq 1970-01-01 00:00:00 +0000
2364+++ test/rbkt/Queries/zorba/xqxq/url-schema-resolver2.xq 2012-10-25 00:20:28 +0000
2365@@ -0,0 +1,29 @@
2366+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
2367+
2368+import module namespace ddl =
2369+ "http://www.zorba-xquery.com/modules/store/dynamic/collections/w3c/ddl";
2370+import module namespace dml =
2371+ "http://www.zorba-xquery.com/modules/store/dynamic/collections/w3c/dml";
2372+
2373+declare namespace resolver = 'http://www.zorba-xquery.com/modules/xqxq/url-resolver';
2374+declare namespace op = "http://www.zorba-xquery.com/options/features";
2375+declare namespace f = "http://www.zorba-xquery.com/features";
2376+declare option op:enable "f:hof";
2377+
2378+declare function resolver:url-resolver($namespace as xs:string, $entity as xs:string) {
2379+ if ($entity = 'schema')
2380+ then
2381+ dml:collection("http://www.zorba-xquery.com/modules/xqxq")//xs:schema[@targetNamespace=$namespace]
2382+ else
2383+ ()
2384+};
2385+
2386+declare variable $coll := "http://www.zorba-xquery.com/modules/xqxq";
2387+declare variable $schema := doc("test.xsd");
2388+ddl:create($coll);
2389+
2390+dml:apply-insert-nodes-first($coll, $schema);
2391+variable $query-key := xqxq:prepare-main-module(
2392+ "import schema namespace test = 'http://test'; validate {<test:test><test:subtest>a</test:subtest><test:subtest2>a</test:subtest2></test:test>}",
2393+ resolver:url-resolver#2, ());
2394+xqxq:evaluate($query-key)
2395
2396=== added file 'test/rbkt/Queries/zorba/xqxq/url-schema-resolver3.xq'
2397--- test/rbkt/Queries/zorba/xqxq/url-schema-resolver3.xq 1970-01-01 00:00:00 +0000
2398+++ test/rbkt/Queries/zorba/xqxq/url-schema-resolver3.xq 2012-10-25 00:20:28 +0000
2399@@ -0,0 +1,29 @@
2400+import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';
2401+
2402+declare namespace resolver = 'http://www.zorba-xquery.com/modules/xqxq/url-resolver';
2403+
2404+declare namespace op = "http://www.zorba-xquery.com/options/features";
2405+declare namespace f = "http://www.zorba-xquery.com/features";
2406+declare option op:enable "f:hof";
2407+
2408+declare function resolver:url-resolver($namespace as xs:string, $entity as xs:string) {
2409+ if($namespace = 'http://test' and $entity = 'schema')
2410+ then
2411+ doc('test.xsd')
2412+ else
2413+ ()
2414+};
2415+
2416+variable $contextQueryID := xqxq:prepare-main-module(
2417+ "import schema namespace test = 'http://test';
2418+ declare variable $cwd as xs:anyURI external;
2419+ validate { doc(resolve-uri('test.xml', $cwd)) }",
2420+ resolver:url-resolver#2, ());
2421+xqxq:bind-variable($contextQueryID, fn:QName("", "cwd"), resolve-uri("."));
2422+variable $contextItem := xqxq:evaluate($contextQueryID);
2423+
2424+variable $queryID := xqxq:prepare-main-module(
2425+ "import schema namespace test = 'http://test'; //*:test",
2426+ resolver:url-resolver#2, ());
2427+xqxq:bind-context-item($queryID, $contextItem);
2428+xqxq:evaluate($queryID)

Subscribers

People subscribed via source and target branches