Merge lp:~zorba-coders/zorba/jsoniq-library-functions into lp:zorba

Proposed by Ghislain Fourny
Status: Merged
Approved by: Ghislain Fourny
Approved revision: 10989
Merged at revision: 11023
Proposed branch: lp:~zorba-coders/zorba/jsoniq-library-functions
Merge into: lp:zorba
Diff against target: 503 lines (+327/-0)
24 files modified
ChangeLog (+2/-0)
modules/org/jsoniq/www/CMakeLists.txt (+2/-0)
modules/org/jsoniq/www/function-library.xq (+174/-0)
modules/org/jsoniq/www/functions.xq (+15/-0)
src/context/static_context.cpp (+3/-0)
src/functions/func_jsoniq_functions_impl.cpp (+22/-0)
src/functions/func_jsoniq_functions_impl.h (+14/-0)
src/functions/function_consts.h (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/jn_accumulate.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/jn_descendant_objects.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/jn_descendant_pairs.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/jn_intersect.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/jn_values.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/object_03.xml.res (+1/-0)
test/rbkt/Queries/zorba/jsoniq/jn_accumulate.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/jn_accumulate.xq (+16/-0)
test/rbkt/Queries/zorba/jsoniq/jn_descendant_objects.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/jn_descendant_objects.xq (+10/-0)
test/rbkt/Queries/zorba/jsoniq/jn_descendant_pairs.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/jn_descendant_pairs.xq (+10/-0)
test/rbkt/Queries/zorba/jsoniq/jn_intersect.xq (+20/-0)
test/rbkt/Queries/zorba/jsoniq/jn_values.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/jn_values.xq (+10/-0)
test/rbkt/Queries/zorba/jsoniq/object_03.xq (+18/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/jsoniq-library-functions
Reviewer Review Type Date Requested Status
Matthias Brantner Approve
Chris Hillery Approve
Till Westmann Approve
Review via email: mp+119347@code.launchpad.net

Commit message

Adding missing JSONiq library functions.

Description of the change

Adding missing JSONiq library functions.

To post a comment you must log in.
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~zorba-coders/zorba/jsoniq-library-functions into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job jsoniq-library-functions-2012-08-13T13-33-00.38Z is
  finished. The final status was:

  1 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

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 jsoniq-library-functions-2012-08-14T13-16-06.204Z is finished. The final status was:

All tests succeeded!

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

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 2 Pending.

Revision history for this message
Till Westmann (tillw) wrote :

Looks good and works for me.

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

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

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 jsoniq-library-functions-2012-08-15T14-11-15.358Z is finished. The final status was:

All tests succeeded!

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

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 1 Approve, 2 Pending.

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

In functions.xq, the error jerr:JNDY0003 raised by jn:error should be documented explicitly using xqdoc's @error tag.

I'm not sure I like the name (function-library) of the new module but I don't have any better suggestions.

review: Needs Fixing
Revision history for this message
Ghislain Fourny (gislenius) wrote :

Hi Matthias,

Thanks! I added the @error tag.

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 jsoniq-library-functions-2012-08-30T14-13-07.942Z is finished. The final status was:

All tests succeeded!

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

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 1 Approve, 1 Needs Fixing, 1 Pending.

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

I still think the definitions of some of these functions are weird, but this proposal does match the spec as it stands at the moment.

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

Ghislain, could you please add the new module to the ChangeLog?

review: Needs Fixing
10988. By Ghislain Fourny

Updated ChangeLog.

Revision history for this message
Ghislain Fourny (gislenius) wrote :

Hi Matthias, this is done.

Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
10989. By Ghislain Fourny

Merged trunk back.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2012-08-31 15:21:31 +0000
3+++ ChangeLog 2012-09-05 12:26:31 +0000
4@@ -6,6 +6,8 @@
5 * Allow prolog variables to be referenced before they are declared (XQuery 3.0 feature)
6 * xml:parse (fragment parsing) now allows for a DOCTYPE declaration at the
7 beginning of the XML document (requested in bug #1016606).
8+ * New module http://www.jsoniq.org/modules/function-library with handy JSONiq functions. jn:object is
9+ also supported.
10
11 Optimizations:
12 * New memory management for compiler expressions (no more ref counting)
13
14=== modified file 'modules/org/jsoniq/www/CMakeLists.txt'
15--- modules/org/jsoniq/www/CMakeLists.txt 2012-01-31 01:00:55 +0000
16+++ modules/org/jsoniq/www/CMakeLists.txt 2012-09-05 12:26:31 +0000
17@@ -15,6 +15,8 @@
18 IF(ZORBA_WITH_JSON)
19 DECLARE_ZORBA_MODULE(FILE functions.xq VERSION 1.0
20 URI "http://www.jsoniq.org/functions")
21+ DECLARE_ZORBA_MODULE(FILE function-library.xq VERSION 1.0
22+ URI "http://www.jsoniq.org/function-library")
23 DECLARE_ZORBA_MODULE (FILE pregenerated/errors.xq
24 URI "http://www.jsoniq.org/errors")
25 ENDIF(ZORBA_WITH_JSON)
26
27=== added file 'modules/org/jsoniq/www/function-library.xq'
28--- modules/org/jsoniq/www/function-library.xq 1970-01-01 00:00:00 +0000
29+++ modules/org/jsoniq/www/function-library.xq 2012-09-05 12:26:31 +0000
30@@ -0,0 +1,174 @@
31+xquery version "1.0";
32+
33+(:
34+ : Copyright 2006-2012 The FLWOR Foundation.
35+ :
36+ : Licensed under the Apache License, Version 2.0 (the "License");
37+ : you may not use this file except in compliance with the License.
38+ : You may obtain a copy of the License at
39+ :
40+ : http://www.apache.org/licenses/LICENSE-2.0
41+ :
42+ : Unless required by applicable law or agreed to in writing, software
43+ : distributed under the License is distributed on an "AS IS" BASIS,
44+ : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
45+ : See the License for the specific language governing permissions and
46+ : limitations under the License.
47+:)
48+
49+
50+(:~
51+ : This module provides the functions defined by the JSONiq specification,
52+ : chapter 8 (Function Library). JSONiq extends
53+ : the XQuery specification to also deal with JSON data natively. See
54+ :
55+ : http://www.jsoniq.org/
56+ :
57+ : for details.
58+ :
59+ : This module depends on having the JSONiq feature enabled in Zorba,
60+ : i.e., Zorba must be compiled with ZORBA_WITH_JSON.
61+ :
62+ : @author Ghislain Fourny
63+ :)
64+module namespace libjn = "http://www.jsoniq.org/function-library";
65+
66+import module namespace jn = "http://www.jsoniq.org/functions";
67+
68+declare namespace ver = "http://www.zorba-xquery.com/options/versioning";
69+declare option ver:module-version "1.0";
70+
71+(:~
72+ : This function dynamically builds an object, like jn:object, except that
73+ : it does not throw an error upon pair collision. Instead, it aggregates them
74+ : into an array.
75+ :
76+ : @param $o A sequence of objects.
77+ : @return The accumulated object.
78+ :)
79+declare function libjn:accumulate($o as object()*) as object()
80+{
81+ {[ $o ]}
82+};
83+
84+(:~
85+ : This function returns all Objects contained within a JSON item, regardless of
86+ : depth.
87+ :
88+ : @param $i A JSON item.
89+ : @return Its descendant objects.
90+ :)
91+declare function libjn:descendant-objects($i as json-item()) as object()*
92+{
93+ if ($i instance of object())
94+ then
95+ (
96+ $i,
97+ for $v in libjn:values($i)
98+ where $v instance of json-item()
99+ return libjn:descendant-objects($v)
100+ )
101+ else if ($i instance of array())
102+ then
103+ (
104+ for $v in libjn:members($i)
105+ where $v instance of json-item()
106+ return libjn:descendant-objects($v)
107+ )
108+ else
109+ ()
110+};
111+
112+(:~
113+ : This function returns all pairs contained within an object, recursively.
114+ :
115+ : @param $o An object.
116+ : @return All direct and indirect descendant pairs.
117+ :)
118+declare function libjn:descendant-pairs($o as object()) as object()*
119+{
120+ for $k in jn:keys($o)
121+ return (
122+ { $k : $o($k) },
123+ if ($o($k) instance of object())
124+ then
125+ libjn:descendant-pairs($o($k))
126+ else ()
127+ )
128+};
129+
130+(:~
131+ : Recursively "flatten" a JSON Array, by replacing any arrays with their
132+ : members. Equivalent to
133+ :
134+ : define function jn:flatten($arg as array()) {
135+ : for $value in jn:values($arg)
136+ : return
137+ : if ($value instance of array())
138+ : then jn:flatten($value)
139+ : else $value
140+ : };
141+ :
142+ : @param $a A JSON Array.
143+ : @return The flattened version of $a.
144+ :)
145+declare function libjn:flatten($a as array()) as item()*
146+{
147+ jn:flatten($a)
148+};
149+
150+(:~ This function returns the intersection of two objects, and aggregates
151+ : values corresponding to the same name into an array.
152+ :
153+ : @param $o A sequence of objects.
154+ : @return Their insersection.
155+ :)
156+declare function libjn:intersect($o as object()*) as object()
157+{
158+ {|
159+ let $common-keys := jn:keys($o[1])[ every $object in $o[position() > 1]
160+ satisfies jn:keys($object) = . ]
161+ for $key in $common-keys
162+ let $values := $o($key)
163+ return
164+ if (count($values) eq 1)
165+ then { $key : $values }
166+ else { $key : [ $values ] }
167+ |}
168+};
169+
170+(:~
171+ : Returns the members of an Array.
172+ :
173+ : @param $a A JSON Array.
174+ : @return The members of the specified array.
175+ :)
176+declare function libjn:members($o as array()) as item()*
177+{
178+ jn:members($o)
179+};
180+
181+(:~
182+ : Creates an object from the specified pairs of another given object.
183+ : Specifically, for each name in $names, if the object $o has a pair with
184+ : that name, then a copy of that pair is included in the new object.
185+ :
186+ : @param $o A JSON Object.
187+ : @param $names The names of the pairs to copy out of $o and insert into the new object
188+ : @return The new object.
189+ :)
190+declare function libjn:project($o as object(), $names as xs:string*) as object()
191+{
192+ jn:project($o, $names)
193+};
194+
195+(:~
196+ : This functions returns all values in an Object.
197+ : @param $i An object.
198+ : @return Its values.
199+ :)
200+declare function libjn:values($i as object()) as item()*
201+{
202+ for $k in jn:keys($i)
203+ return $i($k)
204+};
205\ No newline at end of file
206
207=== modified file 'modules/org/jsoniq/www/functions.xq'
208--- modules/org/jsoniq/www/functions.xq 2012-08-30 13:45:43 +0000
209+++ modules/org/jsoniq/www/functions.xq 2012-09-05 12:26:31 +0000
210@@ -135,3 +135,18 @@
211 :)
212 declare function jn:flatten($a as array()) as item()* external;
213
214+(:~
215+ : This function allows dynamic object construction by merging all
216+ : its object parameters into a single object with a so-called "simple
217+ : object union". A simple object union creates a new object, the pairs
218+ : property of which is obtained by accumulating the pairs of all operand
219+ : objects. An error jerr:JNDY0003 is raised if two pairs with the same
220+ : name are encountered.
221+ :
222+ : @param $o A sequence of objects.
223+ :
224+ : @return The simple object union.
225+ :
226+ : @error jerr:JNDY0003 if there is a pair collision.
227+ :)
228+declare function jn:object($o as object()*) as object() external;
229
230=== modified file 'src/context/static_context.cpp'
231--- src/context/static_context.cpp 2012-08-30 13:45:43 +0000
232+++ src/context/static_context.cpp 2012-09-05 12:26:31 +0000
233@@ -538,6 +538,9 @@
234 #ifndef ZORBA_NO_FULL_TEXT
235 ns == ZORBA_FULL_TEXT_FN_NS ||
236 #endif /* ZORBA_NO_FULL_TEXT */
237+#ifndef ZORBA_WITH_JSON
238+ ns == JSONIQ_FN_NS ||
239+#endif /* ZORBA_WITH_JSON */
240 ns == ZORBA_XML_FN_NS);
241 }
242 else if (ns == W3C_FN_NS || ns == XQUERY_MATH_FN_NS)
243
244=== modified file 'src/functions/func_jsoniq_functions_impl.cpp'
245--- src/functions/func_jsoniq_functions_impl.cpp 2012-08-30 13:45:43 +0000
246+++ src/functions/func_jsoniq_functions_impl.cpp 2012-09-05 12:26:31 +0000
247@@ -18,6 +18,7 @@
248 #include "functions/func_jsoniq_functions.h"
249 #include "functions/func_jsoniq_functions_impl.h"
250
251+#include "runtime/json/json_constructors.h"
252 #include "runtime/json/jsoniq_functions.h"
253 #include "runtime/json/jsoniq_functions_impl.h"
254 #include "runtime/core/item_iterator.h"
255@@ -149,6 +150,20 @@
256 }
257
258
259+/*******************************************************************************
260+
261+********************************************************************************/
262+PlanIter_t jn_object::codegen(
263+ CompilerCB*,
264+ static_context* sctx,
265+ const QueryLoc& loc,
266+ std::vector<PlanIter_t>& argv,
267+ expr& ann) const
268+{
269+ return new JSONObjectIterator(sctx, loc, argv, true, false);
270+}
271+
272+
273 void populate_context_jsoniq_functions_impl(static_context* sctx)
274 {
275 DECL(sctx, op_zorba_object_insert,
276@@ -158,6 +173,13 @@
277 GENV_TYPESYSTEM.JSON_OBJECT_TYPE_ONE,
278 true,
279 GENV_TYPESYSTEM.EMPTY_TYPE));
280+
281+ DECL(sctx, jn_object,
282+ (createQName("http://www.jsoniq.org/functions",
283+ "",
284+ "object"),
285+ GENV_TYPESYSTEM.JSON_OBJECT_TYPE_STAR,
286+ GENV_TYPESYSTEM.JSON_OBJECT_TYPE_ONE));
287 }
288
289
290
291=== modified file 'src/functions/func_jsoniq_functions_impl.h'
292--- src/functions/func_jsoniq_functions_impl.h 2012-08-30 13:45:43 +0000
293+++ src/functions/func_jsoniq_functions_impl.h 2012-09-05 12:26:31 +0000
294@@ -57,6 +57,20 @@
295 };
296
297
298+class jn_object : public function
299+{
300+public:
301+ jn_object(const signature& sig)
302+ :
303+ function(sig, FunctionConsts::JN_OBJECT_1)
304+ {
305+ }
306+
307+ bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
308+
309+ CODEGEN_DECL();
310+};
311+
312
313 #endif // ZORBA_WITH_JSON
314
315
316=== modified file 'src/functions/function_consts.h'
317--- src/functions/function_consts.h 2012-08-30 13:45:43 +0000
318+++ src/functions/function_consts.h 2012-09-05 12:26:31 +0000
319@@ -230,6 +230,7 @@
320
321 #ifdef ZORBA_WITH_JSON
322 OP_OBJECT_INSERT_N,
323+ JN_OBJECT_1,
324 #endif
325
326 #ifndef ZORBA_NO_FULL_TEXT
327
328=== removed directory 'src/runtime/spec/json.moved'
329=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/jn_accumulate.xml.res'
330--- test/rbkt/ExpQueryResults/zorba/jsoniq/jn_accumulate.xml.res 1970-01-01 00:00:00 +0000
331+++ test/rbkt/ExpQueryResults/zorba/jsoniq/jn_accumulate.xml.res 2012-09-05 12:26:31 +0000
332@@ -0,0 +1,1 @@
333+{ "n1" : { "JSONiq XDM node" : "<node>10</node>" }, "n2" : { "JSONiq XDM node" : "<node>20</node>" } }
334
335=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/jn_descendant_objects.xml.res'
336--- test/rbkt/ExpQueryResults/zorba/jsoniq/jn_descendant_objects.xml.res 1970-01-01 00:00:00 +0000
337+++ test/rbkt/ExpQueryResults/zorba/jsoniq/jn_descendant_objects.xml.res 2012-09-05 12:26:31 +0000
338@@ -0,0 +1,1 @@
339+{ "foo" : "bar", "bar" : { "foo" : [ 1 ] }, "foobar" : "foo" }{ "foo" : [ 1 ] }
340
341=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/jn_descendant_pairs.xml.res'
342--- test/rbkt/ExpQueryResults/zorba/jsoniq/jn_descendant_pairs.xml.res 1970-01-01 00:00:00 +0000
343+++ test/rbkt/ExpQueryResults/zorba/jsoniq/jn_descendant_pairs.xml.res 2012-09-05 12:26:31 +0000
344@@ -0,0 +1,1 @@
345+{ "foo" : "bar" }{ "bar" : { "foo" : [ 1 ] } }{ "foo" : [ 1 ] }{ "foobar" : "foo" }
346\ No newline at end of file
347
348=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/jn_intersect.xml.res'
349--- test/rbkt/ExpQueryResults/zorba/jsoniq/jn_intersect.xml.res 1970-01-01 00:00:00 +0000
350+++ test/rbkt/ExpQueryResults/zorba/jsoniq/jn_intersect.xml.res 2012-09-05 12:26:31 +0000
351@@ -0,0 +1,1 @@
352+{ "bar" : [ { "foo" : [ 1 ] }, { "bar" : [ 2 ] }, [ "this" ] ] }
353\ No newline at end of file
354
355=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/jn_values.xml.res'
356--- test/rbkt/ExpQueryResults/zorba/jsoniq/jn_values.xml.res 1970-01-01 00:00:00 +0000
357+++ test/rbkt/ExpQueryResults/zorba/jsoniq/jn_values.xml.res 2012-09-05 12:26:31 +0000
358@@ -0,0 +1,1 @@
359+bar{ "foo" : [ 1 ] } foo
360
361=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/object_03.xml.res'
362--- test/rbkt/ExpQueryResults/zorba/jsoniq/object_03.xml.res 1970-01-01 00:00:00 +0000
363+++ test/rbkt/ExpQueryResults/zorba/jsoniq/object_03.xml.res 2012-09-05 12:26:31 +0000
364@@ -0,0 +1,1 @@
365+{ "toaster" : 200, "blender" : 250, "shirt" : 10, "socks" : 510, "broiler" : 20 }
366
367=== added file 'test/rbkt/Queries/zorba/jsoniq/jn_accumulate.spec'
368--- test/rbkt/Queries/zorba/jsoniq/jn_accumulate.spec 1970-01-01 00:00:00 +0000
369+++ test/rbkt/Queries/zorba/jsoniq/jn_accumulate.spec 2012-09-05 12:26:31 +0000
370@@ -0,0 +1,1 @@
371+Serialization: method=json jsoniq-extensions=yes
372
373=== added file 'test/rbkt/Queries/zorba/jsoniq/jn_accumulate.xq'
374--- test/rbkt/Queries/zorba/jsoniq/jn_accumulate.xq 1970-01-01 00:00:00 +0000
375+++ test/rbkt/Queries/zorba/jsoniq/jn_accumulate.xq 2012-09-05 12:26:31 +0000
376@@ -0,0 +1,16 @@
377+import module namespace libjn = "http://www.jsoniq.org/function-library";
378+
379+declare variable $xdoc :=
380+<nodes>
381+<node>10</node>
382+<node>20</node>
383+</nodes>;
384+
385+variable $obj :=
386+libjn:accumulate(
387+ for $node at $pos in $xdoc//node
388+ return { concat("n", $pos) : $node }
389+);
390+
391+$obj
392+
393
394=== added file 'test/rbkt/Queries/zorba/jsoniq/jn_descendant_objects.spec'
395--- test/rbkt/Queries/zorba/jsoniq/jn_descendant_objects.spec 1970-01-01 00:00:00 +0000
396+++ test/rbkt/Queries/zorba/jsoniq/jn_descendant_objects.spec 2012-09-05 12:26:31 +0000
397@@ -0,0 +1,1 @@
398+Serialization: method=json jsoniq-multiple-items=appended
399
400=== added file 'test/rbkt/Queries/zorba/jsoniq/jn_descendant_objects.xq'
401--- test/rbkt/Queries/zorba/jsoniq/jn_descendant_objects.xq 1970-01-01 00:00:00 +0000
402+++ test/rbkt/Queries/zorba/jsoniq/jn_descendant_objects.xq 2012-09-05 12:26:31 +0000
403@@ -0,0 +1,10 @@
404+import module namespace libjn = "http://www.jsoniq.org/function-library";
405+
406+let $object :=
407+{
408+ "foo" : "bar",
409+ "bar" : { "foo" : [1] },
410+ "foobar" : "foo"
411+}
412+return libjn:descendant-objects($object)
413+
414
415=== added file 'test/rbkt/Queries/zorba/jsoniq/jn_descendant_pairs.spec'
416--- test/rbkt/Queries/zorba/jsoniq/jn_descendant_pairs.spec 1970-01-01 00:00:00 +0000
417+++ test/rbkt/Queries/zorba/jsoniq/jn_descendant_pairs.spec 2012-09-05 12:26:31 +0000
418@@ -0,0 +1,1 @@
419+Serialization: method=json jsoniq-multiple-items=appended
420
421=== added file 'test/rbkt/Queries/zorba/jsoniq/jn_descendant_pairs.xq'
422--- test/rbkt/Queries/zorba/jsoniq/jn_descendant_pairs.xq 1970-01-01 00:00:00 +0000
423+++ test/rbkt/Queries/zorba/jsoniq/jn_descendant_pairs.xq 2012-09-05 12:26:31 +0000
424@@ -0,0 +1,10 @@
425+import module namespace libjn = "http://www.jsoniq.org/function-library";
426+
427+let $object :=
428+{
429+ "foo" : "bar",
430+ "bar" : { "foo" : [1] },
431+ "foobar" : "foo"
432+}
433+return libjn:descendant-pairs($object)
434+
435
436=== added file 'test/rbkt/Queries/zorba/jsoniq/jn_intersect.xq'
437--- test/rbkt/Queries/zorba/jsoniq/jn_intersect.xq 1970-01-01 00:00:00 +0000
438+++ test/rbkt/Queries/zorba/jsoniq/jn_intersect.xq 2012-09-05 12:26:31 +0000
439@@ -0,0 +1,20 @@
440+import module namespace libjn = "http://www.jsoniq.org/function-library";
441+
442+let $object :=
443+{
444+ "foo" : "bar",
445+ "bar" : { "foo" : [1] },
446+ "foobar" : "foo"
447+}
448+let $object2 :=
449+{
450+ "bar" : { "bar" : [2] },
451+ "foobar" : "foo"
452+}
453+let $object3 :=
454+{
455+ "foo" : "bar",
456+ "bar" : [ "this" ]
457+}
458+return libjn:intersect(($object, $object2, $object3))
459+
460
461=== added file 'test/rbkt/Queries/zorba/jsoniq/jn_values.spec'
462--- test/rbkt/Queries/zorba/jsoniq/jn_values.spec 1970-01-01 00:00:00 +0000
463+++ test/rbkt/Queries/zorba/jsoniq/jn_values.spec 2012-09-05 12:26:31 +0000
464@@ -0,0 +1,1 @@
465+Serialization: jsoniq-allow-mixed-xdm-jdm=yes jsoniq-multiple-items=appended
466
467=== added file 'test/rbkt/Queries/zorba/jsoniq/jn_values.xq'
468--- test/rbkt/Queries/zorba/jsoniq/jn_values.xq 1970-01-01 00:00:00 +0000
469+++ test/rbkt/Queries/zorba/jsoniq/jn_values.xq 2012-09-05 12:26:31 +0000
470@@ -0,0 +1,10 @@
471+import module namespace libjn = "http://www.jsoniq.org/function-library";
472+
473+let $object :=
474+{
475+ "foo" : "bar",
476+ "bar" : { "foo" : [1] },
477+ "foobar" : "foo"
478+}
479+return libjn:values($object)
480+
481
482=== added file 'test/rbkt/Queries/zorba/jsoniq/object_03.xq'
483--- test/rbkt/Queries/zorba/jsoniq/object_03.xq 1970-01-01 00:00:00 +0000
484+++ test/rbkt/Queries/zorba/jsoniq/object_03.xq 2012-09-05 12:26:31 +0000
485@@ -0,0 +1,18 @@
486+import module namespace jn = "http://www.jsoniq.org/functions";
487+
488+let $j := ({ "product" : "broiler", "store number" : 1, "quantity" : 20 },
489+{ "product" : "toaster", "store number" : 2, "quantity" : 100 },
490+{ "product" : "toaster", "store number" : 2, "quantity" : 50 },
491+{ "product" : "toaster", "store number" : 3, "quantity" : 50 },
492+{ "product" : "blender", "store number" : 3, "quantity" : 100 },
493+{ "product" : "blender", "store number" : 3, "quantity" : 150 },
494+{ "product" : "socks", "store number" : 1, "quantity" : 500 },
495+{ "product" : "socks", "store number" : 2, "quantity" : 10 },
496+{ "product" : "shirt", "store number" : 3, "quantity" : 10 })
497+return
498+jn:object(
499+ for $sales in $j
500+ let $pname := $sales("product")
501+ group by $pname
502+ return { $pname : sum(for $s in $sales return $s("quantity")) }
503+)

Subscribers

People subscribed via source and target branches