Merge lp:~zorba-coders/zorba/bug-867376 into lp:zorba

Proposed by Luis Rodriguez Gonzalez
Status: Merged
Approved by: Chris Hillery
Approved revision: 11299
Merged at revision: 11431
Proposed branch: lp:~zorba-coders/zorba/bug-867376
Merge into: lp:zorba
Diff against target: 2405 lines (+1391/-162)
40 files modified
ChangeLog (+1/-0)
include/zorba/pregenerated/diagnostic_list.h (+6/-0)
modules/com/zorba-xquery/www/modules/pregenerated/errors.xq (+16/-1)
modules/com/zorba-xquery/www/modules/uri.xq (+99/-4)
src/diagnostics/diagnostic_en.xml (+17/-0)
src/diagnostics/pregenerated/diagnostic_list.cpp (+9/-0)
src/diagnostics/pregenerated/dict_en.cpp (+3/-0)
src/diagnostics/qname.cpp (+1/-0)
src/functions/pregenerated/func_uris.cpp (+44/-0)
src/functions/pregenerated/func_uris.h (+30/-0)
src/functions/pregenerated/function_enum.h (+2/-0)
src/runtime/pregenerated/iterator_enum.h (+2/-0)
src/runtime/spec/uris/uris.xml (+28/-0)
src/runtime/uris/pregenerated/uris.cpp (+56/-0)
src/runtime/uris/pregenerated/uris.h (+64/-0)
src/runtime/uris/uris_impl.cpp (+216/-0)
src/runtime/visitors/pregenerated/planiter_visitor.h (+10/-0)
src/runtime/visitors/pregenerated/printer_visitor.cpp (+28/-0)
src/runtime/visitors/pregenerated/printer_visitor.h (+6/-0)
src/unit_tests/test_uri.cpp (+153/-38)
src/zorbatypes/URI.cpp (+165/-105)
src/zorbatypes/URI.h (+36/-13)
test/fots/CMakeLists.txt (+0/-1)
test/rbkt/ExpQueryResults/zorba/uris/parse-uri.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/uris/serialize-direct-uri.xml.res (+37/-0)
test/rbkt/ExpQueryResults/zorba/uris/serialize-uri.xml.res (+44/-0)
test/rbkt/Queries/zorba/uris/parse-invalid.spec (+1/-0)
test/rbkt/Queries/zorba/uris/parse-invalid.xq (+3/-0)
test/rbkt/Queries/zorba/uris/parse-uri.xq (+6/-0)
test/rbkt/Queries/zorba/uris/serialize-direct-uri.xq (+211/-0)
test/rbkt/Queries/zorba/uris/serialize-uri.xq (+9/-0)
test/rbkt/Queries/zorba/uris/serialize-wrong-opaque-noscheme.spec (+1/-0)
test/rbkt/Queries/zorba/uris/serialize-wrong-opaque-noscheme.xq (+8/-0)
test/rbkt/Queries/zorba/uris/serialize-wrong-opaque.spec (+1/-0)
test/rbkt/Queries/zorba/uris/serialize-wrong-opaque.xq (+10/-0)
test/rbkt/Queries/zorba/uris/serialize-wrong-path1.spec (+1/-0)
test/rbkt/Queries/zorba/uris/serialize-wrong-path1.xq (+9/-0)
test/rbkt/Queries/zorba/uris/serialize-wrong-path2.spec (+1/-0)
test/rbkt/Queries/zorba/uris/serialize-wrong-path2.xq (+10/-0)
test/rbkt/Queries/zorba/uris/uri-source.xml (+46/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug-867376
Reviewer Review Type Date Requested Status
Matthias Brantner Approve
Chris Hillery Approve
Review via email: mp+159233@code.launchpad.net

Commit message

Added URI processing module.

Description of the change

- Fix for Bug 867376 URI processing module

To post a comment you must log in.
Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

- Why is there a schema imported in uri.xq? I don't think it's needed anymore.
- The documentation should say what types of errors the function can raise.
- It would be nice to have constants for the names of the fields in the objects (e.g. scheme, opaque-part)
- Why does the change comment out all language bindings in swig/CMakeLists.txt and test/rbkt/modules/CMakeLists.txt?

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

I think actually there are some error conditions that we're not catching currently. For instance, the following input in serialize-direct-uri.xq:

{ "scheme" : "file", "path" : "d:/a/b/c" }

is a non-opaque URI because it has a path, rather than an opaque-part. But it produces the output:

file:d:/a/b/c

which is an opaque URI. I believe that the input is illegal, because a non-opaque URI with a scheme MUST have a path section that begins with a / character. So the above input should actually raise an error.

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

Also, currently serialize-direct-uri.xq fails because the expected output file serialize-direct-uri.xml.res is missing a couple results, namely the opaque URI tests at the end. Did you forget to commit that file?

Revision history for this message
Luis Rodriguez Gonzalez (kuraru) wrote :

> Also, currently serialize-direct-uri.xq fails because the expected output file
> serialize-direct-uri.xml.res is missing a couple results, namely the opaque
> URI tests at the end. Did you forget to commit that file?
I checked the expected results in my code and it does have the opaque test case results, I don't know why it failed for you. Anyway, I'm updating the code in this branch with some minor fixes for some of Matthias' comments.

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

Hmmm.... weird. Yep, those results are there after all. I'm not sure where they went when I looked at this the first time. Ok then.

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

As for the error condition, I've been thinking about it more, and I'm pretty sure that uri:serialize() needs to enforce at least the following rules:

1. You can specify opaque-part, OR some subset of host/port/path/user-info/query. Not both. (Put another way: If opaque-part is specified, then only scheme and fragment may be additionally be specified.)

2. If you specify opaque-part, scheme is required.

3. If you specify a scheme and a path, then the path MUST start with a / character.

I would suggest introducing a zerr:ZURI0001 "malformed URI components" error message for uri:serialize() which is thrown if any of the above rules are broken, as well as some new test cases for each of them. It might be nice to have separate errors for each, I guess - ZURI0001 "cannot specify opaque-part in conjunction with host/port/path/user-info/query", ZURI0002 "scheme required when specifying opaque-part", and ZURI0003 "path component of absolute URI (ie, one with a scheme) must begin with /".

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

Also - the header comment for uri.xq is wrong:

(:~
 : This module provides string related functions.
 :
 : @author Matthias Brantner
 : @project XDM/atomic
 :
 :)

Revision history for this message
Luis Rodriguez Gonzalez (kuraru) wrote :

> As for the error condition, I've been thinking about it more, and I'm pretty
> sure that uri:serialize() needs to enforce at least the following rules:
>
> 1. You can specify opaque-part, OR some subset of host/port/path/user-
> info/query. Not both. (Put another way: If opaque-part is specified, then only
> scheme and fragment may be additionally be specified.)
>
> 2. If you specify opaque-part, scheme is required.
>
> 3. If you specify a scheme and a path, then the path MUST start with a /
> character.
>
> I would suggest introducing a zerr:ZURI0001 "malformed URI components" error
> message for uri:serialize() which is thrown if any of the above rules are
> broken, as well as some new test cases for each of them. It might be nice to
> have separate errors for each, I guess - ZURI0001 "cannot specify opaque-part
> in conjunction with host/port/path/user-info/query", ZURI0002 "scheme required
> when specifying opaque-part", and ZURI0003 "path component of absolute URI
> (ie, one with a scheme) must begin with /".

I will include the 3 different errors for uri:serialize(), Should I leave uri:parse() without any error code?
I see that in the previous function in the same module they use some predefined XQueryErrorCode inside diagnostic_list.h, Should I include my own codes there?

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

> I will include the 3 different errors for uri:serialize(), Should I leave
> uri:parse() without any error code?

I'm sure there are some reasonable errors for uri:parse(), but I'm not totally sure what they might be. It's possible that URI.cpp will already throw some exceptions if you try to parse a bogus URI, and that might well be good enough.

Matthias, can you think of any specific error cases that we should test out?

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

There are still some test failures. serialize-direct-uris now throws ZURI errors, which is good, but the test needs to be adapted for that (split the failing cases into separate tests with a .spec file containing the Error: you expect).

More worrying, FOTS/fn-resolve-uri is failing. I'm looking into that one a bit.

review: Needs Fixing
Revision history for this message
Luis Rodriguez Gonzalez (kuraru) wrote :

> > I will include the 3 different errors for uri:serialize(), Should I leave
> > uri:parse() without any error code?
>
> I'm sure there are some reasonable errors for uri:parse(), but I'm not totally
> sure what they might be. It's possible that URI.cpp will already throw some
> exceptions if you try to parse a bogus URI, and that might well be good
> enough.
>
> Matthias, can you think of any specific error cases that we should test out?
Actually you are right, the current underlying library throws some exceptions already.

Revision history for this message
Luis Rodriguez Gonzalez (kuraru) wrote :

> There are still some test failures. serialize-direct-uris now throws ZURI
> errors, which is good, but the test needs to be adapted for that (split the
> failing cases into separate tests with a .spec file containing the Error: you
> expect).
>
> More worrying, FOTS/fn-resolve-uri is failing. I'm looking into that one a
> bit.
All failing (as expected) cases were moved to individual test cases. Added also a couple of more to test the other 2 errors (ZURI0001 and ZURI0002).

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

I believe Luis has addressed all concerns, and I have done some touch-ups as well.

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/bug-867376 into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:275 (message):
  Validation queue job bug-867376-2013-05-02T09-13-03.471Z is finished. The
  final status was:

  1 tests did not succeed - changes not commited.

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

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

- Could you give an example in the documentation of uri:parse and show a resulting URI object?
- The names of the variables are all upper-case. I know that we don't have any coding conventions for it but the names in the full-text module are all lower-case. Should we be consistent here?
- uri:parse("foo:bar?") returns "[err:XQST0046]: "bar?": invalid URI literal: "63": invalid character code-point"
  1. why?
  2. the function documentation doesn't mention that this could be raised
- uri:parse("http://foo.com/bc?") returns { "scheme" : "http", "host" : "foo.com", "path" : "/bc" }. Should it return the query part as empty in the JSON object?
- one test doesn't seem to succeed in the queue

review: Needs Fixing
Revision history for this message
Luis Rodriguez Gonzalez (kuraru) wrote :

> - Could you give an example in the documentation of uri:parse and show a
> resulting URI object?
Done
> - The names of the variables are all upper-case. I know that we don't have any
> coding conventions for it but the names in the full-text module are all lower-
> case. Should we be consistent here?
Done
> - uri:parse("foo:bar?") returns "[err:XQST0046]: "bar?": invalid URI literal:
> "63": invalid character code-point"
> 1. why?
> 2. the function documentation doesn't mention that this could be raised
> - uri:parse("http://foo.com/bc?") returns { "scheme" : "http", "host" :
> "foo.com", "path" : "/bc" }. Should it return the query part as empty in the
> JSON object?
Done. I had to change some inner parts of URI class from protected to public.
> - one test doesn't seem to succeed in the queue
I can't figure out what test case went wrong. In the log it only says that something produced a segment fault, but I don't recognize the code that produced it. How can I find the exact test case name and error?

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

I believe all outstanding comments have been addressed; Matthias, one more pass, please?

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

I have pushed some final documentation improvements.

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

One of the FOTS tests crashes

Please see: http://zorbatest.lambda.nu:8080/cdash/testDetails.php?test=71145736&build=31952
On May 2, 2013, at 5:55 PM, Chris Hillery <email address hidden> wrote:

> I believe all outstanding comments have been addressed; Matthias, one more pass, please?
> --
> https://code.launchpad.net/~zorba-coders/zorba/bug-867376/+merge/159233
> You are reviewing the proposed merge of lp:~zorba-coders/zorba/bug-867376 into lp:zorba.

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/bug-867376 into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:275 (message):
  Validation queue job bug-867376-2013-05-03T03-13-20.382Z is finished. The
  final status was:

  1 tests did not succeed - changes not commited.

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

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

> One of the FOTS tests crashes

We already pushed a fix for that one before asking for your re-review (it was an infinite loop eventually causing OOM).

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

The last failing test is because Luis changed the constants back to all lower-case, but forgot to change the corresponding usage of those constants in a test case. However, as I just sent to zorba-dev, I personally believe all-caps is a better approach anyway, so I would like to change the module back rather than changing the test. I will wait to see if anyone has any opinions from my email.

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/bug-867376 into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:275 (message):
  Validation queue job bug-867376-2013-05-03T15-12-05.295Z is finished. The
  final status was:

  1 tests did not succeed - changes not commited.

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

lp:~zorba-coders/zorba/bug-867376 updated
11299. By Chris Hillery

Constants back to all-CAPS, and with explicit type.

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 bug-867376-2013-05-03T23-23-03.988Z 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 2013-05-01 03:58:31 +0000
+++ ChangeLog 2013-05-03 23:21:27 +0000
@@ -104,6 +104,7 @@
104 * Fixed bug #1023362 (xsi:type attribute ignored during validation)104 * Fixed bug #1023362 (xsi:type attribute ignored during validation)
105 * Fixed bug #1025564 (Deprecate -f argument to zorbacmd)105 * Fixed bug #1025564 (Deprecate -f argument to zorbacmd)
106 * Fixed bug #1082740 (support for INF and -INF values in fn:subsequence function). 106 * Fixed bug #1082740 (support for INF and -INF values in fn:subsequence function).
107 * Fixed bug #867376 (uri:parse() and uri:serialize())
107108
108109
109version 2.8110version 2.8
110111
=== modified file 'include/zorba/pregenerated/diagnostic_list.h'
--- include/zorba/pregenerated/diagnostic_list.h 2013-05-02 10:19:11 +0000
+++ include/zorba/pregenerated/diagnostic_list.h 2013-05-03 23:21:27 +0000
@@ -882,6 +882,12 @@
882882
883extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJSE0008_BAD_VALUE;883extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJSE0008_BAD_VALUE;
884884
885extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZURI0001_OPAQUE_WITH_OTHERS;
886
887extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZURI0002_SCHEME_REQUIRED_FOR_OPAQUE;
888
889extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZURI0003_SLASH_NEEDED_FOR_ABSOLUTE_URI;
890
885} // namespace zerr891} // namespace zerr
886892
887namespace jerr {893namespace jerr {
888894
=== modified file 'modules/com/zorba-xquery/www/modules/pregenerated/errors.xq'
--- modules/com/zorba-xquery/www/modules/pregenerated/errors.xq 2013-03-06 00:18:36 +0000
+++ modules/com/zorba-xquery/www/modules/pregenerated/errors.xq 2013-05-03 23:21:27 +0000
@@ -977,4 +977,19 @@
977977
978(:~978(:~
979:)979:)
980declare variable $zerr:ZJSE0008 as xs:QName := fn:QName($zerr:NS, "zerr:ZJSE0008");
981\ No newline at end of file980\ No newline at end of file
981declare variable $zerr:ZJSE0008 as xs:QName := fn:QName($zerr:NS, "zerr:ZJSE0008");
982
983(:~
984 :If the opaque-part section of the URI was specified in conjuction with other non-opaque parts.
985:)
986declare variable $zerr:ZURI0001 as xs:QName := fn:QName($zerr:NS, "zerr:ZURI0001");
987
988(:~
989 :If an opaque-part section was specified without a scheme section.
990:)
991declare variable $zerr:ZURI0002 as xs:QName := fn:QName($zerr:NS, "zerr:ZURI0002");
992
993(:~
994 :If an absolute URI is specified with a path that does not start with slash ("/").
995:)
996declare variable $zerr:ZURI0003 as xs:QName := fn:QName($zerr:NS, "zerr:ZURI0003");
982\ No newline at end of file997\ No newline at end of file
983998
=== modified file 'modules/com/zorba-xquery/www/modules/uri.xq'
--- modules/com/zorba-xquery/www/modules/uri.xq 2013-02-07 17:24:36 +0000
+++ modules/com/zorba-xquery/www/modules/uri.xq 2013-05-03 23:21:27 +0000
@@ -1,4 +1,4 @@
1xquery version "1.0";1xquery version "3.0";
22
3(:3(:
4 : Copyright 2006-2012 The FLWOR Foundation.4 : Copyright 2006-2012 The FLWOR Foundation.
@@ -17,20 +17,71 @@
17:)17:)
1818
19(:~19(:~
20 : This module provides string related functions.20 : This module provides functions for processing URIs and URLs.
21 :21 :
22 : @author Matthias Brantner22 : @author Matthias Brantner, Luis Rodriguez Gonzalez
23 : @project XDM/atomic23 : @project XDM/atomic
24 :24 :
25 :)25 :)
26module namespace uri = "http://www.zorba-xquery.com/modules/uri";26module namespace uri = "http://www.zorba-xquery.com/modules/uri";
2727
28declare namespace zerr = "http://www.zorba-xquery.com/errors";28declare namespace zerr = "http://www.zorba-xquery.com/errors";
29
30declare namespace ver = "http://www.zorba-xquery.com/options/versioning";29declare namespace ver = "http://www.zorba-xquery.com/options/versioning";
31declare option ver:module-version "1.0";30declare option ver:module-version "1.0";
3231
33(:~32(:~
33 : Constant for the "scheme" part of a URI object.
34 :)
35declare variable $uri:SCHEME as xs:string := "scheme";
36
37(:~
38 : Constant for the "authority" part of a URI object.
39 :)
40declare variable $uri:AUTHORITY as xs:string := "authority";
41
42(:~
43 : Constant for the "user-info" part of a URI object.
44 :)
45declare variable $uri:USER-INFO as xs:string := "user-info";
46
47(:~
48 : Constant for the "host" part of a URI object.
49 :)
50declare variable $uri:HOST as xs:string := "host";
51
52(:~
53 : Constant for the "port" part of a URI object.
54 :)
55declare variable $uri:PORT as xs:string := "port";
56
57(:~
58 : Constant for the "path" part of a URI object.
59 :)
60declare variable $uri:PATH as xs:string := "path";
61
62(:~
63 : Constant for the "query" part of a URI object.
64 :)
65declare variable $uri:QUERY as xs:string := "query";
66
67(:~
68 : Constant for the "fragment" part of a URI object.
69 :)
70declare variable $uri:FRAGMENT as xs:string := "fragment";
71
72(:~
73 : Constant for the "opaque-part" part of a URI object.
74 :
75 : If this is set in a URI object, then none of $uri:PATH, $uri:HOST,
76 : $uri:PORT, $uri:USER-INFO, or : $uri:QUERY may be specified.
77 :
78 : If this is set in a URI object, $uri:SCHEME must also be specified
79 : (ie, it must be an absolute URI).
80 :)
81declare variable $uri:OPAQUE-PART as xs:string := "opaque-part";
82
83
84(:~
34 : Percent-decodes (aka URL decoding) the given string.85 : Percent-decodes (aka URL decoding) the given string.
35 :86 :
36 : All percent encoded octets will be translated into their87 : All percent encoded octets will be translated into their
@@ -106,3 +157,47 @@
106 $s as xs:string,157 $s as xs:string,
107 $decode-plus as xs:boolean,158 $decode-plus as xs:boolean,
108 $charset as xs:string) as xs:string external;159 $charset as xs:string) as xs:string external;
160
161(:~
162 : Parses the URI passed as string. The returned object
163 : contains only members with field names declared as constants in
164 : this module.
165 :
166 : For example,
167 : <code>
168 : let my-uri := "http://www.my.project.com/a/b/c?user=john;pass=1234#profile"
169 : return uri:parse(my-uri)
170 : </code>
171 :
172 : returns
173 : <code>
174 : { "squeme" : "http", "host" : "www.my.project.com", "path" : "/a/b/c",
175 : "query" : "user=john;pass=123", "fragment" : "profile" }
176 : </code>
177 :
178 : @param $uri the URI to parse
179 :
180 : @return the JSON object
181 :
182 : @error err:XQST0046 if the URI is textually invalid
183 :)
184declare function uri:parse(
185 $uri as xs:string) as object() external;
186
187(:~
188 : Serialize the URI passed as object into a string.
189 :
190 : @param $uri the object representing the URI
191 :
192 : @return the URI as string
193 :
194 : @error zerr:ZURI0001 if opaque part is specified in conjunction with
195 : host/port/path/user-info/query.
196 :
197 : @error zerr:ZURI0002 if opaque part is present but no scheme is present.
198 :
199 : @error zerr:ZURI0003 if a path component for an absolute URI
200 : doesn't start with "/".
201 :)
202declare function uri:serialize(
203 $uri as object()) as xs:string external;
109204
=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml 2013-05-02 10:19:11 +0000
+++ src/diagnostics/diagnostic_en.xml 2013-05-03 23:21:27 +0000
@@ -3123,6 +3123,23 @@
3123 <diagnostic code="ZJSE0008" name="BAD_VALUE">3123 <diagnostic code="ZJSE0008" name="BAD_VALUE">
3124 <value>"$1": illegal value for JSON type "$2"</value>3124 <value>"$1": illegal value for JSON type "$2"</value>
3125 </diagnostic>3125 </diagnostic>
3126
3127 <!-- /////////// URI procesing errors ///////////////////////////////// -->
3128
3129 <diagnostic code="ZURI0001" name="OPAQUE_WITH_OTHERS">
3130 <comment>If the opaque-part section of the URI was specified in conjuction with other non-opaque parts.</comment>
3131 <value>cannot specify opaque-part in conjunction with host/port/path/user-info/query</value>
3132 </diagnostic>
3133
3134 <diagnostic code="ZURI0002" name="SCHEME_REQUIRED_FOR_OPAQUE">
3135 <comment>If an opaque-part section was specified without a scheme section.</comment>
3136 <value>scheme required when specifying opaque-part</value>
3137 </diagnostic>
3138
3139 <diagnostic code="ZURI0003" name="SLASH_NEEDED_FOR_ABSOLUTE_URI">
3140 <comment>If an absolute URI is specified with a path that does not start with slash ("/").</comment>
3141 <value>path component of absolute URI must begin with /</value>
3142 </diagnostic>
31263143
3127 </namespace>3144 </namespace>
31283145
31293146
=== modified file 'src/diagnostics/pregenerated/diagnostic_list.cpp'
--- src/diagnostics/pregenerated/diagnostic_list.cpp 2013-05-02 10:19:11 +0000
+++ src/diagnostics/pregenerated/diagnostic_list.cpp 2013-05-03 23:21:27 +0000
@@ -1301,6 +1301,15 @@
1301ZorbaErrorCode ZJSE0008_BAD_VALUE( "ZJSE0008" );1301ZorbaErrorCode ZJSE0008_BAD_VALUE( "ZJSE0008" );
13021302
13031303
1304ZorbaErrorCode ZURI0001_OPAQUE_WITH_OTHERS( "ZURI0001" );
1305
1306
1307ZorbaErrorCode ZURI0002_SCHEME_REQUIRED_FOR_OPAQUE( "ZURI0002" );
1308
1309
1310ZorbaErrorCode ZURI0003_SLASH_NEEDED_FOR_ABSOLUTE_URI( "ZURI0003" );
1311
1312
1304} // namespace zerr1313} // namespace zerr
13051314
1306namespace jerr {1315namespace jerr {
13071316
=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp 2013-05-02 10:19:11 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp 2013-05-03 23:21:27 +0000
@@ -488,6 +488,9 @@
488 { "ZSTR0060", "\"$1\": value out of range${ 2}" },488 { "ZSTR0060", "\"$1\": value out of range${ 2}" },
489 { "ZSTR0065", "Zorba did not close properly, objects may still in memory.\\n$1 referenced URI(s) remain in the string pool.\\nFor help avoiding this message please refer to http://www.zorba-xquery.com/html/documentation in section General Architecture -> Memory Leaks." },489 { "ZSTR0065", "Zorba did not close properly, objects may still in memory.\\n$1 referenced URI(s) remain in the string pool.\\nFor help avoiding this message please refer to http://www.zorba-xquery.com/html/documentation in section General Architecture -> Memory Leaks." },
490 { "ZSTR0066", "$1: does not reference a node in collection $2" },490 { "ZSTR0066", "$1: does not reference a node in collection $2" },
491 { "ZURI0001", "cannot specify opaque-part in conjunction with host/port/path/user-info/query" },
492 { "ZURI0002", "scheme required when specifying opaque-part" },
493 { "ZURI0003", "path component of absolute URI must begin with /" },
491 { "ZWST0002", "\"$1\": unknown or unsupported annotation" },494 { "ZWST0002", "\"$1\": unknown or unsupported annotation" },
492 { "ZWST0003", "\"$1\": function declared sequential, but has non-sequential body" },495 { "ZWST0003", "\"$1\": function declared sequential, but has non-sequential body" },
493 { "ZWST0004", "sequential FLWOR expr may not have the semantics you expect" },496 { "ZWST0004", "sequential FLWOR expr may not have the semantics you expect" },
494497
=== modified file 'src/diagnostics/qname.cpp'
--- src/diagnostics/qname.cpp 2013-02-07 17:24:36 +0000
+++ src/diagnostics/qname.cpp 2013-05-03 23:21:27 +0000
@@ -125,6 +125,7 @@
125 case 'O': return ZORBA_OS;125 case 'O': return ZORBA_OS;
126 case 'S': return ZORBA_STORE;126 case 'S': return ZORBA_STORE;
127 case 'X': return ZORBA_XQP;127 case 'X': return ZORBA_XQP;
128 case 'U': return ZORBA_CORE_MODULE;
128129
129 default : ZORBA_ASSERT( false );130 default : ZORBA_ASSERT( false );
130 }131 }
131132
=== modified file 'src/functions/pregenerated/func_uris.cpp'
--- src/functions/pregenerated/func_uris.cpp 2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_uris.cpp 2013-05-03 23:21:27 +0000
@@ -41,6 +41,26 @@
41 return new DecodeURIIterator(sctx, loc, argv);41 return new DecodeURIIterator(sctx, loc, argv);
42}42}
4343
44PlanIter_t fn_zorba_uri_parse::codegen(
45 CompilerCB*,
46 static_context* sctx,
47 const QueryLoc& loc,
48 std::vector<PlanIter_t>& argv,
49 expr& ann) const
50{
51 return new ParseURIIterator(sctx, loc, argv);
52}
53
54PlanIter_t fn_zorba_uri_serialize::codegen(
55 CompilerCB*,
56 static_context* sctx,
57 const QueryLoc& loc,
58 std::vector<PlanIter_t>& argv,
59 expr& ann) const
60{
61 return new SerializeURIIterator(sctx, loc, argv);
62}
63
44void populate_context_uris(static_context* sctx)64void populate_context_uris(static_context* sctx)
45{65{
4666
@@ -56,6 +76,30 @@
5676
57 }77 }
5878
79
80
81
82 {
83 DECL_WITH_KIND(sctx, fn_zorba_uri_parse,
84 (createQName("http://www.zorba-xquery.com/modules/uri","","parse"),
85 GENV_TYPESYSTEM.STRING_TYPE_ONE,
86 GENV_TYPESYSTEM.JSON_OBJECT_TYPE_ONE),
87 FunctionConsts::FN_ZORBA_URI_PARSE_1);
88
89 }
90
91
92
93
94 {
95 DECL_WITH_KIND(sctx, fn_zorba_uri_serialize,
96 (createQName("http://www.zorba-xquery.com/modules/uri","","serialize"),
97 GENV_TYPESYSTEM.JSON_OBJECT_TYPE_ONE,
98 GENV_TYPESYSTEM.STRING_TYPE_ONE),
99 FunctionConsts::FN_ZORBA_URI_SERIALIZE_1);
100
101 }
102
59}103}
60104
61105
62106
=== modified file 'src/functions/pregenerated/func_uris.h'
--- src/functions/pregenerated/func_uris.h 2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_uris.h 2013-05-03 23:21:27 +0000
@@ -53,6 +53,36 @@
53};53};
5454
5555
56//fn-zorba-uri:parse
57class fn_zorba_uri_parse : public function
58{
59public:
60 fn_zorba_uri_parse(const signature& sig, FunctionConsts::FunctionKind kind)
61 :
62 function(sig, kind)
63 {
64
65 }
66
67 CODEGEN_DECL();
68};
69
70
71//fn-zorba-uri:serialize
72class fn_zorba_uri_serialize : public function
73{
74public:
75 fn_zorba_uri_serialize(const signature& sig, FunctionConsts::FunctionKind kind)
76 :
77 function(sig, kind)
78 {
79
80 }
81
82 CODEGEN_DECL();
83};
84
85
56} //namespace zorba86} //namespace zorba
5787
5888
5989
=== modified file 'src/functions/pregenerated/function_enum.h'
--- src/functions/pregenerated/function_enum.h 2013-04-10 21:01:35 +0000
+++ src/functions/pregenerated/function_enum.h 2013-05-03 23:21:27 +0000
@@ -496,6 +496,8 @@
496 FN_ZORBA_STRING_IS_STREAMABLE_1,496 FN_ZORBA_STRING_IS_STREAMABLE_1,
497 FN_ZORBA_STRING_SPLIT_2,497 FN_ZORBA_STRING_SPLIT_2,
498 FN_ZORBA_URI_DECODE_3,498 FN_ZORBA_URI_DECODE_3,
499 FN_ZORBA_URI_PARSE_1,
500 FN_ZORBA_URI_SERIALIZE_1,
499 FN_ZORBA_XQDOC_XQDOC_CONTENT_IMPL_2,501 FN_ZORBA_XQDOC_XQDOC_CONTENT_IMPL_2,
500 FN_ZORBA_XQDOC_XQDOC_CONTENT_OPTIONS_IMPL_3,502 FN_ZORBA_XQDOC_XQDOC_CONTENT_OPTIONS_IMPL_3,
501503
502504
=== modified file 'src/runtime/pregenerated/iterator_enum.h'
--- src/runtime/pregenerated/iterator_enum.h 2013-03-15 08:22:41 +0000
+++ src/runtime/pregenerated/iterator_enum.h 2013-05-03 23:21:27 +0000
@@ -369,6 +369,8 @@
369 TYPE_StringIsStreamableIterator,369 TYPE_StringIsStreamableIterator,
370 TYPE_StringSplitIterator,370 TYPE_StringSplitIterator,
371 TYPE_DecodeURIIterator,371 TYPE_DecodeURIIterator,
372 TYPE_ParseURIIterator,
373 TYPE_SerializeURIIterator,
372 TYPE_XQDocContentIterator,374 TYPE_XQDocContentIterator,
373375
374376
375377
=== modified file 'src/runtime/spec/uris/uris.xml'
--- src/runtime/spec/uris/uris.xml 2013-02-07 17:24:36 +0000
+++ src/runtime/spec/uris/uris.xml 2013-05-03 23:21:27 +0000
@@ -37,4 +37,32 @@
37 </zorba:function>37 </zorba:function>
38</zorba:iterator>38</zorba:iterator>
3939
40<zorba:iterator name="ParseURIIterator">
41
42 <zorba:description author="Zorba Team">
43 uri:parse
44 </zorba:description>
45
46 <zorba:function>
47 <zorba:signature localname="parse" prefix="fn-zorba-uri">
48 <zorba:param>xs:string</zorba:param>
49 <zorba:output>object()</zorba:output>
50 </zorba:signature>
51 </zorba:function>
52</zorba:iterator>
53
54<zorba:iterator name="SerializeURIIterator">
55
56 <zorba:description author="Zorba Team">
57 uri:serialize
58 </zorba:description>
59
60 <zorba:function>
61 <zorba:signature localname="serialize" prefix="fn-zorba-uri">
62 <zorba:param>object()</zorba:param>
63 <zorba:output>xs:string</zorba:output>
64 </zorba:signature>
65 </zorba:function>
66</zorba:iterator>
67
40</zorba:iterators>68</zorba:iterators>
4169
=== modified file 'src/runtime/uris/pregenerated/uris.cpp'
--- src/runtime/uris/pregenerated/uris.cpp 2013-03-05 23:11:50 +0000
+++ src/runtime/uris/pregenerated/uris.cpp 2013-05-03 23:21:27 +0000
@@ -60,6 +60,62 @@
60// </DecodeURIIterator>60// </DecodeURIIterator>
6161
6262
63// <ParseURIIterator>
64SERIALIZABLE_CLASS_VERSIONS(ParseURIIterator)
65
66void ParseURIIterator::serialize(::zorba::serialization::Archiver& ar)
67{
68 serialize_baseclass(ar,
69 (NaryBaseIterator<ParseURIIterator, PlanIteratorState>*)this);
70}
71
72
73void ParseURIIterator::accept(PlanIterVisitor& v) const
74{
75 v.beginVisit(*this);
76
77 std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
78 std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
79 for ( ; lIter != lEnd; ++lIter ){
80 (*lIter)->accept(v);
81 }
82
83 v.endVisit(*this);
84}
85
86ParseURIIterator::~ParseURIIterator() {}
87
88// </ParseURIIterator>
89
90
91// <SerializeURIIterator>
92SERIALIZABLE_CLASS_VERSIONS(SerializeURIIterator)
93
94void SerializeURIIterator::serialize(::zorba::serialization::Archiver& ar)
95{
96 serialize_baseclass(ar,
97 (NaryBaseIterator<SerializeURIIterator, PlanIteratorState>*)this);
98}
99
100
101void SerializeURIIterator::accept(PlanIterVisitor& v) const
102{
103 v.beginVisit(*this);
104
105 std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
106 std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
107 for ( ; lIter != lEnd; ++lIter ){
108 (*lIter)->accept(v);
109 }
110
111 v.endVisit(*this);
112}
113
114SerializeURIIterator::~SerializeURIIterator() {}
115
116// </SerializeURIIterator>
117
118
63119
64}120}
65121
66122
=== modified file 'src/runtime/uris/pregenerated/uris.h'
--- src/runtime/uris/pregenerated/uris.h 2013-03-05 23:11:50 +0000
+++ src/runtime/uris/pregenerated/uris.h 2013-05-03 23:21:27 +0000
@@ -67,6 +67,70 @@
67};67};
6868
6969
70/**
71 *
72 * uri:parse
73 *
74 * Author: Zorba Team
75 */
76class ParseURIIterator : public NaryBaseIterator<ParseURIIterator, PlanIteratorState>
77{
78public:
79 SERIALIZABLE_CLASS(ParseURIIterator);
80
81 SERIALIZABLE_CLASS_CONSTRUCTOR2T(ParseURIIterator,
82 NaryBaseIterator<ParseURIIterator, PlanIteratorState>);
83
84 void serialize( ::zorba::serialization::Archiver& ar);
85
86 ParseURIIterator(
87 static_context* sctx,
88 const QueryLoc& loc,
89 std::vector<PlanIter_t>& children)
90 :
91 NaryBaseIterator<ParseURIIterator, PlanIteratorState>(sctx, loc, children)
92 {}
93
94 virtual ~ParseURIIterator();
95
96 void accept(PlanIterVisitor& v) const;
97
98 bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
99};
100
101
102/**
103 *
104 * uri:serialize
105 *
106 * Author: Zorba Team
107 */
108class SerializeURIIterator : public NaryBaseIterator<SerializeURIIterator, PlanIteratorState>
109{
110public:
111 SERIALIZABLE_CLASS(SerializeURIIterator);
112
113 SERIALIZABLE_CLASS_CONSTRUCTOR2T(SerializeURIIterator,
114 NaryBaseIterator<SerializeURIIterator, PlanIteratorState>);
115
116 void serialize( ::zorba::serialization::Archiver& ar);
117
118 SerializeURIIterator(
119 static_context* sctx,
120 const QueryLoc& loc,
121 std::vector<PlanIter_t>& children)
122 :
123 NaryBaseIterator<SerializeURIIterator, PlanIteratorState>(sctx, loc, children)
124 {}
125
126 virtual ~SerializeURIIterator();
127
128 void accept(PlanIterVisitor& v) const;
129
130 bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
131};
132
133
70}134}
71#endif135#endif
72/*136/*
73137
=== modified file 'src/runtime/uris/uris_impl.cpp'
--- src/runtime/uris/uris_impl.cpp 2013-04-16 21:12:12 +0000
+++ src/runtime/uris/uris_impl.cpp 2013-05-03 23:21:27 +0000
@@ -32,6 +32,18 @@
3232
33#include "util/uri_util.h"33#include "util/uri_util.h"
3434
35#include "zorbatypes/URI.h"
36
37#define SCHEME_NAME "scheme"
38#define OPAQUE_PART_NAME "opaque-part"
39#define AUTHORITY_NAME "authority"
40#define USER_INFO_NAME "user-info"
41#define HOST_NAME "host"
42#define PORT_NAME "port"
43#define PATH_NAME "path"
44#define QUERY_NAME "query"
45#define FRAGMENT_NAME "fragment"
46
35using namespace std;47using namespace std;
3648
37namespace zorba {49namespace zorba {
@@ -101,5 +113,209 @@
101113
102 STACK_END (state);114 STACK_END (state);
103}115}
116
117/******************************************************************************
118*******************************************************************************/
119bool
120ParseURIIterator::nextImpl(store::Item_t& result, PlanState& planState) const
121{
122 store::Item_t lItemURI, lName, lValue;
123 std::vector<store::Item_t> lNames;
124 std::vector<store::Item_t> lValues;
125 zorba::zstring lStrURI, lZKey, lZVal;
126 PlanIteratorState* state;
127 URI uri;
128
129 DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
130
131 consumeNext(lItemURI, theChildren[0].getp(), planState);
132 lItemURI->getStringValue2(lStrURI);
133 uri = URI(lStrURI);
134
135 lZVal = uri.get_scheme();
136 if(!lZVal.empty())
137 {
138 lZKey = zorba::zstring(SCHEME_NAME);
139 GENV_ITEMFACTORY->createString(lName, lZKey);
140 GENV_ITEMFACTORY->createString(lValue, lZVal);
141 lNames.push_back(lName);
142 lValues.push_back(lValue);
143 }
144
145 lZVal = uri.get_opaque_part();
146 if(!lZVal.empty())
147 {
148 lZKey = zorba::zstring(OPAQUE_PART_NAME);
149 GENV_ITEMFACTORY->createString(lName, lZKey);
150 GENV_ITEMFACTORY->createString(lValue, lZVal);
151 lNames.push_back(lName);
152 lValues.push_back(lValue);
153 }
154
155 lZVal = uri.get_encoded_reg_based_authority();
156 if(!lZVal.empty())
157 {
158 lZKey = zorba::zstring(AUTHORITY_NAME);
159 GENV_ITEMFACTORY->createString(lName, lZKey);
160 GENV_ITEMFACTORY->createString(lValue, lZVal);
161 lNames.push_back(lName);
162 lValues.push_back(lValue);
163 }
164
165 lZVal = uri.get_encoded_user_info();
166 if(!lZVal.empty())
167 {
168 lZKey = zorba::zstring(USER_INFO_NAME);
169 GENV_ITEMFACTORY->createString(lName, lZKey);
170 GENV_ITEMFACTORY->createString(lValue, lZVal);
171 lNames.push_back(lName);
172 lValues.push_back(lValue);
173 }
174
175 lZVal = uri.get_host();
176 if(!lZVal.empty())
177 {
178 lZKey = zorba::zstring(HOST_NAME);
179 GENV_ITEMFACTORY->createString(lName, lZKey);
180 GENV_ITEMFACTORY->createString(lValue, lZVal);
181 lNames.push_back(lName);
182 lValues.push_back(lValue);
183 }
184
185 if(uri.get_port() != 0)
186 {
187 lZKey = zorba::zstring(PORT_NAME);
188 GENV_ITEMFACTORY->createString(lName, lZKey);
189 GENV_ITEMFACTORY->createInt(lValue, uri.get_port());
190 lNames.push_back(lName);
191 lValues.push_back(lValue);
192 }
193
194 lZVal = uri.get_encoded_path();
195 if(!lZVal.empty())
196 {
197 lZKey = zorba::zstring(PATH_NAME);
198 GENV_ITEMFACTORY->createString(lName, lZKey);
199 GENV_ITEMFACTORY->createString(lValue, lZVal);
200 lNames.push_back(lName);
201 lValues.push_back(lValue);
202 }
203
204 lZVal = uri.get_encoded_query();
205 if(uri.is_set(URI::QueryString))
206 {
207 lZKey = zorba::zstring(QUERY_NAME);
208 GENV_ITEMFACTORY->createString(lName, lZKey);
209 GENV_ITEMFACTORY->createString(lValue, lZVal);
210 lNames.push_back(lName);
211 lValues.push_back(lValue);
212 }
213
214 lZVal = uri.get_encoded_fragment();
215 if(!lZVal.empty())
216 {
217 lZKey = zorba::zstring(FRAGMENT_NAME);
218 GENV_ITEMFACTORY->createString(lName, lZKey);
219 GENV_ITEMFACTORY->createString(lValue, lZVal);
220 lNames.push_back(lName);
221 lValues.push_back(lValue);
222 }
223
224 GENV_ITEMFACTORY->createJSONObject(result, lNames, lValues);
225
226 STACK_PUSH(result, state );
227
228 STACK_END (state);
229}
230
231/******************************************************************************
232*******************************************************************************/
233bool
234SerializeURIIterator::nextImpl(store::Item_t& result, PlanState& planState) const
235{
236 store::Item_t lItemURI, lItemKey;
237 zorba::zstring lStrValue, lStrKey, lStrRes;
238 store::Iterator_t lKeys;
239 URI uri = URI();
240 int lIntPort = 0;
241 bool lHasSchemeField, lHasOpaqueField, lHasNotOpaqueField;
242
243 PlanIteratorState* state;
244 DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
245
246 consumeNext(lItemURI, theChildren[0].getp(), planState);
247
248 lHasSchemeField = lHasOpaqueField = lHasNotOpaqueField = false;
249 if(lItemURI->isJSONObject()) {
250 lKeys = lItemURI->getObjectKeys();
251 if(!lKeys.isNull()){
252 lKeys->open();
253 while(lKeys->next(lItemKey)){
254 lStrKey = lItemKey->getStringValue();
255 lStrValue = lItemURI->getObjectValue(lItemKey)->getStringValue();
256 if(lStrKey == SCHEME_NAME && !lStrValue.empty()){
257 uri.set_scheme(lStrValue);
258 lHasSchemeField = true;
259 } else if(lStrKey == OPAQUE_PART_NAME && !lStrValue.empty()){
260 uri.set_opaque_part(lStrValue);
261 lHasOpaqueField = true;
262 } else if(lStrKey == AUTHORITY_NAME && !lStrValue.empty()){
263 uri.set_reg_based_authority(lStrValue);
264 lHasNotOpaqueField = true;
265 } else if(lStrKey == USER_INFO_NAME && !lStrValue.empty()){
266 uri.set_user_info(lStrValue);
267 lHasNotOpaqueField = true;
268 } else if(lStrKey == HOST_NAME && !lStrValue.empty()){
269 uri.set_host(lStrValue);
270 lHasNotOpaqueField = true;
271 } else if(lStrKey == PORT_NAME){
272 sscanf(lStrValue.str().c_str(), "%d", &lIntPort);
273 if(lIntPort != 0){
274 uri.set_port(lIntPort);
275 lHasNotOpaqueField = true;
276 }
277 } else if(lStrKey == PATH_NAME && !lStrValue.empty()){
278 uri.set_path(lStrValue);
279 lHasNotOpaqueField = true;
280 } else if(lStrKey == QUERY_NAME){
281 uri.set_query(lStrValue);
282 lHasNotOpaqueField = true;
283 } else if(lStrKey == FRAGMENT_NAME){
284 uri.set_fragment(lStrValue);
285 }
286 }
287 lKeys->close();
288 }
289 }
290
291 // check for errors
292 if(lHasOpaqueField && lHasNotOpaqueField)
293 {
294 throw XQUERY_EXCEPTION(
295 zerr::ZURI0001_OPAQUE_WITH_OTHERS,
296 ERROR_LOC( loc )
297 );
298 }
299 if(lHasOpaqueField && !lHasSchemeField)
300 {
301 throw XQUERY_EXCEPTION(
302 zerr::ZURI0002_SCHEME_REQUIRED_FOR_OPAQUE,
303 ERROR_LOC( loc )
304 );
305 }
306 if(lHasSchemeField && !uri.get_encoded_path().empty() && (uri.get_encoded_path().substr(0,1) != "/"))
307 {
308 throw XQUERY_EXCEPTION(
309 zerr::ZURI0003_SLASH_NEEDED_FOR_ABSOLUTE_URI,
310 ERROR_LOC( loc )
311 );
312 }
313
314 lStrRes = zorba::zstring(uri.toString());
315 STACK_PUSH(GENV_ITEMFACTORY->createString(result, lStrRes), state );
316
317 STACK_END (state);
318}
319
104} // namespace zorba320} // namespace zorba
105/* vim:set et sw=2 ts=2: */321/* vim:set et sw=2 ts=2: */
106322
=== modified file 'src/runtime/visitors/pregenerated/planiter_visitor.h'
--- src/runtime/visitors/pregenerated/planiter_visitor.h 2013-03-15 08:22:41 +0000
+++ src/runtime/visitors/pregenerated/planiter_visitor.h 2013-05-03 23:21:27 +0000
@@ -766,6 +766,10 @@
766766
767 class DecodeURIIterator;767 class DecodeURIIterator;
768768
769 class ParseURIIterator;
770
771 class SerializeURIIterator;
772
769 class XQDocContentIterator;773 class XQDocContentIterator;
770774
771775
@@ -1863,6 +1867,12 @@
1863 virtual void beginVisit ( const DecodeURIIterator& ) = 0;1867 virtual void beginVisit ( const DecodeURIIterator& ) = 0;
1864 virtual void endVisit ( const DecodeURIIterator& ) = 0;1868 virtual void endVisit ( const DecodeURIIterator& ) = 0;
18651869
1870 virtual void beginVisit ( const ParseURIIterator& ) = 0;
1871 virtual void endVisit ( const ParseURIIterator& ) = 0;
1872
1873 virtual void beginVisit ( const SerializeURIIterator& ) = 0;
1874 virtual void endVisit ( const SerializeURIIterator& ) = 0;
1875
1866 virtual void beginVisit ( const XQDocContentIterator& ) = 0;1876 virtual void beginVisit ( const XQDocContentIterator& ) = 0;
1867 virtual void endVisit ( const XQDocContentIterator& ) = 0;1877 virtual void endVisit ( const XQDocContentIterator& ) = 0;
18681878
18691879
=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp'
--- src/runtime/visitors/pregenerated/printer_visitor.cpp 2013-03-27 00:44:34 +0000
+++ src/runtime/visitors/pregenerated/printer_visitor.cpp 2013-05-03 23:21:27 +0000
@@ -4905,6 +4905,34 @@
4905// </DecodeURIIterator>4905// </DecodeURIIterator>
49064906
49074907
4908// <ParseURIIterator>
4909void PrinterVisitor::beginVisit ( const ParseURIIterator& a) {
4910 thePrinter.startBeginVisit("ParseURIIterator", ++theId);
4911 printCommons( &a, theId );
4912 thePrinter.endBeginVisit( theId );
4913}
4914
4915void PrinterVisitor::endVisit ( const ParseURIIterator& ) {
4916 thePrinter.startEndVisit();
4917 thePrinter.endEndVisit();
4918}
4919// </ParseURIIterator>
4920
4921
4922// <SerializeURIIterator>
4923void PrinterVisitor::beginVisit ( const SerializeURIIterator& a) {
4924 thePrinter.startBeginVisit("SerializeURIIterator", ++theId);
4925 printCommons( &a, theId );
4926 thePrinter.endBeginVisit( theId );
4927}
4928
4929void PrinterVisitor::endVisit ( const SerializeURIIterator& ) {
4930 thePrinter.startEndVisit();
4931 thePrinter.endEndVisit();
4932}
4933// </SerializeURIIterator>
4934
4935
4908// <XQDocContentIterator>4936// <XQDocContentIterator>
4909void PrinterVisitor::beginVisit ( const XQDocContentIterator& a) {4937void PrinterVisitor::beginVisit ( const XQDocContentIterator& a) {
4910 thePrinter.startBeginVisit("XQDocContentIterator", ++theId);4938 thePrinter.startBeginVisit("XQDocContentIterator", ++theId);
49114939
=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.h'
--- src/runtime/visitors/pregenerated/printer_visitor.h 2013-03-15 08:22:41 +0000
+++ src/runtime/visitors/pregenerated/printer_visitor.h 2013-05-03 23:21:27 +0000
@@ -1170,6 +1170,12 @@
1170 void beginVisit( const DecodeURIIterator& );1170 void beginVisit( const DecodeURIIterator& );
1171 void endVisit ( const DecodeURIIterator& );1171 void endVisit ( const DecodeURIIterator& );
11721172
1173 void beginVisit( const ParseURIIterator& );
1174 void endVisit ( const ParseURIIterator& );
1175
1176 void beginVisit( const SerializeURIIterator& );
1177 void endVisit ( const SerializeURIIterator& );
1178
1173 void beginVisit( const XQDocContentIterator& );1179 void beginVisit( const XQDocContentIterator& );
1174 void endVisit ( const XQDocContentIterator& );1180 void endVisit ( const XQDocContentIterator& );
11751181
11761182
=== modified file 'src/unit_tests/test_uri.cpp'
--- src/unit_tests/test_uri.cpp 2013-02-07 17:24:36 +0000
+++ src/unit_tests/test_uri.cpp 2013-05-03 23:21:27 +0000
@@ -40,6 +40,7 @@
40 zorba::zstring userinfo;40 zorba::zstring userinfo;
41 zorba::zstring query;41 zorba::zstring query;
42 zorba::zstring path_notation;42 zorba::zstring path_notation;
43 zorba::zstring opaque_part;
43};44};
4445
4546
@@ -66,7 +67,8 @@
66 "/",67 "/",
67 "",68 "",
68 "",69 "",
69 "/" // path notation70 "/", // path notation
71 ""
70 },72 },
71 {73 {
72 "",74 "",
@@ -80,7 +82,8 @@
80 "/",82 "/",
81 "",83 "",
82 "",84 "",
83 "com/zorba-xquery/www/" // path notation85 "com/zorba-xquery/www/", // path notation
86 ""
84 },87 },
85 {88 {
86 "",89 "",
@@ -94,7 +97,8 @@
94 "/",97 "/",
95 "",98 "",
96 "abc=true",99 "abc=true",
97 "com/zorba-xquery/www/" // path notation100 "com/zorba-xquery/www/", // path notation
101 ""
98 },102 },
99 {103 {
100 "",104 "",
@@ -108,7 +112,8 @@
108 "/",112 "/",
109 "",113 "",
110 "abc=true",114 "abc=true",
111 "com/zorba-xquery/www/" // path notation115 "com/zorba-xquery/www/", // path notation
116 ""
112 },117 },
113 {118 {
114 "",119 "",
@@ -122,7 +127,8 @@
122 "/",127 "/",
123 "user",128 "user",
124 "abc=true",129 "abc=true",
125 "com/zorba-xquery/www/" // path notation130 "com/zorba-xquery/www/", // path notation
131 ""
126 },132 },
127 {133 {
128 "",134 "",
@@ -136,7 +142,8 @@
136 "/path1/path2",142 "/path1/path2",
137 "user",143 "user",
138 "abc=true",144 "abc=true",
139 "com/zorba-xquery/www/path1/path2" // path notation145 "com/zorba-xquery/www/path1/path2", // path notation
146 ""
140 },147 },
141 {148 {
142 "",149 "",
@@ -150,7 +157,8 @@
150 "/path1/path2",157 "/path1/path2",
151 "user",158 "user",
152 "abc=true&bcd=false",159 "abc=true&bcd=false",
153 "com/zorba-xquery/www/path1/path2" // path notation160 "com/zorba-xquery/www/path1/path2", // path notation
161 ""
154 },162 },
155 {163 {
156 "",164 "",
@@ -164,7 +172,8 @@
164 "/rfc/rfc1808.txt",172 "/rfc/rfc1808.txt",
165 "",173 "",
166 "",174 "",
167 "za/co/is/ftp/rfc/rfc1808.txt" // path notation175 "za/co/is/ftp/rfc/rfc1808.txt", // path notation
176 ""
168 },177 },
169 {178 {
170 "",179 "",
@@ -178,7 +187,8 @@
178 "/test",187 "/test",
179 "thomas",188 "thomas",
180 "",189 "",
181 "[2001:6f8:9000:876:cccc:bbbb::]/test" // path notation190 "[2001:6f8:9000:876:cccc:bbbb::]/test", // path notation
191 ""
182 },192 },
183 // uri resolver tests193 // uri resolver tests
184 {194 {
@@ -193,7 +203,8 @@
193 "/b/c/g",203 "/b/c/g",
194 "",204 "",
195 "",205 "",
196 "a/b/c/g" // path notation206 "a/b/c/g", // path notation
207 ""
197 },208 },
198 {209 {
199 "http://a/b/c/d;p?q",210 "http://a/b/c/d;p?q",
@@ -207,7 +218,8 @@
207 "/b/c/g",218 "/b/c/g",
208 "",219 "",
209 "",220 "",
210 "a/b/c/g" // path notation221 "a/b/c/g", // path notation
222 ""
211 },223 },
212 {224 {
213 "http://a/b/c/d;p?q",225 "http://a/b/c/d;p?q",
@@ -221,7 +233,8 @@
221 "/b/c/g/",233 "/b/c/g/",
222 "",234 "",
223 "",235 "",
224 "a/b/c/g/" // path notation236 "a/b/c/g/", // path notation
237 ""
225 },238 },
226 {239 {
227 "http://a/b/c/d;p?q",240 "http://a/b/c/d;p?q",
@@ -235,7 +248,8 @@
235 "/g",248 "/g",
236 "",249 "",
237 "",250 "",
238 "a/g" // path notation251 "a/g", // path notation
252 ""
239 },253 },
240 {254 {
241 "http://a/b/c/d;p?q",255 "http://a/b/c/d;p?q",
@@ -249,7 +263,8 @@
249 "/b/c/",263 "/b/c/",
250 "",264 "",
251 "y",265 "y",
252 "a/b/c/" // path notation266 "a/b/c/", // path notation
267 ""
253 },268 },
254 {269 {
255 "http://a/b/c/d;p?q",270 "http://a/b/c/d;p?q",
@@ -263,7 +278,8 @@
263 "/b/c/g",278 "/b/c/g",
264 "",279 "",
265 "y",280 "y",
266 "a/b/c/g" // path notation281 "a/b/c/g", // path notation
282 ""
267 } //,283 } //,
268 //{284 //{
269 // "http://a/b/c/d;p?q",285 // "http://a/b/c/d;p?q",
@@ -276,6 +292,7 @@
276 // "",292 // "",
277 // "/b/c/g",293 // "/b/c/g",
278 // "",294 // "",
295 // "".
279 // ""296 // ""
280 //}297 //}
281 ,298 ,
@@ -291,7 +308,8 @@
291 "/b/c/g",308 "/b/c/g",
292 "",309 "",
293 "",310 "",
294 "a/b/c/g" // path notation311 "a/b/c/g", // path notation
312 ""
295 },313 },
296 {314 {
297 "http://a/b/c/d;p?q",315 "http://a/b/c/d;p?q",
@@ -305,7 +323,8 @@
305 "/b/c/g",323 "/b/c/g",
306 "",324 "",
307 "y",325 "y",
308 "a/b/c/g" // path notation326 "a/b/c/g", // path notation
327 ""
309 },328 },
310 {329 {
311 "http://a/b/c/d;p?q",330 "http://a/b/c/d;p?q",
@@ -319,7 +338,8 @@
319 "/b/c/;x",338 "/b/c/;x",
320 "",339 "",
321 "",340 "",
322 "a/b/c/;x" // path notation341 "a/b/c/;x", // path notation
342 ""
323 },343 },
324 {344 {
325 "http://a/b/c/d;p?q",345 "http://a/b/c/d;p?q",
@@ -333,7 +353,8 @@
333 "/b/c/g;x",353 "/b/c/g;x",
334 "",354 "",
335 "",355 "",
336 "a/b/c/g;x" // path notation356 "a/b/c/g;x", // path notation
357 ""
337 },358 },
338 {359 {
339 "http://a/b/c/d;p?q",360 "http://a/b/c/d;p?q",
@@ -347,7 +368,8 @@
347 "/b/c/g;x",368 "/b/c/g;x",
348 "",369 "",
349 "y",370 "y",
350 "a/b/c/g;x" // path notation371 "a/b/c/g;x", // path notation
372 ""
351 },373 },
352 {374 {
353 "http://a/b/c/d;p?q",375 "http://a/b/c/d;p?q",
@@ -361,7 +383,8 @@
361 "/b/c/",383 "/b/c/",
362 "",384 "",
363 "",385 "",
364 "a/b/c/" // path notation386 "a/b/c/", // path notation
387 ""
365 },388 },
366 {389 {
367 "http://a/b/c/d;p?q",390 "http://a/b/c/d;p?q",
@@ -375,7 +398,8 @@
375 "/b/c/",398 "/b/c/",
376 "",399 "",
377 "",400 "",
378 "a/b/c/" // path notation401 "a/b/c/", // path notation
402 ""
379 },403 },
380 {404 {
381 "http://a/b/c/d;p?q",405 "http://a/b/c/d;p?q",
@@ -389,7 +413,8 @@
389 "/b/",413 "/b/",
390 "",414 "",
391 "",415 "",
392 "a/b/" // path notation416 "a/b/", // path notation
417 ""
393 },418 },
394 {419 {
395 "http://a/b/c/d;p?q",420 "http://a/b/c/d;p?q",
@@ -403,7 +428,8 @@
403 "/b/",428 "/b/",
404 "",429 "",
405 "",430 "",
406 "a/b/" // path notation431 "a/b/", // path notation
432 ""
407 },433 },
408 {434 {
409 "http://a/b/c/d;p?q",435 "http://a/b/c/d;p?q",
@@ -417,7 +443,8 @@
417 "/b/g",443 "/b/g",
418 "",444 "",
419 "",445 "",
420 "a/b/g" // path notation446 "a/b/g", // path notation
447 ""
421 },448 },
422 {449 {
423 "http://a/b/c/d;p?q",450 "http://a/b/c/d;p?q",
@@ -431,7 +458,8 @@
431 "/",458 "/",
432 "",459 "",
433 "",460 "",
434 "a/" // path notation461 "a/", // path notation
462 ""
435 },463 },
436 {464 {
437 "http://a/b/c/d;p?q",465 "http://a/b/c/d;p?q",
@@ -445,7 +473,8 @@
445 "/",473 "/",
446 "",474 "",
447 "",475 "",
448 "a/" // path notation476 "a/", // path notation
477 ""
449 },478 },
450 {479 {
451 "http://a/b/c/d;p?q",480 "http://a/b/c/d;p?q",
@@ -459,7 +488,8 @@
459 "/g",488 "/g",
460 "",489 "",
461 "",490 "",
462 "a/g" // path notation491 "a/g", // path notation
492 ""
463 },493 },
464 {494 {
465 "http://a/b/c/d;p?q",495 "http://a/b/c/d;p?q",
@@ -473,7 +503,8 @@
473 "/b/c/g;x=1/y",503 "/b/c/g;x=1/y",
474 "",504 "",
475 "",505 "",
476 "a/b/c/g;x=1/y" // path notation506 "a/b/c/g;x=1/y", // path notation
507 ""
477 },508 },
478 {509 {
479 "http://a/b/c/d;p?q",510 "http://a/b/c/d;p?q",
@@ -487,7 +518,8 @@
487 "/b/c/y",518 "/b/c/y",
488 "",519 "",
489 "",520 "",
490 "a/b/c/y" // path notation521 "a/b/c/y", // path notation
522 ""
491 },523 },
492 {524 {
493 "http://a/b/c/d;p?q",525 "http://a/b/c/d;p?q",
@@ -501,7 +533,8 @@
501 "/b/c/g",533 "/b/c/g",
502 "",534 "",
503 "",535 "",
504 "a/b/c/g" // path notation536 "a/b/c/g", // path notation
537 ""
505 },538 },
506 {539 {
507 "http://www.example.com/",540 "http://www.example.com/",
@@ -515,7 +548,8 @@
515 "/",548 "/",
516 "",549 "",
517 "",550 "",
518 "example.com" // path notation551 "example.com", // path notation
552 ""
519 },553 },
520 {554 {
521 "http://www.example.com/",555 "http://www.example.com/",
@@ -529,7 +563,8 @@
529 "/dir/file",563 "/dir/file",
530 "",564 "",
531 "",565 "",
532 "example.com" // path notation566 "example.com", // path notation
567 ""
533 },568 },
534 {569 {
535 "",570 "",
@@ -543,7 +578,8 @@
543 "",578 "",
544 "",579 "",
545 "",580 "",
546 "de/msb/www" // path notation581 "de/msb/www", // path notation
582 ""
547 },583 },
548 {584 {
549 "http://www.msb.de/",585 "http://www.msb.de/",
@@ -557,7 +593,8 @@
557 "/lib/helpers",593 "/lib/helpers",
558 "",594 "",
559 "",595 "",
560 "de/msb/www/lib/helpers" // path notation596 "de/msb/www/lib/helpers", // path notation
597 ""
561 },598 },
562 {599 {
563 "",600 "",
@@ -575,7 +612,8 @@
575#endif 612#endif
576 "",613 "",
577 "",614 "",
578 "/d:/a/b/c" // path notation615 "/d:/a/b/c", // path notation
616 ""
579 },617 },
580 {618 {
581 "",619 "",
@@ -593,7 +631,8 @@
593#endif631#endif
594 "",632 "",
595 "",633 "",
596 "localhost/d:/a/b/c" // path notation634 "localhost/d:/a/b/c", // path notation
635 ""
597 },636 },
598 {637 {
599 "file://localhost",638 "file://localhost",
@@ -607,7 +646,83 @@
607 "/Ångström/b/c",646 "/Ångström/b/c",
608 "",647 "",
609 "",648 "",
610 "localhost/Ångström/b/c" // path notation649 "localhost/Ångström/b/c", // path notation
650 ""
651 },
652 {
653 "",
654 "opaq:opaque-uri-part#frag",
655 "opaq:opaque-uri-part#frag",
656 "opaq",
657 0,
658 "frag",
659 "",
660 "",
661 "",
662 "",
663 "",
664 "opaque-uri-part",
665 "opaque-uri-part"
666 },
667 {
668 "opaq:opaque-uri-part",
669 "#frag",
670 "opaq:opaque-uri-part#frag",
671 "opaq",
672 0,
673 "frag",
674 "",
675 "",
676 "",
677 "",
678 "",
679 "opaque-uri-part",
680 "opaque-uri-part"
681 },
682 {
683 "",
684 "opaq:text-file.txt",
685 "opaq:text-file.txt",
686 "opaq",
687 0,
688 "",
689 "",
690 "",
691 "",
692 "",
693 "",
694 "text-file.txt",
695 "text-file.txt"
696 },
697 {
698 "",
699 "ftp:///a/b/c/file.txt",
700 "ftp:///a/b/c/file.txt",
701 "ftp",
702 0,
703 "",
704 "",
705 "",
706 "/a/b/c/file.txt",
707 "",
708 "",
709 "/a/b/c/file.txt",
710 ""
711 },
712 {
713 "",
714 "gopher:///base_dir/file.txt",
715 "gopher:///base_dir/file.txt",
716 "gopher",
717 0,
718 "",
719 "",
720 "",
721 "/base_dir/file.txt",
722 "",
723 "",
724 "/base_dir/file.txt",
725 ""
611 }726 }
612 }; // URITestEntry tests[]727 }; // URITestEntry tests[]
613728
614729
=== modified file 'src/zorbatypes/URI.cpp'
--- src/zorbatypes/URI.cpp 2013-02-07 17:24:36 +0000
+++ src/zorbatypes/URI.cpp 2013-05-03 23:21:27 +0000
@@ -474,7 +474,7 @@
474 : 474 :
475 theState(0),475 theState(0),
476 thePort(0),476 thePort(0),
477 valid(validate)477 theValidate(validate)
478{478{
479 initialize(uri);479 initialize(uri);
480480
@@ -489,7 +489,7 @@
489 :489 :
490 theState(0),490 theState(0),
491 thePort(0),491 thePort(0),
492 valid(validate)492 theValidate(validate)
493{493{
494 initialize(uri, true);494 initialize(uri, true);
495 resolve(&base_uri);495 resolve(&base_uri);
@@ -503,7 +503,7 @@
503 :503 :
504 theState(0),504 theState(0),
505 thePort(0),505 thePort(0),
506 valid(false)506 theValidate(false)
507{507{
508 initialize(full_uri.toString(), false);508 initialize(full_uri.toString(), false);
509 relativize(&base_uri);509 relativize(&base_uri);
@@ -526,7 +526,7 @@
526 :526 :
527 theState(0),527 theState(0),
528 thePort(0),528 thePort(0),
529 valid(true)529 theValidate(true)
530{530{
531}531}
532532
@@ -553,7 +553,7 @@
553 thePath = to_copy.thePath;553 thePath = to_copy.thePath;
554 theQueryString = to_copy.theQueryString;554 theQueryString = to_copy.theQueryString;
555 theFragment = to_copy.theFragment;555 theFragment = to_copy.theFragment;
556 valid = to_copy.valid;556 theValidate = to_copy.theValidate;
557}557}
558558
559559
@@ -572,6 +572,7 @@
572 thePath.clear();572 thePath.clear();
573 theQueryString.clear();573 theQueryString.clear();
574 theFragment.clear();574 theFragment.clear();
575 theOpaquePart.clear();
575576
576 // first, we need to normalize the spaces in the uri577 // first, we need to normalize the spaces in the uri
577 // and only work with the normalized version from this point on578 // and only work with the normalized version from this point on
@@ -615,7 +616,7 @@
615 (lColonIdx > lFragmentIdx && lFragmentIdx != zstring::npos)) 616 (lColonIdx > lFragmentIdx && lFragmentIdx != zstring::npos))
616 {617 {
617 // A standalone base is a valid URI618 // A standalone base is a valid URI
618 if (valid &&619 if (theValidate &&
619 (lColonIdx == 0 || (!have_base && lFragmentIdx != zstring::npos)) &&620 (lColonIdx == 0 || (!have_base && lFragmentIdx != zstring::npos)) &&
620 lTrimmedURILength > 0)621 lTrimmedURILength > 0)
621 {622 {
@@ -631,11 +632,17 @@
631 lIndex = (ulong)theScheme.size() + 1;632 lIndex = (ulong)theScheme.size() + 1;
632 }633 }
633634
635 if(is_set(Scheme) && (lTrimmedURI.compare(lIndex, 1, "/") != 0))
636 {
637 // This is an opaque URI. Set that state here; initializePath() will
638 // actually set the value.
639 set_state(OpaquePart);
640 }
634 /**641 /**
635 * Authority642 * Authority
636 * two slashes means generic URI syntax, so we get the authority643 * two slashes means generic URI syntax, so we get the authority
637 */644 */
638 if ( (lTrimmedURI.compare(lIndex, 2, "//") == 0) ||645 else if ( (lTrimmedURI.compare(lIndex, 2, "//") == 0) ||
639 // allow JAVA FILE constructs without authority, i.e.: file:/D:/myFile 646 // allow JAVA FILE constructs without authority, i.e.: file:/D:/myFile
640 (ZSTREQ(theScheme, "file") && (lTrimmedURI.compare(lIndex, 1, "/") == 0)))647 (ZSTREQ(theScheme, "file") && (lTrimmedURI.compare(lIndex, 1, "/") == 0)))
641 {648 {
@@ -692,19 +699,16 @@
692 set_host(zstring());699 set_host(zstring());
693 }700 }
694 }701 }
695 // do not allow constructs like: file:D:/myFile or http:myFile
696 }702 }
697 else if (ZSTREQ(theScheme, "file") ||703 // do not allow constructs like: file:D:/myFile or http:myFile
698 ZSTREQ(theScheme, "http") ||704 else if (theValidate && (ZSTREQ(theScheme, "file") ||
699 ZSTREQ(theScheme, "https")) 705 ZSTREQ(theScheme, "http") ||
706 ZSTREQ(theScheme, "https") ) )
700 {707 {
701 if (valid)708 throw XQUERY_EXCEPTION(
702 {709 err::XQST0046,
703 throw XQUERY_EXCEPTION(710 ERROR_PARAMS( lTrimmedURI, ZED( BadURISyntaxForScheme_3 ), theScheme )
704 err::XQST0046,711 );
705 ERROR_PARAMS( lTrimmedURI, ZED( BadURISyntaxForScheme_3 ), theScheme )
706 );
707 }
708 }712 }
709713
710 // stop, if we're done here714 // stop, if we're done here
@@ -727,7 +731,7 @@
727{731{
728 zstring::size_type lSchemeSeparatorIdx = uri.find_first_of(":/?#", 0,4 );732 zstring::size_type lSchemeSeparatorIdx = uri.find_first_of(":/?#", 0,4 );
729 733
730 if ( valid && lSchemeSeparatorIdx == zstring::npos ) 734 if ( theValidate && lSchemeSeparatorIdx == zstring::npos )
731 {735 {
732 throw XQUERY_EXCEPTION(736 throw XQUERY_EXCEPTION(
733 err::XQST0046, ERROR_PARAMS( uri, ZED( NoURIScheme ) )737 err::XQST0046, ERROR_PARAMS( uri, ZED( NoURIScheme ) )
@@ -919,18 +923,12 @@
919 ulong lEnd = (ulong)lCodepoints.size();923 ulong lEnd = (ulong)lCodepoints.size();
920 uint32_t lCp = 0;924 uint32_t lCp = 0;
921925
922 if (uri.empty())926 bool lIsOpaque = is_set(OpaquePart);
923 {
924 thePath = uri;
925 set_state(Path);
926 return;
927 }
928927
929 // path - everything up to query string or fragment928 // path - everything up to query string (if not opaque) or fragment
930 if ( lStart < lEnd )929 if ( lStart < lEnd )
931 {930 {
932 // RFC 2732 only allows '[' and ']' to appear in the opaque part.931 if ( ! is_set(Scheme) || lIsOpaque || lCodepoints[lStart] == '/')
933 if ( ! is_set(Scheme) || lCodepoints[lStart] == '/')
934 {932 {
935 // Scan path.933 // Scan path.
936 // abs_path = "/" path_segments934 // abs_path = "/" path_segments
@@ -938,11 +936,20 @@
938 while ( lIndex < lEnd )936 while ( lIndex < lEnd )
939 {937 {
940 lCp = lCodepoints[lIndex];938 lCp = lCodepoints[lIndex];
941 if ( lCp == '?' || lCp == '#' )939 if (lCp == '?') {
940 if ( ! lIsOpaque) {
941 // Query string starting if not opaque
942 break;
943 }
944 // If it is an opaque URI, ? is fine
945 }
946 else if (lCp == '#' ) {
947 // Fragment starting
942 break;948 break;
943949 }
944 if ( lCp == '%' )950 else if ( lCp == '%' )
945 {951 {
952 // Percent-decoding check
946 if ( lIndex + 2 >= lEnd )953 if ( lIndex + 2 >= lEnd )
947 {954 {
948 throw XQUERY_EXCEPTION(err::XQST0046,955 throw XQUERY_EXCEPTION(err::XQST0046,
@@ -965,7 +972,7 @@
965 ERROR_PARAMS(uri, ZED(XQST0046_BadHexDigit_3), lHex2));972 ERROR_PARAMS(uri, ZED(XQST0046_BadHexDigit_3), lHex2));
966 }973 }
967 }974 }
968 else if (!is_unreserved_char(lCp) && !is_path_character(lCp) && valid)975 else if (theValidate && !is_unreserved_char(lCp) && !is_path_character(lCp))
969 {976 {
970 throw XQUERY_EXCEPTION(err::XQST0046,977 throw XQUERY_EXCEPTION(err::XQST0046,
971 ERROR_PARAMS(uri, ZED(BadUnicodeChar_3), lCp));978 ERROR_PARAMS(uri, ZED(BadUnicodeChar_3), lCp));
@@ -992,7 +999,7 @@
992 {999 {
993 // TODO check errors1000 // TODO check errors
994 }1001 }
995 else if (!is_reservered_or_unreserved_char(lCp) && valid)1002 else if (!is_reservered_or_unreserved_char(lCp) && theValidate)
996 {1003 {
997 throw XQUERY_EXCEPTION(1004 throw XQUERY_EXCEPTION(
998 err::XQST0046, ERROR_PARAMS( uri, ZED( BadUnicodeChar_3 ), lCp )1005 err::XQST0046, ERROR_PARAMS( uri, ZED( BadUnicodeChar_3 ), lCp )
@@ -1005,15 +1012,23 @@
1005 } // lStart < lEnd1012 } // lStart < lEnd
10061013
10071014
1008 thePath.clear();1015 // lCodepoints now contains all the processed stuff; put it in the right place
1009 utf8::append_codepoints(lCodepoints.begin() + lStart,1016 if (lIsOpaque) {
1010 lCodepoints.begin() + lIndex,1017 theOpaquePart.clear();
1011 &thePath);1018 utf8::append_codepoints(lCodepoints.begin() + lStart,
10121019 lCodepoints.begin() + lIndex,
1013 set_state(Path);1020 &theOpaquePart);
1021 }
1022 else {
1023 thePath.clear();
1024 utf8::append_codepoints(lCodepoints.begin() + lStart,
1025 lCodepoints.begin() + lIndex,
1026 &thePath);
1027 set_state(Path);
1028 }
10141029
1015 // query - starts with ? and up to fragment or end1030 // query - starts with ? and up to fragment or end
1016 if ( lCp == '?' )1031 if ( ( ! lIsOpaque) && (lCp == '?') )
1017 {1032 {
1018 ++lIndex;1033 ++lIndex;
1019 lStart = lIndex;1034 lStart = lIndex;
@@ -1159,6 +1174,28 @@
1159 }1174 }
1160}1175}
11611176
1177/*******************************************************************************
1178
1179********************************************************************************/
1180void URI::set_query(const zstring& new_query)
1181{
1182 theQueryString = new_query;
1183 set_state(QueryString);
1184}
1185
1186void URI::set_opaque_part(const zstring& new_scheme_specific)
1187{
1188 if (new_scheme_specific.empty())
1189 {
1190 theOpaquePart = new_scheme_specific;
1191 unset_state(OpaquePart);
1192 }
1193 else
1194 {
1195 theOpaquePart = new_scheme_specific;
1196 set_state(OpaquePart);
1197 }
1198}
11621199
1163/*******************************************************************************1200/*******************************************************************************
11641201
@@ -1287,7 +1324,7 @@
1287 set_state(Path);1324 set_state(Path);
1288 }1325 }
12891326
1290 if ( (! is_set(QueryString)) ) 1327 if ( base_uri->is_set(QueryString) && !is_set(QueryString) )
1291 {1328 {
1292 base_uri->get_query(theQueryString);1329 base_uri->get_query(theQueryString);
12931330
@@ -1584,6 +1621,13 @@
1584 std::ostringstream lPathNotation;1621 std::ostringstream lPathNotation;
15851622
1586 std::string lToTokenize;1623 std::string lToTokenize;
1624
1625 if(is_set(OpaquePart))
1626 {
1627 thePathNotation = theOpaquePart.str();
1628 return;
1629 }
1630
1587 if (is_set(Host)) 1631 if (is_set(Host))
1588 {1632 {
1589 lToTokenize = theHost.str();1633 lToTokenize = theHost.str();
@@ -1593,7 +1637,7 @@
1593 lToTokenize = theRegBasedAuthority.str();1637 lToTokenize = theRegBasedAuthority.str();
1594 }1638 }
15951639
1596 std::string::size_type lastPos = 1640 std::string::size_type lastPos =
1597 lToTokenize.find_last_not_of(".", lToTokenize.length());1641 lToTokenize.find_last_not_of(".", lToTokenize.length());
15981642
1599 std::string::size_type pos = lToTokenize.find_last_of(".", lastPos);1643 std::string::size_type pos = lToTokenize.find_last_of(".", lastPos);
@@ -1637,37 +1681,45 @@
1637 if ( is_set(Scheme) )1681 if ( is_set(Scheme) )
1638 lURI << theScheme << ":";1682 lURI << theScheme << ":";
16391683
1640 // Authority1684 if(is_set(OpaquePart))
1641 if ( is_set(Host) || is_set(RegBasedAuthority) ) 1685 {
1642 {1686 // opaque URL
1643 lURI << "//";1687 lURI << theOpaquePart;
1644 if ( is_set(Host) ) 1688 }
1645 {1689 else
1646 if ( is_set(UserInfo) )1690 {
1647 lURI << theUserInfo << "@";1691 // Authority
16481692 if ( is_set(Host) || is_set(RegBasedAuthority) )
1649 lURI << theHost;1693 {
16501694 lURI << "//";
1651 if ( is_set(Port) )1695 if ( is_set(Host) )
1652 lURI << ":" << thePort;1696 {
1653 }1697 if ( is_set(UserInfo) )
1654 else1698 lURI << theUserInfo << "@";
1655 {1699
1656 lURI << theRegBasedAuthority;1700 lURI << theHost;
1657 }1701
1658 }1702 if ( is_set(Port) )
16591703 lURI << ":" << thePort;
1660 if ( is_set(Path) )1704 }
1661 {1705 else
1662 #ifdef WIN321706 {
1663 if(ZSTREQ(theScheme, "file") && !thePath.empty() && (thePath[0] != '/'))1707 lURI << theRegBasedAuthority;
1664 lURI << "/";1708 }
1665 #endif1709 }
1666 lURI << thePath;1710
1667 }1711 if ( is_set(Path) )
16681712 {
1669 if ( is_set(QueryString) )1713 #ifdef WIN32
1670 lURI << "?" << theQueryString;1714 if(ZSTREQ(theScheme, "file") && !thePath.empty() && (thePath[0] != '/'))
1715 lURI << "/";
1716 #endif
1717 lURI << thePath;
1718 }
1719
1720 if ( is_set(QueryString) )
1721 lURI << "?" << theQueryString;
1722 }
16711723
1672 if ( is_set(Fragment) )1724 if ( is_set(Fragment) )
1673 lURI << "#" << theFragment;1725 lURI << "#" << theFragment;
@@ -1687,38 +1739,46 @@
1687 if ( is_set(Scheme) )1739 if ( is_set(Scheme) )
1688 lURI << theScheme << ":";1740 lURI << theScheme << ":";
16891741
1690 // Authority1742 if (is_set(OpaquePart))
1691 if ( is_set(Host) || is_set(RegBasedAuthority) ) 1743 {
1692 {1744 // opaque uri
1693 lURI << "//";1745 lURI << theOpaquePart;
1694 1746 }
1695 if ( is_set(Host) ) 1747 else
1696 {1748 {
1697 if ( is_set(UserInfo) )1749 // Authority
1698 lURI << theUserInfo << "@";1750 if ( is_set(Host) || is_set(RegBasedAuthority) )
16991751 {
1700 lURI << theHost;1752 lURI << "//";
17011753
1702 if ( is_set(Port) )1754 if ( is_set(Host) )
1703 lURI << ":" << thePort;1755 {
1704 }1756 if ( is_set(UserInfo) )
1705 else 1757 lURI << theUserInfo << "@";
1706 {1758
1707 lURI << theRegBasedAuthority;1759 lURI << theHost;
1708 }1760
1709 }1761 if ( is_set(Port) )
17101762 lURI << ":" << thePort;
1711 if ( is_set(Path) )1763 }
1712 {1764 else
1713 #ifdef WIN321765 {
1714 if(ZSTREQ(theScheme, "file") && !thePath.empty() && (thePath[0] != '/'))1766 lURI << theRegBasedAuthority;
1715 lURI << "/";1767 }
1716 #endif1768 }
1717 lURI << thePath;1769
1718 }1770 if ( is_set(Path) )
17191771 {
1720 if ( is_set(QueryString) )1772 #ifdef WIN32
1721 lURI << "?" << theQueryString;1773 if(ZSTREQ(theScheme, "file") && !thePath.empty() && (thePath[0] != '/'))
1774 lURI << "/";
1775 #endif
1776 lURI << thePath;
1777 }
1778
1779 if ( is_set(QueryString) )
1780 lURI << "?" << theQueryString;
1781 }
17221782
1723 if ( is_set(Fragment) )1783 if ( is_set(Fragment) )
1724 lURI << "#" << theFragment;1784 lURI << "#" << theFragment;
17251785
=== modified file 'src/zorbatypes/URI.h'
--- src/zorbatypes/URI.h 2013-02-07 17:24:36 +0000
+++ src/zorbatypes/URI.h 2013-05-03 23:21:27 +0000
@@ -49,19 +49,20 @@
4949
50 static long scanHexSequence(const char* addr, long idx, long end, long& counter);50 static long scanHexSequence(const char* addr, long idx, long end, long& counter);
5151
52protected:
53 enum States 52 enum States
54 {53 {
55 Scheme = 1,54 Scheme = 1,
56 UserInfo = 2,55 UserInfo = 2,
57 Host = 4,56 Host = 4,
58 Port = 8,57 Port = 8,
59 RegBasedAuthority = 16,58 RegBasedAuthority = 16,
60 Path = 32,59 Path = 32,
61 QueryString = 64,60 QueryString = 64,
62 Fragment = 12861 Fragment = 128,
62 OpaquePart = 256
63 };63 };
6464
65protected:
65 // keep track whether particular components of a uri are defined or undefined66 // keep track whether particular components of a uri are defined or undefined
66 mutable uint32_t theState;67 mutable uint32_t theState;
6768
@@ -81,9 +82,10 @@
81 zstring thePath;82 zstring thePath;
82 zstring theQueryString;83 zstring theQueryString;
83 zstring theFragment;84 zstring theFragment;
85 zstring theOpaquePart;
8486
85 // true if the constructed URI is valid87 // true if the constructed URI is valid
86 bool valid;88 bool theValidate;
8789
88public:90public:
89 URI(const zstring& uri, bool validate = true);91 URI(const zstring& uri, bool validate = true);
@@ -154,6 +156,14 @@
154156
155 void clear_fragment();157 void clear_fragment();
156158
159 void set_opaque_part(const zstring& new_opaque_part);
160
161 const zstring& get_opaque_part() const;
162
163 void clear_opaque_part();
164
165 bool is_set(uint32_t s) const { return ((theState & s) > 0); }
166
157protected:167protected:
158 void build_full_text() const;168 void build_full_text() const;
159169
@@ -185,8 +195,6 @@
185195
186 void set_state(uint32_t s) const { theState |= s; }196 void set_state(uint32_t s) const { theState |= s; }
187197
188 bool is_set(uint32_t s) const { return ((theState & s) > 0); }
189
190 void unset_state(uint32_t s) const { theState &= ~s; }198 void unset_state(uint32_t s) const { theState &= ~s; }
191199
192 void invalidate_text() const;200 void invalidate_text() const;
@@ -195,7 +203,9 @@
195203
196inline bool URI::is_valid() const204inline bool URI::is_valid() const
197{205{
198 return valid;206 // If we requested validation originally, and successfully passed the
207 // initialize step - we're valid!
208 return theValidate;
199}209}
200210
201211
@@ -246,9 +256,15 @@
246 return theFragment;256 return theFragment;
247}257}
248258
259inline const zstring& URI::get_opaque_part() const
260{
261 return theOpaquePart;
262}
263
249inline void URI::set_fragment(const zstring &new_fragment)264inline void URI::set_fragment(const zstring &new_fragment)
250{265{
251 theFragment = new_fragment;266 theFragment = new_fragment;
267 set_state(Fragment);
252 invalidate_text();268 invalidate_text();
253}269}
254270
@@ -259,6 +275,13 @@
259 invalidate_text();275 invalidate_text();
260}276}
261277
278inline void URI::clear_opaque_part()
279{
280 theOpaquePart.clear();
281 unset_state(OpaquePart);
282 invalidate_text();
283}
284
262inline void URI::invalidate_text() const285inline void URI::invalidate_text() const
263{286{
264 theASCIIURIText.clear();287 theASCIIURIText.clear();
265288
=== modified file 'test/fots/CMakeLists.txt'
--- test/fots/CMakeLists.txt 2013-05-03 07:40:27 +0000
+++ test/fots/CMakeLists.txt 2013-05-03 23:21:27 +0000
@@ -303,7 +303,6 @@
303EXPECTED_FOTS_FAILURE (prod-ModuleImport module-URIs-12 0)303EXPECTED_FOTS_FAILURE (prod-ModuleImport module-URIs-12 0)
304EXPECTED_FOTS_FAILURE (prod-ModuleImport module-URIs-17 0)304EXPECTED_FOTS_FAILURE (prod-ModuleImport module-URIs-17 0)
305EXPECTED_FOTS_FAILURE (prod-ModuleImport module-URIs-18 0)305EXPECTED_FOTS_FAILURE (prod-ModuleImport module-URIs-18 0)
306EXPECTED_FOTS_FAILURE (prod-ModuleImport module-URIs-19 0)
307EXPECTED_FOTS_FAILURE (prod-ModuleImport modules-collide-var-001 0)306EXPECTED_FOTS_FAILURE (prod-ModuleImport modules-collide-var-001 0)
308EXPECTED_FOTS_FAILURE (prod-ModuleImport modules-collide-fn-001 0)307EXPECTED_FOTS_FAILURE (prod-ModuleImport modules-collide-fn-001 0)
309EXPECTED_FOTS_FAILURE (prod-ModuleImport errata8-002a 0)308EXPECTED_FOTS_FAILURE (prod-ModuleImport errata8-002a 0)
310309
=== added file 'test/rbkt/ExpQueryResults/zorba/uris/parse-uri.xml.res'
--- test/rbkt/ExpQueryResults/zorba/uris/parse-uri.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/uris/parse-uri.xml.res 2013-05-03 23:21:27 +0000
@@ -0,0 +1,1 @@
1{ "scheme" : "http", "path" : "/" }{ "scheme" : "http", "host" : "www.zorba-xquery.com", "path" : "/" }{ "scheme" : "http", "host" : "www.zorba-xquery.com", "path" : "/", "query" : "abc=true" }{ "scheme" : "http", "host" : "www.zorba-xquery.com", "port" : 8080, "path" : "/", "query" : "abc=true" }{ "scheme" : "http", "user-info" : "user", "host" : "www.zorba-xquery.com", "port" : 8080, "path" : "/", "query" : "abc=true" }{ "scheme" : "http", "user-info" : "user", "host" : "www.zorba-xquery.com", "port" : 8080, "path" : "/path1/path2", "query" : "abc=true" }{ "scheme" : "http", "user-info" : "user", "host" : "www.zorba-xquery.com", "port" : 8080, "path" : "/path1/path2", "query" : "abc=true&bcd=false", "fragment" : "fragment" }{ "scheme" : "ftp", "host" : "ftp.is.co.za", "path" : "/rfc/rfc1808.txt" }{ "scheme" : "http", "user-info" : "thomas", "host" : "[2001:6f8:9000:876:cccc:bbbb::]", "port" : 123, "path" : "/test" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/g" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/g" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/g/" }{ "scheme" : "http", "host" : "a", "path" : "/g" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/", "query" : "y" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/g", "query" : "y" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/g", "fragment" : "s" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/g", "query" : "y", "fragment" : "s" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/;x" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/g;x" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/g;x", "query" : "y", "fragment" : "s" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/" }{ "scheme" : "http", "host" : "a", "path" : "/b/" }{ "scheme" : "http", "host" : "a", "path" : "/b/" }{ "scheme" : "http", "host" : "a", "path" : "/b/g" }{ "scheme" : "http", "host" : "a", "path" : "/" }{ "scheme" : "http", "host" : "a", "path" : "/" }{ "scheme" : "http", "host" : "a", "path" : "/g" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/g;x=1/y" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/y" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/g", "fragment" : "s/../x" }{ "scheme" : "http", "host" : "www.example.com", "path" : "/" }{ "scheme" : "http", "host" : "www.example.com", "path" : "/dir/file" }{ "scheme" : "http", "host" : "www.msb.de" }{ "scheme" : "http", "host" : "www.msb.de", "path" : "/lib/helpers" }{ "scheme" : "file", "path" : "/d:/a/b/c" }{ "scheme" : "file", "host" : "localhost", "path" : "/d:/a/b/c" }{ "scheme" : "file", "host" : "localhost", "path" : "/Ångström/b/c" }{ "scheme" : "file", "opaque-part" : "opaque-uri-part", "fragment" : "frag" }{ "scheme" : "file", "opaque-part" : "text-file.txt" }{ "scheme" : "file", "opaque-part" : "bar?" }{ "scheme" : "file", "opaque-part" : "bar?", "fragment" : "frag" }{ "scheme" : "http", "host" : "foo.com", "path" : "/bc", "query" : "" }
0\ No newline at end of file2\ No newline at end of file
13
=== added file 'test/rbkt/ExpQueryResults/zorba/uris/serialize-direct-uri.xml.res'
--- test/rbkt/ExpQueryResults/zorba/uris/serialize-direct-uri.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/uris/serialize-direct-uri.xml.res 2013-05-03 23:21:27 +0000
@@ -0,0 +1,37 @@
1<?xml version="1.0" encoding="UTF-8"?>
2http:/
3 http://www.zorba-xquery.com/
4 http://www.zorba-xquery.com/?abc=true
5 http://www.zorba-xquery.com:8080/?abc=true
6 http://user@www.zorba-xquery.com:8080/?abc=true
7 http://user@www.zorba-xquery.com:8080/path1/path2?abc=true
8 http://user@www.zorba-xquery.com:8080/path1/path2?abc=true&amp;bcd=false
9 ftp://ftp.is.co.za/rfc/rfc1808.txt
10 http://thomas@[2001:6f8:9000:876:cccc:bbbb::]:123/test
11 http://a/b/c/g
12 http://a/b/c/g/
13 http://a/g
14 http://a/b/c/?y
15 http://a/b/c/g?y
16 http://a/b/c/g#s
17 http://a/b/c/g?y#s
18 http://a/b/c/;x
19 http://a/b/c/g;x
20 http://a/b/c/g;x?y#s
21 http://a/b/c
22 http://a/b/c/
23 http://a/b
24 http://a/b/
25 http://a/b/g
26 http://a/
27 http://a/g
28 http://a/b/c/g;x=1/y
29 http://a/b/c/y
30 http://a/b/c/g#s/../x
31 http://www.example.com/
32 http://www.example.com/dir/file
33 http://www.msb.de
34 http://www.msb.de/lib/helpers
35 file://localhost/Ångström/b/c
36 file:opaque-uri-part#frag
37 file:text-file.txt
038
=== added file 'test/rbkt/ExpQueryResults/zorba/uris/serialize-uri.xml.res'
--- test/rbkt/ExpQueryResults/zorba/uris/serialize-uri.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/uris/serialize-uri.xml.res 2013-05-03 23:21:27 +0000
@@ -0,0 +1,44 @@
1<?xml version="1.0" encoding="UTF-8"?>
2http:/
3 http://www.zorba-xquery.com/
4 http://www.zorba-xquery.com/?abc=true
5 http://www.zorba-xquery.com:8080/?abc=true
6 http://user@www.zorba-xquery.com:8080/?abc=true
7 http://user@www.zorba-xquery.com:8080/path1/path2?abc=true
8 http://user@www.zorba-xquery.com:8080/path1/path2?abc=true&amp;bcd=false#fragment
9 ftp://ftp.is.co.za/rfc/rfc1808.txt
10 http://thomas@[2001:6f8:9000:876:cccc:bbbb::]:123/test
11 http://a/b/c/g
12 http://a/b/c/g
13 http://a/b/c/g/
14 http://a/g
15 http://a/b/c/?y
16 http://a/b/c/g?y
17 http://a/b/c/g#s
18 http://a/b/c/g?y#s
19 http://a/b/c/;x
20 http://a/b/c/g;x
21 http://a/b/c/g;x?y#s
22 http://a/b/c/
23 http://a/b/c/
24 http://a/b/
25 http://a/b/
26 http://a/b/g
27 http://a/
28 http://a/
29 http://a/g
30 http://a/b/c/g;x=1/y
31 http://a/b/c/y
32 http://a/b/c/g#s/../x
33 http://www.example.com/
34 http://www.example.com/dir/file
35 http://www.msb.de
36 http://www.msb.de/lib/helpers
37 file:/d:/a/b/c
38 file://localhost/d:/a/b/c
39 file://localhost/Ångström/b/c
40 file:opaque-uri-part#frag
41 file:text-file.txt
42 file:bar?
43 file:bar?#frag
44 http://foo.com/bc?
0\ No newline at end of file45\ No newline at end of file
146
=== added file 'test/rbkt/Queries/zorba/uris/parse-invalid.spec'
--- test/rbkt/Queries/zorba/uris/parse-invalid.spec 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/uris/parse-invalid.spec 2013-05-03 23:21:27 +0000
@@ -0,0 +1,1 @@
1Error: http://www.w3.org/2005/xqt-errors:XQST0046
02
=== added file 'test/rbkt/Queries/zorba/uris/parse-invalid.xq'
--- test/rbkt/Queries/zorba/uris/parse-invalid.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/uris/parse-invalid.xq 2013-05-03 23:21:27 +0000
@@ -0,0 +1,3 @@
1import module namespace uri="http://www.zorba-xquery.com/modules/uri";
2
3uri:parse("foo:bar%%")
04
=== added file 'test/rbkt/Queries/zorba/uris/parse-uri.xq'
--- test/rbkt/Queries/zorba/uris/parse-uri.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/uris/parse-uri.xq 2013-05-03 23:21:27 +0000
@@ -0,0 +1,6 @@
1import module namespace uri = "http://www.zorba-xquery.com/modules/uri";
2
3let $xml-uri-test := fn:doc("uri-source.xml")//uri-element/text()
4
5for $uri in $xml-uri-test
6return uri:parse($uri)
07
=== added file 'test/rbkt/Queries/zorba/uris/serialize-direct-uri.xq'
--- test/rbkt/Queries/zorba/uris/serialize-direct-uri.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/uris/serialize-direct-uri.xq 2013-05-03 23:21:27 +0000
@@ -0,0 +1,211 @@
1import module namespace uri = "http://www.zorba-xquery.com/modules/uri";
2
3let $xml-uri-test := { "uri-test" :
4 [
5 {
6 $uri:SCHEME : "http",
7 $uri:PATH : "/"
8 },
9 {
10 $uri:SCHEME : "http",
11 $uri:HOST : "www.zorba-xquery.com",
12 $uri:PATH : "/"
13 },
14 {
15 $uri:SCHEME : "http",
16 $uri:HOST : "www.zorba-xquery.com",
17 $uri:PATH : "/",
18 $uri:QUERY : "abc=true"
19 },
20 {
21 $uri:SCHEME : "http",
22 $uri:PORT : 8080,
23 $uri:HOST : "www.zorba-xquery.com",
24 $uri:PATH : "/",
25 $uri:QUERY : "abc=true"
26 },
27 {
28 $uri:SCHEME : "http",
29 $uri:PORT : 8080,
30 $uri:HOST : "www.zorba-xquery.com",
31 $uri:PATH : "/",
32 $uri:USER-INFO : "user",
33 $uri:QUERY : "abc=true"
34 },
35 {
36 $uri:SCHEME : "http",
37 $uri:PORT : 8080,
38 $uri:HOST : "www.zorba-xquery.com",
39 $uri:PATH : "/path1/path2",
40 $uri:USER-INFO : "user",
41 $uri:QUERY : "abc=true"
42 },
43 {
44 $uri:SCHEME : "http",
45 $uri:PORT : 8080,
46 $uri:HOST : "www.zorba-xquery.com",
47 $uri:PATH : "/path1/path2",
48 $uri:USER-INFO : "user",
49 $uri:QUERY : "abc=true&amp;bcd=false"
50 },
51 {
52 $uri:SCHEME : "ftp",
53 $uri:HOST : "ftp.is.co.za",
54 $uri:PATH : "/rfc/rfc1808.txt"
55 },
56 {
57 $uri:SCHEME : "http",
58 $uri:PORT : 123,
59 $uri:HOST : "[2001:6f8:9000:876:cccc:bbbb::]",
60 $uri:PATH : "/test",
61 $uri:USER-INFO : "thomas"
62 },
63 {
64 $uri:SCHEME : "http",
65 $uri:HOST : "a",
66 $uri:PATH : "/b/c/g"
67 },
68 {
69 $uri:SCHEME : "http",
70 $uri:HOST : "a",
71 $uri:PATH : "/b/c/g/"
72 },
73 {
74 $uri:SCHEME : "http",
75 $uri:HOST : "a",
76 $uri:PATH : "/g"
77 },
78 {
79 $uri:SCHEME : "http",
80 $uri:HOST : "a",
81 $uri:PATH : "/b/c/",
82 $uri:QUERY : "y"
83 },
84 {
85 $uri:SCHEME : "http",
86 $uri:HOST : "a",
87 $uri:PATH : "/b/c/g",
88 $uri:QUERY : "y"
89 },
90 {
91 $uri:SCHEME : "http",
92 $uri:FRAGMENT : "s",
93 $uri:HOST : "a",
94 $uri:PATH : "/b/c/g"
95 },
96 {
97 $uri:SCHEME : "http",
98 $uri:FRAGMENT : "s",
99 $uri:HOST : "a",
100 $uri:PATH : "/b/c/g",
101 $uri:QUERY : "y"
102 },
103 {
104 $uri:SCHEME : "http",
105 $uri:HOST : "a",
106 $uri:PATH : "/b/c/;x"
107 },
108 {
109 $uri:SCHEME : "http",
110 $uri:HOST : "a",
111 $uri:PATH : "/b/c/g;x"
112 },
113 {
114 $uri:SCHEME : "http",
115 $uri:FRAGMENT : "s",
116 $uri:HOST : "a",
117 $uri:PATH : "/b/c/g;x",
118 $uri:QUERY : "y"
119 },
120 {
121 $uri:SCHEME : "http",
122 $uri:HOST : "a",
123 $uri:PATH : "/b/c"
124 },
125 {
126 $uri:SCHEME : "http",
127 $uri:HOST : "a",
128 $uri:PATH : "/b/c/"
129 },
130 {
131 $uri:SCHEME : "http",
132 $uri:HOST : "a",
133 $uri:PATH : "/b"
134 },
135 {
136 $uri:SCHEME : "http",
137 $uri:HOST : "a",
138 $uri:PATH : "/b/"
139 },
140 {
141 $uri:SCHEME : "http",
142 $uri:HOST : "a",
143 $uri:PATH : "/b/g"
144 },
145 {
146 $uri:SCHEME : "http",
147 $uri:HOST : "a",
148 $uri:PATH : "/"
149 },
150 {
151 $uri:SCHEME : "http",
152 $uri:HOST : "a",
153 $uri:PATH : "/g"
154 },
155 {
156 $uri:SCHEME : "http",
157 $uri:HOST : "a",
158 $uri:PATH : "/b/c/g;x=1/y"
159 },
160 {
161 $uri:SCHEME : "http",
162 $uri:HOST : "a",
163 $uri:PATH : "/b/c/y"
164 },
165 {
166 $uri:SCHEME : "http",
167 $uri:FRAGMENT : "s/../x",
168 $uri:HOST : "a",
169 $uri:PATH : "/b/c/g"
170 },
171 {
172 $uri:SCHEME : "http",
173 $uri:HOST : "www.example.com",
174 $uri:PATH : "/"
175 },
176 {
177 $uri:SCHEME : "http",
178 $uri:HOST : "www.example.com",
179 $uri:PATH : "/dir/file"
180 },
181 {
182 $uri:SCHEME : "http",
183 $uri:HOST : "www.msb.de"
184 },
185 {
186 $uri:SCHEME : "http",
187 $uri:HOST : "www.msb.de",
188 $uri:PATH : "/lib/helpers"
189 },
190 {
191 $uri:SCHEME : "file",
192 $uri:HOST : "localhost",
193 $uri:PATH : "/Ångström/b/c"
194 },
195 {
196 $uri:SCHEME : "file",
197 $uri:OPAQUE-PART : "opaque-uri-part",
198 $uri:FRAGMENT : "frag"
199 },
200 {
201 $uri:SCHEME : "file",
202 $uri:OPAQUE-PART : "text-file.txt"
203 }
204 ]
205}
206
207for $index in 1 to jn:size($xml-uri-test("uri-test"))
208let $uri := $xml-uri-test("uri-test")($index)
209return ( uri:serialize($uri), "
210")
211
0212
=== added file 'test/rbkt/Queries/zorba/uris/serialize-uri.xq'
--- test/rbkt/Queries/zorba/uris/serialize-uri.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/uris/serialize-uri.xq 2013-05-03 23:21:27 +0000
@@ -0,0 +1,9 @@
1import module namespace uri = "http://www.zorba-xquery.com/modules/uri";
2
3let $xml-uri-test := fn:doc("uri-source.xml")//uri-element
4
5for $uri in $xml-uri-test
6let $parsed-uri := uri:parse($uri)
7return concat(uri:serialize($parsed-uri), "
8")
9
010
=== added file 'test/rbkt/Queries/zorba/uris/serialize-wrong-opaque-noscheme.spec'
--- test/rbkt/Queries/zorba/uris/serialize-wrong-opaque-noscheme.spec 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/uris/serialize-wrong-opaque-noscheme.spec 2013-05-03 23:21:27 +0000
@@ -0,0 +1,1 @@
1Error: http://www.zorba-xquery.com/errors:ZURI0002
02
=== added file 'test/rbkt/Queries/zorba/uris/serialize-wrong-opaque-noscheme.xq'
--- test/rbkt/Queries/zorba/uris/serialize-wrong-opaque-noscheme.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/uris/serialize-wrong-opaque-noscheme.xq 2013-05-03 23:21:27 +0000
@@ -0,0 +1,8 @@
1import module namespace uri = "http://www.zorba-xquery.com/modules/uri";
2
3let $wrong-opaque-noscheme-json :=
4 {
5 "opaque-part" : "myfile.xml"
6 }
7
8return uri:serialize($wrong-opaque-noscheme-json)
09
=== added file 'test/rbkt/Queries/zorba/uris/serialize-wrong-opaque.spec'
--- test/rbkt/Queries/zorba/uris/serialize-wrong-opaque.spec 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/uris/serialize-wrong-opaque.spec 2013-05-03 23:21:27 +0000
@@ -0,0 +1,1 @@
1Error: http://www.zorba-xquery.com/errors:ZURI0001
02
=== added file 'test/rbkt/Queries/zorba/uris/serialize-wrong-opaque.xq'
--- test/rbkt/Queries/zorba/uris/serialize-wrong-opaque.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/uris/serialize-wrong-opaque.xq 2013-05-03 23:21:27 +0000
@@ -0,0 +1,10 @@
1import module namespace uri = "http://www.zorba-xquery.com/modules/uri";
2
3let $wrong-opaque-json :=
4 {
5 "scheme" : "http",
6 "opaque-part" : "myfile.xml",
7 "path" : "d:/a/b/c"
8 }
9
10return uri:serialize($wrong-opaque-json)
011
=== added file 'test/rbkt/Queries/zorba/uris/serialize-wrong-path1.spec'
--- test/rbkt/Queries/zorba/uris/serialize-wrong-path1.spec 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/uris/serialize-wrong-path1.spec 2013-05-03 23:21:27 +0000
@@ -0,0 +1,1 @@
1Error: http://www.zorba-xquery.com/errors:ZURI0003
02
=== added file 'test/rbkt/Queries/zorba/uris/serialize-wrong-path1.xq'
--- test/rbkt/Queries/zorba/uris/serialize-wrong-path1.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/uris/serialize-wrong-path1.xq 2013-05-03 23:21:27 +0000
@@ -0,0 +1,9 @@
1import module namespace uri = "http://www.zorba-xquery.com/modules/uri";
2
3let $wrong-path-json :=
4 {
5 "scheme" : "file",
6 "path" : "d:/a/b/c"
7 }
8
9return uri:serialize($wrong-path-json)
010
=== added file 'test/rbkt/Queries/zorba/uris/serialize-wrong-path2.spec'
--- test/rbkt/Queries/zorba/uris/serialize-wrong-path2.spec 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/uris/serialize-wrong-path2.spec 2013-05-03 23:21:27 +0000
@@ -0,0 +1,1 @@
1Error: http://www.zorba-xquery.com/errors:ZURI0003
02
=== added file 'test/rbkt/Queries/zorba/uris/serialize-wrong-path2.xq'
--- test/rbkt/Queries/zorba/uris/serialize-wrong-path2.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/uris/serialize-wrong-path2.xq 2013-05-03 23:21:27 +0000
@@ -0,0 +1,10 @@
1import module namespace uri = "http://www.zorba-xquery.com/modules/uri";
2
3let $wrong-path-json :=
4 {
5 "scheme" : "file",
6 "host" : "localhost",
7 "path" : "d:/a/b/c"
8 }
9
10return uri:serialize($wrong-path-json)
011
=== added file 'test/rbkt/Queries/zorba/uris/uri-source.xml'
--- test/rbkt/Queries/zorba/uris/uri-source.xml 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/uris/uri-source.xml 2013-05-03 23:21:27 +0000
@@ -0,0 +1,46 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<uri-test>
3 <uri-element>http:///</uri-element>
4 <uri-element>http://www.zorba-xquery.com/</uri-element>
5 <uri-element>http://www.zorba-xquery.com/?abc=true</uri-element>
6 <uri-element>http://www.zorba-xquery.com:8080/?abc=true</uri-element>
7 <uri-element>http://user@www.zorba-xquery.com:8080/?abc=true</uri-element>
8 <uri-element>http://user@www.zorba-xquery.com:8080/path1/path2?abc=true</uri-element>
9 <uri-element>http://user@www.zorba-xquery.com:8080/path1/path2?abc=true&amp;bcd=false#fragment</uri-element>
10 <uri-element>ftp://ftp.is.co.za/rfc/rfc1808.txt</uri-element>
11 <uri-element>http://thomas@[2001:6f8:9000:876:cccc:bbbb::]:123/test</uri-element>
12 <uri-element>http://a/b/c/g</uri-element>
13 <uri-element>http://a/b/c/g</uri-element>
14 <uri-element>http://a/b/c/g/</uri-element>
15 <uri-element>http://a/g</uri-element>
16 <uri-element>http://a/b/c/?y</uri-element>
17 <uri-element>http://a/b/c/g?y</uri-element>
18 <uri-element>http://a/b/c/g#s</uri-element>
19 <uri-element>http://a/b/c/g?y#s</uri-element>
20 <uri-element>http://a/b/c/;x</uri-element>
21 <uri-element>http://a/b/c/g;x</uri-element>
22 <uri-element>http://a/b/c/g;x?y#s</uri-element>
23 <uri-element>http://a/b/c/</uri-element>
24 <uri-element>http://a/b/c/</uri-element>
25 <uri-element>http://a/b/</uri-element>
26 <uri-element>http://a/b/</uri-element>
27 <uri-element>http://a/b/g</uri-element>
28 <uri-element>http://a/</uri-element>
29 <uri-element>http://a/</uri-element>
30 <uri-element>http://a/g</uri-element>
31 <uri-element>http://a/b/c/g;x=1/y</uri-element>
32 <uri-element>http://a/b/c/y</uri-element>
33 <uri-element>http://a/b/c/g#s/../x</uri-element>
34 <uri-element>http://www.example.com/</uri-element>
35 <uri-element>http://www.example.com/dir/file</uri-element>
36 <uri-element>http://www.msb.de</uri-element>
37 <uri-element>http://www.msb.de/lib/helpers</uri-element>
38 <uri-element>file:///d:/a/b/c</uri-element>
39 <uri-element>file://localhost/d:/a/b/c</uri-element>
40 <uri-element>file://localhost/Ångström/b/c</uri-element>
41 <uri-element>file:opaque-uri-part#frag</uri-element>
42 <uri-element>file:text-file.txt</uri-element>
43 <uri-element>file:bar?</uri-element>
44 <uri-element>file:bar?#frag</uri-element>
45 <uri-element>http://foo.com/bc?</uri-element>
46</uri-test>

Subscribers

People subscribed via source and target branches