Merge lp:~zorba-coders/zorba/feature-uri_module into lp:zorba
- feature-uri_module
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Matthias Brantner |
Approved revision: | 10663 |
Merged at revision: | 10703 |
Proposed branch: | lp:~zorba-coders/zorba/feature-uri_module |
Merge into: | lp:zorba |
Diff against target: |
811 lines (+586/-0) 25 files modified
ChangeLog (+1/-0) modules/com/zorba-xquery/www/modules/CMakeLists.txt (+2/-0) modules/com/zorba-xquery/www/modules/uri.xq (+108/-0) src/context/static_context.cpp (+7/-0) src/context/static_context.h (+1/-0) src/functions/library.cpp (+2/-0) src/functions/pregenerated/func_uris.cpp (+65/-0) src/functions/pregenerated/func_uris.h (+64/-0) src/functions/pregenerated/function_enum.h (+1/-0) src/runtime/spec/mappings.xml (+4/-0) src/runtime/spec/uris/uris.xml (+40/-0) src/runtime/uris/pregenerated/uris.cpp (+66/-0) src/runtime/uris/pregenerated/uris.h (+80/-0) src/runtime/uris/uris_impl.cpp (+105/-0) src/runtime/visitors/pregenerated/planiter_visitor.h (+5/-0) src/runtime/visitors/pregenerated/printer_visitor.cpp (+15/-0) src/runtime/visitors/pregenerated/printer_visitor.h (+3/-0) test/rbkt/ExpQueryResults/zorba/uris/decode_01.xml.res (+1/-0) test/rbkt/ExpQueryResults/zorba/uris/decode_03.xml.res (+1/-0) test/rbkt/ExpQueryResults/zorba/uris/decode_04.xml.res (+1/-0) test/rbkt/Queries/zorba/uris/decode_01.xq (+3/-0) test/rbkt/Queries/zorba/uris/decode_02.spec (+1/-0) test/rbkt/Queries/zorba/uris/decode_02.xq (+3/-0) test/rbkt/Queries/zorba/uris/decode_03.xq (+4/-0) test/rbkt/Queries/zorba/uris/decode_04.xq (+3/-0) |
To merge this branch: | bzr merge lp:~zorba-coders/zorba/feature-uri_module |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Matthias Brantner | Approve | ||
Chris Hillery | Approve | ||
Review via email: mp+96005@code.launchpad.net |
This proposal supersedes a proposal from 2012-02-24.
Commit message
A new module that provides URL-related functions. Currently, it provides functions to do URL-decoding but other URL-related functions (e.g. to retrieve the scheme or path) will be added later.
Description of the change
A new module that provides URL-related functions. Currently, it provides functions to do URL-decoding but other URL-related functions (e.g. to retrieve the scheme or path) will be added later.
Matthias Brantner (matthias-brantner) : Posted in a previous version of this proposal | # |
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal | # |
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal | # |
The attempt to merge lp:~zorba-coders/zorba/feature-uri_module into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job feature-
finished. The final status was:
2 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Chris Hillery (ceejatec) wrote : Posted in a previous version of this proposal | # |
Two corrections:
- The transcode::stream is given an explicit source encoding of ISO-8859-1. Surely it should be passed lCharset?
- The XQDoc for uri:decode() says that '+' will be replaced with ' ' before percent-decoding. It is in fact done afterwards. I think actually it should be done first, as the doc says, otherwise %2B will get converted to a space which is probably not desirable.
One question: Is it guaranteed to be safe to do percent-decoding and plus-substitution regardless of the encoding of the input string? Are we presuming that since it's been percent-encoded, the input string is strictly ASCII? It may be best to note that assumption in the doc as well.
Matthias Brantner (matthias-brantner) wrote : | # |
- fixed the parameter for the transcoding stream
- changed the code such that plus-decoding is done before percent-decoding as stated in the docs
- added a note about the assumptions on the input to be ascii-only
Chris Hillery (ceejatec) wrote : | # |
Typo: "characeters" in the doc of all three uri.xq functions. Other than that, changes look good. I'll approve now so you can merge after correcting the typo.
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.
Matthias Brantner (matthias-brantner) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~zorba-coders/zorba/feature-uri_module into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job feature-
finished. The final status was:
2 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 : | # |
The attempt to merge lp:~zorba-coders/zorba/feature-uri_module into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job feature-
finished. The final status was:
2 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Chris Hillery (ceejatec) wrote : | # |
The downside of building this functionality into Zorba: In release mode, the .xq file isn't read, so the implemented-
- 10663. By Matthias Brantner
-
fix for the uri module in release module (it's non-pure virtual)
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job feature-
All tests succeeded!
Preview Diff
1 | === modified file 'ChangeLog' |
2 | --- ChangeLog 2012-03-06 00:09:14 +0000 |
3 | +++ ChangeLog 2012-03-06 01:58:21 +0000 |
4 | @@ -13,6 +13,7 @@ |
5 | * Fixed bug 917923 (bug in copying outer var values into the eval dynamic context) |
6 | * Fixed bug 867509 (Can not handle largest xs:unsignedLong values) |
7 | * Fixed bug 924063 (sentence is incorrectly incremented when token characters end without sentence terminator) |
8 | + * New URI module providing percent-decoding functions. |
9 | * Optimization: change the implementation of the free-vars annotation and got rid |
10 | of the annotations map in expressions. |
11 | * Fixed bug 909126 (bug in cloning of var_expr) |
12 | |
13 | === modified file 'modules/com/zorba-xquery/www/modules/CMakeLists.txt' |
14 | --- modules/com/zorba-xquery/www/modules/CMakeLists.txt 2012-02-16 14:11:02 +0000 |
15 | +++ modules/com/zorba-xquery/www/modules/CMakeLists.txt 2012-03-06 01:58:21 +0000 |
16 | @@ -63,6 +63,8 @@ |
17 | URI "http://www.zorba-xquery.com/modules/schema") |
18 | DECLARE_ZORBA_MODULE(FILE string.xq VERSION 2.1 |
19 | URI "http://www.zorba-xquery.com/modules/string") |
20 | +DECLARE_ZORBA_MODULE(FILE uri.xq VERSION 1.0 |
21 | + URI "http://www.zorba-xquery.com/modules/uri") |
22 | DECLARE_ZORBA_MODULE(FILE xml.xq VERSION 2.0 |
23 | URI "http://www.zorba-xquery.com/modules/xml") |
24 | DECLARE_ZORBA_MODULE(FILE xqdoc.xq VERSION 2.0 |
25 | |
26 | === added file 'modules/com/zorba-xquery/www/modules/uri.xq' |
27 | --- modules/com/zorba-xquery/www/modules/uri.xq 1970-01-01 00:00:00 +0000 |
28 | +++ modules/com/zorba-xquery/www/modules/uri.xq 2012-03-06 01:58:21 +0000 |
29 | @@ -0,0 +1,108 @@ |
30 | +xquery version "1.0"; |
31 | + |
32 | +(: |
33 | + : Copyright 2006-2012 The FLWOR Foundation. |
34 | + : |
35 | + : Licensed under the Apache License, Version 2.0 (the "License"); |
36 | + : you may not use this file except in compliance with the License. |
37 | + : You may obtain a copy of the License at |
38 | + : |
39 | + : http://www.apache.org/licenses/LICENSE-2.0 |
40 | + : |
41 | + : Unless required by applicable law or agreed to in writing, software |
42 | + : distributed under the License is distributed on an "AS IS" BASIS, |
43 | + : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
44 | + : See the License for the specific language governing permissions and |
45 | + : limitations under the License. |
46 | +:) |
47 | + |
48 | +(:~ |
49 | + : This module provides string related functions. |
50 | + : |
51 | + : @author Matthias Brantner |
52 | + : @project XDM/atomic |
53 | + : |
54 | + :) |
55 | +module namespace uri = "http://www.zorba-xquery.com/modules/uri"; |
56 | + |
57 | +declare namespace zerr = "http://www.zorba-xquery.com/errors"; |
58 | + |
59 | +declare namespace ver = "http://www.zorba-xquery.com/options/versioning"; |
60 | +declare option ver:module-version "1.0"; |
61 | + |
62 | +(:~ |
63 | + : Percent-decodes (aka URL decoding) the given string. |
64 | + : |
65 | + : All percent encoded octets will be translated into their |
66 | + : decoded UTF-8 representation. |
67 | + : |
68 | + : Please note that the percent encoding guarantees that a string |
69 | + : consists of ASCII characters only. Passing a string that contains |
70 | + : non-ASCII characters results in undefined behavior. |
71 | + : |
72 | + : @param $s the string to decode |
73 | + : |
74 | + : @return the percent decoded string |
75 | + :) |
76 | +declare function uri:decode($u as xs:string) as xs:string |
77 | +{ |
78 | + uri:decode($u, fn:false()) |
79 | +}; |
80 | + |
81 | +(:~ |
82 | + : Percent-decodes (aka URL decoding) the given string. |
83 | + : |
84 | + : All percent encoded octets will be translated into their |
85 | + : decoded UTF-8 representation. |
86 | + : |
87 | + : If $decode-plus is specified all occurrences of the char '+' |
88 | + : will be replaced with a space ' ' before the percent decoding |
89 | + : happens. |
90 | + : |
91 | + : Please note that the percent encoding guarantees that a string |
92 | + : consists of ASCII characters only. Passing a string that contains |
93 | + : non-ASCII characters results in undefined behavior. |
94 | + : |
95 | + : @param $s the string to decode |
96 | + : @param $decode-plus whether '+' chars will be replaced with spaces |
97 | + : |
98 | + : @return the percent decoded string |
99 | + :) |
100 | +declare function uri:decode( |
101 | + $u as xs:string, |
102 | + $decode-plus as xs:boolean) as xs:string |
103 | +{ |
104 | + uri:decode($u, $decode-plus, "UTF-8") |
105 | +}; |
106 | + |
107 | +(:~ |
108 | + : Percent-decodes (aka URL decoding) the given string. |
109 | + : |
110 | + : All percent encoded octets will be translated into their |
111 | + : decoded UTF-8 representation. |
112 | + : |
113 | + : If $decode-plus is specified all occurrences of the char '+' |
114 | + : will be replaced with a space ' ' before the percent decoding |
115 | + : happens. |
116 | + : |
117 | + : The $charset parameter specifies the source charset after precent |
118 | + : decoding. It is used to convert the decoded string into UTF-8. |
119 | + : |
120 | + : Please note that the percent encoding guarantees that a string |
121 | + : consists of ASCII characters only. Passing a string that contains |
122 | + : non-ASCII characters results in undefined behavior. |
123 | + : |
124 | + : @param $s the string to decode |
125 | + : @param $decode-plus whether '+' chars will be replaced with spaces |
126 | + : @param $charset the source charset of the string after percent decoding |
127 | + : |
128 | + : @return the percent decoded string |
129 | + : |
130 | + : @error zerr:ZXQP0006 if the given charset is unknown or not supported |
131 | + : |
132 | + : @error zerr:ZOSE0006 if there is an error transcoding the string |
133 | + :) |
134 | +declare function uri:decode( |
135 | + $s as xs:string, |
136 | + $decode-plus as xs:boolean, |
137 | + $charset as xs:string) as xs:string external; |
138 | |
139 | === modified file 'src/context/static_context.cpp' |
140 | --- src/context/static_context.cpp 2012-02-16 14:11:02 +0000 |
141 | +++ src/context/static_context.cpp 2012-03-06 01:58:21 +0000 |
142 | @@ -366,6 +366,10 @@ |
143 | "http://www.zorba-xquery.com/modules/string"; |
144 | |
145 | const char* |
146 | +static_context::ZORBA_URI_FN_NS = |
147 | +"http://www.zorba-xquery.com/modules/uri"; |
148 | + |
149 | +const char* |
150 | static_context::ZORBA_FETCH_FN_NS = |
151 | "http://www.zorba-xquery.com/modules/fetch"; |
152 | |
153 | @@ -441,6 +445,7 @@ |
154 | ns == ZORBA_REFLECTION_FN_NS || |
155 | ns == ZORBA_SCRIPTING_FN_NS || |
156 | ns == ZORBA_STRING_FN_NS || |
157 | + ns == ZORBA_URI_FN_NS || |
158 | ns == ZORBA_JSON_FN_NS || |
159 | ns == ZORBA_FETCH_FN_NS || |
160 | ns == ZORBA_NODE_FN_NS || |
161 | @@ -488,7 +493,9 @@ |
162 | { |
163 | return (ns == ZORBA_MATH_FN_NS || |
164 | ns == ZORBA_INTROSP_SCTX_FN_NS || |
165 | + ns == ZORBA_STRING_FN_NS || |
166 | ns == ZORBA_JSON_FN_NS || |
167 | + ns == ZORBA_URI_FN_NS || |
168 | ns == ZORBA_RANDOM_FN_NS); |
169 | } |
170 | |
171 | |
172 | === modified file 'src/context/static_context.h' |
173 | --- src/context/static_context.h 2012-02-16 14:11:02 +0000 |
174 | +++ src/context/static_context.h 2012-03-06 01:58:21 +0000 |
175 | @@ -465,6 +465,7 @@ |
176 | static const char* ZORBA_INTROSP_SCTX_FN_NS; |
177 | static const char* ZORBA_REFLECTION_FN_NS; |
178 | static const char* ZORBA_STRING_FN_NS; |
179 | + static const char* ZORBA_URI_FN_NS; |
180 | static const char* ZORBA_FETCH_FN_NS; |
181 | static const char* ZORBA_NODE_FN_NS; |
182 | static const char* ZORBA_XML_FN_NS; |
183 | |
184 | === modified file 'src/functions/library.cpp' |
185 | --- src/functions/library.cpp 2012-02-16 14:11:02 +0000 |
186 | +++ src/functions/library.cpp 2012-03-06 01:58:21 +0000 |
187 | @@ -57,6 +57,7 @@ |
188 | #include "functions/func_sequences.h" |
189 | #include "functions/func_sequences_impl.h" |
190 | #include "functions/func_strings.h" |
191 | +#include "functions/func_uris.h" |
192 | #include "functions/func_json.h" |
193 | #include "functions/func_var_decl.h" |
194 | #include "functions/func_xqdoc.h" |
195 | @@ -121,6 +122,7 @@ |
196 | populate_context_schema(sctx); |
197 | populate_context_sctx(sctx); |
198 | populate_context_strings(sctx); |
199 | + populate_context_uris(sctx); |
200 | populate_context_sequences(sctx); |
201 | populate_context_sequences_impl(sctx); |
202 | populate_context_xqdoc(sctx); |
203 | |
204 | === added file 'src/functions/pregenerated/func_uris.cpp' |
205 | --- src/functions/pregenerated/func_uris.cpp 1970-01-01 00:00:00 +0000 |
206 | +++ src/functions/pregenerated/func_uris.cpp 2012-03-06 01:58:21 +0000 |
207 | @@ -0,0 +1,65 @@ |
208 | +/* |
209 | + * Copyright 2006-2008 The FLWOR Foundation. |
210 | + * |
211 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
212 | + * you may not use this file except in compliance with the License. |
213 | + * You may obtain a copy of the License at |
214 | + * |
215 | + * http://www.apache.org/licenses/LICENSE-2.0 |
216 | + * |
217 | + * Unless required by applicable law or agreed to in writing, software |
218 | + * distributed under the License is distributed on an "AS IS" BASIS, |
219 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
220 | + * See the License for the specific language governing permissions and |
221 | + * limitations under the License. |
222 | + */ |
223 | + |
224 | +// ****************************************** |
225 | +// * * |
226 | +// * THIS IS A GENERATED FILE. DO NOT EDIT! * |
227 | +// * SEE .xml FILE WITH SAME NAME * |
228 | +// * * |
229 | +// ****************************************** |
230 | + |
231 | + |
232 | +#include "stdafx.h" |
233 | +#include "runtime/uris/uris.h" |
234 | +#include "functions/func_uris.h" |
235 | + |
236 | + |
237 | +namespace zorba{ |
238 | + |
239 | + |
240 | + |
241 | +PlanIter_t fn_zorba_uri_decode::codegen( |
242 | + CompilerCB*, |
243 | + static_context* sctx, |
244 | + const QueryLoc& loc, |
245 | + std::vector<PlanIter_t>& argv, |
246 | + expr& ann) const |
247 | +{ |
248 | + return new DecodeURIIterator(sctx, loc, argv); |
249 | +} |
250 | + |
251 | +void populate_context_uris(static_context* sctx) |
252 | +{ |
253 | + { |
254 | + |
255 | + |
256 | + DECL_WITH_KIND(sctx, fn_zorba_uri_decode, |
257 | + (createQName("http://www.zorba-xquery.com/modules/uri","","decode"), |
258 | + GENV_TYPESYSTEM.STRING_TYPE_ONE, |
259 | + GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE, |
260 | + GENV_TYPESYSTEM.STRING_TYPE_ONE, |
261 | + GENV_TYPESYSTEM.STRING_TYPE_ONE), |
262 | + FunctionConsts::FN_ZORBA_URI_DECODE_3); |
263 | + |
264 | + } |
265 | + |
266 | +} |
267 | + |
268 | + |
269 | +} |
270 | + |
271 | + |
272 | + |
273 | |
274 | === added file 'src/functions/pregenerated/func_uris.h' |
275 | --- src/functions/pregenerated/func_uris.h 1970-01-01 00:00:00 +0000 |
276 | +++ src/functions/pregenerated/func_uris.h 2012-03-06 01:58:21 +0000 |
277 | @@ -0,0 +1,64 @@ |
278 | +/* |
279 | + * Copyright 2006-2008 The FLWOR Foundation. |
280 | + * |
281 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
282 | + * you may not use this file except in compliance with the License. |
283 | + * You may obtain a copy of the License at |
284 | + * |
285 | + * http://www.apache.org/licenses/LICENSE-2.0 |
286 | + * |
287 | + * Unless required by applicable law or agreed to in writing, software |
288 | + * distributed under the License is distributed on an "AS IS" BASIS, |
289 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
290 | + * See the License for the specific language governing permissions and |
291 | + * limitations under the License. |
292 | + */ |
293 | + |
294 | +// ****************************************** |
295 | +// * * |
296 | +// * THIS IS A GENERATED FILE. DO NOT EDIT! * |
297 | +// * SEE .xml FILE WITH SAME NAME * |
298 | +// * * |
299 | +// ****************************************** |
300 | + |
301 | + |
302 | +#ifndef ZORBA_FUNCTIONS_URIS_H |
303 | +#define ZORBA_FUNCTIONS_URIS_H |
304 | + |
305 | + |
306 | +#include "common/shared_types.h" |
307 | +#include "functions/function_impl.h" |
308 | + |
309 | + |
310 | +namespace zorba { |
311 | + |
312 | + |
313 | +void populate_context_uris(static_context* sctx); |
314 | + |
315 | + |
316 | + |
317 | + |
318 | +//fn-zorba-uri:decode |
319 | +class fn_zorba_uri_decode : public function |
320 | +{ |
321 | +public: |
322 | + fn_zorba_uri_decode(const signature& sig, FunctionConsts::FunctionKind kind) |
323 | + : |
324 | + function(sig, kind) |
325 | + { |
326 | + |
327 | + } |
328 | + |
329 | + CODEGEN_DECL(); |
330 | +}; |
331 | + |
332 | + |
333 | +} //namespace zorba |
334 | + |
335 | + |
336 | +#endif |
337 | +/* |
338 | + * Local variables: |
339 | + * mode: c++ |
340 | + * End: |
341 | + */ |
342 | |
343 | === modified file 'src/functions/pregenerated/function_enum.h' |
344 | --- src/functions/pregenerated/function_enum.h 2012-02-16 14:11:02 +0000 |
345 | +++ src/functions/pregenerated/function_enum.h 2012-03-06 01:58:21 +0000 |
346 | @@ -374,6 +374,7 @@ |
347 | FN_ZORBA_STRING_MATERIALIZE_1, |
348 | FN_ZORBA_STRING_IS_STREAMABLE_1, |
349 | FN_ZORBA_STRING_SPLIT_2, |
350 | + FN_ZORBA_URI_DECODE_3, |
351 | FN_ZORBA_XQDOC_XQDOC_1, |
352 | FN_ZORBA_XQDOC_XQDOC_CONTENT_1, |
353 | |
354 | |
355 | === modified file 'src/runtime/spec/mappings.xml' |
356 | --- src/runtime/spec/mappings.xml 2012-02-16 14:11:02 +0000 |
357 | +++ src/runtime/spec/mappings.xml 2012-03-06 01:58:21 +0000 |
358 | @@ -106,6 +106,10 @@ |
359 | define="ZORBA_STRING_FN_NS" |
360 | prefix="fn-zorba-string"/> |
361 | |
362 | + <zorba:namespace uri="http://www.zorba-xquery.com/modules/uri" |
363 | + define="ZORBA_URI_FN_NS" |
364 | + prefix="fn-zorba-uri"/> |
365 | + |
366 | <zorba:namespace uri="http://www.zorba-xquery.com/modules/converters/json" |
367 | define="ZORBA_JSON_FN_NS" |
368 | prefix="fn-zorba-json"/> |
369 | |
370 | === added directory 'src/runtime/spec/uris' |
371 | === added file 'src/runtime/spec/uris/uris.xml' |
372 | --- src/runtime/spec/uris/uris.xml 1970-01-01 00:00:00 +0000 |
373 | +++ src/runtime/spec/uris/uris.xml 2012-03-06 01:58:21 +0000 |
374 | @@ -0,0 +1,40 @@ |
375 | +<?xml version="1.0" encoding="UTF-8"?> |
376 | + |
377 | +<!-- |
378 | +///////////////////////////////////////////////////////////////////////////////// |
379 | +// // |
380 | +// 7.2 Functions to Assemble and Disassemble Strings |
381 | +// // |
382 | +///////////////////////////////////////////////////////////////////////////////// |
383 | +--> |
384 | +<zorba:iterators |
385 | + xmlns:zorba="http://www.zorba-xquery.com" |
386 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
387 | + xsi:schemaLocation="http://www.zorba-xquery.com ../runtime.xsd"> |
388 | + |
389 | +<zorba:header> |
390 | + <zorba:include form="Quoted">zorbautils/checked_vector.h</zorba:include> |
391 | + <zorba:include form="Quoted">zorbatypes/schema_types.h</zorba:include> |
392 | +</zorba:header> |
393 | + |
394 | +<!-- |
395 | +/******************************************************************************* |
396 | +********************************************************************************/ |
397 | +--> |
398 | +<zorba:iterator name="DecodeURIIterator"> |
399 | + |
400 | + <zorba:description author="Zorba Team"> |
401 | + uri:decode |
402 | + </zorba:description> |
403 | + |
404 | + <zorba:function> |
405 | + <zorba:signature localname="decode" prefix="fn-zorba-uri"> |
406 | + <zorba:param>xs:string</zorba:param> |
407 | + <zorba:param>xs:boolean</zorba:param> |
408 | + <zorba:param>xs:string</zorba:param> |
409 | + <zorba:output>xs:string</zorba:output> |
410 | + </zorba:signature> |
411 | + </zorba:function> |
412 | +</zorba:iterator> |
413 | + |
414 | +</zorba:iterators> |
415 | |
416 | === added directory 'src/runtime/uris' |
417 | === added directory 'src/runtime/uris/pregenerated' |
418 | === added file 'src/runtime/uris/pregenerated/uris.cpp' |
419 | --- src/runtime/uris/pregenerated/uris.cpp 1970-01-01 00:00:00 +0000 |
420 | +++ src/runtime/uris/pregenerated/uris.cpp 2012-03-06 01:58:21 +0000 |
421 | @@ -0,0 +1,66 @@ |
422 | +/* |
423 | + * Copyright 2006-2008 The FLWOR Foundation. |
424 | + * |
425 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
426 | + * you may not use this file except in compliance with the License. |
427 | + * You may obtain a copy of the License at |
428 | + * |
429 | + * http://www.apache.org/licenses/LICENSE-2.0 |
430 | + * |
431 | + * Unless required by applicable law or agreed to in writing, software |
432 | + * distributed under the License is distributed on an "AS IS" BASIS, |
433 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
434 | + * See the License for the specific language governing permissions and |
435 | + * limitations under the License. |
436 | + */ |
437 | + |
438 | +// ****************************************** |
439 | +// * * |
440 | +// * THIS IS A GENERATED FILE. DO NOT EDIT! * |
441 | +// * SEE .xml FILE WITH SAME NAME * |
442 | +// * * |
443 | +// ****************************************** |
444 | + |
445 | +#include "stdafx.h" |
446 | +#include "zorbatypes/rchandle.h" |
447 | +#include "zorbatypes/zstring.h" |
448 | +#include "runtime/visitors/planiter_visitor.h" |
449 | +#include "runtime/uris/uris.h" |
450 | +#include "system/globalenv.h" |
451 | + |
452 | + |
453 | + |
454 | +namespace zorba { |
455 | + |
456 | +// <DecodeURIIterator> |
457 | +const char* DecodeURIIterator::class_name_str = "DecodeURIIterator"; |
458 | +DecodeURIIterator::class_factory<DecodeURIIterator> |
459 | +DecodeURIIterator::g_class_factory; |
460 | + |
461 | +const serialization::ClassVersion |
462 | +DecodeURIIterator::class_versions[] ={{ 1, 0x000905, false}}; |
463 | + |
464 | +const int DecodeURIIterator::class_versions_count = |
465 | +sizeof(DecodeURIIterator::class_versions)/sizeof(struct serialization::ClassVersion); |
466 | + |
467 | +void DecodeURIIterator::accept(PlanIterVisitor& v) const { |
468 | + v.beginVisit(*this); |
469 | + |
470 | + std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin(); |
471 | + std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end(); |
472 | + for ( ; lIter != lEnd; ++lIter ){ |
473 | + (*lIter)->accept(v); |
474 | + } |
475 | + |
476 | + v.endVisit(*this); |
477 | +} |
478 | + |
479 | +DecodeURIIterator::~DecodeURIIterator() {} |
480 | + |
481 | +// </DecodeURIIterator> |
482 | + |
483 | + |
484 | + |
485 | +} |
486 | + |
487 | + |
488 | |
489 | === added file 'src/runtime/uris/pregenerated/uris.h' |
490 | --- src/runtime/uris/pregenerated/uris.h 1970-01-01 00:00:00 +0000 |
491 | +++ src/runtime/uris/pregenerated/uris.h 2012-03-06 01:58:21 +0000 |
492 | @@ -0,0 +1,80 @@ |
493 | +/* |
494 | + * Copyright 2006-2008 The FLWOR Foundation. |
495 | + * |
496 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
497 | + * you may not use this file except in compliance with the License. |
498 | + * You may obtain a copy of the License at |
499 | + * |
500 | + * http://www.apache.org/licenses/LICENSE-2.0 |
501 | + * |
502 | + * Unless required by applicable law or agreed to in writing, software |
503 | + * distributed under the License is distributed on an "AS IS" BASIS, |
504 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
505 | + * See the License for the specific language governing permissions and |
506 | + * limitations under the License. |
507 | + */ |
508 | + |
509 | +// ****************************************** |
510 | +// * * |
511 | +// * THIS IS A GENERATED FILE. DO NOT EDIT! * |
512 | +// * SEE .xml FILE WITH SAME NAME * |
513 | +// * * |
514 | +// ****************************************** |
515 | +#ifndef ZORBA_RUNTIME_URIS_URIS_H |
516 | +#define ZORBA_RUNTIME_URIS_URIS_H |
517 | + |
518 | + |
519 | +#include "common/shared_types.h" |
520 | + |
521 | + |
522 | + |
523 | +#include "runtime/base/narybase.h" |
524 | +#include "zorbautils/checked_vector.h" |
525 | +#include "zorbatypes/schema_types.h" |
526 | + |
527 | + |
528 | +namespace zorba { |
529 | + |
530 | +/** |
531 | + * |
532 | + * uri:decode |
533 | + * |
534 | + * Author: Zorba Team |
535 | + */ |
536 | +class DecodeURIIterator : public NaryBaseIterator<DecodeURIIterator, PlanIteratorState> |
537 | +{ |
538 | +public: |
539 | + SERIALIZABLE_CLASS(DecodeURIIterator); |
540 | + |
541 | + SERIALIZABLE_CLASS_CONSTRUCTOR2T(DecodeURIIterator, |
542 | + NaryBaseIterator<DecodeURIIterator, PlanIteratorState>); |
543 | + |
544 | + void serialize( ::zorba::serialization::Archiver& ar) |
545 | + { |
546 | + serialize_baseclass(ar, |
547 | + (NaryBaseIterator<DecodeURIIterator, PlanIteratorState>*)this); |
548 | + } |
549 | + |
550 | + DecodeURIIterator( |
551 | + static_context* sctx, |
552 | + const QueryLoc& loc, |
553 | + std::vector<PlanIter_t>& children) |
554 | + : |
555 | + NaryBaseIterator<DecodeURIIterator, PlanIteratorState>(sctx, loc, children) |
556 | + {} |
557 | + |
558 | + virtual ~DecodeURIIterator(); |
559 | + |
560 | + void accept(PlanIterVisitor& v) const; |
561 | + |
562 | + bool nextImpl(store::Item_t& result, PlanState& aPlanState) const; |
563 | +}; |
564 | + |
565 | + |
566 | +} |
567 | +#endif |
568 | +/* |
569 | + * Local variables: |
570 | + * mode: c++ |
571 | + * End: |
572 | + */ |
573 | |
574 | === added file 'src/runtime/uris/uris_impl.cpp' |
575 | --- src/runtime/uris/uris_impl.cpp 1970-01-01 00:00:00 +0000 |
576 | +++ src/runtime/uris/uris_impl.cpp 2012-03-06 01:58:21 +0000 |
577 | @@ -0,0 +1,105 @@ |
578 | +/* |
579 | + * Copyright 2006-2012 The FLWOR Foundation. |
580 | + * |
581 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
582 | + * you may not use this file except in compliance with the License. |
583 | + * You may obtain a copy of the License at |
584 | + * |
585 | + * http://www.apache.org/licenses/LICENSE-2.0 |
586 | + * |
587 | + * Unless required by applicable law or agreed to in writing, software |
588 | + * distributed under the License is distributed on an "AS IS" BASIS, |
589 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
590 | + * See the License for the specific language governing permissions and |
591 | + * limitations under the License. |
592 | + */ |
593 | +#include "stdafx.h" |
594 | + |
595 | +#include <algorithm> |
596 | + |
597 | +#include "common/common.h" |
598 | + |
599 | +#include "diagnostics/assert.h" |
600 | +#include "diagnostics/xquery_diagnostics.h" |
601 | +#include "diagnostics/util_macros.h" |
602 | + |
603 | +#include "runtime/uris/uris.h" |
604 | + |
605 | +#include "system/globalenv.h" |
606 | +#include "store/api/item_factory.h" |
607 | + |
608 | +#include "zorba/transcode_stream.h" |
609 | + |
610 | +#include "util/uri_util.h" |
611 | + |
612 | +using namespace std; |
613 | + |
614 | +namespace zorba { |
615 | + |
616 | +/****************************************************************************** |
617 | +*******************************************************************************/ |
618 | +bool |
619 | +DecodeURIIterator::nextImpl(store::Item_t& result, PlanState& planState) const |
620 | +{ |
621 | + store::Item_t lString, lDecodePlus, lEncoding; |
622 | + zstring lDecodedString, lCharset; |
623 | + |
624 | + PlanIteratorState* state; |
625 | + DEFAULT_STACK_INIT(PlanIteratorState, state, planState); |
626 | + |
627 | + consumeNext(lString, theChildren[0].getp(), planState); |
628 | + consumeNext(lDecodePlus, theChildren[1].getp(), planState); |
629 | + consumeNext(lEncoding, theChildren[2].getp(), planState); |
630 | + |
631 | + lString->getStringValue2(lDecodedString); |
632 | + lEncoding->getStringValue2(lCharset); |
633 | + |
634 | + if (lDecodePlus->getBooleanValue()) |
635 | + { |
636 | + std::replace( lDecodedString.begin(), lDecodedString.end(), '+', ' ' ); |
637 | + } |
638 | + |
639 | + uri::decode(lDecodedString); |
640 | + |
641 | + if (transcode::is_necessary(lCharset.c_str())) |
642 | + { |
643 | + if (!transcode::is_supported(lCharset.c_str())) |
644 | + { |
645 | + throw XQUERY_EXCEPTION( |
646 | + zerr::ZXQP0006_UNKNOWN_ENCODING, |
647 | + ERROR_PARAMS( lCharset ), |
648 | + ERROR_LOC( loc ) |
649 | + ); |
650 | + } |
651 | + |
652 | + try |
653 | + { |
654 | + transcode::stream<istringstream> lTranscoder( |
655 | + lCharset.c_str(), |
656 | + lDecodedString.c_str() |
657 | + ); |
658 | + |
659 | + lDecodedString.clear(); |
660 | + char buf[1024]; |
661 | + while (lTranscoder.good()) |
662 | + { |
663 | + lTranscoder.read(buf, 1024); |
664 | + lDecodedString.append(buf, lTranscoder.gcount()); |
665 | + } |
666 | + } |
667 | + catch (ZorbaException& e) |
668 | + { |
669 | + throw XQUERY_EXCEPTION( |
670 | + zerr::ZOSE0006_TRANSCODING_ERROR, |
671 | + ERROR_PARAMS( e.what() ), |
672 | + ERROR_LOC( loc ) |
673 | + ); |
674 | + } |
675 | + } |
676 | + |
677 | + STACK_PUSH(GENV_ITEMFACTORY->createString(result, lDecodedString), state ); |
678 | + |
679 | + STACK_END (state); |
680 | +} |
681 | +} // namespace zorba |
682 | +/* vim:set et sw=2 ts=2: */ |
683 | |
684 | === modified file 'src/runtime/visitors/pregenerated/planiter_visitor.h' |
685 | --- src/runtime/visitors/pregenerated/planiter_visitor.h 2012-02-16 14:11:02 +0000 |
686 | +++ src/runtime/visitors/pregenerated/planiter_visitor.h 2012-03-06 01:58:21 +0000 |
687 | @@ -588,6 +588,8 @@ |
688 | |
689 | class StringSplitIterator; |
690 | |
691 | + class DecodeURIIterator; |
692 | + |
693 | class XQDocIterator; |
694 | |
695 | class XQDocContentIterator; |
696 | @@ -1438,6 +1440,9 @@ |
697 | virtual void beginVisit ( const StringSplitIterator& ) = 0; |
698 | virtual void endVisit ( const StringSplitIterator& ) = 0; |
699 | |
700 | + virtual void beginVisit ( const DecodeURIIterator& ) = 0; |
701 | + virtual void endVisit ( const DecodeURIIterator& ) = 0; |
702 | + |
703 | virtual void beginVisit ( const XQDocIterator& ) = 0; |
704 | virtual void endVisit ( const XQDocIterator& ) = 0; |
705 | |
706 | |
707 | === modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp' |
708 | --- src/runtime/visitors/pregenerated/printer_visitor.cpp 2012-02-16 14:11:02 +0000 |
709 | +++ src/runtime/visitors/pregenerated/printer_visitor.cpp 2012-03-06 01:58:21 +0000 |
710 | @@ -64,6 +64,7 @@ |
711 | #include "runtime/store/documents.h" |
712 | #include "runtime/store/maps.h" |
713 | #include "runtime/strings/strings.h" |
714 | +#include "runtime/uris/uris.h" |
715 | #include "runtime/xqdoc/xqdoc.h" |
716 | |
717 | namespace zorba{ |
718 | @@ -4004,6 +4005,20 @@ |
719 | // </StringSplitIterator> |
720 | |
721 | |
722 | +// <DecodeURIIterator> |
723 | +void PrinterVisitor::beginVisit ( const DecodeURIIterator& a) { |
724 | + thePrinter.startBeginVisit("DecodeURIIterator", ++theId); |
725 | + printCommons( &a, theId ); |
726 | + thePrinter.endBeginVisit( theId ); |
727 | +} |
728 | + |
729 | +void PrinterVisitor::endVisit ( const DecodeURIIterator& ) { |
730 | + thePrinter.startEndVisit(); |
731 | + thePrinter.endEndVisit(); |
732 | +} |
733 | +// </DecodeURIIterator> |
734 | + |
735 | + |
736 | // <XQDocIterator> |
737 | void PrinterVisitor::beginVisit ( const XQDocIterator& a) { |
738 | thePrinter.startBeginVisit("XQDocIterator", ++theId); |
739 | |
740 | === modified file 'src/runtime/visitors/pregenerated/printer_visitor.h' |
741 | --- src/runtime/visitors/pregenerated/printer_visitor.h 2012-02-16 14:11:02 +0000 |
742 | +++ src/runtime/visitors/pregenerated/printer_visitor.h 2012-03-06 01:58:21 +0000 |
743 | @@ -885,6 +885,9 @@ |
744 | void beginVisit( const StringSplitIterator& ); |
745 | void endVisit ( const StringSplitIterator& ); |
746 | |
747 | + void beginVisit( const DecodeURIIterator& ); |
748 | + void endVisit ( const DecodeURIIterator& ); |
749 | + |
750 | void beginVisit( const XQDocIterator& ); |
751 | void endVisit ( const XQDocIterator& ); |
752 | |
753 | |
754 | === added directory 'test/rbkt/ExpQueryResults/zorba/uris' |
755 | === added file 'test/rbkt/ExpQueryResults/zorba/uris/decode_01.xml.res' |
756 | --- test/rbkt/ExpQueryResults/zorba/uris/decode_01.xml.res 1970-01-01 00:00:00 +0000 |
757 | +++ test/rbkt/ExpQueryResults/zorba/uris/decode_01.xml.res 2012-03-06 01:58:21 +0000 |
758 | @@ -0,0 +1,1 @@ |
759 | +foo=ä¥FÅõ |
760 | |
761 | === added file 'test/rbkt/ExpQueryResults/zorba/uris/decode_03.xml.res' |
762 | --- test/rbkt/ExpQueryResults/zorba/uris/decode_03.xml.res 1970-01-01 00:00:00 +0000 |
763 | +++ test/rbkt/ExpQueryResults/zorba/uris/decode_03.xml.res 2012-03-06 01:58:21 +0000 |
764 | @@ -0,0 +1,1 @@ |
765 | +ä¨bcö |
766 | |
767 | === added file 'test/rbkt/ExpQueryResults/zorba/uris/decode_04.xml.res' |
768 | --- test/rbkt/ExpQueryResults/zorba/uris/decode_04.xml.res 1970-01-01 00:00:00 +0000 |
769 | +++ test/rbkt/ExpQueryResults/zorba/uris/decode_04.xml.res 2012-03-06 01:58:21 +0000 |
770 | @@ -0,0 +1,1 @@ |
771 | +äö ü |
772 | |
773 | === added directory 'test/rbkt/Queries/zorba/uris' |
774 | === added file 'test/rbkt/Queries/zorba/uris/decode_01.xq' |
775 | --- test/rbkt/Queries/zorba/uris/decode_01.xq 1970-01-01 00:00:00 +0000 |
776 | +++ test/rbkt/Queries/zorba/uris/decode_01.xq 2012-03-06 01:58:21 +0000 |
777 | @@ -0,0 +1,3 @@ |
778 | +import module namespace u = "http://www.zorba-xquery.com/modules/uri"; |
779 | + |
780 | +u:decode("foo=%E4%A5F%C5%F5", fn:false(), "ISO-8859-1") |
781 | |
782 | === added file 'test/rbkt/Queries/zorba/uris/decode_02.spec' |
783 | --- test/rbkt/Queries/zorba/uris/decode_02.spec 1970-01-01 00:00:00 +0000 |
784 | +++ test/rbkt/Queries/zorba/uris/decode_02.spec 2012-03-06 01:58:21 +0000 |
785 | @@ -0,0 +1,1 @@ |
786 | +Error: http://www.zorba-xquery.com/errors:ZXQP0006 |
787 | |
788 | === added file 'test/rbkt/Queries/zorba/uris/decode_02.xq' |
789 | --- test/rbkt/Queries/zorba/uris/decode_02.xq 1970-01-01 00:00:00 +0000 |
790 | +++ test/rbkt/Queries/zorba/uris/decode_02.xq 2012-03-06 01:58:21 +0000 |
791 | @@ -0,0 +1,3 @@ |
792 | +import module namespace u = "http://www.zorba-xquery.com/modules/uri"; |
793 | + |
794 | +u:decode("foo=%E4%A5F%C5%F5", fn:false(), "foo") |
795 | |
796 | === added file 'test/rbkt/Queries/zorba/uris/decode_03.xq' |
797 | --- test/rbkt/Queries/zorba/uris/decode_03.xq 1970-01-01 00:00:00 +0000 |
798 | +++ test/rbkt/Queries/zorba/uris/decode_03.xq 2012-03-06 01:58:21 +0000 |
799 | @@ -0,0 +1,4 @@ |
800 | +import module namespace u = "http://www.zorba-xquery.com/modules/uri"; |
801 | + |
802 | +u:decode("%C3%A4%C2%A8bc%C3%B6", fn:false()) |
803 | + |
804 | |
805 | === added file 'test/rbkt/Queries/zorba/uris/decode_04.xq' |
806 | --- test/rbkt/Queries/zorba/uris/decode_04.xq 1970-01-01 00:00:00 +0000 |
807 | +++ test/rbkt/Queries/zorba/uris/decode_04.xq 2012-03-06 01:58:21 +0000 |
808 | @@ -0,0 +1,3 @@ |
809 | +import module namespace u = "http://www.zorba-xquery.com/modules/uri"; |
810 | + |
811 | +u:decode("%C3%A4%C3%B6+%C3%BC", fn:true()) |
Validation queue starting for merge proposal. zorbatest. lambda. nu:8080/ remotequeue/ feature- uri_module- 2012-02- 24T03-31- 06.652Z/ log.html
Log at: http://