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
=== modified file 'ChangeLog'
--- ChangeLog 2012-08-31 15:21:31 +0000
+++ ChangeLog 2012-09-05 12:26:31 +0000
@@ -6,6 +6,8 @@
6 * Allow prolog variables to be referenced before they are declared (XQuery 3.0 feature)6 * Allow prolog variables to be referenced before they are declared (XQuery 3.0 feature)
7 * xml:parse (fragment parsing) now allows for a DOCTYPE declaration at the 7 * xml:parse (fragment parsing) now allows for a DOCTYPE declaration at the
8 beginning of the XML document (requested in bug #1016606).8 beginning of the XML document (requested in bug #1016606).
9 * New module http://www.jsoniq.org/modules/function-library with handy JSONiq functions. jn:object is
10 also supported.
911
10Optimizations:12Optimizations:
11 * New memory management for compiler expressions (no more ref counting)13 * New memory management for compiler expressions (no more ref counting)
1214
=== modified file 'modules/org/jsoniq/www/CMakeLists.txt'
--- modules/org/jsoniq/www/CMakeLists.txt 2012-01-31 01:00:55 +0000
+++ modules/org/jsoniq/www/CMakeLists.txt 2012-09-05 12:26:31 +0000
@@ -15,6 +15,8 @@
15IF(ZORBA_WITH_JSON)15IF(ZORBA_WITH_JSON)
16 DECLARE_ZORBA_MODULE(FILE functions.xq VERSION 1.016 DECLARE_ZORBA_MODULE(FILE functions.xq VERSION 1.0
17 URI "http://www.jsoniq.org/functions")17 URI "http://www.jsoniq.org/functions")
18 DECLARE_ZORBA_MODULE(FILE function-library.xq VERSION 1.0
19 URI "http://www.jsoniq.org/function-library")
18 DECLARE_ZORBA_MODULE (FILE pregenerated/errors.xq20 DECLARE_ZORBA_MODULE (FILE pregenerated/errors.xq
19 URI "http://www.jsoniq.org/errors")21 URI "http://www.jsoniq.org/errors")
20ENDIF(ZORBA_WITH_JSON)22ENDIF(ZORBA_WITH_JSON)
2123
=== added file 'modules/org/jsoniq/www/function-library.xq'
--- modules/org/jsoniq/www/function-library.xq 1970-01-01 00:00:00 +0000
+++ modules/org/jsoniq/www/function-library.xq 2012-09-05 12:26:31 +0000
@@ -0,0 +1,174 @@
1xquery version "1.0";
2
3(:
4 : Copyright 2006-2012 The FLWOR Foundation.
5 :
6 : Licensed under the Apache License, Version 2.0 (the "License");
7 : you may not use this file except in compliance with the License.
8 : You may obtain a copy of the License at
9 :
10 : http://www.apache.org/licenses/LICENSE-2.0
11 :
12 : Unless required by applicable law or agreed to in writing, software
13 : distributed under the License is distributed on an "AS IS" BASIS,
14 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 : See the License for the specific language governing permissions and
16 : limitations under the License.
17:)
18
19
20(:~
21 : This module provides the functions defined by the JSONiq specification,
22 : chapter 8 (Function Library). JSONiq extends
23 : the XQuery specification to also deal with JSON data natively. See
24 :
25 : http://www.jsoniq.org/
26 :
27 : for details.
28 :
29 : This module depends on having the JSONiq feature enabled in Zorba,
30 : i.e., Zorba must be compiled with ZORBA_WITH_JSON.
31 :
32 : @author Ghislain Fourny
33 :)
34module namespace libjn = "http://www.jsoniq.org/function-library";
35
36import module namespace jn = "http://www.jsoniq.org/functions";
37
38declare namespace ver = "http://www.zorba-xquery.com/options/versioning";
39declare option ver:module-version "1.0";
40
41(:~
42 : This function dynamically builds an object, like jn:object, except that
43 : it does not throw an error upon pair collision. Instead, it aggregates them
44 : into an array.
45 :
46 : @param $o A sequence of objects.
47 : @return The accumulated object.
48 :)
49declare function libjn:accumulate($o as object()*) as object()
50{
51 {[ $o ]}
52};
53
54(:~
55 : This function returns all Objects contained within a JSON item, regardless of
56 : depth.
57 :
58 : @param $i A JSON item.
59 : @return Its descendant objects.
60 :)
61declare function libjn:descendant-objects($i as json-item()) as object()*
62{
63 if ($i instance of object())
64 then
65 (
66 $i,
67 for $v in libjn:values($i)
68 where $v instance of json-item()
69 return libjn:descendant-objects($v)
70 )
71 else if ($i instance of array())
72 then
73 (
74 for $v in libjn:members($i)
75 where $v instance of json-item()
76 return libjn:descendant-objects($v)
77 )
78 else
79 ()
80};
81
82(:~
83 : This function returns all pairs contained within an object, recursively.
84 :
85 : @param $o An object.
86 : @return All direct and indirect descendant pairs.
87 :)
88declare function libjn:descendant-pairs($o as object()) as object()*
89{
90 for $k in jn:keys($o)
91 return (
92 { $k : $o($k) },
93 if ($o($k) instance of object())
94 then
95 libjn:descendant-pairs($o($k))
96 else ()
97 )
98};
99
100(:~
101 : Recursively "flatten" a JSON Array, by replacing any arrays with their
102 : members. Equivalent to
103 :
104 : define function jn:flatten($arg as array()) {
105 : for $value in jn:values($arg)
106 : return
107 : if ($value instance of array())
108 : then jn:flatten($value)
109 : else $value
110 : };
111 :
112 : @param $a A JSON Array.
113 : @return The flattened version of $a.
114 :)
115declare function libjn:flatten($a as array()) as item()*
116{
117 jn:flatten($a)
118};
119
120(:~ This function returns the intersection of two objects, and aggregates
121 : values corresponding to the same name into an array.
122 :
123 : @param $o A sequence of objects.
124 : @return Their insersection.
125 :)
126declare function libjn:intersect($o as object()*) as object()
127{
128 {|
129 let $common-keys := jn:keys($o[1])[ every $object in $o[position() > 1]
130 satisfies jn:keys($object) = . ]
131 for $key in $common-keys
132 let $values := $o($key)
133 return
134 if (count($values) eq 1)
135 then { $key : $values }
136 else { $key : [ $values ] }
137 |}
138};
139
140(:~
141 : Returns the members of an Array.
142 :
143 : @param $a A JSON Array.
144 : @return The members of the specified array.
145 :)
146declare function libjn:members($o as array()) as item()*
147{
148 jn:members($o)
149};
150
151(:~
152 : Creates an object from the specified pairs of another given object.
153 : Specifically, for each name in $names, if the object $o has a pair with
154 : that name, then a copy of that pair is included in the new object.
155 :
156 : @param $o A JSON Object.
157 : @param $names The names of the pairs to copy out of $o and insert into the new object
158 : @return The new object.
159 :)
160declare function libjn:project($o as object(), $names as xs:string*) as object()
161{
162 jn:project($o, $names)
163};
164
165(:~
166 : This functions returns all values in an Object.
167 : @param $i An object.
168 : @return Its values.
169 :)
170declare function libjn:values($i as object()) as item()*
171{
172 for $k in jn:keys($i)
173 return $i($k)
174};
0\ No newline at end of file175\ No newline at end of file
1176
=== modified file 'modules/org/jsoniq/www/functions.xq'
--- modules/org/jsoniq/www/functions.xq 2012-08-30 13:45:43 +0000
+++ modules/org/jsoniq/www/functions.xq 2012-09-05 12:26:31 +0000
@@ -135,3 +135,18 @@
135 :)135 :)
136declare function jn:flatten($a as array()) as item()* external;136declare function jn:flatten($a as array()) as item()* external;
137137
138(:~
139 : This function allows dynamic object construction by merging all
140 : its object parameters into a single object with a so-called "simple
141 : object union". A simple object union creates a new object, the pairs
142 : property of which is obtained by accumulating the pairs of all operand
143 : objects. An error jerr:JNDY0003 is raised if two pairs with the same
144 : name are encountered.
145 :
146 : @param $o A sequence of objects.
147 :
148 : @return The simple object union.
149 :
150 : @error jerr:JNDY0003 if there is a pair collision.
151 :)
152declare function jn:object($o as object()*) as object() external;
138153
=== modified file 'src/context/static_context.cpp'
--- src/context/static_context.cpp 2012-08-30 13:45:43 +0000
+++ src/context/static_context.cpp 2012-09-05 12:26:31 +0000
@@ -538,6 +538,9 @@
538#ifndef ZORBA_NO_FULL_TEXT538#ifndef ZORBA_NO_FULL_TEXT
539 ns == ZORBA_FULL_TEXT_FN_NS ||539 ns == ZORBA_FULL_TEXT_FN_NS ||
540#endif /* ZORBA_NO_FULL_TEXT */540#endif /* ZORBA_NO_FULL_TEXT */
541#ifndef ZORBA_WITH_JSON
542 ns == JSONIQ_FN_NS ||
543#endif /* ZORBA_WITH_JSON */
541 ns == ZORBA_XML_FN_NS);544 ns == ZORBA_XML_FN_NS);
542 }545 }
543 else if (ns == W3C_FN_NS || ns == XQUERY_MATH_FN_NS)546 else if (ns == W3C_FN_NS || ns == XQUERY_MATH_FN_NS)
544547
=== modified file 'src/functions/func_jsoniq_functions_impl.cpp'
--- src/functions/func_jsoniq_functions_impl.cpp 2012-08-30 13:45:43 +0000
+++ src/functions/func_jsoniq_functions_impl.cpp 2012-09-05 12:26:31 +0000
@@ -18,6 +18,7 @@
18#include "functions/func_jsoniq_functions.h"18#include "functions/func_jsoniq_functions.h"
19#include "functions/func_jsoniq_functions_impl.h"19#include "functions/func_jsoniq_functions_impl.h"
2020
21#include "runtime/json/json_constructors.h"
21#include "runtime/json/jsoniq_functions.h"22#include "runtime/json/jsoniq_functions.h"
22#include "runtime/json/jsoniq_functions_impl.h"23#include "runtime/json/jsoniq_functions_impl.h"
23#include "runtime/core/item_iterator.h"24#include "runtime/core/item_iterator.h"
@@ -149,6 +150,20 @@
149}150}
150151
151152
153/*******************************************************************************
154
155********************************************************************************/
156PlanIter_t jn_object::codegen(
157 CompilerCB*,
158 static_context* sctx,
159 const QueryLoc& loc,
160 std::vector<PlanIter_t>& argv,
161 expr& ann) const
162{
163 return new JSONObjectIterator(sctx, loc, argv, true, false);
164}
165
166
152void populate_context_jsoniq_functions_impl(static_context* sctx)167void populate_context_jsoniq_functions_impl(static_context* sctx)
153{168{
154 DECL(sctx, op_zorba_object_insert,169 DECL(sctx, op_zorba_object_insert,
@@ -158,6 +173,13 @@
158 GENV_TYPESYSTEM.JSON_OBJECT_TYPE_ONE,173 GENV_TYPESYSTEM.JSON_OBJECT_TYPE_ONE,
159 true,174 true,
160 GENV_TYPESYSTEM.EMPTY_TYPE));175 GENV_TYPESYSTEM.EMPTY_TYPE));
176
177 DECL(sctx, jn_object,
178 (createQName("http://www.jsoniq.org/functions",
179 "",
180 "object"),
181 GENV_TYPESYSTEM.JSON_OBJECT_TYPE_STAR,
182 GENV_TYPESYSTEM.JSON_OBJECT_TYPE_ONE));
161}183}
162184
163185
164186
=== modified file 'src/functions/func_jsoniq_functions_impl.h'
--- src/functions/func_jsoniq_functions_impl.h 2012-08-30 13:45:43 +0000
+++ src/functions/func_jsoniq_functions_impl.h 2012-09-05 12:26:31 +0000
@@ -57,6 +57,20 @@
57};57};
5858
5959
60class jn_object : public function
61{
62public:
63 jn_object(const signature& sig)
64 :
65 function(sig, FunctionConsts::JN_OBJECT_1)
66 {
67 }
68
69 bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
70
71 CODEGEN_DECL();
72};
73
6074
61#endif // ZORBA_WITH_JSON75#endif // ZORBA_WITH_JSON
6276
6377
=== modified file 'src/functions/function_consts.h'
--- src/functions/function_consts.h 2012-08-30 13:45:43 +0000
+++ src/functions/function_consts.h 2012-09-05 12:26:31 +0000
@@ -230,6 +230,7 @@
230230
231#ifdef ZORBA_WITH_JSON231#ifdef ZORBA_WITH_JSON
232 OP_OBJECT_INSERT_N,232 OP_OBJECT_INSERT_N,
233 JN_OBJECT_1,
233#endif234#endif
234235
235#ifndef ZORBA_NO_FULL_TEXT236#ifndef ZORBA_NO_FULL_TEXT
236237
=== removed directory 'src/runtime/spec/json.moved'
=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/jn_accumulate.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/jn_accumulate.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/jn_accumulate.xml.res 2012-09-05 12:26:31 +0000
@@ -0,0 +1,1 @@
1{ "n1" : { "JSONiq XDM node" : "<node>10</node>" }, "n2" : { "JSONiq XDM node" : "<node>20</node>" } }
02
=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/jn_descendant_objects.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/jn_descendant_objects.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/jn_descendant_objects.xml.res 2012-09-05 12:26:31 +0000
@@ -0,0 +1,1 @@
1{ "foo" : "bar", "bar" : { "foo" : [ 1 ] }, "foobar" : "foo" }{ "foo" : [ 1 ] }
02
=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/jn_descendant_pairs.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/jn_descendant_pairs.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/jn_descendant_pairs.xml.res 2012-09-05 12:26:31 +0000
@@ -0,0 +1,1 @@
1{ "foo" : "bar" }{ "bar" : { "foo" : [ 1 ] } }{ "foo" : [ 1 ] }{ "foobar" : "foo" }
0\ No newline at end of file2\ No newline at end of file
13
=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/jn_intersect.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/jn_intersect.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/jn_intersect.xml.res 2012-09-05 12:26:31 +0000
@@ -0,0 +1,1 @@
1{ "bar" : [ { "foo" : [ 1 ] }, { "bar" : [ 2 ] }, [ "this" ] ] }
0\ No newline at end of file2\ No newline at end of file
13
=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/jn_values.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/jn_values.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/jn_values.xml.res 2012-09-05 12:26:31 +0000
@@ -0,0 +1,1 @@
1bar{ "foo" : [ 1 ] } foo
02
=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/object_03.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/object_03.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/object_03.xml.res 2012-09-05 12:26:31 +0000
@@ -0,0 +1,1 @@
1{ "toaster" : 200, "blender" : 250, "shirt" : 10, "socks" : 510, "broiler" : 20 }
02
=== added file 'test/rbkt/Queries/zorba/jsoniq/jn_accumulate.spec'
--- test/rbkt/Queries/zorba/jsoniq/jn_accumulate.spec 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jn_accumulate.spec 2012-09-05 12:26:31 +0000
@@ -0,0 +1,1 @@
1Serialization: method=json jsoniq-extensions=yes
02
=== added file 'test/rbkt/Queries/zorba/jsoniq/jn_accumulate.xq'
--- test/rbkt/Queries/zorba/jsoniq/jn_accumulate.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jn_accumulate.xq 2012-09-05 12:26:31 +0000
@@ -0,0 +1,16 @@
1import module namespace libjn = "http://www.jsoniq.org/function-library";
2
3declare variable $xdoc :=
4<nodes>
5<node>10</node>
6<node>20</node>
7</nodes>;
8
9variable $obj :=
10libjn:accumulate(
11 for $node at $pos in $xdoc//node
12 return { concat("n", $pos) : $node }
13);
14
15$obj
16
017
=== added file 'test/rbkt/Queries/zorba/jsoniq/jn_descendant_objects.spec'
--- test/rbkt/Queries/zorba/jsoniq/jn_descendant_objects.spec 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jn_descendant_objects.spec 2012-09-05 12:26:31 +0000
@@ -0,0 +1,1 @@
1Serialization: method=json jsoniq-multiple-items=appended
02
=== added file 'test/rbkt/Queries/zorba/jsoniq/jn_descendant_objects.xq'
--- test/rbkt/Queries/zorba/jsoniq/jn_descendant_objects.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jn_descendant_objects.xq 2012-09-05 12:26:31 +0000
@@ -0,0 +1,10 @@
1import module namespace libjn = "http://www.jsoniq.org/function-library";
2
3let $object :=
4{
5 "foo" : "bar",
6 "bar" : { "foo" : [1] },
7 "foobar" : "foo"
8}
9return libjn:descendant-objects($object)
10
011
=== added file 'test/rbkt/Queries/zorba/jsoniq/jn_descendant_pairs.spec'
--- test/rbkt/Queries/zorba/jsoniq/jn_descendant_pairs.spec 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jn_descendant_pairs.spec 2012-09-05 12:26:31 +0000
@@ -0,0 +1,1 @@
1Serialization: method=json jsoniq-multiple-items=appended
02
=== added file 'test/rbkt/Queries/zorba/jsoniq/jn_descendant_pairs.xq'
--- test/rbkt/Queries/zorba/jsoniq/jn_descendant_pairs.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jn_descendant_pairs.xq 2012-09-05 12:26:31 +0000
@@ -0,0 +1,10 @@
1import module namespace libjn = "http://www.jsoniq.org/function-library";
2
3let $object :=
4{
5 "foo" : "bar",
6 "bar" : { "foo" : [1] },
7 "foobar" : "foo"
8}
9return libjn:descendant-pairs($object)
10
011
=== added file 'test/rbkt/Queries/zorba/jsoniq/jn_intersect.xq'
--- test/rbkt/Queries/zorba/jsoniq/jn_intersect.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jn_intersect.xq 2012-09-05 12:26:31 +0000
@@ -0,0 +1,20 @@
1import module namespace libjn = "http://www.jsoniq.org/function-library";
2
3let $object :=
4{
5 "foo" : "bar",
6 "bar" : { "foo" : [1] },
7 "foobar" : "foo"
8}
9let $object2 :=
10{
11 "bar" : { "bar" : [2] },
12 "foobar" : "foo"
13}
14let $object3 :=
15{
16 "foo" : "bar",
17 "bar" : [ "this" ]
18}
19return libjn:intersect(($object, $object2, $object3))
20
021
=== added file 'test/rbkt/Queries/zorba/jsoniq/jn_values.spec'
--- test/rbkt/Queries/zorba/jsoniq/jn_values.spec 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jn_values.spec 2012-09-05 12:26:31 +0000
@@ -0,0 +1,1 @@
1Serialization: jsoniq-allow-mixed-xdm-jdm=yes jsoniq-multiple-items=appended
02
=== added file 'test/rbkt/Queries/zorba/jsoniq/jn_values.xq'
--- test/rbkt/Queries/zorba/jsoniq/jn_values.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jn_values.xq 2012-09-05 12:26:31 +0000
@@ -0,0 +1,10 @@
1import module namespace libjn = "http://www.jsoniq.org/function-library";
2
3let $object :=
4{
5 "foo" : "bar",
6 "bar" : { "foo" : [1] },
7 "foobar" : "foo"
8}
9return libjn:values($object)
10
011
=== added file 'test/rbkt/Queries/zorba/jsoniq/object_03.xq'
--- test/rbkt/Queries/zorba/jsoniq/object_03.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/object_03.xq 2012-09-05 12:26:31 +0000
@@ -0,0 +1,18 @@
1import module namespace jn = "http://www.jsoniq.org/functions";
2
3let $j := ({ "product" : "broiler", "store number" : 1, "quantity" : 20 },
4{ "product" : "toaster", "store number" : 2, "quantity" : 100 },
5{ "product" : "toaster", "store number" : 2, "quantity" : 50 },
6{ "product" : "toaster", "store number" : 3, "quantity" : 50 },
7{ "product" : "blender", "store number" : 3, "quantity" : 100 },
8{ "product" : "blender", "store number" : 3, "quantity" : 150 },
9{ "product" : "socks", "store number" : 1, "quantity" : 500 },
10{ "product" : "socks", "store number" : 2, "quantity" : 10 },
11{ "product" : "shirt", "store number" : 3, "quantity" : 10 })
12return
13jn:object(
14 for $sales in $j
15 let $pname := $sales("product")
16 group by $pname
17 return { $pname : sum(for $s in $sales return $s("quantity")) }
18)

Subscribers

People subscribed via source and target branches