Merge lp:~zorba-coders/zorba/markos-scratch into lp:zorba

Proposed by Markos Zaharioudakis
Status: Merged
Merged at revision: 11599
Proposed branch: lp:~zorba-coders/zorba/markos-scratch
Merge into: lp:zorba
Diff against target: 1998 lines (+725/-601)
30 files modified
ChangeLog (+7/-0)
modules/org/jsoniq/www/function-library.xq (+140/-102)
modules/org/jsoniq/www/functions.xq (+71/-52)
src/compiler/rewriter/rules/fold_rules.cpp (+1/-1)
src/functions/func_jsoniq_functions_impl.cpp (+59/-41)
src/functions/pregenerated/func_jsoniq_functions.cpp (+26/-25)
src/functions/pregenerated/func_jsoniq_functions.h (+32/-22)
src/functions/pregenerated/function_enum.h (+1/-1)
src/runtime/booleans/BooleanImpl.cpp (+1/-8)
src/runtime/json/jsoniq_functions_impl.cpp (+177/-188)
src/runtime/json/pregenerated/jsoniq_functions.cpp (+50/-31)
src/runtime/json/pregenerated/jsoniq_functions.h (+60/-50)
src/runtime/pregenerated/iterator_enum.h (+1/-1)
src/runtime/spec/json/jsoniq_functions.xml (+50/-46)
src/runtime/visitors/pregenerated/planiter_visitor.h (+5/-5)
src/runtime/visitors/pregenerated/printer_visitor.cpp (+14/-14)
src/runtime/visitors/pregenerated/printer_visitor.h (+3/-3)
swig/ruby/tests/test12.rb (+3/-2)
test/rbkt/ExpQueryResults/zorba/jsoniq/ebv02.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/ebv03.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/json_doc_3.xml.res (+1/-0)
test/rbkt/Queries/zorba/jsoniq/ebv02.spec (+0/-1)
test/rbkt/Queries/zorba/jsoniq/ebv03.spec (+0/-1)
test/rbkt/Queries/zorba/jsoniq/input2.json (+1/-1)
test/rbkt/Queries/zorba/jsoniq/json_doc_1.xq (+7/-1)
test/rbkt/Queries/zorba/jsoniq/json_doc_2.xq (+5/-1)
test/rbkt/Queries/zorba/jsoniq/json_doc_3.spec (+0/-1)
test/rbkt/Queries/zorba/jsoniq/json_doc_3.xq (+4/-1)
test/rbkt/Queries/zorba/jsoniq/json_doc_4.xq (+0/-1)
test/rbkt/Queries/zorba/jsoniq/json_doc_5.xq (+4/-1)
To merge this branch: bzr merge lp:~zorba-coders/zorba/markos-scratch
Reviewer Review Type Date Requested Status
Markos Zaharioudakis Approve
Review via email: mp+180110@code.launchpad.net

Commit message

1. EBV on jsoniq items returns true instead of error
2. Updated signature (and implementation) of jn and libjn functions according to latest spec
3. Removed from libjn functions that were also in jn
4. Removed jn:json-doc function

Description of the change

1. EBV on jsoniq items returns true instead of error
2. Updated signature (and implementation) of jn and libjn functions according to latest spec
3. Removed from libjn functions that were also in jn
4. Removed jn:json-doc function

To post a comment you must log in.
11205. By Markos Zaharioudakis

1. EBV on jsoniq items returns true instead of error, 2. Updated signature (and implementation) of jn and libjn functions according to latest spec, 3. Removed from libjn functions that were also in jn, 4. Removed jn:json-doc function

Revision history for this message
Markos Zaharioudakis (markos-za) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue starting for the following merge proposals:
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/180110

Progress dashboard at http://jenkins.lambda.nu/view/ValidationQueue

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue result for https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/180110

Stage "TestZorbaUbuntu" failed.
2 tests failed (8401 total tests run).

Check test results at http://jenkins.lambda.nu/job/TestZorbaUbuntu/216/testReport/ to view the results.

11206. By Markos Zaharioudakis

added documentation to private functions

11207. By Markos Zaharioudakis

merge from trunk

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue starting for the following merge proposals:
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/180110

Progress dashboard at http://jenkins.lambda.nu/view/ValidationQueue

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue result for https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/180110

Stage "TestZorbaUbuntu" failed.
1 tests failed (8401 total tests run).

Check test results at http://jenkins.lambda.nu/job/TestZorbaUbuntu/219/testReport/ to view the results.

11208. By Markos Zaharioudakis

fixed ruby test

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue starting for the following merge proposals:
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/180110

Progress dashboard at http://jenkins.lambda.nu/view/ValidationQueue

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue succeeded - proposal merged!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2013-08-13 19:19:44 +0000
3+++ ChangeLog 2013-08-14 19:07:42 +0000
4@@ -11,6 +11,7 @@
5 New Features:
6 * The grouping variable in a group by clause is now optional
7 * New syntax for array lookup: expr1[[expr2]]
8+ * New jsoniq functions: jn:trim() and libjn:descendant-arrays()
9
10 Optimizations:
11 * Implemented hoisting optimization for general FLWOR.
12@@ -68,8 +69,14 @@
13 * Object/array navigation allows item()* as the type of the input sequence
14 (doing implicit iteration over the input sequence and skipping items
15 that are not objects/arrays).
16+ * Several of the jsoniq functions now allow item()* as the type of the input
17+ sequence (doing implicit iteration over the input sequence and skipping or
18+ simply propagating items that are not objects/arrays).
19 * Bug fix: selector value in object/array navigation is always cast to
20 string/integer
21+ * The function jn:is-null() has been removed.
22+ * EBV on jsoniq items now returns true (instead of raising an error).
23+ * Removed from libjn module the functions that existed in the jn module as well.
24 * Renamed xqxq module to zorba-query module(zq module).
25
26 version 2.9
27
28=== modified file 'modules/org/jsoniq/www/function-library.xq'
29--- modules/org/jsoniq/www/function-library.xq 2013-08-09 08:27:30 +0000
30+++ modules/org/jsoniq/www/function-library.xq 2013-08-14 19:07:42 +0000
31@@ -1,4 +1,4 @@
32-xquery version "1.0";
33+jsoniq version "1.0";
34
35 (:
36 : Copyright 2006-2012 The FLWOR Foundation.
37@@ -36,27 +36,83 @@
38 declare namespace ver = "http://zorba.io/options/versioning";
39 declare option ver:module-version "1.0";
40
41+
42 (:~
43- : This function dynamically builds an object, like jn:object, except that
44- : it does not throw an error upon pair collision. Instead, it aggregates them
45- : into an array.
46+ : This function dynamically builds an object, like the {||} syntax, except that
47+ : it does not throw an error upon pair collision. Instead, it accumulates them
48+ : into an array, if more than one.
49 :
50- : @param $o A sequence of objects.
51+ : @param $items A sequence of items, the objects of which are going to be
52+ : accumulated into a single object.
53 : @return The accumulated object.
54 :)
55-declare function libjn:accumulate($o as object()*) as object()
56-{
57- {[ $o ]}
58-};
59-
60-(:~
61- : This function returns all Objects contained within a JSON item, regardless of
62- : depth.
63- :
64- : @param $i A JSON item.
65- : @return Its descendant objects.
66- :)
67-declare function libjn:descendant-objects($i as json-item()) as object()*
68+declare function libjn:accumulate($items as item()*) as object()
69+{
70+ {[ $items ]}
71+};
72+
73+
74+(:~
75+ : This function returns all arrays contained at any depth within a sequence of items.
76+ :
77+ : @param $items A sequence of items.
78+ : @return The descendant arrays of the input sequence.
79+ :)
80+declare function libjn:descendant-arrays($items as item()*) as array()*
81+{
82+ for $i in $items
83+ return libjn:descendant-arrays-priv($i)
84+};
85+
86+
87+(:~
88+ : Helper function for libjn:descendant-arrays()
89+ :
90+ : @param $i An item
91+ : @return The descendant arrays of the item
92+ :)
93+declare %private function libjn:descendant-arrays-priv($i as item()) as array()*
94+{
95+ typeswitch ($i)
96+
97+ case object() return
98+ for $v in libjn:values($i)
99+ where $v instance of json-item()
100+ return libjn:descendant-arrays-priv($v)
101+
102+ case array() return
103+ (
104+ $i,
105+ for $v in $i[]
106+ where $v instance of json-item()
107+ return libjn:descendant-arrays-priv($v)
108+ )
109+
110+ default return
111+ ()
112+};
113+
114+
115+(:~
116+ : This function returns all objects contained at any depth within a sequence of items.
117+ :
118+ : @param $items A sequence of items.
119+ : @return The descendant objects of the input sequence.
120+ :)
121+declare function libjn:descendant-objects($items as item()*) as object()*
122+{
123+ for $i in $items
124+ return libjn:descendant-objects-priv($i)
125+};
126+
127+
128+(:~
129+ : Helper function for libjn:descendant-objects()
130+ :
131+ : @param $i An item
132+ : @return The descendant objects of the item
133+ :)
134+declare %private function libjn:descendant-objects-priv($i as item()) as object()*
135 {
136 if ($i instance of object())
137 then
138@@ -64,109 +120,91 @@
139 $i,
140 for $v in libjn:values($i)
141 where $v instance of json-item()
142- return libjn:descendant-objects($v)
143+ return libjn:descendant-objects-priv($v)
144 )
145 else if ($i instance of array())
146 then
147 (
148- for $v in libjn:members($i)
149+ for $v in $i[]
150 where $v instance of json-item()
151- return libjn:descendant-objects($v)
152+ return libjn:descendant-objects-priv($v)
153 )
154 else
155 ()
156 };
157
158+
159 (:~
160- : This function returns all pairs contained within an object, recursively.
161+ : This function returns all pairs contained at any depth within an sequence of items.
162 :
163 : @param $o An object.
164 : @return All direct and indirect descendant pairs.
165 :)
166-declare function libjn:descendant-pairs($o as object()) as object()*
167-{
168- for $k in jn:keys($o)
169- return (
170- { $k : $o($k) },
171- if ($o($k) instance of object())
172- then
173- libjn:descendant-pairs($o($k))
174- else ()
175- )
176-};
177-
178-(:~
179- : Recursively "flatten" a JSON Array, by replacing any arrays with their
180- : members. Equivalent to
181- :
182- : define function jn:flatten($arg as array()) {
183- : for $value in jn:values($arg)
184- : return
185- : if ($value instance of array())
186- : then jn:flatten($value)
187- : else $value
188- : };
189- :
190- : @param $a A JSON Array.
191- : @return The flattened version of $a.
192- :)
193-declare function libjn:flatten($a as array()) as item()*
194-{
195- jn:flatten($a)
196-};
197-
198-(:~ This function returns the intersection of two objects, and aggregates
199- : values corresponding to the same name into an array.
200- :
201- : @param $o A sequence of objects.
202- : @return Their insersection.
203- :)
204-declare function libjn:intersect($o as object()*) as object()
205+declare function libjn:descendant-pairs($items as item()*) as object()*
206+{
207+ for $i in $items
208+ return libjn:descendant-pairs-priv($i)
209+};
210+
211+
212+(:~
213+ : Helper function for libjn:descendant-pairs()
214+ :
215+ : @param $i An item
216+ : @return The descendant pairs of the item
217+ :)
218+declare function libjn:descendant-pairs-priv($i as item()) as object()*
219+{
220+ typeswitch ($i)
221+
222+ case $o as object() return
223+ for $k in jn:keys($o)
224+ return
225+ (
226+ { $k : $o($k) },
227+ libjn:descendant-pairs-priv($o($k))
228+ )
229+
230+ case $a as array() return
231+ for $i in $a[]
232+ where $i instance of json-item()
233+ return libjn:descendant-pairs-priv($i)
234+
235+ default return
236+ ()
237+};
238+
239+
240+(:~
241+ : This function returns the intersection of the objects contained in the
242+ : given sequence of items, aggregating values corresponding to the same key
243+ : into an array.
244+ :
245+ : @param $items A sequence of items.
246+ : @return The insersection of the objects contained in $items.
247+ :)
248+declare function libjn:intersect($items as item()*) as object()
249 {
250 {|
251- let $common-keys := jn:keys($o[1])[ every $object in $o[position() > 1]
252- satisfies jn:keys($object) = . ]
253- for $key in $common-keys
254- let $values := $o($key)
255- return
256- if (count($values) eq 1)
257- then { $key : $values }
258- else { $key : [ $values ] }
259+ let $objects := $items[$$ instance of object()]
260+ for $key in keys(head($objects))
261+ where every $o in tail($objects)
262+ satisfies exists(index-of(keys($o), $key))
263+ return { $key : $objects.$key }
264 |}
265 };
266
267-(:~
268- : Returns the members of an Array.
269- :
270- : @param $a A JSON Array.
271- : @return The members of the specified array.
272- :)
273-declare function libjn:members($o as array()) as item()*
274-{
275- jn:members($o)
276-};
277-
278-(:~
279- : Creates an object from the specified pairs of another given object.
280- : Specifically, for each name in $names, if the object $o has a pair with
281- : that name, then a copy of that pair is included in the new object.
282- :
283- : @param $o A JSON Object.
284- : @param $names The names of the pairs to copy out of $o and insert into the new object
285- : @return The new object.
286- :)
287-declare function libjn:project($o as object(), $names as xs:string*) as object()
288-{
289- jn:project($o, $names)
290-};
291-
292-(:~
293- : This functions returns all values in an Object.
294- : @param $i An object.
295- : @return Its values.
296- :)
297-declare function libjn:values($i as object()) as item()*
298-{
299+
300+(:~
301+ : This functions returns all values of all objects contained in a sequence of items.
302+ :
303+ : @param $items A sequence of items.
304+ : @return The values inside the objects of the sequence.
305+ :)
306+declare function libjn:values($items as item()*) as item()*
307+{
308+ for $i in $items
309 for $k in jn:keys($i)
310- return $i($k)
311+ return ($i treat as object())($k)
312 };
313+
314
315=== modified file 'modules/org/jsoniq/www/functions.xq'
316--- modules/org/jsoniq/www/functions.xq 2013-08-12 12:49:39 +0000
317+++ modules/org/jsoniq/www/functions.xq 2013-08-14 19:07:42 +0000
318@@ -52,8 +52,7 @@
319 : @param $items the items to be decoded.
320 : @return the decoded items.
321 :)
322-declare function jn:decode-from-roundtrip(
323- $items as item()*) as item()* external;
324+declare function jn:decode-from-roundtrip($items as item()*) as item()* external;
325
326
327 (:~
328@@ -90,8 +89,8 @@
329 : @return the decoded items.
330 :)
331 declare function jn:decode-from-roundtrip(
332- $items as item()*,
333- $options as object()) as item()* external;
334+ $items as item*,
335+ $options as object) as item* external;
336
337
338 (:~
339@@ -111,8 +110,7 @@
340 : @param $items the items to be encoded.
341 : @return the encoded items.
342 :)
343-declare function jn:encode-for-roundtrip(
344- $items as item()*) as item()* external;
345+declare function jn:encode-for-roundtrip($items as item()*) as item()* external;
346
347
348 (:~
349@@ -140,8 +138,8 @@
350 : @return the encoded items.
351 :)
352 declare function jn:encode-for-roundtrip(
353- $items as item()*,
354- $options as object()) as item()* external;
355+ $items as item*,
356+ $options as object) as item* external;
357
358
359 (:~
360@@ -157,7 +155,8 @@
361 :
362 : @error jerr:JNDY0021 if the given string is not valid JSON.
363 :)
364-declare function jn:parse-json($j as xs:string?) as json-item()* external;
365+declare function jn:parse-json($j as string?) as json-item* external;
366+
367
368 (:~
369 : This function parses a given string as JSON and returns a sequence
370@@ -179,9 +178,7 @@
371 :
372 : @return a sequence of JSON Object or Array item.
373 :)
374-declare function jn:parse-json(
375- $j as xs:string?,
376- $o as object()) as json-item()* external;
377+declare function jn:parse-json($j as string?, $o as object) as json-item* external;
378
379
380 (:~
381@@ -193,29 +190,45 @@
382 : items of any other kind are simply skipped.
383 : @return The distinct keys of the objects in the input sequence.
384 :)
385-declare function jn:keys($o as item()*) as xs:string* external;
386-
387-
388-(:~
389- : Creates an object from the specified pairs of another given object.
390- : Specifically, for each name in $names, if the object $o has a pair with
391- : that name, then a copy of that pair is included in the new object.
392- :
393- : @param $o A JSON Object.
394- : @param $names The names of the pairs to copy out of $o and insert into the new object
395- : @return The new object.
396- :)
397-declare function jn:project($o as object(), $names as xs:string*) as object() external;
398-
399-
400-(:~
401- : Returns the size of a JSON Array. The size of an Array is
402- : the number of members contained within it.
403- :
404- : @param $j A JSON Array.
405- : @return The number of items in $j.
406- :)
407-declare function jn:size($j as array()?) as xs:integer? external;
408+declare function jn:keys($o as item*) as string* external;
409+
410+
411+(:~
412+ : For each item in the given sequence, this function returns the item itself,
413+ : if it is not an object, or its "projected" copy if it is an object. Projecting
414+ : an object by a set of keys means creating a new object from the specified pairs
415+ : of the source object. Specifically, for each key in $keys, if the object has a
416+ : pair with that key, then a copy of that pair is included in the new object.
417+ :
418+ : @param $items A sequence of items.
419+ : @param $keys The keys of the pairs to include from each object in $items.
420+ : @return The projection of the original sequence.
421+ :)
422+declare function jn:project($items as item*, $keys as string*) as item* external;
423+
424+
425+(:~
426+ : For each item in the given sequence, this function returns the item itself,
427+ : if it is not an object, or its "trimmed" copy, if it is an object. Trimming
428+ : an object by a set of keys means creating a new object containing all the
429+ : pairs of the source object except the ones whose key appears in the given
430+ : set of keys.
431+ :
432+ : @param $items A sequence of items.
433+ : @param $keys The keys of the pairs to exclude from each object in $items.
434+ : @return The trimmed version of the input sequence.
435+ :)
436+declare function jn:trim($items as item*, $keys as string*) as item* external;
437+
438+
439+(:~
440+ : Returns the size of a JSON array, or the empty sequence if no array is given.
441+ : The size of an Array is the number of members contained within it.
442+ :
443+ : @param $array A JSON array.
444+ : @return The number of items in $array, or the empty sequence if $array is empty.
445+ :)
446+declare function jn:size($a as array?) as integer? external;
447
448
449 (:~
450@@ -226,30 +239,36 @@
451 : items of any other kind are simply skipped.
452 : @return The members of the arrays in the input sequence.
453 :)
454-declare function jn:members($a as item()*) as item()* external;
455+declare function jn:members($a as item*) as item* external;
456
457
458 (:~
459- : Recursively "flatten" a JSON Array, by replacing any arrays with their
460- : members. Equivalent to
461- :
462- : define function jn:flatten($arg as item())
463+ : For each item in the given sequence, this function returns the item itself,
464+ : if it is not an array, or a sequence of items "flattened-out" from the array.
465+ : Flattening an array means replacing the array with its members, and recursively
466+ : flattening any arrays in the members sequence.
467+ :
468+ : Note: The function is equivalent to
469+ :
470+ : define function jn:flatten($args as item()*)
471 : {
472- : if ($arg instance of array())
473- : then
474- : for $value in jn:values($arg)
475- : return
476- : if ($value instance of array())
477- : then jn:flatten($value)
478- : else $value
479- : else
480- : ()
481+ : for $arg in args
482+ : return
483+ : if ($arg instance of array())
484+ : then
485+ : for $value in $arg[]
486+ : return
487+ : if ($value instance of array())
488+ : then jn:flatten($value[])
489+ : else $value
490+ : else
491+ : $arg
492 : };
493 :
494- : @param $a A JSON Array.
495- : @return The flattened version of $a.
496+ : @param $items A sequence of items
497+ : @return The flattened-out items of the arrays in $items.
498 :)
499-declare function jn:flatten($a as item()) as item()* external;
500+declare function jn:flatten($items as item*) as item* external;
501
502
503 (:~
504
505=== modified file 'src/compiler/rewriter/rules/fold_rules.cpp'
506--- src/compiler/rewriter/rules/fold_rules.cpp 2013-07-24 23:29:35 +0000
507+++ src/compiler/rewriter/rules/fold_rules.cpp 2013-08-14 19:07:42 +0000
508@@ -769,7 +769,7 @@
509 xqtref_t argType = arg->get_return_type();
510 if (TypeOps::is_subtype(tm,
511 *argType,
512- *GENV_TYPESYSTEM.ANY_NODE_TYPE_PLUS,
513+ *GENV_TYPESYSTEM.STRUCTURED_ITEM_TYPE_PLUS,
514 arg->get_loc()))
515 {
516 return rCtx.theEM->create_const_expr(sctx, udf, fo->get_loc(), true);
517
518=== modified file 'src/functions/func_jsoniq_functions_impl.cpp'
519--- src/functions/func_jsoniq_functions_impl.cpp 2013-08-12 12:49:39 +0000
520+++ src/functions/func_jsoniq_functions_impl.cpp 2013-08-14 19:07:42 +0000
521@@ -34,6 +34,30 @@
522 /*******************************************************************************
523
524 ********************************************************************************/
525+PlanIter_t fn_jsoniq_parse_json::codegen(
526+ CompilerCB*,
527+ static_context* sctx,
528+ const QueryLoc& loc,
529+ std::vector<PlanIter_t>& argv,
530+ expr& ann) const
531+{
532+ SingletonIterator* lArg = dynamic_cast<SingletonIterator*>(argv[0].getp());
533+ if (lArg && lArg->getValue()->isAtomic())
534+ {
535+ const QueryLoc& lArgLoc = lArg->getLocation();
536+ return new JSONParseIterator(sctx, loc, argv, lArgLoc);
537+ }
538+ else
539+ {
540+ QueryLoc lArgLoc = QueryLoc::null;
541+ return new JSONParseIterator(sctx, loc, argv, lArgLoc);
542+ }
543+}
544+
545+
546+/*******************************************************************************
547+
548+********************************************************************************/
549 xqtref_t op_zorba_json_item_accessor::getReturnType(const fo_expr* caller) const
550 {
551 if (caller->get_arg(0)->get_return_type()->max_card() == 0)
552@@ -46,6 +70,23 @@
553 /*******************************************************************************
554
555 ********************************************************************************/
556+PlanIter_t fn_jsoniq_keys::codegen(
557+ CompilerCB*,
558+ static_context* sctx,
559+ const QueryLoc& loc,
560+ std::vector<PlanIter_t>& argv,
561+ expr& arg) const
562+{
563+ if (arg.get_return_type()->max_card() <= 1)
564+ return new SingleObjectNamesIterator(sctx, loc, argv[0]);
565+
566+ return new JSONObjectNamesIterator(sctx, loc, argv[0]);
567+}
568+
569+
570+/*******************************************************************************
571+
572+********************************************************************************/
573 xqtref_t op_zorba_object_value::getReturnType(const fo_expr* caller) const
574 {
575 if (caller->get_arg(0)->get_return_type()->max_card() == 0)
576@@ -58,6 +99,24 @@
577 /*******************************************************************************
578
579 ********************************************************************************/
580+xqtref_t fn_jsoniq_project::getReturnType(const fo_expr* caller) const
581+{
582+ return caller->get_arg(0)->get_return_type();
583+}
584+
585+
586+/*******************************************************************************
587+
588+********************************************************************************/
589+xqtref_t fn_jsoniq_trim::getReturnType(const fo_expr* caller) const
590+{
591+ return caller->get_arg(0)->get_return_type();
592+}
593+
594+
595+/*******************************************************************************
596+
597+********************************************************************************/
598 xqtref_t op_zorba_array_member::getReturnType(const fo_expr* caller) const
599 {
600 if (caller->get_arg(0)->get_return_type()->max_card() == 0)
601@@ -82,23 +141,6 @@
602 /*******************************************************************************
603
604 ********************************************************************************/
605-PlanIter_t fn_jsoniq_keys::codegen(
606- CompilerCB*,
607- static_context* sctx,
608- const QueryLoc& loc,
609- std::vector<PlanIter_t>& argv,
610- expr& arg) const
611-{
612- if (arg.get_return_type()->max_card() <= 1)
613- return new SingleObjectNamesIterator(sctx, loc, argv[0]);
614-
615- return new JSONObjectNamesIterator(sctx, loc, argv[0]);
616-}
617-
618-
619-/*******************************************************************************
620-
621-********************************************************************************/
622 PlanIter_t fn_jsoniq_members::codegen(
623 CompilerCB*,
624 static_context* sctx,
625@@ -209,30 +251,6 @@
626 /*******************************************************************************
627
628 ********************************************************************************/
629-PlanIter_t fn_jsoniq_parse_json::codegen(
630- CompilerCB*,
631- static_context* sctx,
632- const QueryLoc& loc,
633- std::vector<PlanIter_t>& argv,
634- expr& ann) const
635-{
636- SingletonIterator* lArg = dynamic_cast<SingletonIterator*>(argv[0].getp());
637- if (lArg && lArg->getValue()->isAtomic())
638- {
639- const QueryLoc& lArgLoc = lArg->getLocation();
640- return new JSONParseIterator(sctx, loc, argv, lArgLoc);
641- }
642- else
643- {
644- QueryLoc lArgLoc = QueryLoc::null;
645- return new JSONParseIterator(sctx, loc, argv, lArgLoc);
646- }
647-}
648-
649-
650-/*******************************************************************************
651-
652-********************************************************************************/
653 PlanIter_t jn_object::codegen(
654 CompilerCB*,
655 static_context* sctx,
656
657=== modified file 'src/functions/pregenerated/func_jsoniq_functions.cpp'
658--- src/functions/pregenerated/func_jsoniq_functions.cpp 2013-08-12 12:49:39 +0000
659+++ src/functions/pregenerated/func_jsoniq_functions.cpp 2013-08-14 19:07:42 +0000
660@@ -52,16 +52,6 @@
661 }
662
663
664-PlanIter_t fn_jsoniq_json_doc::codegen(
665- CompilerCB*,
666- static_context* sctx,
667- const QueryLoc& loc,
668- std::vector<PlanIter_t>& argv,
669- expr& ann) const
670-{
671- return new JSONDocIterator(sctx, loc, argv);
672-}
673-
674 PlanIter_t op_zorba_json_item_accessor::codegen(
675 CompilerCB*,
676 static_context* sctx,
677@@ -103,6 +93,16 @@
678 return new JSONObjectProjectIterator(sctx, loc, argv[0], argv[1]);
679 }
680
681+PlanIter_t fn_jsoniq_trim::codegen(
682+ CompilerCB*,
683+ static_context* sctx,
684+ const QueryLoc& loc,
685+ std::vector<PlanIter_t>& argv,
686+ expr& ann) const
687+{
688+ return new JSONObjectTrimIterator(sctx, loc, argv[0], argv[1]);
689+}
690+
691 PlanIter_t op_zorba_array_member::codegen(
692 CompilerCB*,
693 static_context* sctx,
694@@ -295,18 +295,6 @@
695
696
697 {
698- DECL_WITH_KIND(sctx, fn_jsoniq_json_doc,
699- (createQName("http://jsoniq.org/functions","","json-doc"),
700- GENV_TYPESYSTEM.STRING_TYPE_QUESTION,
701- GENV_TYPESYSTEM.JSON_ITEM_TYPE_STAR),
702- FunctionConsts::FN_JSONIQ_JSON_DOC_1);
703-
704- }
705-
706-
707-
708-
709- {
710 DECL_WITH_KIND(sctx, op_zorba_json_item_accessor,
711 (createQName("http://zorba.io/internal/zorba-ops","","json-item-accessor"),
712 GENV_TYPESYSTEM.ITEM_TYPE_QUESTION,
713@@ -371,9 +359,9 @@
714 {
715 DECL_WITH_KIND(sctx, fn_jsoniq_project,
716 (createQName("http://jsoniq.org/functions","","project"),
717- GENV_TYPESYSTEM.JSON_OBJECT_TYPE_ONE,
718+ GENV_TYPESYSTEM.ITEM_TYPE_STAR,
719 GENV_TYPESYSTEM.STRING_TYPE_STAR,
720- GENV_TYPESYSTEM.JSON_OBJECT_TYPE_ONE),
721+ GENV_TYPESYSTEM.ITEM_TYPE_STAR),
722 FunctionConsts::FN_JSONIQ_PROJECT_2);
723
724 }
725@@ -382,6 +370,19 @@
726
727
728 {
729+ DECL_WITH_KIND(sctx, fn_jsoniq_trim,
730+ (createQName("http://jsoniq.org/functions","","trim"),
731+ GENV_TYPESYSTEM.ITEM_TYPE_STAR,
732+ GENV_TYPESYSTEM.STRING_TYPE_STAR,
733+ GENV_TYPESYSTEM.ITEM_TYPE_STAR),
734+ FunctionConsts::FN_JSONIQ_TRIM_2);
735+
736+ }
737+
738+
739+
740+
741+ {
742 DECL_WITH_KIND(sctx, op_zorba_array_member,
743 (createQName("http://zorba.io/internal/zorba-ops","","array-member"),
744 GENV_TYPESYSTEM.ITEM_TYPE_QUESTION,
745@@ -433,7 +434,7 @@
746 {
747 DECL_WITH_KIND(sctx, fn_jsoniq_flatten,
748 (createQName("http://jsoniq.org/functions","","flatten"),
749- GENV_TYPESYSTEM.ITEM_TYPE_ONE,
750+ GENV_TYPESYSTEM.ITEM_TYPE_STAR,
751 GENV_TYPESYSTEM.ITEM_TYPE_STAR),
752 FunctionConsts::FN_JSONIQ_FLATTEN_1);
753
754
755=== modified file 'src/functions/pregenerated/func_jsoniq_functions.h'
756--- src/functions/pregenerated/func_jsoniq_functions.h 2013-08-12 12:49:39 +0000
757+++ src/functions/pregenerated/func_jsoniq_functions.h 2013-08-14 19:07:42 +0000
758@@ -95,25 +95,6 @@
759 };
760
761
762-//fn-jsoniq:json-doc
763-class fn_jsoniq_json_doc : public function
764-{
765-public:
766- fn_jsoniq_json_doc(const signature& sig, FunctionConsts::FunctionKind kind)
767- :
768- function(sig, kind)
769- {
770-
771- }
772-
773- bool accessesDynCtx() const { return true; }
774-
775- bool isSource() const { return true; }
776-
777- CODEGEN_DECL();
778-};
779-
780-
781 //op-zorba:json-item-accessor
782 class op_zorba_json_item_accessor : public function
783 {
784@@ -207,9 +188,36 @@
785
786 }
787
788- bool propagatesInputNodes(expr* fo, csize producer) const { return producer == 0; }
789-
790- bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
791+ xqtref_t getReturnType(const fo_expr* caller) const;
792+
793+ bool propagatesInputNodes(expr* fo, csize producer) const { return producer == 0; }
794+
795+ bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
796+
797+ bool isMap(csize producer) const { return producer == 0; }
798+
799+ CODEGEN_DECL();
800+};
801+
802+
803+//fn-jsoniq:trim
804+class fn_jsoniq_trim : public function
805+{
806+public:
807+ fn_jsoniq_trim(const signature& sig, FunctionConsts::FunctionKind kind)
808+ :
809+ function(sig, kind)
810+ {
811+
812+ }
813+
814+ xqtref_t getReturnType(const fo_expr* caller) const;
815+
816+ bool propagatesInputNodes(expr* fo, csize producer) const { return producer == 0; }
817+
818+ bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
819+
820+ bool isMap(csize producer) const { return producer == 0; }
821
822 CODEGEN_DECL();
823 };
824@@ -312,6 +320,8 @@
825
826 bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
827
828+ bool isMap(csize producer) const { return producer == 0; }
829+
830 CODEGEN_DECL();
831 };
832
833
834=== modified file 'src/functions/pregenerated/function_enum.h'
835--- src/functions/pregenerated/function_enum.h 2013-08-12 12:49:39 +0000
836+++ src/functions/pregenerated/function_enum.h 2013-08-14 19:07:42 +0000
837@@ -258,13 +258,13 @@
838 FN_JSONIQ_ENCODE_FOR_ROUNDTRIP_2,
839 FN_JSONIQ_PARSE_JSON_1,
840 FN_JSONIQ_PARSE_JSON_2,
841- FN_JSONIQ_JSON_DOC_1,
842 OP_ZORBA_JSON_ITEM_ACCESSOR_1,
843 OP_ZORBA_JSON_ITEM_ACCESSOR_2,
844 FN_JSONIQ_KEYS_1,
845 OP_ZORBA_KEYS_1,
846 OP_ZORBA_OBJECT_VALUE_2,
847 FN_JSONIQ_PROJECT_2,
848+ FN_JSONIQ_TRIM_2,
849 OP_ZORBA_ARRAY_MEMBER_2,
850 FN_JSONIQ_MEMBERS_1,
851 OP_ZORBA_MEMBERS_1,
852
853=== modified file 'src/runtime/booleans/BooleanImpl.cpp'
854--- src/runtime/booleans/BooleanImpl.cpp 2013-06-11 09:43:21 +0000
855+++ src/runtime/booleans/BooleanImpl.cpp 2013-08-14 19:07:42 +0000
856@@ -116,18 +116,11 @@
857 // empty sequence => false
858 result = negate ^ false;
859 }
860- else if (item->isNode())
861+ else if (item->isNode() || item->isJSONItem())
862 {
863 // node => true
864 result = negate ^ true;
865 }
866- else if (item->isJSONItem())
867- {
868- xqtref_t type = tm->create_value_type(item);
869-
870- RAISE_ERROR(err::FORG0006, loc,
871- ERROR_PARAMS(ZED(BadArgTypeForFn_2o34o), *type, "fn:boolean" ));
872- }
873 else
874 {
875 store::SchemaTypeCode type = item->getTypeCode();
876
877=== modified file 'src/runtime/json/jsoniq_functions_impl.cpp'
878--- src/runtime/json/jsoniq_functions_impl.cpp 2013-08-12 12:49:39 +0000
879+++ src/runtime/json/jsoniq_functions_impl.cpp 2013-08-14 19:07:42 +0000
880@@ -895,96 +895,6 @@
881
882
883 /*******************************************************************************
884-
885-********************************************************************************/
886-void JSONDocIteratorState::init(PlanState& aState)
887-{
888- PlanIteratorState::init(aState);
889- theStream = nullptr;
890- theGotOne = false;
891- loader_ = nullptr;
892-}
893-
894-
895-void JSONDocIteratorState::reset(PlanState& aState)
896-{
897- PlanIteratorState::reset(aState);
898- theGotOne = false;
899- delete loader_;
900- loader_ = nullptr;
901-}
902-
903-
904-JSONDocIteratorState::~JSONDocIteratorState()
905-{
906- delete loader_;
907-}
908-
909-
910-bool JSONDocIterator::nextImpl(store::Item_t& result, PlanState& planState) const
911-{
912- store::Item_t uriItem;
913- JSONDocIteratorState* state;
914- zstring uriString;
915- zstring lErrorMessage;
916- internal::StreamResource* lStreamResource;
917- zstring lNormUri;
918- DEFAULT_STACK_INIT(JSONDocIteratorState, state, planState);
919-
920- if (consumeNext(uriItem, theChildren[0].getp(), planState))
921- {
922- uriItem->getStringValue2(uriString);
923- // Normalize input to handle filesystem paths, etc.
924- normalizeInputUri(uriString, theSctx, loc, &lNormUri);
925-
926- // Resolve URI to a stream
927- state->theResource = theSctx->resolve_uri(
928- lNormUri,
929- internal::EntityData::DOCUMENT,
930- lErrorMessage);
931-
932- lStreamResource =
933- dynamic_cast<internal::StreamResource*>(state->theResource.get());
934- if (lStreamResource == NULL)
935- {
936- throw XQUERY_EXCEPTION(
937- err::FODC0002,
938- ERROR_PARAMS(uriString, lErrorMessage),
939- ERROR_LOC(loc));
940- }
941-
942- state->theStream = lStreamResource->getStream();
943- if (state->theStream == NULL)
944- {
945- throw XQUERY_EXCEPTION(
946- err::FODC0002,
947- ERROR_PARAMS( uriString ),
948- ERROR_LOC(loc));
949- }
950-
951- state->theGotOne = false;
952- state->loader_ = new json::loader( *state->theStream, true );
953-
954- while ( state->loader_->next( &result ) )
955- {
956- if (!state->theGotOne)
957- {
958- state->theGotOne = true;
959- STACK_PUSH(true, state);
960- }
961- else
962- {
963- RAISE_ERROR(jerr::JNDY0021, loc,
964- ERROR_PARAMS(ZED(JNDY0021_UnexpectedExtraContent)));
965- }
966- }
967- }
968-
969- STACK_END(state);
970-}
971-
972-
973-/*******************************************************************************
974 op_zorba:json-item-accessor($i as item()?, $sel as item()?) as item()?
975
976 op_zorba:json-item-accessor($i as item()?) as item()*
977@@ -1071,7 +981,7 @@
978
979
980 /*******************************************************************************
981- op-zorba:names($o as item()) as xs:string*
982+ op-zorba:keys($o as item()) as xs:string*
983 ********************************************************************************/
984 bool SingleObjectNamesIterator::nextImpl(
985 store::Item_t& result,
986@@ -1125,7 +1035,7 @@
987
988
989 /*******************************************************************************
990- jn:names($o as item()*) as xs:string*
991+ jn:keys($o as item()*) as xs:string*
992 ********************************************************************************/
993
994 void JSONObjectNamesIteratorState::init(PlanState& planState)
995@@ -1161,12 +1071,14 @@
996 while (state->theNames->next(result))
997 {
998 name = result->getStringValue();
999+
1000 if (!state->theNamesSet->exists(name))
1001 {
1002 state->theNamesSet->insert(name);
1003 STACK_PUSH(true, state);
1004 }
1005 }
1006+
1007 state->theNames = NULL;
1008 }
1009 }
1010@@ -1176,7 +1088,7 @@
1011
1012
1013 /*******************************************************************************
1014- json:value($o as item(), $name as item()?) as item()?
1015+ op-zorba:object-value($o as item()?, $name as item()?) as item()?
1016
1017 Note: the translator always wraps the $name param to a [cast as xs:string?]
1018 expr, so we don's have to check the type of the selector item here.
1019@@ -1199,7 +1111,7 @@
1020 {
1021 result = input->getObjectValue(name);
1022
1023- STACK_PUSH(result != NULL, state);
1024+ STACK_PUSH(result != NULL, state);
1025 }
1026 }
1027 }
1028@@ -1209,86 +1121,137 @@
1029
1030
1031 /*******************************************************************************
1032- json:project($o as object(), $names as xs:string*) as object()
1033+ jn:project($items as item()*, $names as xs:string*) as item()*
1034 ********************************************************************************/
1035 bool JSONObjectProjectIterator::nextImpl(
1036- store::Item_t& result,
1037- PlanState& planState) const
1038+ store::Item_t& result,
1039+ PlanState& planState) const
1040 {
1041- store::Item_t obj;
1042 store::Item_t key;
1043 store::Iterator_t keysIte;
1044 store::Item_t value;
1045- store::Item_t name;
1046- std::vector<store::Item_t> names;
1047- csize numNames = 0;
1048+ csize numKeys = 0;
1049 store::CopyMode copymode;
1050- std::vector<store::Item_t> newNames;
1051+ std::vector<store::Item_t> newKeys;
1052 std::vector<store::Item_t> newValues;
1053 csize i;
1054
1055- PlanIteratorState* state;
1056- DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
1057-
1058- consumeNext(obj, theChild0.getp(), planState);
1059-
1060- while (consumeNext(name, theChild1.getp(), planState))
1061- {
1062- ++numNames;
1063- names.resize(numNames);
1064- names[numNames - 1].transfer(name);
1065- }
1066-
1067- keysIte = obj->getObjectKeys();
1068- keysIte->open();
1069-
1070- while (keysIte->next(key))
1071- {
1072- for (i = 0; i < numNames; ++i)
1073- {
1074- if (names[i]->getStringValue() == key->getStringValue())
1075- break;
1076- }
1077-
1078- if (i < numNames)
1079- {
1080- value = obj->getObjectValue(key);
1081-
1082- if (value->isStructuredItem())
1083- value = value->copy(NULL, copymode);
1084-
1085- newValues.push_back(value);
1086- newNames.push_back(key);
1087- }
1088- }
1089-
1090- keysIte->close();
1091-
1092- GENV_ITEMFACTORY->createJSONObject(result, newNames, newValues);
1093-
1094- STACK_PUSH(true, state);
1095+ JSONObjectProjectIteratorState* state;
1096+ DEFAULT_STACK_INIT(JSONObjectProjectIteratorState, state, planState);
1097+
1098+ state->theFilterKeys.clear();
1099+
1100+ while (consumeNext(key, theChild1.getp(), planState))
1101+ {
1102+ ++numKeys;
1103+ state->theFilterKeys.resize(numKeys);
1104+ state->theFilterKeys[numKeys - 1].transfer(key);
1105+ }
1106+
1107+ while (consumeNext(result, theChild0.getp(), planState))
1108+ {
1109+ if (result->isObject())
1110+ {
1111+ numKeys = state->theFilterKeys.size();
1112+
1113+ keysIte = result->getObjectKeys();
1114+ keysIte->open();
1115+
1116+ while (keysIte->next(key))
1117+ {
1118+ for (i = 0; i < numKeys; ++i)
1119+ {
1120+ if (state->theFilterKeys[i]->getStringValue() == key->getStringValue())
1121+ break;
1122+ }
1123+
1124+ if (i < numKeys)
1125+ {
1126+ value = result->getObjectValue(key);
1127+
1128+ if (value->isStructuredItem())
1129+ value = value->copy(NULL, copymode);
1130+
1131+ newValues.push_back(value);
1132+ newKeys.push_back(key);
1133+ }
1134+ }
1135+
1136+ keysIte->close();
1137+
1138+ GENV_ITEMFACTORY->createJSONObject(result, newKeys, newValues);
1139+ }
1140+
1141+ STACK_PUSH(true, state);
1142+ }
1143+
1144 STACK_END(state);
1145 }
1146
1147
1148 /*******************************************************************************
1149- j:size($i as array()) as xs:integer*
1150+ jn:trim($items as item()*, $names as xs:string*) as item()*
1151 ********************************************************************************/
1152-bool JSONArraySizeIterator::nextImpl(
1153+bool JSONObjectTrimIterator::nextImpl(
1154 store::Item_t& result,
1155 PlanState& planState) const
1156 {
1157- store::Item_t item;
1158- xs_integer size;
1159-
1160- PlanIteratorState* state;
1161- DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
1162-
1163- if (consumeNext(item, theChild.getp(), planState))
1164- {
1165- size = item->getArraySize();
1166-
1167- STACK_PUSH(GENV_ITEMFACTORY->createInteger(result, size), state);
1168+ store::Item_t key;
1169+ store::Iterator_t keysIte;
1170+ store::Item_t value;
1171+ csize numKeys = 0;
1172+ store::CopyMode copymode;
1173+ std::vector<store::Item_t> newKeys;
1174+ std::vector<store::Item_t> newValues;
1175+ csize i;
1176+
1177+ JSONObjectTrimIteratorState* state;
1178+ DEFAULT_STACK_INIT(JSONObjectTrimIteratorState, state, planState);
1179+
1180+ state->theFilterKeys.clear();
1181+
1182+ while (consumeNext(key, theChild1.getp(), planState))
1183+ {
1184+ ++numKeys;
1185+ state->theFilterKeys.resize(numKeys);
1186+ state->theFilterKeys[numKeys - 1].transfer(key);
1187+ }
1188+
1189+ while (consumeNext(result, theChild0.getp(), planState))
1190+ {
1191+ if (result->isObject())
1192+ {
1193+ numKeys = state->theFilterKeys.size();
1194+
1195+ keysIte = result->getObjectKeys();
1196+ keysIte->open();
1197+
1198+ while (keysIte->next(key))
1199+ {
1200+ for (i = 0; i < numKeys; ++i)
1201+ {
1202+ if (state->theFilterKeys[i]->getStringValue() == key->getStringValue())
1203+ break;
1204+ }
1205+
1206+ if (i >= numKeys)
1207+ {
1208+ value = result->getObjectValue(key);
1209+
1210+ if (value->isStructuredItem())
1211+ value = value->copy(NULL, copymode);
1212+
1213+ newValues.push_back(value);
1214+ newKeys.push_back(key);
1215+ }
1216+ }
1217+
1218+ keysIte->close();
1219+
1220+ GENV_ITEMFACTORY->createJSONObject(result, newKeys, newValues);
1221+ }
1222+
1223+ STACK_PUSH(true, state);
1224 }
1225
1226 STACK_END(state);
1227@@ -1296,7 +1259,7 @@
1228
1229
1230 /*******************************************************************************
1231- json:member($a as item(), $pos as item()?) as item()?
1232+ op-zorba:member($a as item()?, $pos as item()?) as item()?
1233
1234 Note: the translator always wraps the $pos param to a [cast as xs:integer?]
1235 expr, so we don's have to check the type of the selector item here.
1236@@ -1438,9 +1401,31 @@
1237
1238
1239 /*******************************************************************************
1240- json:flatten($a as item()) as item()*
1241-
1242- op-zorba:flatten-internal($a as item()*) as item()*
1243+ jn:size($i as array()?) as xs:integer?
1244+********************************************************************************/
1245+bool JSONArraySizeIterator::nextImpl(
1246+ store::Item_t& result,
1247+ PlanState& planState) const
1248+{
1249+ store::Item_t item;
1250+ xs_integer size;
1251+
1252+ PlanIteratorState* state;
1253+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
1254+
1255+ if (consumeNext(item, theChild.getp(), planState))
1256+ {
1257+ size = item->getArraySize();
1258+
1259+ STACK_PUSH(GENV_ITEMFACTORY->createInteger(result, size), state);
1260+ }
1261+
1262+ STACK_END(state);
1263+}
1264+
1265+
1266+/*******************************************************************************
1267+ jn:flatten($items as item()*) as item()*
1268 ********************************************************************************/
1269 void JSONArrayFlattenIteratorState::reset(PlanState& planState)
1270 {
1271@@ -1453,47 +1438,51 @@
1272
1273
1274 bool JSONArrayFlattenIterator::nextImpl(
1275- store::Item_t& result,
1276- PlanState& planState) const
1277+ store::Item_t& result,
1278+ PlanState& planState) const
1279 {
1280- store::Item_t item;
1281 bool foundArray = false;
1282
1283 JSONArrayFlattenIteratorState* state;
1284 DEFAULT_STACK_INIT(JSONArrayFlattenIteratorState, state, planState);
1285
1286- consumeNext(item, theChild.getp(), planState);
1287-
1288- if (item->isArray())
1289+ while (consumeNext(result, theChild.getp(), planState))
1290 {
1291- state->theStack.push(item->getArrayValues());
1292-
1293- state->theStack.top()->open();
1294-
1295- while (!state->theStack.empty())
1296+ if (result->isArray())
1297 {
1298- while (state->theStack.top()->next(result))
1299+ state->theStack.push(result->getArrayValues());
1300+
1301+ state->theStack.top()->open();
1302+
1303+ while (!state->theStack.empty())
1304 {
1305- if (result->isArray())
1306+ while (state->theStack.top()->next(result))
1307 {
1308- state->theStack.push(result->getArrayValues());
1309- state->theStack.top()->open();
1310+ if (result->isArray())
1311+ {
1312+ state->theStack.push(result->getArrayValues());
1313+ state->theStack.top()->open();
1314
1315- foundArray = true;
1316- break;
1317- }
1318+ foundArray = true;
1319+ break;
1320+ }
1321
1322- STACK_PUSH(true, state);
1323- }
1324-
1325- if (foundArray)
1326- {
1327- foundArray = false;
1328- continue;
1329- }
1330-
1331- state->theStack.top()->close();
1332- state->theStack.pop();
1333+ STACK_PUSH(true, state);
1334+ }
1335+
1336+ if (foundArray)
1337+ {
1338+ foundArray = false;
1339+ continue;
1340+ }
1341+
1342+ state->theStack.top()->close();
1343+ state->theStack.pop();
1344+ }
1345+ }
1346+ else
1347+ {
1348+ STACK_PUSH(true, state);
1349 }
1350 }
1351
1352
1353=== modified file 'src/runtime/json/pregenerated/jsoniq_functions.cpp'
1354--- src/runtime/json/pregenerated/jsoniq_functions.cpp 2013-08-12 12:49:39 +0000
1355+++ src/runtime/json/pregenerated/jsoniq_functions.cpp 2013-08-14 19:07:42 +0000
1356@@ -144,36 +144,6 @@
1357 // </JSONParseIterator>
1358
1359
1360-// <JSONDocIterator>
1361-SERIALIZABLE_CLASS_VERSIONS(JSONDocIterator)
1362-
1363-void JSONDocIterator::serialize(::zorba::serialization::Archiver& ar)
1364-{
1365- serialize_baseclass(ar,
1366- (NaryBaseIterator<JSONDocIterator, JSONDocIteratorState>*)this);
1367-}
1368-
1369-
1370-void JSONDocIterator::accept(PlanIterVisitor& v) const
1371-{
1372- v.beginVisit(*this);
1373-
1374- std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
1375- std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
1376- for ( ; lIter != lEnd; ++lIter ){
1377- (*lIter)->accept(v);
1378- }
1379-
1380- v.endVisit(*this);
1381-}
1382-
1383-JSONDocIterator::~JSONDocIterator() {}
1384-
1385-JSONDocIteratorState::JSONDocIteratorState() {}
1386-
1387-// </JSONDocIterator>
1388-
1389-
1390 // <JSONItemAccessorIterator>
1391 SERIALIZABLE_CLASS_VERSIONS(JSONItemAccessorIterator)
1392
1393@@ -309,7 +279,7 @@
1394 void JSONObjectProjectIterator::serialize(::zorba::serialization::Archiver& ar)
1395 {
1396 serialize_baseclass(ar,
1397- (BinaryBaseIterator<JSONObjectProjectIterator, PlanIteratorState>*)this);
1398+ (BinaryBaseIterator<JSONObjectProjectIterator, JSONObjectProjectIteratorState>*)this);
1399 }
1400
1401
1402@@ -325,9 +295,58 @@
1403
1404 JSONObjectProjectIterator::~JSONObjectProjectIterator() {}
1405
1406+JSONObjectProjectIteratorState::JSONObjectProjectIteratorState() {}
1407+
1408+JSONObjectProjectIteratorState::~JSONObjectProjectIteratorState() {}
1409+
1410+
1411+void JSONObjectProjectIteratorState::init(PlanState& planState) {
1412+ PlanIteratorState::init(planState);
1413+}
1414+
1415+void JSONObjectProjectIteratorState::reset(PlanState& planState) {
1416+ PlanIteratorState::reset(planState);
1417+}
1418 // </JSONObjectProjectIterator>
1419
1420
1421+// <JSONObjectTrimIterator>
1422+SERIALIZABLE_CLASS_VERSIONS(JSONObjectTrimIterator)
1423+
1424+void JSONObjectTrimIterator::serialize(::zorba::serialization::Archiver& ar)
1425+{
1426+ serialize_baseclass(ar,
1427+ (BinaryBaseIterator<JSONObjectTrimIterator, JSONObjectTrimIteratorState>*)this);
1428+}
1429+
1430+
1431+void JSONObjectTrimIterator::accept(PlanIterVisitor& v) const
1432+{
1433+ v.beginVisit(*this);
1434+
1435+ theChild0->accept(v);
1436+theChild1->accept(v);
1437+
1438+ v.endVisit(*this);
1439+}
1440+
1441+JSONObjectTrimIterator::~JSONObjectTrimIterator() {}
1442+
1443+JSONObjectTrimIteratorState::JSONObjectTrimIteratorState() {}
1444+
1445+JSONObjectTrimIteratorState::~JSONObjectTrimIteratorState() {}
1446+
1447+
1448+void JSONObjectTrimIteratorState::init(PlanState& planState) {
1449+ PlanIteratorState::init(planState);
1450+}
1451+
1452+void JSONObjectTrimIteratorState::reset(PlanState& planState) {
1453+ PlanIteratorState::reset(planState);
1454+}
1455+// </JSONObjectTrimIterator>
1456+
1457+
1458 // <JSONArrayMemberIterator>
1459 SERIALIZABLE_CLASS_VERSIONS(JSONArrayMemberIterator)
1460
1461
1462=== modified file 'src/runtime/json/pregenerated/jsoniq_functions.h'
1463--- src/runtime/json/pregenerated/jsoniq_functions.h 2013-08-12 12:49:39 +0000
1464+++ src/runtime/json/pregenerated/jsoniq_functions.h 2013-08-14 19:07:42 +0000
1465@@ -192,52 +192,6 @@
1466
1467
1468 /**
1469- * jn:json-doc
1470- * Author: Zorba Team
1471- */
1472-class JSONDocIteratorState : public PlanIteratorState
1473-{
1474-public:
1475- std::auto_ptr<internal::Resource> theResource; //
1476- std::istream* theStream; //
1477- bool theGotOne; //
1478- json::loader* loader_; //
1479-
1480- JSONDocIteratorState();
1481-
1482- ~JSONDocIteratorState();
1483-
1484- void init(PlanState&);
1485- void reset(PlanState&);
1486-};
1487-
1488-class JSONDocIterator : public NaryBaseIterator<JSONDocIterator, JSONDocIteratorState>
1489-{
1490-public:
1491- SERIALIZABLE_CLASS(JSONDocIterator);
1492-
1493- SERIALIZABLE_CLASS_CONSTRUCTOR2T(JSONDocIterator,
1494- NaryBaseIterator<JSONDocIterator, JSONDocIteratorState>);
1495-
1496- void serialize( ::zorba::serialization::Archiver& ar);
1497-
1498- JSONDocIterator(
1499- static_context* sctx,
1500- const QueryLoc& loc,
1501- std::vector<PlanIter_t>& children)
1502- :
1503- NaryBaseIterator<JSONDocIterator, JSONDocIteratorState>(sctx, loc, children)
1504- {}
1505-
1506- virtual ~JSONDocIterator();
1507-
1508- void accept(PlanIterVisitor& v) const;
1509-
1510- bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
1511-};
1512-
1513-
1514-/**
1515 *
1516 * Author:
1517 */
1518@@ -288,7 +242,7 @@
1519 {
1520 public:
1521 store::Iterator_t theNames; //
1522- std::auto_ptr<HashSet<zstring, HashMapZStringCmp> > theNamesSet; //
1523+ std::unique_ptr<HashSet<zstring, HashMapZStringCmp> > theNamesSet; //
1524
1525 JSONObjectNamesIteratorState();
1526
1527@@ -403,13 +357,26 @@
1528 *
1529 * Author:
1530 */
1531-class JSONObjectProjectIterator : public BinaryBaseIterator<JSONObjectProjectIterator, PlanIteratorState>
1532+class JSONObjectProjectIteratorState : public PlanIteratorState
1533+{
1534+public:
1535+ std::vector<store::Item_t> theFilterKeys; //
1536+
1537+ JSONObjectProjectIteratorState();
1538+
1539+ ~JSONObjectProjectIteratorState();
1540+
1541+ void init(PlanState&);
1542+ void reset(PlanState&);
1543+};
1544+
1545+class JSONObjectProjectIterator : public BinaryBaseIterator<JSONObjectProjectIterator, JSONObjectProjectIteratorState>
1546 {
1547 public:
1548 SERIALIZABLE_CLASS(JSONObjectProjectIterator);
1549
1550 SERIALIZABLE_CLASS_CONSTRUCTOR2T(JSONObjectProjectIterator,
1551- BinaryBaseIterator<JSONObjectProjectIterator, PlanIteratorState>);
1552+ BinaryBaseIterator<JSONObjectProjectIterator, JSONObjectProjectIteratorState>);
1553
1554 void serialize( ::zorba::serialization::Archiver& ar);
1555
1556@@ -418,7 +385,7 @@
1557 const QueryLoc& loc,
1558 PlanIter_t& child1, PlanIter_t& child2)
1559 :
1560- BinaryBaseIterator<JSONObjectProjectIterator, PlanIteratorState>(sctx, loc, child1, child2)
1561+ BinaryBaseIterator<JSONObjectProjectIterator, JSONObjectProjectIteratorState>(sctx, loc, child1, child2)
1562 {}
1563
1564 virtual ~JSONObjectProjectIterator();
1565@@ -433,6 +400,49 @@
1566 *
1567 * Author:
1568 */
1569+class JSONObjectTrimIteratorState : public PlanIteratorState
1570+{
1571+public:
1572+ std::vector<store::Item_t> theFilterKeys; //
1573+
1574+ JSONObjectTrimIteratorState();
1575+
1576+ ~JSONObjectTrimIteratorState();
1577+
1578+ void init(PlanState&);
1579+ void reset(PlanState&);
1580+};
1581+
1582+class JSONObjectTrimIterator : public BinaryBaseIterator<JSONObjectTrimIterator, JSONObjectTrimIteratorState>
1583+{
1584+public:
1585+ SERIALIZABLE_CLASS(JSONObjectTrimIterator);
1586+
1587+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(JSONObjectTrimIterator,
1588+ BinaryBaseIterator<JSONObjectTrimIterator, JSONObjectTrimIteratorState>);
1589+
1590+ void serialize( ::zorba::serialization::Archiver& ar);
1591+
1592+ JSONObjectTrimIterator(
1593+ static_context* sctx,
1594+ const QueryLoc& loc,
1595+ PlanIter_t& child1, PlanIter_t& child2)
1596+ :
1597+ BinaryBaseIterator<JSONObjectTrimIterator, JSONObjectTrimIteratorState>(sctx, loc, child1, child2)
1598+ {}
1599+
1600+ virtual ~JSONObjectTrimIterator();
1601+
1602+ void accept(PlanIterVisitor& v) const;
1603+
1604+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
1605+};
1606+
1607+
1608+/**
1609+ *
1610+ * Author:
1611+ */
1612 class JSONArrayMemberIterator : public BinaryBaseIterator<JSONArrayMemberIterator, PlanIteratorState>
1613 {
1614 public:
1615
1616=== modified file 'src/runtime/pregenerated/iterator_enum.h'
1617--- src/runtime/pregenerated/iterator_enum.h 2013-08-12 12:49:39 +0000
1618+++ src/runtime/pregenerated/iterator_enum.h 2013-08-14 19:07:42 +0000
1619@@ -167,12 +167,12 @@
1620 TYPE_JSONDecodeFromRoundtripIterator,
1621 TYPE_JSONEncodeForRoundtripIterator,
1622 TYPE_JSONParseIterator,
1623- TYPE_JSONDocIterator,
1624 TYPE_JSONItemAccessorIterator,
1625 TYPE_JSONObjectNamesIterator,
1626 TYPE_SingleObjectNamesIterator,
1627 TYPE_JSONObjectValueIterator,
1628 TYPE_JSONObjectProjectIterator,
1629+ TYPE_JSONObjectTrimIterator,
1630 TYPE_JSONArrayMemberIterator,
1631 TYPE_JSONArrayMembersIterator,
1632 TYPE_SingleArrayMembersIterator,
1633
1634=== modified file 'src/runtime/spec/json/jsoniq_functions.xml'
1635--- src/runtime/spec/json/jsoniq_functions.xml 2013-08-12 12:49:39 +0000
1636+++ src/runtime/spec/json/jsoniq_functions.xml 2013-08-14 19:07:42 +0000
1637@@ -202,39 +202,6 @@
1638 /*******************************************************************************
1639 ********************************************************************************/
1640 -->
1641-<zorba:iterator name="JSONDocIterator">
1642-
1643- <zorba:description author="Zorba Team">jn:json-doc</zorba:description>
1644-
1645- <zorba:function>
1646-
1647- <zorba:signature localname="json-doc" prefix="fn-jsoniq">
1648- <zorba:param>xs:string?</zorba:param>
1649- <zorba:output>json-item()*</zorba:output>
1650- </zorba:signature>
1651-
1652- <zorba:methods>
1653- <zorba:accessesDynCtx returnValue="true"/>
1654- <zorba:isSource returnValue="true"/>
1655- </zorba:methods>
1656-
1657- </zorba:function>
1658-
1659- <zorba:state generateInit="false" generateReset="false" generateDestructor="false">
1660- <zorba:member type="std::auto_ptr&lt;internal::Resource&gt;" name="theResource" brief=""/>
1661- <zorba:member type="std::istream*" name="theStream" brief=""/>
1662- <zorba:member type="bool" name="theGotOne" brief=""/>
1663- <zorba:member type="json::loader*" name="loader_" brief=""/>
1664- </zorba:state>
1665-
1666-</zorba:iterator>
1667-
1668-
1669-
1670-<!--
1671-/*******************************************************************************
1672-********************************************************************************/
1673--->
1674 <zorba:iterator name="JSONItemAccessorIterator">
1675
1676 <zorba:function isDeterministic="true">
1677@@ -292,7 +259,7 @@
1678
1679 <zorba:member type="store::Iterator_t" name="theNames"/>
1680
1681- <zorba:member type="std::auto_ptr&lt;HashSet&lt;zstring, HashMapZStringCmp> >"
1682+ <zorba:member type="std::unique_ptr&lt;HashSet&lt;zstring, HashMapZStringCmp> >"
1683 name="theNamesSet"/>
1684 </zorba:state>
1685
1686@@ -365,17 +332,53 @@
1687 <zorba:function isDeterministic="true">
1688
1689 <zorba:signature localname="project" prefix="fn-jsoniq">
1690- <zorba:param>object()</zorba:param>
1691- <zorba:param>xs:string*</zorba:param>
1692- <zorba:output>object()</zorba:output>
1693- </zorba:signature>
1694-
1695- <zorba:methods>
1696- <zorba:propagatesInputNodes producer="0"/>
1697- <zorba:mustCopyInputNodes value="false"/>
1698- </zorba:methods>
1699-
1700- </zorba:function>
1701+ <zorba:param>item()*</zorba:param>
1702+ <zorba:param>xs:string*</zorba:param>
1703+ <zorba:output>item()*</zorba:output>
1704+ </zorba:signature>
1705+
1706+ <zorba:methods>
1707+ <zorba:getReturnType/>
1708+ <zorba:propagatesInputNodes producer="0"/>
1709+ <zorba:mustCopyInputNodes value="false"/>
1710+ <zorba:isMap producer="0"/>
1711+ </zorba:methods>
1712+
1713+ </zorba:function>
1714+
1715+ <zorba:state>
1716+ <zorba:member type="std::vector&lt;store::Item_t&gt;" name="theFilterKeys"/>
1717+ </zorba:state>
1718+
1719+</zorba:iterator>
1720+
1721+
1722+<!--
1723+/*******************************************************************************
1724+********************************************************************************/
1725+-->
1726+<zorba:iterator name="JSONObjectTrimIterator" arity="binary">
1727+
1728+ <zorba:function isDeterministic="true">
1729+
1730+ <zorba:signature localname="trim" prefix="fn-jsoniq">
1731+ <zorba:param>item()*</zorba:param>
1732+ <zorba:param>xs:string*</zorba:param>
1733+ <zorba:output>item()*</zorba:output>
1734+ </zorba:signature>
1735+
1736+ <zorba:methods>
1737+ <zorba:getReturnType/>
1738+ <zorba:propagatesInputNodes producer="0"/>
1739+ <zorba:mustCopyInputNodes value="false"/>
1740+ <zorba:isMap producer="0"/>
1741+ </zorba:methods>
1742+
1743+ </zorba:function>
1744+
1745+ <zorba:state>
1746+ <zorba:member type="std::vector&lt;store::Item_t&gt;" name="theFilterKeys"/>
1747+ </zorba:state>
1748
1749 </zorba:iterator>
1750
1751@@ -507,13 +510,14 @@
1752 <zorba:function isDeterministic="true">
1753
1754 <zorba:signature localname="flatten" prefix="fn-jsoniq">
1755- <zorba:param>item()</zorba:param>
1756+ <zorba:param>item()*</zorba:param>
1757 <zorba:output>item()*</zorba:output>
1758 </zorba:signature>
1759
1760 <zorba:methods>
1761 <zorba:propagatesInputNodes value="true"/>
1762 <zorba:mustCopyInputNodes value="false"/>
1763+ <zorba:isMap producer="0"/>
1764 </zorba:methods>
1765
1766 </zorba:function>
1767
1768=== modified file 'src/runtime/visitors/pregenerated/planiter_visitor.h'
1769--- src/runtime/visitors/pregenerated/planiter_visitor.h 2013-08-12 12:49:39 +0000
1770+++ src/runtime/visitors/pregenerated/planiter_visitor.h 2013-08-14 19:07:42 +0000
1771@@ -340,8 +340,6 @@
1772
1773 class JSONParseIterator;
1774
1775- class JSONDocIterator;
1776-
1777 class JSONItemAccessorIterator;
1778
1779 class JSONObjectNamesIterator;
1780@@ -352,6 +350,8 @@
1781
1782 class JSONObjectProjectIterator;
1783
1784+ class JSONObjectTrimIterator;
1785+
1786 class JSONArrayMemberIterator;
1787
1788 class JSONArrayMembersIterator;
1789@@ -1214,9 +1214,6 @@
1790 virtual void beginVisit ( const JSONParseIterator& ) = 0;
1791 virtual void endVisit ( const JSONParseIterator& ) = 0;
1792
1793- virtual void beginVisit ( const JSONDocIterator& ) = 0;
1794- virtual void endVisit ( const JSONDocIterator& ) = 0;
1795-
1796 virtual void beginVisit ( const JSONItemAccessorIterator& ) = 0;
1797 virtual void endVisit ( const JSONItemAccessorIterator& ) = 0;
1798
1799@@ -1232,6 +1229,9 @@
1800 virtual void beginVisit ( const JSONObjectProjectIterator& ) = 0;
1801 virtual void endVisit ( const JSONObjectProjectIterator& ) = 0;
1802
1803+ virtual void beginVisit ( const JSONObjectTrimIterator& ) = 0;
1804+ virtual void endVisit ( const JSONObjectTrimIterator& ) = 0;
1805+
1806 virtual void beginVisit ( const JSONArrayMemberIterator& ) = 0;
1807 virtual void endVisit ( const JSONArrayMemberIterator& ) = 0;
1808
1809
1810=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp'
1811--- src/runtime/visitors/pregenerated/printer_visitor.cpp 2013-08-12 12:49:39 +0000
1812+++ src/runtime/visitors/pregenerated/printer_visitor.cpp 2013-08-14 19:07:42 +0000
1813@@ -2052,20 +2052,6 @@
1814 // </JSONParseIterator>
1815
1816
1817-// <JSONDocIterator>
1818-void PrinterVisitor::beginVisit ( const JSONDocIterator& a) {
1819- thePrinter.startBeginVisit("JSONDocIterator", ++theId);
1820- printCommons( &a, theId );
1821- thePrinter.endBeginVisit( theId );
1822-}
1823-
1824-void PrinterVisitor::endVisit ( const JSONDocIterator& ) {
1825- thePrinter.startEndVisit();
1826- thePrinter.endEndVisit();
1827-}
1828-// </JSONDocIterator>
1829-
1830-
1831 // <JSONItemAccessorIterator>
1832 void PrinterVisitor::beginVisit ( const JSONItemAccessorIterator& a) {
1833 thePrinter.startBeginVisit("JSONItemAccessorIterator", ++theId);
1834@@ -2136,6 +2122,20 @@
1835 // </JSONObjectProjectIterator>
1836
1837
1838+// <JSONObjectTrimIterator>
1839+void PrinterVisitor::beginVisit ( const JSONObjectTrimIterator& a) {
1840+ thePrinter.startBeginVisit("JSONObjectTrimIterator", ++theId);
1841+ printCommons( &a, theId );
1842+ thePrinter.endBeginVisit( theId );
1843+}
1844+
1845+void PrinterVisitor::endVisit ( const JSONObjectTrimIterator& ) {
1846+ thePrinter.startEndVisit();
1847+ thePrinter.endEndVisit();
1848+}
1849+// </JSONObjectTrimIterator>
1850+
1851+
1852 // <JSONArrayMemberIterator>
1853 void PrinterVisitor::beginVisit ( const JSONArrayMemberIterator& a) {
1854 thePrinter.startBeginVisit("JSONArrayMemberIterator", ++theId);
1855
1856=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.h'
1857--- src/runtime/visitors/pregenerated/printer_visitor.h 2013-08-12 12:49:39 +0000
1858+++ src/runtime/visitors/pregenerated/printer_visitor.h 2013-08-14 19:07:42 +0000
1859@@ -520,9 +520,6 @@
1860 void beginVisit( const JSONParseIterator& );
1861 void endVisit ( const JSONParseIterator& );
1862
1863- void beginVisit( const JSONDocIterator& );
1864- void endVisit ( const JSONDocIterator& );
1865-
1866 void beginVisit( const JSONItemAccessorIterator& );
1867 void endVisit ( const JSONItemAccessorIterator& );
1868
1869@@ -538,6 +535,9 @@
1870 void beginVisit( const JSONObjectProjectIterator& );
1871 void endVisit ( const JSONObjectProjectIterator& );
1872
1873+ void beginVisit( const JSONObjectTrimIterator& );
1874+ void endVisit ( const JSONObjectTrimIterator& );
1875+
1876 void beginVisit( const JSONArrayMemberIterator& );
1877 void endVisit ( const JSONArrayMemberIterator& );
1878
1879
1880=== modified file 'swig/ruby/tests/test12.rb'
1881--- swig/ruby/tests/test12.rb 2013-04-17 16:58:03 +0000
1882+++ swig/ruby/tests/test12.rb 2013-08-14 19:07:42 +0000
1883@@ -31,7 +31,8 @@
1884
1885 print "Running: Compile query string using JSONiq \n"
1886 query = <<-eoquery
1887- let $sats := jn:json-doc("@rubyPathFiles@/tests/satellites.json")('satellites')
1888+ import module namespace file='http://expath.org/ns/file';
1889+ let $sats := jn:parse-json(file:read-text("@rubyPathFiles@/tests/satellites.json"))('satellites')
1890 return {
1891 'visible' : [
1892 for $sat in jn:keys($sats)
1893@@ -49,4 +50,4 @@
1894 test(zorba, query)
1895
1896 zorba.shutdown()
1897-Zorba_api::InMemoryStore.shutdown(store)
1898\ No newline at end of file
1899+Zorba_api::InMemoryStore.shutdown(store)
1900
1901=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/ebv02.xml.res'
1902--- test/rbkt/ExpQueryResults/zorba/jsoniq/ebv02.xml.res 1970-01-01 00:00:00 +0000
1903+++ test/rbkt/ExpQueryResults/zorba/jsoniq/ebv02.xml.res 2013-08-14 19:07:42 +0000
1904@@ -0,0 +1,1 @@
1905+true
1906
1907=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/ebv03.xml.res'
1908--- test/rbkt/ExpQueryResults/zorba/jsoniq/ebv03.xml.res 1970-01-01 00:00:00 +0000
1909+++ test/rbkt/ExpQueryResults/zorba/jsoniq/ebv03.xml.res 2013-08-14 19:07:42 +0000
1910@@ -0,0 +1,1 @@
1911+true
1912
1913=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/json_doc_3.xml.res'
1914--- test/rbkt/ExpQueryResults/zorba/jsoniq/json_doc_3.xml.res 1970-01-01 00:00:00 +0000
1915+++ test/rbkt/ExpQueryResults/zorba/jsoniq/json_doc_3.xml.res 2013-08-14 19:07:42 +0000
1916@@ -0,0 +1,1 @@
1917+{ "foo" : "bar" }{ "bar" : "foo" }
1918
1919=== removed file 'test/rbkt/ExpQueryResults/zorba/jsoniq/json_doc_4.xml.res'
1920=== removed file 'test/rbkt/Queries/zorba/jsoniq/ebv02.spec'
1921--- test/rbkt/Queries/zorba/jsoniq/ebv02.spec 2012-03-12 17:04:56 +0000
1922+++ test/rbkt/Queries/zorba/jsoniq/ebv02.spec 1970-01-01 00:00:00 +0000
1923@@ -1,1 +0,0 @@
1924-Error: http://www.w3.org/2005/xqt-errors:FORG0006
1925
1926=== removed file 'test/rbkt/Queries/zorba/jsoniq/ebv03.spec'
1927--- test/rbkt/Queries/zorba/jsoniq/ebv03.spec 2012-02-07 20:19:48 +0000
1928+++ test/rbkt/Queries/zorba/jsoniq/ebv03.spec 1970-01-01 00:00:00 +0000
1929@@ -1,1 +0,0 @@
1930-Error: http://www.w3.org/2005/xqt-errors:FORG0006
1931
1932=== modified file 'test/rbkt/Queries/zorba/jsoniq/input2.json'
1933--- test/rbkt/Queries/zorba/jsoniq/input2.json 2012-10-15 13:39:36 +0000
1934+++ test/rbkt/Queries/zorba/jsoniq/input2.json 2013-08-14 19:07:42 +0000
1935@@ -1,1 +1,1 @@
1936-{ "foo" : "bar" } { "bar" : "foo" }
1937+{ "foo" : "bar" }{ "bar" : "foo" }
1938
1939=== modified file 'test/rbkt/Queries/zorba/jsoniq/json_doc_1.xq'
1940--- test/rbkt/Queries/zorba/jsoniq/json_doc_1.xq 2012-10-15 13:39:36 +0000
1941+++ test/rbkt/Queries/zorba/jsoniq/json_doc_1.xq 2013-08-14 19:07:42 +0000
1942@@ -1,1 +1,7 @@
1943-jn:json-doc("input1.json")
1944\ No newline at end of file
1945+
1946+import module namespace fetch="http://www.zorba-xquery.com/modules/fetch";
1947+
1948+import module namespace file="http://expath.org/ns/file";
1949+
1950+
1951+jn:parse-json(file:read-text("$RBKT_SRC_DIR/Queries/zorba/jsoniq/input1.json"))
1952
1953=== modified file 'test/rbkt/Queries/zorba/jsoniq/json_doc_2.xq'
1954--- test/rbkt/Queries/zorba/jsoniq/json_doc_2.xq 2012-10-15 13:39:36 +0000
1955+++ test/rbkt/Queries/zorba/jsoniq/json_doc_2.xq 2013-08-14 19:07:42 +0000
1956@@ -1,1 +1,5 @@
1957-[ jn:json-doc("input1.json")("foo") ]
1958\ No newline at end of file
1959+
1960+import module namespace file="http://expath.org/ns/file";
1961+
1962+
1963+[ jn:parse-json(file:read-text("$RBKT_SRC_DIR/Queries/zorba/jsoniq/input1.json"))("foo") ]
1964
1965=== removed file 'test/rbkt/Queries/zorba/jsoniq/json_doc_3.spec'
1966--- test/rbkt/Queries/zorba/jsoniq/json_doc_3.spec 2012-10-15 13:49:49 +0000
1967+++ test/rbkt/Queries/zorba/jsoniq/json_doc_3.spec 1970-01-01 00:00:00 +0000
1968@@ -1,1 +0,0 @@
1969-Error: http://jsoniq.org/errors:JNDY0021
1970
1971=== modified file 'test/rbkt/Queries/zorba/jsoniq/json_doc_3.xq'
1972--- test/rbkt/Queries/zorba/jsoniq/json_doc_3.xq 2012-10-15 13:39:36 +0000
1973+++ test/rbkt/Queries/zorba/jsoniq/json_doc_3.xq 2013-08-14 19:07:42 +0000
1974@@ -1,1 +1,4 @@
1975-jn:json-doc("input2.json")
1976\ No newline at end of file
1977+
1978+import module namespace file="http://expath.org/ns/file";
1979+
1980+jn:parse-json(file:read-text("$RBKT_SRC_DIR/Queries/zorba/jsoniq/input2.json"))
1981
1982=== removed file 'test/rbkt/Queries/zorba/jsoniq/json_doc_4.xq'
1983--- test/rbkt/Queries/zorba/jsoniq/json_doc_4.xq 2012-10-15 13:49:49 +0000
1984+++ test/rbkt/Queries/zorba/jsoniq/json_doc_4.xq 1970-01-01 00:00:00 +0000
1985@@ -1,1 +0,0 @@
1986-jn:json-doc(())
1987\ No newline at end of file
1988
1989=== modified file 'test/rbkt/Queries/zorba/jsoniq/json_doc_5.xq'
1990--- test/rbkt/Queries/zorba/jsoniq/json_doc_5.xq 2012-10-15 13:49:49 +0000
1991+++ test/rbkt/Queries/zorba/jsoniq/json_doc_5.xq 2013-08-14 19:07:42 +0000
1992@@ -1,1 +1,4 @@
1993-jn:json-doc("input3.json")
1994\ No newline at end of file
1995+
1996+import module namespace file="http://expath.org/ns/file";
1997+
1998+jn:parse-json(file:read-text("$RBKT_SRC_DIR/Queries/zorba/jsoniq/input3.json"))

Subscribers

People subscribed via source and target branches