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
1=== modified file 'ChangeLog'
2--- ChangeLog 2013-05-01 03:58:31 +0000
3+++ ChangeLog 2013-05-03 23:21:27 +0000
4@@ -104,6 +104,7 @@
5 * Fixed bug #1023362 (xsi:type attribute ignored during validation)
6 * Fixed bug #1025564 (Deprecate -f argument to zorbacmd)
7 * Fixed bug #1082740 (support for INF and -INF values in fn:subsequence function).
8+ * Fixed bug #867376 (uri:parse() and uri:serialize())
9
10
11 version 2.8
12
13=== modified file 'include/zorba/pregenerated/diagnostic_list.h'
14--- include/zorba/pregenerated/diagnostic_list.h 2013-05-02 10:19:11 +0000
15+++ include/zorba/pregenerated/diagnostic_list.h 2013-05-03 23:21:27 +0000
16@@ -882,6 +882,12 @@
17
18 extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJSE0008_BAD_VALUE;
19
20+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZURI0001_OPAQUE_WITH_OTHERS;
21+
22+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZURI0002_SCHEME_REQUIRED_FOR_OPAQUE;
23+
24+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZURI0003_SLASH_NEEDED_FOR_ABSOLUTE_URI;
25+
26 } // namespace zerr
27
28 namespace jerr {
29
30=== modified file 'modules/com/zorba-xquery/www/modules/pregenerated/errors.xq'
31--- modules/com/zorba-xquery/www/modules/pregenerated/errors.xq 2013-03-06 00:18:36 +0000
32+++ modules/com/zorba-xquery/www/modules/pregenerated/errors.xq 2013-05-03 23:21:27 +0000
33@@ -977,4 +977,19 @@
34
35 (:~
36 :)
37-declare variable $zerr:ZJSE0008 as xs:QName := fn:QName($zerr:NS, "zerr:ZJSE0008");
38\ No newline at end of file
39+declare variable $zerr:ZJSE0008 as xs:QName := fn:QName($zerr:NS, "zerr:ZJSE0008");
40+
41+(:~
42+ :If the opaque-part section of the URI was specified in conjuction with other non-opaque parts.
43+:)
44+declare variable $zerr:ZURI0001 as xs:QName := fn:QName($zerr:NS, "zerr:ZURI0001");
45+
46+(:~
47+ :If an opaque-part section was specified without a scheme section.
48+:)
49+declare variable $zerr:ZURI0002 as xs:QName := fn:QName($zerr:NS, "zerr:ZURI0002");
50+
51+(:~
52+ :If an absolute URI is specified with a path that does not start with slash ("/").
53+:)
54+declare variable $zerr:ZURI0003 as xs:QName := fn:QName($zerr:NS, "zerr:ZURI0003");
55\ No newline at end of file
56
57=== modified file 'modules/com/zorba-xquery/www/modules/uri.xq'
58--- modules/com/zorba-xquery/www/modules/uri.xq 2013-02-07 17:24:36 +0000
59+++ modules/com/zorba-xquery/www/modules/uri.xq 2013-05-03 23:21:27 +0000
60@@ -1,4 +1,4 @@
61-xquery version "1.0";
62+xquery version "3.0";
63
64 (:
65 : Copyright 2006-2012 The FLWOR Foundation.
66@@ -17,20 +17,71 @@
67 :)
68
69 (:~
70- : This module provides string related functions.
71+ : This module provides functions for processing URIs and URLs.
72 :
73- : @author Matthias Brantner
74+ : @author Matthias Brantner, Luis Rodriguez Gonzalez
75 : @project XDM/atomic
76 :
77 :)
78 module namespace uri = "http://www.zorba-xquery.com/modules/uri";
79
80 declare namespace zerr = "http://www.zorba-xquery.com/errors";
81-
82 declare namespace ver = "http://www.zorba-xquery.com/options/versioning";
83 declare option ver:module-version "1.0";
84
85 (:~
86+ : Constant for the "scheme" part of a URI object.
87+ :)
88+declare variable $uri:SCHEME as xs:string := "scheme";
89+
90+(:~
91+ : Constant for the "authority" part of a URI object.
92+ :)
93+declare variable $uri:AUTHORITY as xs:string := "authority";
94+
95+(:~
96+ : Constant for the "user-info" part of a URI object.
97+ :)
98+declare variable $uri:USER-INFO as xs:string := "user-info";
99+
100+(:~
101+ : Constant for the "host" part of a URI object.
102+ :)
103+declare variable $uri:HOST as xs:string := "host";
104+
105+(:~
106+ : Constant for the "port" part of a URI object.
107+ :)
108+declare variable $uri:PORT as xs:string := "port";
109+
110+(:~
111+ : Constant for the "path" part of a URI object.
112+ :)
113+declare variable $uri:PATH as xs:string := "path";
114+
115+(:~
116+ : Constant for the "query" part of a URI object.
117+ :)
118+declare variable $uri:QUERY as xs:string := "query";
119+
120+(:~
121+ : Constant for the "fragment" part of a URI object.
122+ :)
123+declare variable $uri:FRAGMENT as xs:string := "fragment";
124+
125+(:~
126+ : Constant for the "opaque-part" part of a URI object.
127+ :
128+ : If this is set in a URI object, then none of $uri:PATH, $uri:HOST,
129+ : $uri:PORT, $uri:USER-INFO, or : $uri:QUERY may be specified.
130+ :
131+ : If this is set in a URI object, $uri:SCHEME must also be specified
132+ : (ie, it must be an absolute URI).
133+ :)
134+declare variable $uri:OPAQUE-PART as xs:string := "opaque-part";
135+
136+
137+(:~
138 : Percent-decodes (aka URL decoding) the given string.
139 :
140 : All percent encoded octets will be translated into their
141@@ -106,3 +157,47 @@
142 $s as xs:string,
143 $decode-plus as xs:boolean,
144 $charset as xs:string) as xs:string external;
145+
146+(:~
147+ : Parses the URI passed as string. The returned object
148+ : contains only members with field names declared as constants in
149+ : this module.
150+ :
151+ : For example,
152+ : <code>
153+ : let my-uri := "http://www.my.project.com/a/b/c?user=john;pass=1234#profile"
154+ : return uri:parse(my-uri)
155+ : </code>
156+ :
157+ : returns
158+ : <code>
159+ : { "squeme" : "http", "host" : "www.my.project.com", "path" : "/a/b/c",
160+ : "query" : "user=john;pass=123", "fragment" : "profile" }
161+ : </code>
162+ :
163+ : @param $uri the URI to parse
164+ :
165+ : @return the JSON object
166+ :
167+ : @error err:XQST0046 if the URI is textually invalid
168+ :)
169+declare function uri:parse(
170+ $uri as xs:string) as object() external;
171+
172+(:~
173+ : Serialize the URI passed as object into a string.
174+ :
175+ : @param $uri the object representing the URI
176+ :
177+ : @return the URI as string
178+ :
179+ : @error zerr:ZURI0001 if opaque part is specified in conjunction with
180+ : host/port/path/user-info/query.
181+ :
182+ : @error zerr:ZURI0002 if opaque part is present but no scheme is present.
183+ :
184+ : @error zerr:ZURI0003 if a path component for an absolute URI
185+ : doesn't start with "/".
186+ :)
187+declare function uri:serialize(
188+ $uri as object()) as xs:string external;
189
190=== modified file 'src/diagnostics/diagnostic_en.xml'
191--- src/diagnostics/diagnostic_en.xml 2013-05-02 10:19:11 +0000
192+++ src/diagnostics/diagnostic_en.xml 2013-05-03 23:21:27 +0000
193@@ -3123,6 +3123,23 @@
194 <diagnostic code="ZJSE0008" name="BAD_VALUE">
195 <value>"$1": illegal value for JSON type "$2"</value>
196 </diagnostic>
197+
198+ <!-- /////////// URI procesing errors ///////////////////////////////// -->
199+
200+ <diagnostic code="ZURI0001" name="OPAQUE_WITH_OTHERS">
201+ <comment>If the opaque-part section of the URI was specified in conjuction with other non-opaque parts.</comment>
202+ <value>cannot specify opaque-part in conjunction with host/port/path/user-info/query</value>
203+ </diagnostic>
204+
205+ <diagnostic code="ZURI0002" name="SCHEME_REQUIRED_FOR_OPAQUE">
206+ <comment>If an opaque-part section was specified without a scheme section.</comment>
207+ <value>scheme required when specifying opaque-part</value>
208+ </diagnostic>
209+
210+ <diagnostic code="ZURI0003" name="SLASH_NEEDED_FOR_ABSOLUTE_URI">
211+ <comment>If an absolute URI is specified with a path that does not start with slash ("/").</comment>
212+ <value>path component of absolute URI must begin with /</value>
213+ </diagnostic>
214
215 </namespace>
216
217
218=== modified file 'src/diagnostics/pregenerated/diagnostic_list.cpp'
219--- src/diagnostics/pregenerated/diagnostic_list.cpp 2013-05-02 10:19:11 +0000
220+++ src/diagnostics/pregenerated/diagnostic_list.cpp 2013-05-03 23:21:27 +0000
221@@ -1301,6 +1301,15 @@
222 ZorbaErrorCode ZJSE0008_BAD_VALUE( "ZJSE0008" );
223
224
225+ZorbaErrorCode ZURI0001_OPAQUE_WITH_OTHERS( "ZURI0001" );
226+
227+
228+ZorbaErrorCode ZURI0002_SCHEME_REQUIRED_FOR_OPAQUE( "ZURI0002" );
229+
230+
231+ZorbaErrorCode ZURI0003_SLASH_NEEDED_FOR_ABSOLUTE_URI( "ZURI0003" );
232+
233+
234 } // namespace zerr
235
236 namespace jerr {
237
238=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
239--- src/diagnostics/pregenerated/dict_en.cpp 2013-05-02 10:19:11 +0000
240+++ src/diagnostics/pregenerated/dict_en.cpp 2013-05-03 23:21:27 +0000
241@@ -488,6 +488,9 @@
242 { "ZSTR0060", "\"$1\": value out of range${ 2}" },
243 { "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." },
244 { "ZSTR0066", "$1: does not reference a node in collection $2" },
245+ { "ZURI0001", "cannot specify opaque-part in conjunction with host/port/path/user-info/query" },
246+ { "ZURI0002", "scheme required when specifying opaque-part" },
247+ { "ZURI0003", "path component of absolute URI must begin with /" },
248 { "ZWST0002", "\"$1\": unknown or unsupported annotation" },
249 { "ZWST0003", "\"$1\": function declared sequential, but has non-sequential body" },
250 { "ZWST0004", "sequential FLWOR expr may not have the semantics you expect" },
251
252=== modified file 'src/diagnostics/qname.cpp'
253--- src/diagnostics/qname.cpp 2013-02-07 17:24:36 +0000
254+++ src/diagnostics/qname.cpp 2013-05-03 23:21:27 +0000
255@@ -125,6 +125,7 @@
256 case 'O': return ZORBA_OS;
257 case 'S': return ZORBA_STORE;
258 case 'X': return ZORBA_XQP;
259+ case 'U': return ZORBA_CORE_MODULE;
260
261 default : ZORBA_ASSERT( false );
262 }
263
264=== modified file 'src/functions/pregenerated/func_uris.cpp'
265--- src/functions/pregenerated/func_uris.cpp 2013-03-05 23:11:50 +0000
266+++ src/functions/pregenerated/func_uris.cpp 2013-05-03 23:21:27 +0000
267@@ -41,6 +41,26 @@
268 return new DecodeURIIterator(sctx, loc, argv);
269 }
270
271+PlanIter_t fn_zorba_uri_parse::codegen(
272+ CompilerCB*,
273+ static_context* sctx,
274+ const QueryLoc& loc,
275+ std::vector<PlanIter_t>& argv,
276+ expr& ann) const
277+{
278+ return new ParseURIIterator(sctx, loc, argv);
279+}
280+
281+PlanIter_t fn_zorba_uri_serialize::codegen(
282+ CompilerCB*,
283+ static_context* sctx,
284+ const QueryLoc& loc,
285+ std::vector<PlanIter_t>& argv,
286+ expr& ann) const
287+{
288+ return new SerializeURIIterator(sctx, loc, argv);
289+}
290+
291 void populate_context_uris(static_context* sctx)
292 {
293
294@@ -56,6 +76,30 @@
295
296 }
297
298+
299+
300+
301+ {
302+ DECL_WITH_KIND(sctx, fn_zorba_uri_parse,
303+ (createQName("http://www.zorba-xquery.com/modules/uri","","parse"),
304+ GENV_TYPESYSTEM.STRING_TYPE_ONE,
305+ GENV_TYPESYSTEM.JSON_OBJECT_TYPE_ONE),
306+ FunctionConsts::FN_ZORBA_URI_PARSE_1);
307+
308+ }
309+
310+
311+
312+
313+ {
314+ DECL_WITH_KIND(sctx, fn_zorba_uri_serialize,
315+ (createQName("http://www.zorba-xquery.com/modules/uri","","serialize"),
316+ GENV_TYPESYSTEM.JSON_OBJECT_TYPE_ONE,
317+ GENV_TYPESYSTEM.STRING_TYPE_ONE),
318+ FunctionConsts::FN_ZORBA_URI_SERIALIZE_1);
319+
320+ }
321+
322 }
323
324
325
326=== modified file 'src/functions/pregenerated/func_uris.h'
327--- src/functions/pregenerated/func_uris.h 2013-03-05 23:11:50 +0000
328+++ src/functions/pregenerated/func_uris.h 2013-05-03 23:21:27 +0000
329@@ -53,6 +53,36 @@
330 };
331
332
333+//fn-zorba-uri:parse
334+class fn_zorba_uri_parse : public function
335+{
336+public:
337+ fn_zorba_uri_parse(const signature& sig, FunctionConsts::FunctionKind kind)
338+ :
339+ function(sig, kind)
340+ {
341+
342+ }
343+
344+ CODEGEN_DECL();
345+};
346+
347+
348+//fn-zorba-uri:serialize
349+class fn_zorba_uri_serialize : public function
350+{
351+public:
352+ fn_zorba_uri_serialize(const signature& sig, FunctionConsts::FunctionKind kind)
353+ :
354+ function(sig, kind)
355+ {
356+
357+ }
358+
359+ CODEGEN_DECL();
360+};
361+
362+
363 } //namespace zorba
364
365
366
367=== modified file 'src/functions/pregenerated/function_enum.h'
368--- src/functions/pregenerated/function_enum.h 2013-04-10 21:01:35 +0000
369+++ src/functions/pregenerated/function_enum.h 2013-05-03 23:21:27 +0000
370@@ -496,6 +496,8 @@
371 FN_ZORBA_STRING_IS_STREAMABLE_1,
372 FN_ZORBA_STRING_SPLIT_2,
373 FN_ZORBA_URI_DECODE_3,
374+ FN_ZORBA_URI_PARSE_1,
375+ FN_ZORBA_URI_SERIALIZE_1,
376 FN_ZORBA_XQDOC_XQDOC_CONTENT_IMPL_2,
377 FN_ZORBA_XQDOC_XQDOC_CONTENT_OPTIONS_IMPL_3,
378
379
380=== modified file 'src/runtime/pregenerated/iterator_enum.h'
381--- src/runtime/pregenerated/iterator_enum.h 2013-03-15 08:22:41 +0000
382+++ src/runtime/pregenerated/iterator_enum.h 2013-05-03 23:21:27 +0000
383@@ -369,6 +369,8 @@
384 TYPE_StringIsStreamableIterator,
385 TYPE_StringSplitIterator,
386 TYPE_DecodeURIIterator,
387+ TYPE_ParseURIIterator,
388+ TYPE_SerializeURIIterator,
389 TYPE_XQDocContentIterator,
390
391
392
393=== modified file 'src/runtime/spec/uris/uris.xml'
394--- src/runtime/spec/uris/uris.xml 2013-02-07 17:24:36 +0000
395+++ src/runtime/spec/uris/uris.xml 2013-05-03 23:21:27 +0000
396@@ -37,4 +37,32 @@
397 </zorba:function>
398 </zorba:iterator>
399
400+<zorba:iterator name="ParseURIIterator">
401+
402+ <zorba:description author="Zorba Team">
403+ uri:parse
404+ </zorba:description>
405+
406+ <zorba:function>
407+ <zorba:signature localname="parse" prefix="fn-zorba-uri">
408+ <zorba:param>xs:string</zorba:param>
409+ <zorba:output>object()</zorba:output>
410+ </zorba:signature>
411+ </zorba:function>
412+</zorba:iterator>
413+
414+<zorba:iterator name="SerializeURIIterator">
415+
416+ <zorba:description author="Zorba Team">
417+ uri:serialize
418+ </zorba:description>
419+
420+ <zorba:function>
421+ <zorba:signature localname="serialize" prefix="fn-zorba-uri">
422+ <zorba:param>object()</zorba:param>
423+ <zorba:output>xs:string</zorba:output>
424+ </zorba:signature>
425+ </zorba:function>
426+</zorba:iterator>
427+
428 </zorba:iterators>
429
430=== modified file 'src/runtime/uris/pregenerated/uris.cpp'
431--- src/runtime/uris/pregenerated/uris.cpp 2013-03-05 23:11:50 +0000
432+++ src/runtime/uris/pregenerated/uris.cpp 2013-05-03 23:21:27 +0000
433@@ -60,6 +60,62 @@
434 // </DecodeURIIterator>
435
436
437+// <ParseURIIterator>
438+SERIALIZABLE_CLASS_VERSIONS(ParseURIIterator)
439+
440+void ParseURIIterator::serialize(::zorba::serialization::Archiver& ar)
441+{
442+ serialize_baseclass(ar,
443+ (NaryBaseIterator<ParseURIIterator, PlanIteratorState>*)this);
444+}
445+
446+
447+void ParseURIIterator::accept(PlanIterVisitor& v) const
448+{
449+ v.beginVisit(*this);
450+
451+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
452+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
453+ for ( ; lIter != lEnd; ++lIter ){
454+ (*lIter)->accept(v);
455+ }
456+
457+ v.endVisit(*this);
458+}
459+
460+ParseURIIterator::~ParseURIIterator() {}
461+
462+// </ParseURIIterator>
463+
464+
465+// <SerializeURIIterator>
466+SERIALIZABLE_CLASS_VERSIONS(SerializeURIIterator)
467+
468+void SerializeURIIterator::serialize(::zorba::serialization::Archiver& ar)
469+{
470+ serialize_baseclass(ar,
471+ (NaryBaseIterator<SerializeURIIterator, PlanIteratorState>*)this);
472+}
473+
474+
475+void SerializeURIIterator::accept(PlanIterVisitor& v) const
476+{
477+ v.beginVisit(*this);
478+
479+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
480+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
481+ for ( ; lIter != lEnd; ++lIter ){
482+ (*lIter)->accept(v);
483+ }
484+
485+ v.endVisit(*this);
486+}
487+
488+SerializeURIIterator::~SerializeURIIterator() {}
489+
490+// </SerializeURIIterator>
491+
492+
493
494 }
495
496
497=== modified file 'src/runtime/uris/pregenerated/uris.h'
498--- src/runtime/uris/pregenerated/uris.h 2013-03-05 23:11:50 +0000
499+++ src/runtime/uris/pregenerated/uris.h 2013-05-03 23:21:27 +0000
500@@ -67,6 +67,70 @@
501 };
502
503
504+/**
505+ *
506+ * uri:parse
507+ *
508+ * Author: Zorba Team
509+ */
510+class ParseURIIterator : public NaryBaseIterator<ParseURIIterator, PlanIteratorState>
511+{
512+public:
513+ SERIALIZABLE_CLASS(ParseURIIterator);
514+
515+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(ParseURIIterator,
516+ NaryBaseIterator<ParseURIIterator, PlanIteratorState>);
517+
518+ void serialize( ::zorba::serialization::Archiver& ar);
519+
520+ ParseURIIterator(
521+ static_context* sctx,
522+ const QueryLoc& loc,
523+ std::vector<PlanIter_t>& children)
524+ :
525+ NaryBaseIterator<ParseURIIterator, PlanIteratorState>(sctx, loc, children)
526+ {}
527+
528+ virtual ~ParseURIIterator();
529+
530+ void accept(PlanIterVisitor& v) const;
531+
532+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
533+};
534+
535+
536+/**
537+ *
538+ * uri:serialize
539+ *
540+ * Author: Zorba Team
541+ */
542+class SerializeURIIterator : public NaryBaseIterator<SerializeURIIterator, PlanIteratorState>
543+{
544+public:
545+ SERIALIZABLE_CLASS(SerializeURIIterator);
546+
547+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(SerializeURIIterator,
548+ NaryBaseIterator<SerializeURIIterator, PlanIteratorState>);
549+
550+ void serialize( ::zorba::serialization::Archiver& ar);
551+
552+ SerializeURIIterator(
553+ static_context* sctx,
554+ const QueryLoc& loc,
555+ std::vector<PlanIter_t>& children)
556+ :
557+ NaryBaseIterator<SerializeURIIterator, PlanIteratorState>(sctx, loc, children)
558+ {}
559+
560+ virtual ~SerializeURIIterator();
561+
562+ void accept(PlanIterVisitor& v) const;
563+
564+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
565+};
566+
567+
568 }
569 #endif
570 /*
571
572=== modified file 'src/runtime/uris/uris_impl.cpp'
573--- src/runtime/uris/uris_impl.cpp 2013-04-16 21:12:12 +0000
574+++ src/runtime/uris/uris_impl.cpp 2013-05-03 23:21:27 +0000
575@@ -32,6 +32,18 @@
576
577 #include "util/uri_util.h"
578
579+#include "zorbatypes/URI.h"
580+
581+#define SCHEME_NAME "scheme"
582+#define OPAQUE_PART_NAME "opaque-part"
583+#define AUTHORITY_NAME "authority"
584+#define USER_INFO_NAME "user-info"
585+#define HOST_NAME "host"
586+#define PORT_NAME "port"
587+#define PATH_NAME "path"
588+#define QUERY_NAME "query"
589+#define FRAGMENT_NAME "fragment"
590+
591 using namespace std;
592
593 namespace zorba {
594@@ -101,5 +113,209 @@
595
596 STACK_END (state);
597 }
598+
599+/******************************************************************************
600+*******************************************************************************/
601+bool
602+ParseURIIterator::nextImpl(store::Item_t& result, PlanState& planState) const
603+{
604+ store::Item_t lItemURI, lName, lValue;
605+ std::vector<store::Item_t> lNames;
606+ std::vector<store::Item_t> lValues;
607+ zorba::zstring lStrURI, lZKey, lZVal;
608+ PlanIteratorState* state;
609+ URI uri;
610+
611+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
612+
613+ consumeNext(lItemURI, theChildren[0].getp(), planState);
614+ lItemURI->getStringValue2(lStrURI);
615+ uri = URI(lStrURI);
616+
617+ lZVal = uri.get_scheme();
618+ if(!lZVal.empty())
619+ {
620+ lZKey = zorba::zstring(SCHEME_NAME);
621+ GENV_ITEMFACTORY->createString(lName, lZKey);
622+ GENV_ITEMFACTORY->createString(lValue, lZVal);
623+ lNames.push_back(lName);
624+ lValues.push_back(lValue);
625+ }
626+
627+ lZVal = uri.get_opaque_part();
628+ if(!lZVal.empty())
629+ {
630+ lZKey = zorba::zstring(OPAQUE_PART_NAME);
631+ GENV_ITEMFACTORY->createString(lName, lZKey);
632+ GENV_ITEMFACTORY->createString(lValue, lZVal);
633+ lNames.push_back(lName);
634+ lValues.push_back(lValue);
635+ }
636+
637+ lZVal = uri.get_encoded_reg_based_authority();
638+ if(!lZVal.empty())
639+ {
640+ lZKey = zorba::zstring(AUTHORITY_NAME);
641+ GENV_ITEMFACTORY->createString(lName, lZKey);
642+ GENV_ITEMFACTORY->createString(lValue, lZVal);
643+ lNames.push_back(lName);
644+ lValues.push_back(lValue);
645+ }
646+
647+ lZVal = uri.get_encoded_user_info();
648+ if(!lZVal.empty())
649+ {
650+ lZKey = zorba::zstring(USER_INFO_NAME);
651+ GENV_ITEMFACTORY->createString(lName, lZKey);
652+ GENV_ITEMFACTORY->createString(lValue, lZVal);
653+ lNames.push_back(lName);
654+ lValues.push_back(lValue);
655+ }
656+
657+ lZVal = uri.get_host();
658+ if(!lZVal.empty())
659+ {
660+ lZKey = zorba::zstring(HOST_NAME);
661+ GENV_ITEMFACTORY->createString(lName, lZKey);
662+ GENV_ITEMFACTORY->createString(lValue, lZVal);
663+ lNames.push_back(lName);
664+ lValues.push_back(lValue);
665+ }
666+
667+ if(uri.get_port() != 0)
668+ {
669+ lZKey = zorba::zstring(PORT_NAME);
670+ GENV_ITEMFACTORY->createString(lName, lZKey);
671+ GENV_ITEMFACTORY->createInt(lValue, uri.get_port());
672+ lNames.push_back(lName);
673+ lValues.push_back(lValue);
674+ }
675+
676+ lZVal = uri.get_encoded_path();
677+ if(!lZVal.empty())
678+ {
679+ lZKey = zorba::zstring(PATH_NAME);
680+ GENV_ITEMFACTORY->createString(lName, lZKey);
681+ GENV_ITEMFACTORY->createString(lValue, lZVal);
682+ lNames.push_back(lName);
683+ lValues.push_back(lValue);
684+ }
685+
686+ lZVal = uri.get_encoded_query();
687+ if(uri.is_set(URI::QueryString))
688+ {
689+ lZKey = zorba::zstring(QUERY_NAME);
690+ GENV_ITEMFACTORY->createString(lName, lZKey);
691+ GENV_ITEMFACTORY->createString(lValue, lZVal);
692+ lNames.push_back(lName);
693+ lValues.push_back(lValue);
694+ }
695+
696+ lZVal = uri.get_encoded_fragment();
697+ if(!lZVal.empty())
698+ {
699+ lZKey = zorba::zstring(FRAGMENT_NAME);
700+ GENV_ITEMFACTORY->createString(lName, lZKey);
701+ GENV_ITEMFACTORY->createString(lValue, lZVal);
702+ lNames.push_back(lName);
703+ lValues.push_back(lValue);
704+ }
705+
706+ GENV_ITEMFACTORY->createJSONObject(result, lNames, lValues);
707+
708+ STACK_PUSH(result, state );
709+
710+ STACK_END (state);
711+}
712+
713+/******************************************************************************
714+*******************************************************************************/
715+bool
716+SerializeURIIterator::nextImpl(store::Item_t& result, PlanState& planState) const
717+{
718+ store::Item_t lItemURI, lItemKey;
719+ zorba::zstring lStrValue, lStrKey, lStrRes;
720+ store::Iterator_t lKeys;
721+ URI uri = URI();
722+ int lIntPort = 0;
723+ bool lHasSchemeField, lHasOpaqueField, lHasNotOpaqueField;
724+
725+ PlanIteratorState* state;
726+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
727+
728+ consumeNext(lItemURI, theChildren[0].getp(), planState);
729+
730+ lHasSchemeField = lHasOpaqueField = lHasNotOpaqueField = false;
731+ if(lItemURI->isJSONObject()) {
732+ lKeys = lItemURI->getObjectKeys();
733+ if(!lKeys.isNull()){
734+ lKeys->open();
735+ while(lKeys->next(lItemKey)){
736+ lStrKey = lItemKey->getStringValue();
737+ lStrValue = lItemURI->getObjectValue(lItemKey)->getStringValue();
738+ if(lStrKey == SCHEME_NAME && !lStrValue.empty()){
739+ uri.set_scheme(lStrValue);
740+ lHasSchemeField = true;
741+ } else if(lStrKey == OPAQUE_PART_NAME && !lStrValue.empty()){
742+ uri.set_opaque_part(lStrValue);
743+ lHasOpaqueField = true;
744+ } else if(lStrKey == AUTHORITY_NAME && !lStrValue.empty()){
745+ uri.set_reg_based_authority(lStrValue);
746+ lHasNotOpaqueField = true;
747+ } else if(lStrKey == USER_INFO_NAME && !lStrValue.empty()){
748+ uri.set_user_info(lStrValue);
749+ lHasNotOpaqueField = true;
750+ } else if(lStrKey == HOST_NAME && !lStrValue.empty()){
751+ uri.set_host(lStrValue);
752+ lHasNotOpaqueField = true;
753+ } else if(lStrKey == PORT_NAME){
754+ sscanf(lStrValue.str().c_str(), "%d", &lIntPort);
755+ if(lIntPort != 0){
756+ uri.set_port(lIntPort);
757+ lHasNotOpaqueField = true;
758+ }
759+ } else if(lStrKey == PATH_NAME && !lStrValue.empty()){
760+ uri.set_path(lStrValue);
761+ lHasNotOpaqueField = true;
762+ } else if(lStrKey == QUERY_NAME){
763+ uri.set_query(lStrValue);
764+ lHasNotOpaqueField = true;
765+ } else if(lStrKey == FRAGMENT_NAME){
766+ uri.set_fragment(lStrValue);
767+ }
768+ }
769+ lKeys->close();
770+ }
771+ }
772+
773+ // check for errors
774+ if(lHasOpaqueField && lHasNotOpaqueField)
775+ {
776+ throw XQUERY_EXCEPTION(
777+ zerr::ZURI0001_OPAQUE_WITH_OTHERS,
778+ ERROR_LOC( loc )
779+ );
780+ }
781+ if(lHasOpaqueField && !lHasSchemeField)
782+ {
783+ throw XQUERY_EXCEPTION(
784+ zerr::ZURI0002_SCHEME_REQUIRED_FOR_OPAQUE,
785+ ERROR_LOC( loc )
786+ );
787+ }
788+ if(lHasSchemeField && !uri.get_encoded_path().empty() && (uri.get_encoded_path().substr(0,1) != "/"))
789+ {
790+ throw XQUERY_EXCEPTION(
791+ zerr::ZURI0003_SLASH_NEEDED_FOR_ABSOLUTE_URI,
792+ ERROR_LOC( loc )
793+ );
794+ }
795+
796+ lStrRes = zorba::zstring(uri.toString());
797+ STACK_PUSH(GENV_ITEMFACTORY->createString(result, lStrRes), state );
798+
799+ STACK_END (state);
800+}
801+
802 } // namespace zorba
803 /* vim:set et sw=2 ts=2: */
804
805=== modified file 'src/runtime/visitors/pregenerated/planiter_visitor.h'
806--- src/runtime/visitors/pregenerated/planiter_visitor.h 2013-03-15 08:22:41 +0000
807+++ src/runtime/visitors/pregenerated/planiter_visitor.h 2013-05-03 23:21:27 +0000
808@@ -766,6 +766,10 @@
809
810 class DecodeURIIterator;
811
812+ class ParseURIIterator;
813+
814+ class SerializeURIIterator;
815+
816 class XQDocContentIterator;
817
818
819@@ -1863,6 +1867,12 @@
820 virtual void beginVisit ( const DecodeURIIterator& ) = 0;
821 virtual void endVisit ( const DecodeURIIterator& ) = 0;
822
823+ virtual void beginVisit ( const ParseURIIterator& ) = 0;
824+ virtual void endVisit ( const ParseURIIterator& ) = 0;
825+
826+ virtual void beginVisit ( const SerializeURIIterator& ) = 0;
827+ virtual void endVisit ( const SerializeURIIterator& ) = 0;
828+
829 virtual void beginVisit ( const XQDocContentIterator& ) = 0;
830 virtual void endVisit ( const XQDocContentIterator& ) = 0;
831
832
833=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp'
834--- src/runtime/visitors/pregenerated/printer_visitor.cpp 2013-03-27 00:44:34 +0000
835+++ src/runtime/visitors/pregenerated/printer_visitor.cpp 2013-05-03 23:21:27 +0000
836@@ -4905,6 +4905,34 @@
837 // </DecodeURIIterator>
838
839
840+// <ParseURIIterator>
841+void PrinterVisitor::beginVisit ( const ParseURIIterator& a) {
842+ thePrinter.startBeginVisit("ParseURIIterator", ++theId);
843+ printCommons( &a, theId );
844+ thePrinter.endBeginVisit( theId );
845+}
846+
847+void PrinterVisitor::endVisit ( const ParseURIIterator& ) {
848+ thePrinter.startEndVisit();
849+ thePrinter.endEndVisit();
850+}
851+// </ParseURIIterator>
852+
853+
854+// <SerializeURIIterator>
855+void PrinterVisitor::beginVisit ( const SerializeURIIterator& a) {
856+ thePrinter.startBeginVisit("SerializeURIIterator", ++theId);
857+ printCommons( &a, theId );
858+ thePrinter.endBeginVisit( theId );
859+}
860+
861+void PrinterVisitor::endVisit ( const SerializeURIIterator& ) {
862+ thePrinter.startEndVisit();
863+ thePrinter.endEndVisit();
864+}
865+// </SerializeURIIterator>
866+
867+
868 // <XQDocContentIterator>
869 void PrinterVisitor::beginVisit ( const XQDocContentIterator& a) {
870 thePrinter.startBeginVisit("XQDocContentIterator", ++theId);
871
872=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.h'
873--- src/runtime/visitors/pregenerated/printer_visitor.h 2013-03-15 08:22:41 +0000
874+++ src/runtime/visitors/pregenerated/printer_visitor.h 2013-05-03 23:21:27 +0000
875@@ -1170,6 +1170,12 @@
876 void beginVisit( const DecodeURIIterator& );
877 void endVisit ( const DecodeURIIterator& );
878
879+ void beginVisit( const ParseURIIterator& );
880+ void endVisit ( const ParseURIIterator& );
881+
882+ void beginVisit( const SerializeURIIterator& );
883+ void endVisit ( const SerializeURIIterator& );
884+
885 void beginVisit( const XQDocContentIterator& );
886 void endVisit ( const XQDocContentIterator& );
887
888
889=== modified file 'src/unit_tests/test_uri.cpp'
890--- src/unit_tests/test_uri.cpp 2013-02-07 17:24:36 +0000
891+++ src/unit_tests/test_uri.cpp 2013-05-03 23:21:27 +0000
892@@ -40,6 +40,7 @@
893 zorba::zstring userinfo;
894 zorba::zstring query;
895 zorba::zstring path_notation;
896+ zorba::zstring opaque_part;
897 };
898
899
900@@ -66,7 +67,8 @@
901 "/",
902 "",
903 "",
904- "/" // path notation
905+ "/", // path notation
906+ ""
907 },
908 {
909 "",
910@@ -80,7 +82,8 @@
911 "/",
912 "",
913 "",
914- "com/zorba-xquery/www/" // path notation
915+ "com/zorba-xquery/www/", // path notation
916+ ""
917 },
918 {
919 "",
920@@ -94,7 +97,8 @@
921 "/",
922 "",
923 "abc=true",
924- "com/zorba-xquery/www/" // path notation
925+ "com/zorba-xquery/www/", // path notation
926+ ""
927 },
928 {
929 "",
930@@ -108,7 +112,8 @@
931 "/",
932 "",
933 "abc=true",
934- "com/zorba-xquery/www/" // path notation
935+ "com/zorba-xquery/www/", // path notation
936+ ""
937 },
938 {
939 "",
940@@ -122,7 +127,8 @@
941 "/",
942 "user",
943 "abc=true",
944- "com/zorba-xquery/www/" // path notation
945+ "com/zorba-xquery/www/", // path notation
946+ ""
947 },
948 {
949 "",
950@@ -136,7 +142,8 @@
951 "/path1/path2",
952 "user",
953 "abc=true",
954- "com/zorba-xquery/www/path1/path2" // path notation
955+ "com/zorba-xquery/www/path1/path2", // path notation
956+ ""
957 },
958 {
959 "",
960@@ -150,7 +157,8 @@
961 "/path1/path2",
962 "user",
963 "abc=true&bcd=false",
964- "com/zorba-xquery/www/path1/path2" // path notation
965+ "com/zorba-xquery/www/path1/path2", // path notation
966+ ""
967 },
968 {
969 "",
970@@ -164,7 +172,8 @@
971 "/rfc/rfc1808.txt",
972 "",
973 "",
974- "za/co/is/ftp/rfc/rfc1808.txt" // path notation
975+ "za/co/is/ftp/rfc/rfc1808.txt", // path notation
976+ ""
977 },
978 {
979 "",
980@@ -178,7 +187,8 @@
981 "/test",
982 "thomas",
983 "",
984- "[2001:6f8:9000:876:cccc:bbbb::]/test" // path notation
985+ "[2001:6f8:9000:876:cccc:bbbb::]/test", // path notation
986+ ""
987 },
988 // uri resolver tests
989 {
990@@ -193,7 +203,8 @@
991 "/b/c/g",
992 "",
993 "",
994- "a/b/c/g" // path notation
995+ "a/b/c/g", // path notation
996+ ""
997 },
998 {
999 "http://a/b/c/d;p?q",
1000@@ -207,7 +218,8 @@
1001 "/b/c/g",
1002 "",
1003 "",
1004- "a/b/c/g" // path notation
1005+ "a/b/c/g", // path notation
1006+ ""
1007 },
1008 {
1009 "http://a/b/c/d;p?q",
1010@@ -221,7 +233,8 @@
1011 "/b/c/g/",
1012 "",
1013 "",
1014- "a/b/c/g/" // path notation
1015+ "a/b/c/g/", // path notation
1016+ ""
1017 },
1018 {
1019 "http://a/b/c/d;p?q",
1020@@ -235,7 +248,8 @@
1021 "/g",
1022 "",
1023 "",
1024- "a/g" // path notation
1025+ "a/g", // path notation
1026+ ""
1027 },
1028 {
1029 "http://a/b/c/d;p?q",
1030@@ -249,7 +263,8 @@
1031 "/b/c/",
1032 "",
1033 "y",
1034- "a/b/c/" // path notation
1035+ "a/b/c/", // path notation
1036+ ""
1037 },
1038 {
1039 "http://a/b/c/d;p?q",
1040@@ -263,7 +278,8 @@
1041 "/b/c/g",
1042 "",
1043 "y",
1044- "a/b/c/g" // path notation
1045+ "a/b/c/g", // path notation
1046+ ""
1047 } //,
1048 //{
1049 // "http://a/b/c/d;p?q",
1050@@ -276,6 +292,7 @@
1051 // "",
1052 // "/b/c/g",
1053 // "",
1054+ // "".
1055 // ""
1056 //}
1057 ,
1058@@ -291,7 +308,8 @@
1059 "/b/c/g",
1060 "",
1061 "",
1062- "a/b/c/g" // path notation
1063+ "a/b/c/g", // path notation
1064+ ""
1065 },
1066 {
1067 "http://a/b/c/d;p?q",
1068@@ -305,7 +323,8 @@
1069 "/b/c/g",
1070 "",
1071 "y",
1072- "a/b/c/g" // path notation
1073+ "a/b/c/g", // path notation
1074+ ""
1075 },
1076 {
1077 "http://a/b/c/d;p?q",
1078@@ -319,7 +338,8 @@
1079 "/b/c/;x",
1080 "",
1081 "",
1082- "a/b/c/;x" // path notation
1083+ "a/b/c/;x", // path notation
1084+ ""
1085 },
1086 {
1087 "http://a/b/c/d;p?q",
1088@@ -333,7 +353,8 @@
1089 "/b/c/g;x",
1090 "",
1091 "",
1092- "a/b/c/g;x" // path notation
1093+ "a/b/c/g;x", // path notation
1094+ ""
1095 },
1096 {
1097 "http://a/b/c/d;p?q",
1098@@ -347,7 +368,8 @@
1099 "/b/c/g;x",
1100 "",
1101 "y",
1102- "a/b/c/g;x" // path notation
1103+ "a/b/c/g;x", // path notation
1104+ ""
1105 },
1106 {
1107 "http://a/b/c/d;p?q",
1108@@ -361,7 +383,8 @@
1109 "/b/c/",
1110 "",
1111 "",
1112- "a/b/c/" // path notation
1113+ "a/b/c/", // path notation
1114+ ""
1115 },
1116 {
1117 "http://a/b/c/d;p?q",
1118@@ -375,7 +398,8 @@
1119 "/b/c/",
1120 "",
1121 "",
1122- "a/b/c/" // path notation
1123+ "a/b/c/", // path notation
1124+ ""
1125 },
1126 {
1127 "http://a/b/c/d;p?q",
1128@@ -389,7 +413,8 @@
1129 "/b/",
1130 "",
1131 "",
1132- "a/b/" // path notation
1133+ "a/b/", // path notation
1134+ ""
1135 },
1136 {
1137 "http://a/b/c/d;p?q",
1138@@ -403,7 +428,8 @@
1139 "/b/",
1140 "",
1141 "",
1142- "a/b/" // path notation
1143+ "a/b/", // path notation
1144+ ""
1145 },
1146 {
1147 "http://a/b/c/d;p?q",
1148@@ -417,7 +443,8 @@
1149 "/b/g",
1150 "",
1151 "",
1152- "a/b/g" // path notation
1153+ "a/b/g", // path notation
1154+ ""
1155 },
1156 {
1157 "http://a/b/c/d;p?q",
1158@@ -431,7 +458,8 @@
1159 "/",
1160 "",
1161 "",
1162- "a/" // path notation
1163+ "a/", // path notation
1164+ ""
1165 },
1166 {
1167 "http://a/b/c/d;p?q",
1168@@ -445,7 +473,8 @@
1169 "/",
1170 "",
1171 "",
1172- "a/" // path notation
1173+ "a/", // path notation
1174+ ""
1175 },
1176 {
1177 "http://a/b/c/d;p?q",
1178@@ -459,7 +488,8 @@
1179 "/g",
1180 "",
1181 "",
1182- "a/g" // path notation
1183+ "a/g", // path notation
1184+ ""
1185 },
1186 {
1187 "http://a/b/c/d;p?q",
1188@@ -473,7 +503,8 @@
1189 "/b/c/g;x=1/y",
1190 "",
1191 "",
1192- "a/b/c/g;x=1/y" // path notation
1193+ "a/b/c/g;x=1/y", // path notation
1194+ ""
1195 },
1196 {
1197 "http://a/b/c/d;p?q",
1198@@ -487,7 +518,8 @@
1199 "/b/c/y",
1200 "",
1201 "",
1202- "a/b/c/y" // path notation
1203+ "a/b/c/y", // path notation
1204+ ""
1205 },
1206 {
1207 "http://a/b/c/d;p?q",
1208@@ -501,7 +533,8 @@
1209 "/b/c/g",
1210 "",
1211 "",
1212- "a/b/c/g" // path notation
1213+ "a/b/c/g", // path notation
1214+ ""
1215 },
1216 {
1217 "http://www.example.com/",
1218@@ -515,7 +548,8 @@
1219 "/",
1220 "",
1221 "",
1222- "example.com" // path notation
1223+ "example.com", // path notation
1224+ ""
1225 },
1226 {
1227 "http://www.example.com/",
1228@@ -529,7 +563,8 @@
1229 "/dir/file",
1230 "",
1231 "",
1232- "example.com" // path notation
1233+ "example.com", // path notation
1234+ ""
1235 },
1236 {
1237 "",
1238@@ -543,7 +578,8 @@
1239 "",
1240 "",
1241 "",
1242- "de/msb/www" // path notation
1243+ "de/msb/www", // path notation
1244+ ""
1245 },
1246 {
1247 "http://www.msb.de/",
1248@@ -557,7 +593,8 @@
1249 "/lib/helpers",
1250 "",
1251 "",
1252- "de/msb/www/lib/helpers" // path notation
1253+ "de/msb/www/lib/helpers", // path notation
1254+ ""
1255 },
1256 {
1257 "",
1258@@ -575,7 +612,8 @@
1259 #endif
1260 "",
1261 "",
1262- "/d:/a/b/c" // path notation
1263+ "/d:/a/b/c", // path notation
1264+ ""
1265 },
1266 {
1267 "",
1268@@ -593,7 +631,8 @@
1269 #endif
1270 "",
1271 "",
1272- "localhost/d:/a/b/c" // path notation
1273+ "localhost/d:/a/b/c", // path notation
1274+ ""
1275 },
1276 {
1277 "file://localhost",
1278@@ -607,7 +646,83 @@
1279 "/Ångström/b/c",
1280 "",
1281 "",
1282- "localhost/Ångström/b/c" // path notation
1283+ "localhost/Ångström/b/c", // path notation
1284+ ""
1285+ },
1286+ {
1287+ "",
1288+ "opaq:opaque-uri-part#frag",
1289+ "opaq:opaque-uri-part#frag",
1290+ "opaq",
1291+ 0,
1292+ "frag",
1293+ "",
1294+ "",
1295+ "",
1296+ "",
1297+ "",
1298+ "opaque-uri-part",
1299+ "opaque-uri-part"
1300+ },
1301+ {
1302+ "opaq:opaque-uri-part",
1303+ "#frag",
1304+ "opaq:opaque-uri-part#frag",
1305+ "opaq",
1306+ 0,
1307+ "frag",
1308+ "",
1309+ "",
1310+ "",
1311+ "",
1312+ "",
1313+ "opaque-uri-part",
1314+ "opaque-uri-part"
1315+ },
1316+ {
1317+ "",
1318+ "opaq:text-file.txt",
1319+ "opaq:text-file.txt",
1320+ "opaq",
1321+ 0,
1322+ "",
1323+ "",
1324+ "",
1325+ "",
1326+ "",
1327+ "",
1328+ "text-file.txt",
1329+ "text-file.txt"
1330+ },
1331+ {
1332+ "",
1333+ "ftp:///a/b/c/file.txt",
1334+ "ftp:///a/b/c/file.txt",
1335+ "ftp",
1336+ 0,
1337+ "",
1338+ "",
1339+ "",
1340+ "/a/b/c/file.txt",
1341+ "",
1342+ "",
1343+ "/a/b/c/file.txt",
1344+ ""
1345+ },
1346+ {
1347+ "",
1348+ "gopher:///base_dir/file.txt",
1349+ "gopher:///base_dir/file.txt",
1350+ "gopher",
1351+ 0,
1352+ "",
1353+ "",
1354+ "",
1355+ "/base_dir/file.txt",
1356+ "",
1357+ "",
1358+ "/base_dir/file.txt",
1359+ ""
1360 }
1361 }; // URITestEntry tests[]
1362
1363
1364=== modified file 'src/zorbatypes/URI.cpp'
1365--- src/zorbatypes/URI.cpp 2013-02-07 17:24:36 +0000
1366+++ src/zorbatypes/URI.cpp 2013-05-03 23:21:27 +0000
1367@@ -474,7 +474,7 @@
1368 :
1369 theState(0),
1370 thePort(0),
1371- valid(validate)
1372+ theValidate(validate)
1373 {
1374 initialize(uri);
1375
1376@@ -489,7 +489,7 @@
1377 :
1378 theState(0),
1379 thePort(0),
1380- valid(validate)
1381+ theValidate(validate)
1382 {
1383 initialize(uri, true);
1384 resolve(&base_uri);
1385@@ -503,7 +503,7 @@
1386 :
1387 theState(0),
1388 thePort(0),
1389- valid(false)
1390+ theValidate(false)
1391 {
1392 initialize(full_uri.toString(), false);
1393 relativize(&base_uri);
1394@@ -526,7 +526,7 @@
1395 :
1396 theState(0),
1397 thePort(0),
1398- valid(true)
1399+ theValidate(true)
1400 {
1401 }
1402
1403@@ -553,7 +553,7 @@
1404 thePath = to_copy.thePath;
1405 theQueryString = to_copy.theQueryString;
1406 theFragment = to_copy.theFragment;
1407- valid = to_copy.valid;
1408+ theValidate = to_copy.theValidate;
1409 }
1410
1411
1412@@ -572,6 +572,7 @@
1413 thePath.clear();
1414 theQueryString.clear();
1415 theFragment.clear();
1416+ theOpaquePart.clear();
1417
1418 // first, we need to normalize the spaces in the uri
1419 // and only work with the normalized version from this point on
1420@@ -615,7 +616,7 @@
1421 (lColonIdx > lFragmentIdx && lFragmentIdx != zstring::npos))
1422 {
1423 // A standalone base is a valid URI
1424- if (valid &&
1425+ if (theValidate &&
1426 (lColonIdx == 0 || (!have_base && lFragmentIdx != zstring::npos)) &&
1427 lTrimmedURILength > 0)
1428 {
1429@@ -631,11 +632,17 @@
1430 lIndex = (ulong)theScheme.size() + 1;
1431 }
1432
1433+ if(is_set(Scheme) && (lTrimmedURI.compare(lIndex, 1, "/") != 0))
1434+ {
1435+ // This is an opaque URI. Set that state here; initializePath() will
1436+ // actually set the value.
1437+ set_state(OpaquePart);
1438+ }
1439 /**
1440 * Authority
1441 * two slashes means generic URI syntax, so we get the authority
1442 */
1443- if ( (lTrimmedURI.compare(lIndex, 2, "//") == 0) ||
1444+ else if ( (lTrimmedURI.compare(lIndex, 2, "//") == 0) ||
1445 // allow JAVA FILE constructs without authority, i.e.: file:/D:/myFile
1446 (ZSTREQ(theScheme, "file") && (lTrimmedURI.compare(lIndex, 1, "/") == 0)))
1447 {
1448@@ -692,19 +699,16 @@
1449 set_host(zstring());
1450 }
1451 }
1452- // do not allow constructs like: file:D:/myFile or http:myFile
1453 }
1454- else if (ZSTREQ(theScheme, "file") ||
1455- ZSTREQ(theScheme, "http") ||
1456- ZSTREQ(theScheme, "https"))
1457+ // do not allow constructs like: file:D:/myFile or http:myFile
1458+ else if (theValidate && (ZSTREQ(theScheme, "file") ||
1459+ ZSTREQ(theScheme, "http") ||
1460+ ZSTREQ(theScheme, "https") ) )
1461 {
1462- if (valid)
1463- {
1464- throw XQUERY_EXCEPTION(
1465- err::XQST0046,
1466- ERROR_PARAMS( lTrimmedURI, ZED( BadURISyntaxForScheme_3 ), theScheme )
1467- );
1468- }
1469+ throw XQUERY_EXCEPTION(
1470+ err::XQST0046,
1471+ ERROR_PARAMS( lTrimmedURI, ZED( BadURISyntaxForScheme_3 ), theScheme )
1472+ );
1473 }
1474
1475 // stop, if we're done here
1476@@ -727,7 +731,7 @@
1477 {
1478 zstring::size_type lSchemeSeparatorIdx = uri.find_first_of(":/?#", 0,4 );
1479
1480- if ( valid && lSchemeSeparatorIdx == zstring::npos )
1481+ if ( theValidate && lSchemeSeparatorIdx == zstring::npos )
1482 {
1483 throw XQUERY_EXCEPTION(
1484 err::XQST0046, ERROR_PARAMS( uri, ZED( NoURIScheme ) )
1485@@ -919,18 +923,12 @@
1486 ulong lEnd = (ulong)lCodepoints.size();
1487 uint32_t lCp = 0;
1488
1489- if (uri.empty())
1490- {
1491- thePath = uri;
1492- set_state(Path);
1493- return;
1494- }
1495+ bool lIsOpaque = is_set(OpaquePart);
1496
1497- // path - everything up to query string or fragment
1498+ // path - everything up to query string (if not opaque) or fragment
1499 if ( lStart < lEnd )
1500 {
1501- // RFC 2732 only allows '[' and ']' to appear in the opaque part.
1502- if ( ! is_set(Scheme) || lCodepoints[lStart] == '/')
1503+ if ( ! is_set(Scheme) || lIsOpaque || lCodepoints[lStart] == '/')
1504 {
1505 // Scan path.
1506 // abs_path = "/" path_segments
1507@@ -938,11 +936,20 @@
1508 while ( lIndex < lEnd )
1509 {
1510 lCp = lCodepoints[lIndex];
1511- if ( lCp == '?' || lCp == '#' )
1512+ if (lCp == '?') {
1513+ if ( ! lIsOpaque) {
1514+ // Query string starting if not opaque
1515+ break;
1516+ }
1517+ // If it is an opaque URI, ? is fine
1518+ }
1519+ else if (lCp == '#' ) {
1520+ // Fragment starting
1521 break;
1522-
1523- if ( lCp == '%' )
1524+ }
1525+ else if ( lCp == '%' )
1526 {
1527+ // Percent-decoding check
1528 if ( lIndex + 2 >= lEnd )
1529 {
1530 throw XQUERY_EXCEPTION(err::XQST0046,
1531@@ -965,7 +972,7 @@
1532 ERROR_PARAMS(uri, ZED(XQST0046_BadHexDigit_3), lHex2));
1533 }
1534 }
1535- else if (!is_unreserved_char(lCp) && !is_path_character(lCp) && valid)
1536+ else if (theValidate && !is_unreserved_char(lCp) && !is_path_character(lCp))
1537 {
1538 throw XQUERY_EXCEPTION(err::XQST0046,
1539 ERROR_PARAMS(uri, ZED(BadUnicodeChar_3), lCp));
1540@@ -992,7 +999,7 @@
1541 {
1542 // TODO check errors
1543 }
1544- else if (!is_reservered_or_unreserved_char(lCp) && valid)
1545+ else if (!is_reservered_or_unreserved_char(lCp) && theValidate)
1546 {
1547 throw XQUERY_EXCEPTION(
1548 err::XQST0046, ERROR_PARAMS( uri, ZED( BadUnicodeChar_3 ), lCp )
1549@@ -1005,15 +1012,23 @@
1550 } // lStart < lEnd
1551
1552
1553- thePath.clear();
1554- utf8::append_codepoints(lCodepoints.begin() + lStart,
1555- lCodepoints.begin() + lIndex,
1556- &thePath);
1557-
1558- set_state(Path);
1559+ // lCodepoints now contains all the processed stuff; put it in the right place
1560+ if (lIsOpaque) {
1561+ theOpaquePart.clear();
1562+ utf8::append_codepoints(lCodepoints.begin() + lStart,
1563+ lCodepoints.begin() + lIndex,
1564+ &theOpaquePart);
1565+ }
1566+ else {
1567+ thePath.clear();
1568+ utf8::append_codepoints(lCodepoints.begin() + lStart,
1569+ lCodepoints.begin() + lIndex,
1570+ &thePath);
1571+ set_state(Path);
1572+ }
1573
1574 // query - starts with ? and up to fragment or end
1575- if ( lCp == '?' )
1576+ if ( ( ! lIsOpaque) && (lCp == '?') )
1577 {
1578 ++lIndex;
1579 lStart = lIndex;
1580@@ -1159,6 +1174,28 @@
1581 }
1582 }
1583
1584+/*******************************************************************************
1585+
1586+********************************************************************************/
1587+void URI::set_query(const zstring& new_query)
1588+{
1589+ theQueryString = new_query;
1590+ set_state(QueryString);
1591+}
1592+
1593+void URI::set_opaque_part(const zstring& new_scheme_specific)
1594+{
1595+ if (new_scheme_specific.empty())
1596+ {
1597+ theOpaquePart = new_scheme_specific;
1598+ unset_state(OpaquePart);
1599+ }
1600+ else
1601+ {
1602+ theOpaquePart = new_scheme_specific;
1603+ set_state(OpaquePart);
1604+ }
1605+}
1606
1607 /*******************************************************************************
1608
1609@@ -1287,7 +1324,7 @@
1610 set_state(Path);
1611 }
1612
1613- if ( (! is_set(QueryString)) )
1614+ if ( base_uri->is_set(QueryString) && !is_set(QueryString) )
1615 {
1616 base_uri->get_query(theQueryString);
1617
1618@@ -1584,6 +1621,13 @@
1619 std::ostringstream lPathNotation;
1620
1621 std::string lToTokenize;
1622+
1623+ if(is_set(OpaquePart))
1624+ {
1625+ thePathNotation = theOpaquePart.str();
1626+ return;
1627+ }
1628+
1629 if (is_set(Host))
1630 {
1631 lToTokenize = theHost.str();
1632@@ -1593,7 +1637,7 @@
1633 lToTokenize = theRegBasedAuthority.str();
1634 }
1635
1636- std::string::size_type lastPos =
1637+ std::string::size_type lastPos =
1638 lToTokenize.find_last_not_of(".", lToTokenize.length());
1639
1640 std::string::size_type pos = lToTokenize.find_last_of(".", lastPos);
1641@@ -1637,37 +1681,45 @@
1642 if ( is_set(Scheme) )
1643 lURI << theScheme << ":";
1644
1645- // Authority
1646- if ( is_set(Host) || is_set(RegBasedAuthority) )
1647- {
1648- lURI << "//";
1649- if ( is_set(Host) )
1650- {
1651- if ( is_set(UserInfo) )
1652- lURI << theUserInfo << "@";
1653-
1654- lURI << theHost;
1655-
1656- if ( is_set(Port) )
1657- lURI << ":" << thePort;
1658- }
1659- else
1660- {
1661- lURI << theRegBasedAuthority;
1662- }
1663- }
1664-
1665- if ( is_set(Path) )
1666- {
1667- #ifdef WIN32
1668- if(ZSTREQ(theScheme, "file") && !thePath.empty() && (thePath[0] != '/'))
1669- lURI << "/";
1670- #endif
1671- lURI << thePath;
1672- }
1673-
1674- if ( is_set(QueryString) )
1675- lURI << "?" << theQueryString;
1676+ if(is_set(OpaquePart))
1677+ {
1678+ // opaque URL
1679+ lURI << theOpaquePart;
1680+ }
1681+ else
1682+ {
1683+ // Authority
1684+ if ( is_set(Host) || is_set(RegBasedAuthority) )
1685+ {
1686+ lURI << "//";
1687+ if ( is_set(Host) )
1688+ {
1689+ if ( is_set(UserInfo) )
1690+ lURI << theUserInfo << "@";
1691+
1692+ lURI << theHost;
1693+
1694+ if ( is_set(Port) )
1695+ lURI << ":" << thePort;
1696+ }
1697+ else
1698+ {
1699+ lURI << theRegBasedAuthority;
1700+ }
1701+ }
1702+
1703+ if ( is_set(Path) )
1704+ {
1705+ #ifdef WIN32
1706+ if(ZSTREQ(theScheme, "file") && !thePath.empty() && (thePath[0] != '/'))
1707+ lURI << "/";
1708+ #endif
1709+ lURI << thePath;
1710+ }
1711+
1712+ if ( is_set(QueryString) )
1713+ lURI << "?" << theQueryString;
1714+ }
1715
1716 if ( is_set(Fragment) )
1717 lURI << "#" << theFragment;
1718@@ -1687,38 +1739,46 @@
1719 if ( is_set(Scheme) )
1720 lURI << theScheme << ":";
1721
1722- // Authority
1723- if ( is_set(Host) || is_set(RegBasedAuthority) )
1724- {
1725- lURI << "//";
1726-
1727- if ( is_set(Host) )
1728- {
1729- if ( is_set(UserInfo) )
1730- lURI << theUserInfo << "@";
1731-
1732- lURI << theHost;
1733-
1734- if ( is_set(Port) )
1735- lURI << ":" << thePort;
1736- }
1737- else
1738- {
1739- lURI << theRegBasedAuthority;
1740- }
1741- }
1742-
1743- if ( is_set(Path) )
1744- {
1745- #ifdef WIN32
1746- if(ZSTREQ(theScheme, "file") && !thePath.empty() && (thePath[0] != '/'))
1747- lURI << "/";
1748- #endif
1749- lURI << thePath;
1750- }
1751-
1752- if ( is_set(QueryString) )
1753- lURI << "?" << theQueryString;
1754+ if (is_set(OpaquePart))
1755+ {
1756+ // opaque uri
1757+ lURI << theOpaquePart;
1758+ }
1759+ else
1760+ {
1761+ // Authority
1762+ if ( is_set(Host) || is_set(RegBasedAuthority) )
1763+ {
1764+ lURI << "//";
1765+
1766+ if ( is_set(Host) )
1767+ {
1768+ if ( is_set(UserInfo) )
1769+ lURI << theUserInfo << "@";
1770+
1771+ lURI << theHost;
1772+
1773+ if ( is_set(Port) )
1774+ lURI << ":" << thePort;
1775+ }
1776+ else
1777+ {
1778+ lURI << theRegBasedAuthority;
1779+ }
1780+ }
1781+
1782+ if ( is_set(Path) )
1783+ {
1784+ #ifdef WIN32
1785+ if(ZSTREQ(theScheme, "file") && !thePath.empty() && (thePath[0] != '/'))
1786+ lURI << "/";
1787+ #endif
1788+ lURI << thePath;
1789+ }
1790+
1791+ if ( is_set(QueryString) )
1792+ lURI << "?" << theQueryString;
1793+ }
1794
1795 if ( is_set(Fragment) )
1796 lURI << "#" << theFragment;
1797
1798=== modified file 'src/zorbatypes/URI.h'
1799--- src/zorbatypes/URI.h 2013-02-07 17:24:36 +0000
1800+++ src/zorbatypes/URI.h 2013-05-03 23:21:27 +0000
1801@@ -49,19 +49,20 @@
1802
1803 static long scanHexSequence(const char* addr, long idx, long end, long& counter);
1804
1805-protected:
1806 enum States
1807 {
1808- Scheme = 1,
1809- UserInfo = 2,
1810- Host = 4,
1811- Port = 8,
1812- RegBasedAuthority = 16,
1813- Path = 32,
1814- QueryString = 64,
1815- Fragment = 128
1816+ Scheme = 1,
1817+ UserInfo = 2,
1818+ Host = 4,
1819+ Port = 8,
1820+ RegBasedAuthority = 16,
1821+ Path = 32,
1822+ QueryString = 64,
1823+ Fragment = 128,
1824+ OpaquePart = 256
1825 };
1826
1827+protected:
1828 // keep track whether particular components of a uri are defined or undefined
1829 mutable uint32_t theState;
1830
1831@@ -81,9 +82,10 @@
1832 zstring thePath;
1833 zstring theQueryString;
1834 zstring theFragment;
1835+ zstring theOpaquePart;
1836
1837 // true if the constructed URI is valid
1838- bool valid;
1839+ bool theValidate;
1840
1841 public:
1842 URI(const zstring& uri, bool validate = true);
1843@@ -154,6 +156,14 @@
1844
1845 void clear_fragment();
1846
1847+ void set_opaque_part(const zstring& new_opaque_part);
1848+
1849+ const zstring& get_opaque_part() const;
1850+
1851+ void clear_opaque_part();
1852+
1853+ bool is_set(uint32_t s) const { return ((theState & s) > 0); }
1854+
1855 protected:
1856 void build_full_text() const;
1857
1858@@ -185,8 +195,6 @@
1859
1860 void set_state(uint32_t s) const { theState |= s; }
1861
1862- bool is_set(uint32_t s) const { return ((theState & s) > 0); }
1863-
1864 void unset_state(uint32_t s) const { theState &= ~s; }
1865
1866 void invalidate_text() const;
1867@@ -195,7 +203,9 @@
1868
1869 inline bool URI::is_valid() const
1870 {
1871- return valid;
1872+ // If we requested validation originally, and successfully passed the
1873+ // initialize step - we're valid!
1874+ return theValidate;
1875 }
1876
1877
1878@@ -246,9 +256,15 @@
1879 return theFragment;
1880 }
1881
1882+inline const zstring& URI::get_opaque_part() const
1883+{
1884+ return theOpaquePart;
1885+}
1886+
1887 inline void URI::set_fragment(const zstring &new_fragment)
1888 {
1889 theFragment = new_fragment;
1890+ set_state(Fragment);
1891 invalidate_text();
1892 }
1893
1894@@ -259,6 +275,13 @@
1895 invalidate_text();
1896 }
1897
1898+inline void URI::clear_opaque_part()
1899+{
1900+ theOpaquePart.clear();
1901+ unset_state(OpaquePart);
1902+ invalidate_text();
1903+}
1904+
1905 inline void URI::invalidate_text() const
1906 {
1907 theASCIIURIText.clear();
1908
1909=== modified file 'test/fots/CMakeLists.txt'
1910--- test/fots/CMakeLists.txt 2013-05-03 07:40:27 +0000
1911+++ test/fots/CMakeLists.txt 2013-05-03 23:21:27 +0000
1912@@ -303,7 +303,6 @@
1913 EXPECTED_FOTS_FAILURE (prod-ModuleImport module-URIs-12 0)
1914 EXPECTED_FOTS_FAILURE (prod-ModuleImport module-URIs-17 0)
1915 EXPECTED_FOTS_FAILURE (prod-ModuleImport module-URIs-18 0)
1916-EXPECTED_FOTS_FAILURE (prod-ModuleImport module-URIs-19 0)
1917 EXPECTED_FOTS_FAILURE (prod-ModuleImport modules-collide-var-001 0)
1918 EXPECTED_FOTS_FAILURE (prod-ModuleImport modules-collide-fn-001 0)
1919 EXPECTED_FOTS_FAILURE (prod-ModuleImport errata8-002a 0)
1920
1921=== added file 'test/rbkt/ExpQueryResults/zorba/uris/parse-uri.xml.res'
1922--- test/rbkt/ExpQueryResults/zorba/uris/parse-uri.xml.res 1970-01-01 00:00:00 +0000
1923+++ test/rbkt/ExpQueryResults/zorba/uris/parse-uri.xml.res 2013-05-03 23:21:27 +0000
1924@@ -0,0 +1,1 @@
1925+{ "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" : "" }
1926\ No newline at end of file
1927
1928=== added file 'test/rbkt/ExpQueryResults/zorba/uris/serialize-direct-uri.xml.res'
1929--- test/rbkt/ExpQueryResults/zorba/uris/serialize-direct-uri.xml.res 1970-01-01 00:00:00 +0000
1930+++ test/rbkt/ExpQueryResults/zorba/uris/serialize-direct-uri.xml.res 2013-05-03 23:21:27 +0000
1931@@ -0,0 +1,37 @@
1932+<?xml version="1.0" encoding="UTF-8"?>
1933+http:/
1934+ http://www.zorba-xquery.com/
1935+ http://www.zorba-xquery.com/?abc=true
1936+ http://www.zorba-xquery.com:8080/?abc=true
1937+ http://user@www.zorba-xquery.com:8080/?abc=true
1938+ http://user@www.zorba-xquery.com:8080/path1/path2?abc=true
1939+ http://user@www.zorba-xquery.com:8080/path1/path2?abc=true&amp;bcd=false
1940+ ftp://ftp.is.co.za/rfc/rfc1808.txt
1941+ http://thomas@[2001:6f8:9000:876:cccc:bbbb::]:123/test
1942+ http://a/b/c/g
1943+ http://a/b/c/g/
1944+ http://a/g
1945+ http://a/b/c/?y
1946+ http://a/b/c/g?y
1947+ http://a/b/c/g#s
1948+ http://a/b/c/g?y#s
1949+ http://a/b/c/;x
1950+ http://a/b/c/g;x
1951+ http://a/b/c/g;x?y#s
1952+ http://a/b/c
1953+ http://a/b/c/
1954+ http://a/b
1955+ http://a/b/
1956+ http://a/b/g
1957+ http://a/
1958+ http://a/g
1959+ http://a/b/c/g;x=1/y
1960+ http://a/b/c/y
1961+ http://a/b/c/g#s/../x
1962+ http://www.example.com/
1963+ http://www.example.com/dir/file
1964+ http://www.msb.de
1965+ http://www.msb.de/lib/helpers
1966+ file://localhost/Ångström/b/c
1967+ file:opaque-uri-part#frag
1968+ file:text-file.txt
1969
1970=== added file 'test/rbkt/ExpQueryResults/zorba/uris/serialize-uri.xml.res'
1971--- test/rbkt/ExpQueryResults/zorba/uris/serialize-uri.xml.res 1970-01-01 00:00:00 +0000
1972+++ test/rbkt/ExpQueryResults/zorba/uris/serialize-uri.xml.res 2013-05-03 23:21:27 +0000
1973@@ -0,0 +1,44 @@
1974+<?xml version="1.0" encoding="UTF-8"?>
1975+http:/
1976+ http://www.zorba-xquery.com/
1977+ http://www.zorba-xquery.com/?abc=true
1978+ http://www.zorba-xquery.com:8080/?abc=true
1979+ http://user@www.zorba-xquery.com:8080/?abc=true
1980+ http://user@www.zorba-xquery.com:8080/path1/path2?abc=true
1981+ http://user@www.zorba-xquery.com:8080/path1/path2?abc=true&amp;bcd=false#fragment
1982+ ftp://ftp.is.co.za/rfc/rfc1808.txt
1983+ http://thomas@[2001:6f8:9000:876:cccc:bbbb::]:123/test
1984+ http://a/b/c/g
1985+ http://a/b/c/g
1986+ http://a/b/c/g/
1987+ http://a/g
1988+ http://a/b/c/?y
1989+ http://a/b/c/g?y
1990+ http://a/b/c/g#s
1991+ http://a/b/c/g?y#s
1992+ http://a/b/c/;x
1993+ http://a/b/c/g;x
1994+ http://a/b/c/g;x?y#s
1995+ http://a/b/c/
1996+ http://a/b/c/
1997+ http://a/b/
1998+ http://a/b/
1999+ http://a/b/g
2000+ http://a/
2001+ http://a/
2002+ http://a/g
2003+ http://a/b/c/g;x=1/y
2004+ http://a/b/c/y
2005+ http://a/b/c/g#s/../x
2006+ http://www.example.com/
2007+ http://www.example.com/dir/file
2008+ http://www.msb.de
2009+ http://www.msb.de/lib/helpers
2010+ file:/d:/a/b/c
2011+ file://localhost/d:/a/b/c
2012+ file://localhost/Ångström/b/c
2013+ file:opaque-uri-part#frag
2014+ file:text-file.txt
2015+ file:bar?
2016+ file:bar?#frag
2017+ http://foo.com/bc?
2018\ No newline at end of file
2019
2020=== added file 'test/rbkt/Queries/zorba/uris/parse-invalid.spec'
2021--- test/rbkt/Queries/zorba/uris/parse-invalid.spec 1970-01-01 00:00:00 +0000
2022+++ test/rbkt/Queries/zorba/uris/parse-invalid.spec 2013-05-03 23:21:27 +0000
2023@@ -0,0 +1,1 @@
2024+Error: http://www.w3.org/2005/xqt-errors:XQST0046
2025
2026=== added file 'test/rbkt/Queries/zorba/uris/parse-invalid.xq'
2027--- test/rbkt/Queries/zorba/uris/parse-invalid.xq 1970-01-01 00:00:00 +0000
2028+++ test/rbkt/Queries/zorba/uris/parse-invalid.xq 2013-05-03 23:21:27 +0000
2029@@ -0,0 +1,3 @@
2030+import module namespace uri="http://www.zorba-xquery.com/modules/uri";
2031+
2032+uri:parse("foo:bar%%")
2033
2034=== added file 'test/rbkt/Queries/zorba/uris/parse-uri.xq'
2035--- test/rbkt/Queries/zorba/uris/parse-uri.xq 1970-01-01 00:00:00 +0000
2036+++ test/rbkt/Queries/zorba/uris/parse-uri.xq 2013-05-03 23:21:27 +0000
2037@@ -0,0 +1,6 @@
2038+import module namespace uri = "http://www.zorba-xquery.com/modules/uri";
2039+
2040+let $xml-uri-test := fn:doc("uri-source.xml")//uri-element/text()
2041+
2042+for $uri in $xml-uri-test
2043+return uri:parse($uri)
2044
2045=== added file 'test/rbkt/Queries/zorba/uris/serialize-direct-uri.xq'
2046--- test/rbkt/Queries/zorba/uris/serialize-direct-uri.xq 1970-01-01 00:00:00 +0000
2047+++ test/rbkt/Queries/zorba/uris/serialize-direct-uri.xq 2013-05-03 23:21:27 +0000
2048@@ -0,0 +1,211 @@
2049+import module namespace uri = "http://www.zorba-xquery.com/modules/uri";
2050+
2051+let $xml-uri-test := { "uri-test" :
2052+ [
2053+ {
2054+ $uri:SCHEME : "http",
2055+ $uri:PATH : "/"
2056+ },
2057+ {
2058+ $uri:SCHEME : "http",
2059+ $uri:HOST : "www.zorba-xquery.com",
2060+ $uri:PATH : "/"
2061+ },
2062+ {
2063+ $uri:SCHEME : "http",
2064+ $uri:HOST : "www.zorba-xquery.com",
2065+ $uri:PATH : "/",
2066+ $uri:QUERY : "abc=true"
2067+ },
2068+ {
2069+ $uri:SCHEME : "http",
2070+ $uri:PORT : 8080,
2071+ $uri:HOST : "www.zorba-xquery.com",
2072+ $uri:PATH : "/",
2073+ $uri:QUERY : "abc=true"
2074+ },
2075+ {
2076+ $uri:SCHEME : "http",
2077+ $uri:PORT : 8080,
2078+ $uri:HOST : "www.zorba-xquery.com",
2079+ $uri:PATH : "/",
2080+ $uri:USER-INFO : "user",
2081+ $uri:QUERY : "abc=true"
2082+ },
2083+ {
2084+ $uri:SCHEME : "http",
2085+ $uri:PORT : 8080,
2086+ $uri:HOST : "www.zorba-xquery.com",
2087+ $uri:PATH : "/path1/path2",
2088+ $uri:USER-INFO : "user",
2089+ $uri:QUERY : "abc=true"
2090+ },
2091+ {
2092+ $uri:SCHEME : "http",
2093+ $uri:PORT : 8080,
2094+ $uri:HOST : "www.zorba-xquery.com",
2095+ $uri:PATH : "/path1/path2",
2096+ $uri:USER-INFO : "user",
2097+ $uri:QUERY : "abc=true&amp;bcd=false"
2098+ },
2099+ {
2100+ $uri:SCHEME : "ftp",
2101+ $uri:HOST : "ftp.is.co.za",
2102+ $uri:PATH : "/rfc/rfc1808.txt"
2103+ },
2104+ {
2105+ $uri:SCHEME : "http",
2106+ $uri:PORT : 123,
2107+ $uri:HOST : "[2001:6f8:9000:876:cccc:bbbb::]",
2108+ $uri:PATH : "/test",
2109+ $uri:USER-INFO : "thomas"
2110+ },
2111+ {
2112+ $uri:SCHEME : "http",
2113+ $uri:HOST : "a",
2114+ $uri:PATH : "/b/c/g"
2115+ },
2116+ {
2117+ $uri:SCHEME : "http",
2118+ $uri:HOST : "a",
2119+ $uri:PATH : "/b/c/g/"
2120+ },
2121+ {
2122+ $uri:SCHEME : "http",
2123+ $uri:HOST : "a",
2124+ $uri:PATH : "/g"
2125+ },
2126+ {
2127+ $uri:SCHEME : "http",
2128+ $uri:HOST : "a",
2129+ $uri:PATH : "/b/c/",
2130+ $uri:QUERY : "y"
2131+ },
2132+ {
2133+ $uri:SCHEME : "http",
2134+ $uri:HOST : "a",
2135+ $uri:PATH : "/b/c/g",
2136+ $uri:QUERY : "y"
2137+ },
2138+ {
2139+ $uri:SCHEME : "http",
2140+ $uri:FRAGMENT : "s",
2141+ $uri:HOST : "a",
2142+ $uri:PATH : "/b/c/g"
2143+ },
2144+ {
2145+ $uri:SCHEME : "http",
2146+ $uri:FRAGMENT : "s",
2147+ $uri:HOST : "a",
2148+ $uri:PATH : "/b/c/g",
2149+ $uri:QUERY : "y"
2150+ },
2151+ {
2152+ $uri:SCHEME : "http",
2153+ $uri:HOST : "a",
2154+ $uri:PATH : "/b/c/;x"
2155+ },
2156+ {
2157+ $uri:SCHEME : "http",
2158+ $uri:HOST : "a",
2159+ $uri:PATH : "/b/c/g;x"
2160+ },
2161+ {
2162+ $uri:SCHEME : "http",
2163+ $uri:FRAGMENT : "s",
2164+ $uri:HOST : "a",
2165+ $uri:PATH : "/b/c/g;x",
2166+ $uri:QUERY : "y"
2167+ },
2168+ {
2169+ $uri:SCHEME : "http",
2170+ $uri:HOST : "a",
2171+ $uri:PATH : "/b/c"
2172+ },
2173+ {
2174+ $uri:SCHEME : "http",
2175+ $uri:HOST : "a",
2176+ $uri:PATH : "/b/c/"
2177+ },
2178+ {
2179+ $uri:SCHEME : "http",
2180+ $uri:HOST : "a",
2181+ $uri:PATH : "/b"
2182+ },
2183+ {
2184+ $uri:SCHEME : "http",
2185+ $uri:HOST : "a",
2186+ $uri:PATH : "/b/"
2187+ },
2188+ {
2189+ $uri:SCHEME : "http",
2190+ $uri:HOST : "a",
2191+ $uri:PATH : "/b/g"
2192+ },
2193+ {
2194+ $uri:SCHEME : "http",
2195+ $uri:HOST : "a",
2196+ $uri:PATH : "/"
2197+ },
2198+ {
2199+ $uri:SCHEME : "http",
2200+ $uri:HOST : "a",
2201+ $uri:PATH : "/g"
2202+ },
2203+ {
2204+ $uri:SCHEME : "http",
2205+ $uri:HOST : "a",
2206+ $uri:PATH : "/b/c/g;x=1/y"
2207+ },
2208+ {
2209+ $uri:SCHEME : "http",
2210+ $uri:HOST : "a",
2211+ $uri:PATH : "/b/c/y"
2212+ },
2213+ {
2214+ $uri:SCHEME : "http",
2215+ $uri:FRAGMENT : "s/../x",
2216+ $uri:HOST : "a",
2217+ $uri:PATH : "/b/c/g"
2218+ },
2219+ {
2220+ $uri:SCHEME : "http",
2221+ $uri:HOST : "www.example.com",
2222+ $uri:PATH : "/"
2223+ },
2224+ {
2225+ $uri:SCHEME : "http",
2226+ $uri:HOST : "www.example.com",
2227+ $uri:PATH : "/dir/file"
2228+ },
2229+ {
2230+ $uri:SCHEME : "http",
2231+ $uri:HOST : "www.msb.de"
2232+ },
2233+ {
2234+ $uri:SCHEME : "http",
2235+ $uri:HOST : "www.msb.de",
2236+ $uri:PATH : "/lib/helpers"
2237+ },
2238+ {
2239+ $uri:SCHEME : "file",
2240+ $uri:HOST : "localhost",
2241+ $uri:PATH : "/Ångström/b/c"
2242+ },
2243+ {
2244+ $uri:SCHEME : "file",
2245+ $uri:OPAQUE-PART : "opaque-uri-part",
2246+ $uri:FRAGMENT : "frag"
2247+ },
2248+ {
2249+ $uri:SCHEME : "file",
2250+ $uri:OPAQUE-PART : "text-file.txt"
2251+ }
2252+ ]
2253+}
2254+
2255+for $index in 1 to jn:size($xml-uri-test("uri-test"))
2256+let $uri := $xml-uri-test("uri-test")($index)
2257+return ( uri:serialize($uri), "
2258+")
2259+
2260
2261=== added file 'test/rbkt/Queries/zorba/uris/serialize-uri.xq'
2262--- test/rbkt/Queries/zorba/uris/serialize-uri.xq 1970-01-01 00:00:00 +0000
2263+++ test/rbkt/Queries/zorba/uris/serialize-uri.xq 2013-05-03 23:21:27 +0000
2264@@ -0,0 +1,9 @@
2265+import module namespace uri = "http://www.zorba-xquery.com/modules/uri";
2266+
2267+let $xml-uri-test := fn:doc("uri-source.xml")//uri-element
2268+
2269+for $uri in $xml-uri-test
2270+let $parsed-uri := uri:parse($uri)
2271+return concat(uri:serialize($parsed-uri), "
2272+")
2273+
2274
2275=== added file 'test/rbkt/Queries/zorba/uris/serialize-wrong-opaque-noscheme.spec'
2276--- test/rbkt/Queries/zorba/uris/serialize-wrong-opaque-noscheme.spec 1970-01-01 00:00:00 +0000
2277+++ test/rbkt/Queries/zorba/uris/serialize-wrong-opaque-noscheme.spec 2013-05-03 23:21:27 +0000
2278@@ -0,0 +1,1 @@
2279+Error: http://www.zorba-xquery.com/errors:ZURI0002
2280
2281=== added file 'test/rbkt/Queries/zorba/uris/serialize-wrong-opaque-noscheme.xq'
2282--- test/rbkt/Queries/zorba/uris/serialize-wrong-opaque-noscheme.xq 1970-01-01 00:00:00 +0000
2283+++ test/rbkt/Queries/zorba/uris/serialize-wrong-opaque-noscheme.xq 2013-05-03 23:21:27 +0000
2284@@ -0,0 +1,8 @@
2285+import module namespace uri = "http://www.zorba-xquery.com/modules/uri";
2286+
2287+let $wrong-opaque-noscheme-json :=
2288+ {
2289+ "opaque-part" : "myfile.xml"
2290+ }
2291+
2292+return uri:serialize($wrong-opaque-noscheme-json)
2293
2294=== added file 'test/rbkt/Queries/zorba/uris/serialize-wrong-opaque.spec'
2295--- test/rbkt/Queries/zorba/uris/serialize-wrong-opaque.spec 1970-01-01 00:00:00 +0000
2296+++ test/rbkt/Queries/zorba/uris/serialize-wrong-opaque.spec 2013-05-03 23:21:27 +0000
2297@@ -0,0 +1,1 @@
2298+Error: http://www.zorba-xquery.com/errors:ZURI0001
2299
2300=== added file 'test/rbkt/Queries/zorba/uris/serialize-wrong-opaque.xq'
2301--- test/rbkt/Queries/zorba/uris/serialize-wrong-opaque.xq 1970-01-01 00:00:00 +0000
2302+++ test/rbkt/Queries/zorba/uris/serialize-wrong-opaque.xq 2013-05-03 23:21:27 +0000
2303@@ -0,0 +1,10 @@
2304+import module namespace uri = "http://www.zorba-xquery.com/modules/uri";
2305+
2306+let $wrong-opaque-json :=
2307+ {
2308+ "scheme" : "http",
2309+ "opaque-part" : "myfile.xml",
2310+ "path" : "d:/a/b/c"
2311+ }
2312+
2313+return uri:serialize($wrong-opaque-json)
2314
2315=== added file 'test/rbkt/Queries/zorba/uris/serialize-wrong-path1.spec'
2316--- test/rbkt/Queries/zorba/uris/serialize-wrong-path1.spec 1970-01-01 00:00:00 +0000
2317+++ test/rbkt/Queries/zorba/uris/serialize-wrong-path1.spec 2013-05-03 23:21:27 +0000
2318@@ -0,0 +1,1 @@
2319+Error: http://www.zorba-xquery.com/errors:ZURI0003
2320
2321=== added file 'test/rbkt/Queries/zorba/uris/serialize-wrong-path1.xq'
2322--- test/rbkt/Queries/zorba/uris/serialize-wrong-path1.xq 1970-01-01 00:00:00 +0000
2323+++ test/rbkt/Queries/zorba/uris/serialize-wrong-path1.xq 2013-05-03 23:21:27 +0000
2324@@ -0,0 +1,9 @@
2325+import module namespace uri = "http://www.zorba-xquery.com/modules/uri";
2326+
2327+let $wrong-path-json :=
2328+ {
2329+ "scheme" : "file",
2330+ "path" : "d:/a/b/c"
2331+ }
2332+
2333+return uri:serialize($wrong-path-json)
2334
2335=== added file 'test/rbkt/Queries/zorba/uris/serialize-wrong-path2.spec'
2336--- test/rbkt/Queries/zorba/uris/serialize-wrong-path2.spec 1970-01-01 00:00:00 +0000
2337+++ test/rbkt/Queries/zorba/uris/serialize-wrong-path2.spec 2013-05-03 23:21:27 +0000
2338@@ -0,0 +1,1 @@
2339+Error: http://www.zorba-xquery.com/errors:ZURI0003
2340
2341=== added file 'test/rbkt/Queries/zorba/uris/serialize-wrong-path2.xq'
2342--- test/rbkt/Queries/zorba/uris/serialize-wrong-path2.xq 1970-01-01 00:00:00 +0000
2343+++ test/rbkt/Queries/zorba/uris/serialize-wrong-path2.xq 2013-05-03 23:21:27 +0000
2344@@ -0,0 +1,10 @@
2345+import module namespace uri = "http://www.zorba-xquery.com/modules/uri";
2346+
2347+let $wrong-path-json :=
2348+ {
2349+ "scheme" : "file",
2350+ "host" : "localhost",
2351+ "path" : "d:/a/b/c"
2352+ }
2353+
2354+return uri:serialize($wrong-path-json)
2355
2356=== added file 'test/rbkt/Queries/zorba/uris/uri-source.xml'
2357--- test/rbkt/Queries/zorba/uris/uri-source.xml 1970-01-01 00:00:00 +0000
2358+++ test/rbkt/Queries/zorba/uris/uri-source.xml 2013-05-03 23:21:27 +0000
2359@@ -0,0 +1,46 @@
2360+<?xml version="1.0" encoding="UTF-8"?>
2361+<uri-test>
2362+ <uri-element>http:///</uri-element>
2363+ <uri-element>http://www.zorba-xquery.com/</uri-element>
2364+ <uri-element>http://www.zorba-xquery.com/?abc=true</uri-element>
2365+ <uri-element>http://www.zorba-xquery.com:8080/?abc=true</uri-element>
2366+ <uri-element>http://user@www.zorba-xquery.com:8080/?abc=true</uri-element>
2367+ <uri-element>http://user@www.zorba-xquery.com:8080/path1/path2?abc=true</uri-element>
2368+ <uri-element>http://user@www.zorba-xquery.com:8080/path1/path2?abc=true&amp;bcd=false#fragment</uri-element>
2369+ <uri-element>ftp://ftp.is.co.za/rfc/rfc1808.txt</uri-element>
2370+ <uri-element>http://thomas@[2001:6f8:9000:876:cccc:bbbb::]:123/test</uri-element>
2371+ <uri-element>http://a/b/c/g</uri-element>
2372+ <uri-element>http://a/b/c/g</uri-element>
2373+ <uri-element>http://a/b/c/g/</uri-element>
2374+ <uri-element>http://a/g</uri-element>
2375+ <uri-element>http://a/b/c/?y</uri-element>
2376+ <uri-element>http://a/b/c/g?y</uri-element>
2377+ <uri-element>http://a/b/c/g#s</uri-element>
2378+ <uri-element>http://a/b/c/g?y#s</uri-element>
2379+ <uri-element>http://a/b/c/;x</uri-element>
2380+ <uri-element>http://a/b/c/g;x</uri-element>
2381+ <uri-element>http://a/b/c/g;x?y#s</uri-element>
2382+ <uri-element>http://a/b/c/</uri-element>
2383+ <uri-element>http://a/b/c/</uri-element>
2384+ <uri-element>http://a/b/</uri-element>
2385+ <uri-element>http://a/b/</uri-element>
2386+ <uri-element>http://a/b/g</uri-element>
2387+ <uri-element>http://a/</uri-element>
2388+ <uri-element>http://a/</uri-element>
2389+ <uri-element>http://a/g</uri-element>
2390+ <uri-element>http://a/b/c/g;x=1/y</uri-element>
2391+ <uri-element>http://a/b/c/y</uri-element>
2392+ <uri-element>http://a/b/c/g#s/../x</uri-element>
2393+ <uri-element>http://www.example.com/</uri-element>
2394+ <uri-element>http://www.example.com/dir/file</uri-element>
2395+ <uri-element>http://www.msb.de</uri-element>
2396+ <uri-element>http://www.msb.de/lib/helpers</uri-element>
2397+ <uri-element>file:///d:/a/b/c</uri-element>
2398+ <uri-element>file://localhost/d:/a/b/c</uri-element>
2399+ <uri-element>file://localhost/Ångström/b/c</uri-element>
2400+ <uri-element>file:opaque-uri-part#frag</uri-element>
2401+ <uri-element>file:text-file.txt</uri-element>
2402+ <uri-element>file:bar?</uri-element>
2403+ <uri-element>file:bar?#frag</uri-element>
2404+ <uri-element>http://foo.com/bc?</uri-element>
2405+</uri-test>

Subscribers

People subscribed via source and target branches