Merge lp:~zorba-coders/zorba/feature-uri_module into lp:zorba

Proposed by Matthias Brantner
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
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.

To post a comment you must log in.
Revision history for this message
Matthias Brantner (matthias-brantner) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal
Revision history for this message
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/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job feature-uri_module-2012-02-24T03-31-06.652Z is
  finished. The final status was:

  2 tests did not succeed - changes not commited.

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

Revision history for this message
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.

Revision history for this message
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

Revision history for this message
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.

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
Matthias Brantner (matthias-brantner) :
review: Approve
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/feature-uri_module 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 feature-uri_module-2012-03-05T23-11-19.724Z is
  finished. The final status was:

  2 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 :

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/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job feature-uri_module-2012-03-06T00-39-09.268Z is
  finished. The final status was:

  2 tests did not succeed - changes not commited.

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

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

The downside of building this functionality into Zorba: In release mode, the .xq file isn't read, so the implemented-in-XQuery functions don't exist. I don't remember the right solution, though.

10663. By Matthias Brantner

fix for the uri module in release module (it's non-pure virtual)

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 feature-uri_module-2012-03-06T02-57-33.518Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ChangeLog'
--- ChangeLog 2012-03-06 00:09:14 +0000
+++ ChangeLog 2012-03-06 01:58:21 +0000
@@ -13,6 +13,7 @@
13 * Fixed bug 917923 (bug in copying outer var values into the eval dynamic context)13 * Fixed bug 917923 (bug in copying outer var values into the eval dynamic context)
14 * Fixed bug 867509 (Can not handle largest xs:unsignedLong values)14 * Fixed bug 867509 (Can not handle largest xs:unsignedLong values)
15 * Fixed bug 924063 (sentence is incorrectly incremented when token characters end without sentence terminator)15 * Fixed bug 924063 (sentence is incorrectly incremented when token characters end without sentence terminator)
16 * New URI module providing percent-decoding functions.
16 * Optimization: change the implementation of the free-vars annotation and got rid17 * Optimization: change the implementation of the free-vars annotation and got rid
17 of the annotations map in expressions.18 of the annotations map in expressions.
18 * Fixed bug 909126 (bug in cloning of var_expr)19 * Fixed bug 909126 (bug in cloning of var_expr)
1920
=== modified file 'modules/com/zorba-xquery/www/modules/CMakeLists.txt'
--- modules/com/zorba-xquery/www/modules/CMakeLists.txt 2012-02-16 14:11:02 +0000
+++ modules/com/zorba-xquery/www/modules/CMakeLists.txt 2012-03-06 01:58:21 +0000
@@ -63,6 +63,8 @@
63 URI "http://www.zorba-xquery.com/modules/schema")63 URI "http://www.zorba-xquery.com/modules/schema")
64DECLARE_ZORBA_MODULE(FILE string.xq VERSION 2.164DECLARE_ZORBA_MODULE(FILE string.xq VERSION 2.1
65 URI "http://www.zorba-xquery.com/modules/string")65 URI "http://www.zorba-xquery.com/modules/string")
66DECLARE_ZORBA_MODULE(FILE uri.xq VERSION 1.0
67 URI "http://www.zorba-xquery.com/modules/uri")
66DECLARE_ZORBA_MODULE(FILE xml.xq VERSION 2.068DECLARE_ZORBA_MODULE(FILE xml.xq VERSION 2.0
67 URI "http://www.zorba-xquery.com/modules/xml")69 URI "http://www.zorba-xquery.com/modules/xml")
68DECLARE_ZORBA_MODULE(FILE xqdoc.xq VERSION 2.070DECLARE_ZORBA_MODULE(FILE xqdoc.xq VERSION 2.0
6971
=== added file 'modules/com/zorba-xquery/www/modules/uri.xq'
--- modules/com/zorba-xquery/www/modules/uri.xq 1970-01-01 00:00:00 +0000
+++ modules/com/zorba-xquery/www/modules/uri.xq 2012-03-06 01:58:21 +0000
@@ -0,0 +1,108 @@
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 : This module provides string related functions.
21 :
22 : @author Matthias Brantner
23 : @project XDM/atomic
24 :
25 :)
26module namespace uri = "http://www.zorba-xquery.com/modules/uri";
27
28declare namespace zerr = "http://www.zorba-xquery.com/errors";
29
30declare namespace ver = "http://www.zorba-xquery.com/options/versioning";
31declare option ver:module-version "1.0";
32
33(:~
34 : Percent-decodes (aka URL decoding) the given string.
35 :
36 : All percent encoded octets will be translated into their
37 : decoded UTF-8 representation.
38 :
39 : Please note that the percent encoding guarantees that a string
40 : consists of ASCII characters only. Passing a string that contains
41 : non-ASCII characters results in undefined behavior.
42 :
43 : @param $s the string to decode
44 :
45 : @return the percent decoded string
46 :)
47declare function uri:decode($u as xs:string) as xs:string
48{
49 uri:decode($u, fn:false())
50};
51
52(:~
53 : Percent-decodes (aka URL decoding) the given string.
54 :
55 : All percent encoded octets will be translated into their
56 : decoded UTF-8 representation.
57 :
58 : If $decode-plus is specified all occurrences of the char '+'
59 : will be replaced with a space ' ' before the percent decoding
60 : happens.
61 :
62 : Please note that the percent encoding guarantees that a string
63 : consists of ASCII characters only. Passing a string that contains
64 : non-ASCII characters results in undefined behavior.
65 :
66 : @param $s the string to decode
67 : @param $decode-plus whether '+' chars will be replaced with spaces
68 :
69 : @return the percent decoded string
70 :)
71declare function uri:decode(
72 $u as xs:string,
73 $decode-plus as xs:boolean) as xs:string
74{
75 uri:decode($u, $decode-plus, "UTF-8")
76};
77
78(:~
79 : Percent-decodes (aka URL decoding) the given string.
80 :
81 : All percent encoded octets will be translated into their
82 : decoded UTF-8 representation.
83 :
84 : If $decode-plus is specified all occurrences of the char '+'
85 : will be replaced with a space ' ' before the percent decoding
86 : happens.
87 :
88 : The $charset parameter specifies the source charset after precent
89 : decoding. It is used to convert the decoded string into UTF-8.
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 : @param $charset the source charset of the string after percent decoding
98 :
99 : @return the percent decoded string
100 :
101 : @error zerr:ZXQP0006 if the given charset is unknown or not supported
102 :
103 : @error zerr:ZOSE0006 if there is an error transcoding the string
104 :)
105declare function uri:decode(
106 $s as xs:string,
107 $decode-plus as xs:boolean,
108 $charset as xs:string) as xs:string external;
0109
=== modified file 'src/context/static_context.cpp'
--- src/context/static_context.cpp 2012-02-16 14:11:02 +0000
+++ src/context/static_context.cpp 2012-03-06 01:58:21 +0000
@@ -366,6 +366,10 @@
366"http://www.zorba-xquery.com/modules/string";366"http://www.zorba-xquery.com/modules/string";
367367
368const char*368const char*
369static_context::ZORBA_URI_FN_NS =
370"http://www.zorba-xquery.com/modules/uri";
371
372const char*
369static_context::ZORBA_FETCH_FN_NS = 373static_context::ZORBA_FETCH_FN_NS =
370"http://www.zorba-xquery.com/modules/fetch";374"http://www.zorba-xquery.com/modules/fetch";
371375
@@ -441,6 +445,7 @@
441 ns == ZORBA_REFLECTION_FN_NS ||445 ns == ZORBA_REFLECTION_FN_NS ||
442 ns == ZORBA_SCRIPTING_FN_NS ||446 ns == ZORBA_SCRIPTING_FN_NS ||
443 ns == ZORBA_STRING_FN_NS ||447 ns == ZORBA_STRING_FN_NS ||
448 ns == ZORBA_URI_FN_NS ||
444 ns == ZORBA_JSON_FN_NS ||449 ns == ZORBA_JSON_FN_NS ||
445 ns == ZORBA_FETCH_FN_NS ||450 ns == ZORBA_FETCH_FN_NS ||
446 ns == ZORBA_NODE_FN_NS ||451 ns == ZORBA_NODE_FN_NS ||
@@ -488,7 +493,9 @@
488 {493 {
489 return (ns == ZORBA_MATH_FN_NS ||494 return (ns == ZORBA_MATH_FN_NS ||
490 ns == ZORBA_INTROSP_SCTX_FN_NS ||495 ns == ZORBA_INTROSP_SCTX_FN_NS ||
496 ns == ZORBA_STRING_FN_NS ||
491 ns == ZORBA_JSON_FN_NS ||497 ns == ZORBA_JSON_FN_NS ||
498 ns == ZORBA_URI_FN_NS ||
492 ns == ZORBA_RANDOM_FN_NS);499 ns == ZORBA_RANDOM_FN_NS);
493 }500 }
494501
495502
=== modified file 'src/context/static_context.h'
--- src/context/static_context.h 2012-02-16 14:11:02 +0000
+++ src/context/static_context.h 2012-03-06 01:58:21 +0000
@@ -465,6 +465,7 @@
465 static const char* ZORBA_INTROSP_SCTX_FN_NS;465 static const char* ZORBA_INTROSP_SCTX_FN_NS;
466 static const char* ZORBA_REFLECTION_FN_NS;466 static const char* ZORBA_REFLECTION_FN_NS;
467 static const char* ZORBA_STRING_FN_NS;467 static const char* ZORBA_STRING_FN_NS;
468 static const char* ZORBA_URI_FN_NS;
468 static const char* ZORBA_FETCH_FN_NS;469 static const char* ZORBA_FETCH_FN_NS;
469 static const char* ZORBA_NODE_FN_NS;470 static const char* ZORBA_NODE_FN_NS;
470 static const char* ZORBA_XML_FN_NS;471 static const char* ZORBA_XML_FN_NS;
471472
=== modified file 'src/functions/library.cpp'
--- src/functions/library.cpp 2012-02-16 14:11:02 +0000
+++ src/functions/library.cpp 2012-03-06 01:58:21 +0000
@@ -57,6 +57,7 @@
57#include "functions/func_sequences.h"57#include "functions/func_sequences.h"
58#include "functions/func_sequences_impl.h"58#include "functions/func_sequences_impl.h"
59#include "functions/func_strings.h"59#include "functions/func_strings.h"
60#include "functions/func_uris.h"
60#include "functions/func_json.h"61#include "functions/func_json.h"
61#include "functions/func_var_decl.h"62#include "functions/func_var_decl.h"
62#include "functions/func_xqdoc.h"63#include "functions/func_xqdoc.h"
@@ -121,6 +122,7 @@
121 populate_context_schema(sctx);122 populate_context_schema(sctx);
122 populate_context_sctx(sctx);123 populate_context_sctx(sctx);
123 populate_context_strings(sctx);124 populate_context_strings(sctx);
125 populate_context_uris(sctx);
124 populate_context_sequences(sctx);126 populate_context_sequences(sctx);
125 populate_context_sequences_impl(sctx);127 populate_context_sequences_impl(sctx);
126 populate_context_xqdoc(sctx);128 populate_context_xqdoc(sctx);
127129
=== added file 'src/functions/pregenerated/func_uris.cpp'
--- src/functions/pregenerated/func_uris.cpp 1970-01-01 00:00:00 +0000
+++ src/functions/pregenerated/func_uris.cpp 2012-03-06 01:58:21 +0000
@@ -0,0 +1,65 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17// ******************************************
18// * *
19// * THIS IS A GENERATED FILE. DO NOT EDIT! *
20// * SEE .xml FILE WITH SAME NAME *
21// * *
22// ******************************************
23
24
25#include "stdafx.h"
26#include "runtime/uris/uris.h"
27#include "functions/func_uris.h"
28
29
30namespace zorba{
31
32
33
34PlanIter_t fn_zorba_uri_decode::codegen(
35 CompilerCB*,
36 static_context* sctx,
37 const QueryLoc& loc,
38 std::vector<PlanIter_t>& argv,
39 expr& ann) const
40{
41 return new DecodeURIIterator(sctx, loc, argv);
42}
43
44void populate_context_uris(static_context* sctx)
45{
46 {
47
48
49 DECL_WITH_KIND(sctx, fn_zorba_uri_decode,
50 (createQName("http://www.zorba-xquery.com/modules/uri","","decode"),
51 GENV_TYPESYSTEM.STRING_TYPE_ONE,
52 GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE,
53 GENV_TYPESYSTEM.STRING_TYPE_ONE,
54 GENV_TYPESYSTEM.STRING_TYPE_ONE),
55 FunctionConsts::FN_ZORBA_URI_DECODE_3);
56
57 }
58
59}
60
61
62}
63
64
65
066
=== added file 'src/functions/pregenerated/func_uris.h'
--- src/functions/pregenerated/func_uris.h 1970-01-01 00:00:00 +0000
+++ src/functions/pregenerated/func_uris.h 2012-03-06 01:58:21 +0000
@@ -0,0 +1,64 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17// ******************************************
18// * *
19// * THIS IS A GENERATED FILE. DO NOT EDIT! *
20// * SEE .xml FILE WITH SAME NAME *
21// * *
22// ******************************************
23
24
25#ifndef ZORBA_FUNCTIONS_URIS_H
26#define ZORBA_FUNCTIONS_URIS_H
27
28
29#include "common/shared_types.h"
30#include "functions/function_impl.h"
31
32
33namespace zorba {
34
35
36void populate_context_uris(static_context* sctx);
37
38
39
40
41//fn-zorba-uri:decode
42class fn_zorba_uri_decode : public function
43{
44public:
45 fn_zorba_uri_decode(const signature& sig, FunctionConsts::FunctionKind kind)
46 :
47 function(sig, kind)
48 {
49
50 }
51
52 CODEGEN_DECL();
53};
54
55
56} //namespace zorba
57
58
59#endif
60/*
61 * Local variables:
62 * mode: c++
63 * End:
64 */
065
=== modified file 'src/functions/pregenerated/function_enum.h'
--- src/functions/pregenerated/function_enum.h 2012-02-16 14:11:02 +0000
+++ src/functions/pregenerated/function_enum.h 2012-03-06 01:58:21 +0000
@@ -374,6 +374,7 @@
374 FN_ZORBA_STRING_MATERIALIZE_1,374 FN_ZORBA_STRING_MATERIALIZE_1,
375 FN_ZORBA_STRING_IS_STREAMABLE_1,375 FN_ZORBA_STRING_IS_STREAMABLE_1,
376 FN_ZORBA_STRING_SPLIT_2,376 FN_ZORBA_STRING_SPLIT_2,
377 FN_ZORBA_URI_DECODE_3,
377 FN_ZORBA_XQDOC_XQDOC_1,378 FN_ZORBA_XQDOC_XQDOC_1,
378 FN_ZORBA_XQDOC_XQDOC_CONTENT_1,379 FN_ZORBA_XQDOC_XQDOC_CONTENT_1,
379380
380381
=== modified file 'src/runtime/spec/mappings.xml'
--- src/runtime/spec/mappings.xml 2012-02-16 14:11:02 +0000
+++ src/runtime/spec/mappings.xml 2012-03-06 01:58:21 +0000
@@ -106,6 +106,10 @@
106 define="ZORBA_STRING_FN_NS" 106 define="ZORBA_STRING_FN_NS"
107 prefix="fn-zorba-string"/>107 prefix="fn-zorba-string"/>
108108
109 <zorba:namespace uri="http://www.zorba-xquery.com/modules/uri"
110 define="ZORBA_URI_FN_NS"
111 prefix="fn-zorba-uri"/>
112
109 <zorba:namespace uri="http://www.zorba-xquery.com/modules/converters/json"113 <zorba:namespace uri="http://www.zorba-xquery.com/modules/converters/json"
110 define="ZORBA_JSON_FN_NS" 114 define="ZORBA_JSON_FN_NS"
111 prefix="fn-zorba-json"/>115 prefix="fn-zorba-json"/>
112116
=== added directory 'src/runtime/spec/uris'
=== added file 'src/runtime/spec/uris/uris.xml'
--- src/runtime/spec/uris/uris.xml 1970-01-01 00:00:00 +0000
+++ src/runtime/spec/uris/uris.xml 2012-03-06 01:58:21 +0000
@@ -0,0 +1,40 @@
1<?xml version="1.0" encoding="UTF-8"?>
2
3<!--
4/////////////////////////////////////////////////////////////////////////////////
5// //
6// 7.2 Functions to Assemble and Disassemble Strings
7// //
8/////////////////////////////////////////////////////////////////////////////////
9-->
10<zorba:iterators
11 xmlns:zorba="http://www.zorba-xquery.com"
12 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
13 xsi:schemaLocation="http://www.zorba-xquery.com ../runtime.xsd">
14
15<zorba:header>
16 <zorba:include form="Quoted">zorbautils/checked_vector.h</zorba:include>
17 <zorba:include form="Quoted">zorbatypes/schema_types.h</zorba:include>
18</zorba:header>
19
20<!--
21/*******************************************************************************
22********************************************************************************/
23-->
24<zorba:iterator name="DecodeURIIterator">
25
26 <zorba:description author="Zorba Team">
27 uri:decode
28 </zorba:description>
29
30 <zorba:function>
31 <zorba:signature localname="decode" prefix="fn-zorba-uri">
32 <zorba:param>xs:string</zorba:param>
33 <zorba:param>xs:boolean</zorba:param>
34 <zorba:param>xs:string</zorba:param>
35 <zorba:output>xs:string</zorba:output>
36 </zorba:signature>
37 </zorba:function>
38</zorba:iterator>
39
40</zorba:iterators>
041
=== added directory 'src/runtime/uris'
=== added directory 'src/runtime/uris/pregenerated'
=== added file 'src/runtime/uris/pregenerated/uris.cpp'
--- src/runtime/uris/pregenerated/uris.cpp 1970-01-01 00:00:00 +0000
+++ src/runtime/uris/pregenerated/uris.cpp 2012-03-06 01:58:21 +0000
@@ -0,0 +1,66 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17// ******************************************
18// * *
19// * THIS IS A GENERATED FILE. DO NOT EDIT! *
20// * SEE .xml FILE WITH SAME NAME *
21// * *
22// ******************************************
23
24#include "stdafx.h"
25#include "zorbatypes/rchandle.h"
26#include "zorbatypes/zstring.h"
27#include "runtime/visitors/planiter_visitor.h"
28#include "runtime/uris/uris.h"
29#include "system/globalenv.h"
30
31
32
33namespace zorba {
34
35// <DecodeURIIterator>
36const char* DecodeURIIterator::class_name_str = "DecodeURIIterator";
37DecodeURIIterator::class_factory<DecodeURIIterator>
38DecodeURIIterator::g_class_factory;
39
40const serialization::ClassVersion
41DecodeURIIterator::class_versions[] ={{ 1, 0x000905, false}};
42
43const int DecodeURIIterator::class_versions_count =
44sizeof(DecodeURIIterator::class_versions)/sizeof(struct serialization::ClassVersion);
45
46void DecodeURIIterator::accept(PlanIterVisitor& v) const {
47 v.beginVisit(*this);
48
49 std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
50 std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
51 for ( ; lIter != lEnd; ++lIter ){
52 (*lIter)->accept(v);
53 }
54
55 v.endVisit(*this);
56}
57
58DecodeURIIterator::~DecodeURIIterator() {}
59
60// </DecodeURIIterator>
61
62
63
64}
65
66
067
=== added file 'src/runtime/uris/pregenerated/uris.h'
--- src/runtime/uris/pregenerated/uris.h 1970-01-01 00:00:00 +0000
+++ src/runtime/uris/pregenerated/uris.h 2012-03-06 01:58:21 +0000
@@ -0,0 +1,80 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17// ******************************************
18// * *
19// * THIS IS A GENERATED FILE. DO NOT EDIT! *
20// * SEE .xml FILE WITH SAME NAME *
21// * *
22// ******************************************
23#ifndef ZORBA_RUNTIME_URIS_URIS_H
24#define ZORBA_RUNTIME_URIS_URIS_H
25
26
27#include "common/shared_types.h"
28
29
30
31#include "runtime/base/narybase.h"
32#include "zorbautils/checked_vector.h"
33#include "zorbatypes/schema_types.h"
34
35
36namespace zorba {
37
38/**
39 *
40 * uri:decode
41 *
42 * Author: Zorba Team
43 */
44class DecodeURIIterator : public NaryBaseIterator<DecodeURIIterator, PlanIteratorState>
45{
46public:
47 SERIALIZABLE_CLASS(DecodeURIIterator);
48
49 SERIALIZABLE_CLASS_CONSTRUCTOR2T(DecodeURIIterator,
50 NaryBaseIterator<DecodeURIIterator, PlanIteratorState>);
51
52 void serialize( ::zorba::serialization::Archiver& ar)
53 {
54 serialize_baseclass(ar,
55 (NaryBaseIterator<DecodeURIIterator, PlanIteratorState>*)this);
56 }
57
58 DecodeURIIterator(
59 static_context* sctx,
60 const QueryLoc& loc,
61 std::vector<PlanIter_t>& children)
62 :
63 NaryBaseIterator<DecodeURIIterator, PlanIteratorState>(sctx, loc, children)
64 {}
65
66 virtual ~DecodeURIIterator();
67
68 void accept(PlanIterVisitor& v) const;
69
70 bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
71};
72
73
74}
75#endif
76/*
77 * Local variables:
78 * mode: c++
79 * End:
80 */
081
=== added file 'src/runtime/uris/uris_impl.cpp'
--- src/runtime/uris/uris_impl.cpp 1970-01-01 00:00:00 +0000
+++ src/runtime/uris/uris_impl.cpp 2012-03-06 01:58:21 +0000
@@ -0,0 +1,105 @@
1/*
2 * Copyright 2006-2012 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#include "stdafx.h"
17
18#include <algorithm>
19
20#include "common/common.h"
21
22#include "diagnostics/assert.h"
23#include "diagnostics/xquery_diagnostics.h"
24#include "diagnostics/util_macros.h"
25
26#include "runtime/uris/uris.h"
27
28#include "system/globalenv.h"
29#include "store/api/item_factory.h"
30
31#include "zorba/transcode_stream.h"
32
33#include "util/uri_util.h"
34
35using namespace std;
36
37namespace zorba {
38
39/******************************************************************************
40*******************************************************************************/
41bool
42DecodeURIIterator::nextImpl(store::Item_t& result, PlanState& planState) const
43{
44 store::Item_t lString, lDecodePlus, lEncoding;
45 zstring lDecodedString, lCharset;
46
47 PlanIteratorState* state;
48 DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
49
50 consumeNext(lString, theChildren[0].getp(), planState);
51 consumeNext(lDecodePlus, theChildren[1].getp(), planState);
52 consumeNext(lEncoding, theChildren[2].getp(), planState);
53
54 lString->getStringValue2(lDecodedString);
55 lEncoding->getStringValue2(lCharset);
56
57 if (lDecodePlus->getBooleanValue())
58 {
59 std::replace( lDecodedString.begin(), lDecodedString.end(), '+', ' ' );
60 }
61
62 uri::decode(lDecodedString);
63
64 if (transcode::is_necessary(lCharset.c_str()))
65 {
66 if (!transcode::is_supported(lCharset.c_str()))
67 {
68 throw XQUERY_EXCEPTION(
69 zerr::ZXQP0006_UNKNOWN_ENCODING,
70 ERROR_PARAMS( lCharset ),
71 ERROR_LOC( loc )
72 );
73 }
74
75 try
76 {
77 transcode::stream<istringstream> lTranscoder(
78 lCharset.c_str(),
79 lDecodedString.c_str()
80 );
81
82 lDecodedString.clear();
83 char buf[1024];
84 while (lTranscoder.good())
85 {
86 lTranscoder.read(buf, 1024);
87 lDecodedString.append(buf, lTranscoder.gcount());
88 }
89 }
90 catch (ZorbaException& e)
91 {
92 throw XQUERY_EXCEPTION(
93 zerr::ZOSE0006_TRANSCODING_ERROR,
94 ERROR_PARAMS( e.what() ),
95 ERROR_LOC( loc )
96 );
97 }
98 }
99
100 STACK_PUSH(GENV_ITEMFACTORY->createString(result, lDecodedString), state );
101
102 STACK_END (state);
103}
104} // namespace zorba
105/* vim:set et sw=2 ts=2: */
0106
=== modified file 'src/runtime/visitors/pregenerated/planiter_visitor.h'
--- src/runtime/visitors/pregenerated/planiter_visitor.h 2012-02-16 14:11:02 +0000
+++ src/runtime/visitors/pregenerated/planiter_visitor.h 2012-03-06 01:58:21 +0000
@@ -588,6 +588,8 @@
588588
589 class StringSplitIterator;589 class StringSplitIterator;
590590
591 class DecodeURIIterator;
592
591 class XQDocIterator;593 class XQDocIterator;
592594
593 class XQDocContentIterator;595 class XQDocContentIterator;
@@ -1438,6 +1440,9 @@
1438 virtual void beginVisit ( const StringSplitIterator& ) = 0;1440 virtual void beginVisit ( const StringSplitIterator& ) = 0;
1439 virtual void endVisit ( const StringSplitIterator& ) = 0;1441 virtual void endVisit ( const StringSplitIterator& ) = 0;
14401442
1443 virtual void beginVisit ( const DecodeURIIterator& ) = 0;
1444 virtual void endVisit ( const DecodeURIIterator& ) = 0;
1445
1441 virtual void beginVisit ( const XQDocIterator& ) = 0;1446 virtual void beginVisit ( const XQDocIterator& ) = 0;
1442 virtual void endVisit ( const XQDocIterator& ) = 0;1447 virtual void endVisit ( const XQDocIterator& ) = 0;
14431448
14441449
=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp'
--- src/runtime/visitors/pregenerated/printer_visitor.cpp 2012-02-16 14:11:02 +0000
+++ src/runtime/visitors/pregenerated/printer_visitor.cpp 2012-03-06 01:58:21 +0000
@@ -64,6 +64,7 @@
64#include "runtime/store/documents.h"64#include "runtime/store/documents.h"
65#include "runtime/store/maps.h"65#include "runtime/store/maps.h"
66#include "runtime/strings/strings.h"66#include "runtime/strings/strings.h"
67#include "runtime/uris/uris.h"
67#include "runtime/xqdoc/xqdoc.h"68#include "runtime/xqdoc/xqdoc.h"
6869
69namespace zorba{70namespace zorba{
@@ -4004,6 +4005,20 @@
4004// </StringSplitIterator>4005// </StringSplitIterator>
40054006
40064007
4008// <DecodeURIIterator>
4009void PrinterVisitor::beginVisit ( const DecodeURIIterator& a) {
4010 thePrinter.startBeginVisit("DecodeURIIterator", ++theId);
4011 printCommons( &a, theId );
4012 thePrinter.endBeginVisit( theId );
4013}
4014
4015void PrinterVisitor::endVisit ( const DecodeURIIterator& ) {
4016 thePrinter.startEndVisit();
4017 thePrinter.endEndVisit();
4018}
4019// </DecodeURIIterator>
4020
4021
4007// <XQDocIterator>4022// <XQDocIterator>
4008void PrinterVisitor::beginVisit ( const XQDocIterator& a) {4023void PrinterVisitor::beginVisit ( const XQDocIterator& a) {
4009 thePrinter.startBeginVisit("XQDocIterator", ++theId);4024 thePrinter.startBeginVisit("XQDocIterator", ++theId);
40104025
=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.h'
--- src/runtime/visitors/pregenerated/printer_visitor.h 2012-02-16 14:11:02 +0000
+++ src/runtime/visitors/pregenerated/printer_visitor.h 2012-03-06 01:58:21 +0000
@@ -885,6 +885,9 @@
885 void beginVisit( const StringSplitIterator& );885 void beginVisit( const StringSplitIterator& );
886 void endVisit ( const StringSplitIterator& );886 void endVisit ( const StringSplitIterator& );
887887
888 void beginVisit( const DecodeURIIterator& );
889 void endVisit ( const DecodeURIIterator& );
890
888 void beginVisit( const XQDocIterator& );891 void beginVisit( const XQDocIterator& );
889 void endVisit ( const XQDocIterator& );892 void endVisit ( const XQDocIterator& );
890893
891894
=== added directory 'test/rbkt/ExpQueryResults/zorba/uris'
=== added file 'test/rbkt/ExpQueryResults/zorba/uris/decode_01.xml.res'
--- test/rbkt/ExpQueryResults/zorba/uris/decode_01.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/uris/decode_01.xml.res 2012-03-06 01:58:21 +0000
@@ -0,0 +1,1 @@
1foo=ä¥FÅõ
02
=== added file 'test/rbkt/ExpQueryResults/zorba/uris/decode_03.xml.res'
--- test/rbkt/ExpQueryResults/zorba/uris/decode_03.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/uris/decode_03.xml.res 2012-03-06 01:58:21 +0000
@@ -0,0 +1,1 @@
1ä¨bcö
02
=== added file 'test/rbkt/ExpQueryResults/zorba/uris/decode_04.xml.res'
--- test/rbkt/ExpQueryResults/zorba/uris/decode_04.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/uris/decode_04.xml.res 2012-03-06 01:58:21 +0000
@@ -0,0 +1,1 @@
1äö ü
02
=== added directory 'test/rbkt/Queries/zorba/uris'
=== added file 'test/rbkt/Queries/zorba/uris/decode_01.xq'
--- test/rbkt/Queries/zorba/uris/decode_01.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/uris/decode_01.xq 2012-03-06 01:58:21 +0000
@@ -0,0 +1,3 @@
1import module namespace u = "http://www.zorba-xquery.com/modules/uri";
2
3u:decode("foo=%E4%A5F%C5%F5", fn:false(), "ISO-8859-1")
04
=== added file 'test/rbkt/Queries/zorba/uris/decode_02.spec'
--- test/rbkt/Queries/zorba/uris/decode_02.spec 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/uris/decode_02.spec 2012-03-06 01:58:21 +0000
@@ -0,0 +1,1 @@
1Error: http://www.zorba-xquery.com/errors:ZXQP0006
02
=== added file 'test/rbkt/Queries/zorba/uris/decode_02.xq'
--- test/rbkt/Queries/zorba/uris/decode_02.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/uris/decode_02.xq 2012-03-06 01:58:21 +0000
@@ -0,0 +1,3 @@
1import module namespace u = "http://www.zorba-xquery.com/modules/uri";
2
3u:decode("foo=%E4%A5F%C5%F5", fn:false(), "foo")
04
=== added file 'test/rbkt/Queries/zorba/uris/decode_03.xq'
--- test/rbkt/Queries/zorba/uris/decode_03.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/uris/decode_03.xq 2012-03-06 01:58:21 +0000
@@ -0,0 +1,4 @@
1import module namespace u = "http://www.zorba-xquery.com/modules/uri";
2
3u:decode("%C3%A4%C2%A8bc%C3%B6", fn:false())
4
05
=== added file 'test/rbkt/Queries/zorba/uris/decode_04.xq'
--- test/rbkt/Queries/zorba/uris/decode_04.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/uris/decode_04.xq 2012-03-06 01:58:21 +0000
@@ -0,0 +1,3 @@
1import module namespace u = "http://www.zorba-xquery.com/modules/uri";
2
3u:decode("%C3%A4%C3%B6+%C3%BC", fn:true())

Subscribers

People subscribed via source and target branches