Merge lp:~zorba-coders/zorba/jsoniq-library-functions into lp:zorba
- jsoniq-library-functions
- Merge into trunk
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 | ||||
Related bugs: |
|
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.
Zorba Build Bot (zorba-buildbot) wrote : | # |
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/
Validation queue job jsoniq-
finished. The final status was:
1 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job jsoniq-
All tests succeeded!
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.
Till Westmann (tillw) wrote : | # |
Looks good and works for me.
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.
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job jsoniq-
All tests succeeded!
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.
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.
Ghislain Fourny (gislenius) wrote : | # |
Hi Matthias,
Thanks! I added the @error tag.
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job jsoniq-
All tests succeeded!
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.
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.
Matthias Brantner (matthias-brantner) wrote : | # |
Ghislain, could you please add the new module to the ChangeLog?
- 10988. By Ghislain Fourny
-
Updated ChangeLog.
Ghislain Fourny (gislenius) wrote : | # |
Hi Matthias, this is done.
Matthias Brantner (matthias-brantner) : | # |
- 10989. By Ghislain Fourny
-
Merged trunk back.
Preview Diff
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 | 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) |
6 | 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 |
7 | 8 | beginning of the XML document (requested in bug #1016606). | 8 | beginning of the XML document (requested in bug #1016606). |
8 | 9 | * New module http://www.jsoniq.org/modules/function-library with handy JSONiq functions. jn:object is | ||
9 | 10 | also supported. | ||
10 | 9 | 11 | ||
11 | 10 | Optimizations: | 12 | Optimizations: |
12 | 11 | * New memory management for compiler expressions (no more ref counting) | 13 | * New memory management for compiler expressions (no more ref counting) |
13 | 12 | 14 | ||
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 | 15 | IF(ZORBA_WITH_JSON) | 15 | IF(ZORBA_WITH_JSON) |
19 | 16 | DECLARE_ZORBA_MODULE(FILE functions.xq VERSION 1.0 | 16 | DECLARE_ZORBA_MODULE(FILE functions.xq VERSION 1.0 |
20 | 17 | URI "http://www.jsoniq.org/functions") | 17 | URI "http://www.jsoniq.org/functions") |
21 | 18 | DECLARE_ZORBA_MODULE(FILE function-library.xq VERSION 1.0 | ||
22 | 19 | URI "http://www.jsoniq.org/function-library") | ||
23 | 18 | DECLARE_ZORBA_MODULE (FILE pregenerated/errors.xq | 20 | DECLARE_ZORBA_MODULE (FILE pregenerated/errors.xq |
24 | 19 | URI "http://www.jsoniq.org/errors") | 21 | URI "http://www.jsoniq.org/errors") |
25 | 20 | ENDIF(ZORBA_WITH_JSON) | 22 | ENDIF(ZORBA_WITH_JSON) |
26 | 21 | 23 | ||
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 | 1 | xquery version "1.0"; | ||
32 | 2 | |||
33 | 3 | (: | ||
34 | 4 | : Copyright 2006-2012 The FLWOR Foundation. | ||
35 | 5 | : | ||
36 | 6 | : Licensed under the Apache License, Version 2.0 (the "License"); | ||
37 | 7 | : you may not use this file except in compliance with the License. | ||
38 | 8 | : You may obtain a copy of the License at | ||
39 | 9 | : | ||
40 | 10 | : http://www.apache.org/licenses/LICENSE-2.0 | ||
41 | 11 | : | ||
42 | 12 | : Unless required by applicable law or agreed to in writing, software | ||
43 | 13 | : distributed under the License is distributed on an "AS IS" BASIS, | ||
44 | 14 | : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
45 | 15 | : See the License for the specific language governing permissions and | ||
46 | 16 | : limitations under the License. | ||
47 | 17 | :) | ||
48 | 18 | |||
49 | 19 | |||
50 | 20 | (:~ | ||
51 | 21 | : This module provides the functions defined by the JSONiq specification, | ||
52 | 22 | : chapter 8 (Function Library). JSONiq extends | ||
53 | 23 | : the XQuery specification to also deal with JSON data natively. See | ||
54 | 24 | : | ||
55 | 25 | : http://www.jsoniq.org/ | ||
56 | 26 | : | ||
57 | 27 | : for details. | ||
58 | 28 | : | ||
59 | 29 | : This module depends on having the JSONiq feature enabled in Zorba, | ||
60 | 30 | : i.e., Zorba must be compiled with ZORBA_WITH_JSON. | ||
61 | 31 | : | ||
62 | 32 | : @author Ghislain Fourny | ||
63 | 33 | :) | ||
64 | 34 | module namespace libjn = "http://www.jsoniq.org/function-library"; | ||
65 | 35 | |||
66 | 36 | import module namespace jn = "http://www.jsoniq.org/functions"; | ||
67 | 37 | |||
68 | 38 | declare namespace ver = "http://www.zorba-xquery.com/options/versioning"; | ||
69 | 39 | declare option ver:module-version "1.0"; | ||
70 | 40 | |||
71 | 41 | (:~ | ||
72 | 42 | : This function dynamically builds an object, like jn:object, except that | ||
73 | 43 | : it does not throw an error upon pair collision. Instead, it aggregates them | ||
74 | 44 | : into an array. | ||
75 | 45 | : | ||
76 | 46 | : @param $o A sequence of objects. | ||
77 | 47 | : @return The accumulated object. | ||
78 | 48 | :) | ||
79 | 49 | declare function libjn:accumulate($o as object()*) as object() | ||
80 | 50 | { | ||
81 | 51 | {[ $o ]} | ||
82 | 52 | }; | ||
83 | 53 | |||
84 | 54 | (:~ | ||
85 | 55 | : This function returns all Objects contained within a JSON item, regardless of | ||
86 | 56 | : depth. | ||
87 | 57 | : | ||
88 | 58 | : @param $i A JSON item. | ||
89 | 59 | : @return Its descendant objects. | ||
90 | 60 | :) | ||
91 | 61 | declare function libjn:descendant-objects($i as json-item()) as object()* | ||
92 | 62 | { | ||
93 | 63 | if ($i instance of object()) | ||
94 | 64 | then | ||
95 | 65 | ( | ||
96 | 66 | $i, | ||
97 | 67 | for $v in libjn:values($i) | ||
98 | 68 | where $v instance of json-item() | ||
99 | 69 | return libjn:descendant-objects($v) | ||
100 | 70 | ) | ||
101 | 71 | else if ($i instance of array()) | ||
102 | 72 | then | ||
103 | 73 | ( | ||
104 | 74 | for $v in libjn:members($i) | ||
105 | 75 | where $v instance of json-item() | ||
106 | 76 | return libjn:descendant-objects($v) | ||
107 | 77 | ) | ||
108 | 78 | else | ||
109 | 79 | () | ||
110 | 80 | }; | ||
111 | 81 | |||
112 | 82 | (:~ | ||
113 | 83 | : This function returns all pairs contained within an object, recursively. | ||
114 | 84 | : | ||
115 | 85 | : @param $o An object. | ||
116 | 86 | : @return All direct and indirect descendant pairs. | ||
117 | 87 | :) | ||
118 | 88 | declare function libjn:descendant-pairs($o as object()) as object()* | ||
119 | 89 | { | ||
120 | 90 | for $k in jn:keys($o) | ||
121 | 91 | return ( | ||
122 | 92 | { $k : $o($k) }, | ||
123 | 93 | if ($o($k) instance of object()) | ||
124 | 94 | then | ||
125 | 95 | libjn:descendant-pairs($o($k)) | ||
126 | 96 | else () | ||
127 | 97 | ) | ||
128 | 98 | }; | ||
129 | 99 | |||
130 | 100 | (:~ | ||
131 | 101 | : Recursively "flatten" a JSON Array, by replacing any arrays with their | ||
132 | 102 | : members. Equivalent to | ||
133 | 103 | : | ||
134 | 104 | : define function jn:flatten($arg as array()) { | ||
135 | 105 | : for $value in jn:values($arg) | ||
136 | 106 | : return | ||
137 | 107 | : if ($value instance of array()) | ||
138 | 108 | : then jn:flatten($value) | ||
139 | 109 | : else $value | ||
140 | 110 | : }; | ||
141 | 111 | : | ||
142 | 112 | : @param $a A JSON Array. | ||
143 | 113 | : @return The flattened version of $a. | ||
144 | 114 | :) | ||
145 | 115 | declare function libjn:flatten($a as array()) as item()* | ||
146 | 116 | { | ||
147 | 117 | jn:flatten($a) | ||
148 | 118 | }; | ||
149 | 119 | |||
150 | 120 | (:~ This function returns the intersection of two objects, and aggregates | ||
151 | 121 | : values corresponding to the same name into an array. | ||
152 | 122 | : | ||
153 | 123 | : @param $o A sequence of objects. | ||
154 | 124 | : @return Their insersection. | ||
155 | 125 | :) | ||
156 | 126 | declare function libjn:intersect($o as object()*) as object() | ||
157 | 127 | { | ||
158 | 128 | {| | ||
159 | 129 | let $common-keys := jn:keys($o[1])[ every $object in $o[position() > 1] | ||
160 | 130 | satisfies jn:keys($object) = . ] | ||
161 | 131 | for $key in $common-keys | ||
162 | 132 | let $values := $o($key) | ||
163 | 133 | return | ||
164 | 134 | if (count($values) eq 1) | ||
165 | 135 | then { $key : $values } | ||
166 | 136 | else { $key : [ $values ] } | ||
167 | 137 | |} | ||
168 | 138 | }; | ||
169 | 139 | |||
170 | 140 | (:~ | ||
171 | 141 | : Returns the members of an Array. | ||
172 | 142 | : | ||
173 | 143 | : @param $a A JSON Array. | ||
174 | 144 | : @return The members of the specified array. | ||
175 | 145 | :) | ||
176 | 146 | declare function libjn:members($o as array()) as item()* | ||
177 | 147 | { | ||
178 | 148 | jn:members($o) | ||
179 | 149 | }; | ||
180 | 150 | |||
181 | 151 | (:~ | ||
182 | 152 | : Creates an object from the specified pairs of another given object. | ||
183 | 153 | : Specifically, for each name in $names, if the object $o has a pair with | ||
184 | 154 | : that name, then a copy of that pair is included in the new object. | ||
185 | 155 | : | ||
186 | 156 | : @param $o A JSON Object. | ||
187 | 157 | : @param $names The names of the pairs to copy out of $o and insert into the new object | ||
188 | 158 | : @return The new object. | ||
189 | 159 | :) | ||
190 | 160 | declare function libjn:project($o as object(), $names as xs:string*) as object() | ||
191 | 161 | { | ||
192 | 162 | jn:project($o, $names) | ||
193 | 163 | }; | ||
194 | 164 | |||
195 | 165 | (:~ | ||
196 | 166 | : This functions returns all values in an Object. | ||
197 | 167 | : @param $i An object. | ||
198 | 168 | : @return Its values. | ||
199 | 169 | :) | ||
200 | 170 | declare function libjn:values($i as object()) as item()* | ||
201 | 171 | { | ||
202 | 172 | for $k in jn:keys($i) | ||
203 | 173 | return $i($k) | ||
204 | 174 | }; | ||
205 | 0 | \ No newline at end of file | 175 | \ No newline at end of file |
206 | 1 | 176 | ||
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 | 135 | :) | 135 | :) |
212 | 136 | declare function jn:flatten($a as array()) as item()* external; | 136 | declare function jn:flatten($a as array()) as item()* external; |
213 | 137 | 137 | ||
214 | 138 | (:~ | ||
215 | 139 | : This function allows dynamic object construction by merging all | ||
216 | 140 | : its object parameters into a single object with a so-called "simple | ||
217 | 141 | : object union". A simple object union creates a new object, the pairs | ||
218 | 142 | : property of which is obtained by accumulating the pairs of all operand | ||
219 | 143 | : objects. An error jerr:JNDY0003 is raised if two pairs with the same | ||
220 | 144 | : name are encountered. | ||
221 | 145 | : | ||
222 | 146 | : @param $o A sequence of objects. | ||
223 | 147 | : | ||
224 | 148 | : @return The simple object union. | ||
225 | 149 | : | ||
226 | 150 | : @error jerr:JNDY0003 if there is a pair collision. | ||
227 | 151 | :) | ||
228 | 152 | declare function jn:object($o as object()*) as object() external; | ||
229 | 138 | 153 | ||
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 | 538 | #ifndef ZORBA_NO_FULL_TEXT | 538 | #ifndef ZORBA_NO_FULL_TEXT |
235 | 539 | ns == ZORBA_FULL_TEXT_FN_NS || | 539 | ns == ZORBA_FULL_TEXT_FN_NS || |
236 | 540 | #endif /* ZORBA_NO_FULL_TEXT */ | 540 | #endif /* ZORBA_NO_FULL_TEXT */ |
237 | 541 | #ifndef ZORBA_WITH_JSON | ||
238 | 542 | ns == JSONIQ_FN_NS || | ||
239 | 543 | #endif /* ZORBA_WITH_JSON */ | ||
240 | 541 | ns == ZORBA_XML_FN_NS); | 544 | ns == ZORBA_XML_FN_NS); |
241 | 542 | } | 545 | } |
242 | 543 | else if (ns == W3C_FN_NS || ns == XQUERY_MATH_FN_NS) | 546 | else if (ns == W3C_FN_NS || ns == XQUERY_MATH_FN_NS) |
243 | 544 | 547 | ||
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 | 18 | #include "functions/func_jsoniq_functions.h" | 18 | #include "functions/func_jsoniq_functions.h" |
249 | 19 | #include "functions/func_jsoniq_functions_impl.h" | 19 | #include "functions/func_jsoniq_functions_impl.h" |
250 | 20 | 20 | ||
251 | 21 | #include "runtime/json/json_constructors.h" | ||
252 | 21 | #include "runtime/json/jsoniq_functions.h" | 22 | #include "runtime/json/jsoniq_functions.h" |
253 | 22 | #include "runtime/json/jsoniq_functions_impl.h" | 23 | #include "runtime/json/jsoniq_functions_impl.h" |
254 | 23 | #include "runtime/core/item_iterator.h" | 24 | #include "runtime/core/item_iterator.h" |
255 | @@ -149,6 +150,20 @@ | |||
256 | 149 | } | 150 | } |
257 | 150 | 151 | ||
258 | 151 | 152 | ||
259 | 153 | /******************************************************************************* | ||
260 | 154 | |||
261 | 155 | ********************************************************************************/ | ||
262 | 156 | PlanIter_t jn_object::codegen( | ||
263 | 157 | CompilerCB*, | ||
264 | 158 | static_context* sctx, | ||
265 | 159 | const QueryLoc& loc, | ||
266 | 160 | std::vector<PlanIter_t>& argv, | ||
267 | 161 | expr& ann) const | ||
268 | 162 | { | ||
269 | 163 | return new JSONObjectIterator(sctx, loc, argv, true, false); | ||
270 | 164 | } | ||
271 | 165 | |||
272 | 166 | |||
273 | 152 | void populate_context_jsoniq_functions_impl(static_context* sctx) | 167 | void populate_context_jsoniq_functions_impl(static_context* sctx) |
274 | 153 | { | 168 | { |
275 | 154 | DECL(sctx, op_zorba_object_insert, | 169 | DECL(sctx, op_zorba_object_insert, |
276 | @@ -158,6 +173,13 @@ | |||
277 | 158 | GENV_TYPESYSTEM.JSON_OBJECT_TYPE_ONE, | 173 | GENV_TYPESYSTEM.JSON_OBJECT_TYPE_ONE, |
278 | 159 | true, | 174 | true, |
279 | 160 | GENV_TYPESYSTEM.EMPTY_TYPE)); | 175 | GENV_TYPESYSTEM.EMPTY_TYPE)); |
280 | 176 | |||
281 | 177 | DECL(sctx, jn_object, | ||
282 | 178 | (createQName("http://www.jsoniq.org/functions", | ||
283 | 179 | "", | ||
284 | 180 | "object"), | ||
285 | 181 | GENV_TYPESYSTEM.JSON_OBJECT_TYPE_STAR, | ||
286 | 182 | GENV_TYPESYSTEM.JSON_OBJECT_TYPE_ONE)); | ||
287 | 161 | } | 183 | } |
288 | 162 | 184 | ||
289 | 163 | 185 | ||
290 | 164 | 186 | ||
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 | 57 | }; | 57 | }; |
296 | 58 | 58 | ||
297 | 59 | 59 | ||
298 | 60 | class jn_object : public function | ||
299 | 61 | { | ||
300 | 62 | public: | ||
301 | 63 | jn_object(const signature& sig) | ||
302 | 64 | : | ||
303 | 65 | function(sig, FunctionConsts::JN_OBJECT_1) | ||
304 | 66 | { | ||
305 | 67 | } | ||
306 | 68 | |||
307 | 69 | bool mustCopyInputNodes(expr* fo, csize producer) const { return true; } | ||
308 | 70 | |||
309 | 71 | CODEGEN_DECL(); | ||
310 | 72 | }; | ||
311 | 73 | |||
312 | 60 | 74 | ||
313 | 61 | #endif // ZORBA_WITH_JSON | 75 | #endif // ZORBA_WITH_JSON |
314 | 62 | 76 | ||
315 | 63 | 77 | ||
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 | 230 | 230 | ||
321 | 231 | #ifdef ZORBA_WITH_JSON | 231 | #ifdef ZORBA_WITH_JSON |
322 | 232 | OP_OBJECT_INSERT_N, | 232 | OP_OBJECT_INSERT_N, |
323 | 233 | JN_OBJECT_1, | ||
324 | 233 | #endif | 234 | #endif |
325 | 234 | 235 | ||
326 | 235 | #ifndef ZORBA_NO_FULL_TEXT | 236 | #ifndef ZORBA_NO_FULL_TEXT |
327 | 236 | 237 | ||
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 | 1 | { "n1" : { "JSONiq XDM node" : "<node>10</node>" }, "n2" : { "JSONiq XDM node" : "<node>20</node>" } } | ||
334 | 0 | 2 | ||
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 | 1 | { "foo" : "bar", "bar" : { "foo" : [ 1 ] }, "foobar" : "foo" }{ "foo" : [ 1 ] } | ||
340 | 0 | 2 | ||
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 | 1 | { "foo" : "bar" }{ "bar" : { "foo" : [ 1 ] } }{ "foo" : [ 1 ] }{ "foobar" : "foo" } | ||
346 | 0 | \ No newline at end of file | 2 | \ No newline at end of file |
347 | 1 | 3 | ||
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 | 1 | { "bar" : [ { "foo" : [ 1 ] }, { "bar" : [ 2 ] }, [ "this" ] ] } | ||
353 | 0 | \ No newline at end of file | 2 | \ No newline at end of file |
354 | 1 | 3 | ||
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 | 1 | bar{ "foo" : [ 1 ] } foo | ||
360 | 0 | 2 | ||
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 | 1 | { "toaster" : 200, "blender" : 250, "shirt" : 10, "socks" : 510, "broiler" : 20 } | ||
366 | 0 | 2 | ||
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 | 1 | Serialization: method=json jsoniq-extensions=yes | ||
372 | 0 | 2 | ||
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 | 1 | import module namespace libjn = "http://www.jsoniq.org/function-library"; | ||
378 | 2 | |||
379 | 3 | declare variable $xdoc := | ||
380 | 4 | <nodes> | ||
381 | 5 | <node>10</node> | ||
382 | 6 | <node>20</node> | ||
383 | 7 | </nodes>; | ||
384 | 8 | |||
385 | 9 | variable $obj := | ||
386 | 10 | libjn:accumulate( | ||
387 | 11 | for $node at $pos in $xdoc//node | ||
388 | 12 | return { concat("n", $pos) : $node } | ||
389 | 13 | ); | ||
390 | 14 | |||
391 | 15 | $obj | ||
392 | 16 | |||
393 | 0 | 17 | ||
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 | 1 | Serialization: method=json jsoniq-multiple-items=appended | ||
399 | 0 | 2 | ||
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 | 1 | import module namespace libjn = "http://www.jsoniq.org/function-library"; | ||
405 | 2 | |||
406 | 3 | let $object := | ||
407 | 4 | { | ||
408 | 5 | "foo" : "bar", | ||
409 | 6 | "bar" : { "foo" : [1] }, | ||
410 | 7 | "foobar" : "foo" | ||
411 | 8 | } | ||
412 | 9 | return libjn:descendant-objects($object) | ||
413 | 10 | |||
414 | 0 | 11 | ||
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 | 1 | Serialization: method=json jsoniq-multiple-items=appended | ||
420 | 0 | 2 | ||
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 | 1 | import module namespace libjn = "http://www.jsoniq.org/function-library"; | ||
426 | 2 | |||
427 | 3 | let $object := | ||
428 | 4 | { | ||
429 | 5 | "foo" : "bar", | ||
430 | 6 | "bar" : { "foo" : [1] }, | ||
431 | 7 | "foobar" : "foo" | ||
432 | 8 | } | ||
433 | 9 | return libjn:descendant-pairs($object) | ||
434 | 10 | |||
435 | 0 | 11 | ||
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 | 1 | import module namespace libjn = "http://www.jsoniq.org/function-library"; | ||
441 | 2 | |||
442 | 3 | let $object := | ||
443 | 4 | { | ||
444 | 5 | "foo" : "bar", | ||
445 | 6 | "bar" : { "foo" : [1] }, | ||
446 | 7 | "foobar" : "foo" | ||
447 | 8 | } | ||
448 | 9 | let $object2 := | ||
449 | 10 | { | ||
450 | 11 | "bar" : { "bar" : [2] }, | ||
451 | 12 | "foobar" : "foo" | ||
452 | 13 | } | ||
453 | 14 | let $object3 := | ||
454 | 15 | { | ||
455 | 16 | "foo" : "bar", | ||
456 | 17 | "bar" : [ "this" ] | ||
457 | 18 | } | ||
458 | 19 | return libjn:intersect(($object, $object2, $object3)) | ||
459 | 20 | |||
460 | 0 | 21 | ||
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 | 1 | Serialization: jsoniq-allow-mixed-xdm-jdm=yes jsoniq-multiple-items=appended | ||
466 | 0 | 2 | ||
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 | 1 | import module namespace libjn = "http://www.jsoniq.org/function-library"; | ||
472 | 2 | |||
473 | 3 | let $object := | ||
474 | 4 | { | ||
475 | 5 | "foo" : "bar", | ||
476 | 6 | "bar" : { "foo" : [1] }, | ||
477 | 7 | "foobar" : "foo" | ||
478 | 8 | } | ||
479 | 9 | return libjn:values($object) | ||
480 | 10 | |||
481 | 0 | 11 | ||
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 | 1 | import module namespace jn = "http://www.jsoniq.org/functions"; | ||
487 | 2 | |||
488 | 3 | let $j := ({ "product" : "broiler", "store number" : 1, "quantity" : 20 }, | ||
489 | 4 | { "product" : "toaster", "store number" : 2, "quantity" : 100 }, | ||
490 | 5 | { "product" : "toaster", "store number" : 2, "quantity" : 50 }, | ||
491 | 6 | { "product" : "toaster", "store number" : 3, "quantity" : 50 }, | ||
492 | 7 | { "product" : "blender", "store number" : 3, "quantity" : 100 }, | ||
493 | 8 | { "product" : "blender", "store number" : 3, "quantity" : 150 }, | ||
494 | 9 | { "product" : "socks", "store number" : 1, "quantity" : 500 }, | ||
495 | 10 | { "product" : "socks", "store number" : 2, "quantity" : 10 }, | ||
496 | 11 | { "product" : "shirt", "store number" : 3, "quantity" : 10 }) | ||
497 | 12 | return | ||
498 | 13 | jn:object( | ||
499 | 14 | for $sales in $j | ||
500 | 15 | let $pname := $sales("product") | ||
501 | 16 | group by $pname | ||
502 | 17 | return { $pname : sum(for $s in $sales return $s("quantity")) } | ||
503 | 18 | ) |
Validation queue starting for merge proposal. zorbatest. lambda. nu:8080/ remotequeue/ jsoniq- library- functions- 2012-08- 13T13-33- 00.38Z/ log.html
Log at: http://