Merge lp:~paul-lucas/zorba/feature-json_strip_array into lp:zorba
- feature-json_strip_array
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Paul J. Lucas | ||||
Approved revision: | 11163 | ||||
Merged at revision: | 11139 | ||||
Proposed branch: | lp:~paul-lucas/zorba/feature-json_strip_array | ||||
Merge into: | lp:zorba | ||||
Diff against target: |
2825 lines (+859/-721) 83 files modified
ChangeLog (+4/-0) modules/org/jsoniq/www/functions.xq (+1/-0) modules/org/jsoniq/www/pregenerated/errors.xq (+1/-1) modules/w3c/pregenerated/xqt-errors.xq (+2/-2) src/compiler/parser/query_loc.h (+22/-10) src/diagnostics/diagnostic_en.xml (+77/-86) src/diagnostics/pregenerated/dict_en.cpp (+8/-8) src/diagnostics/pregenerated/dict_zed_keys.h (+8/-8) src/runtime/CMakeLists.txt (+1/-0) src/runtime/json/json_impl.cpp (+2/-4) src/runtime/json/json_loader.cpp (+277/-0) src/runtime/json/json_loader.h (+139/-0) src/runtime/json/jsoniq_functions_impl.cpp (+109/-110) src/runtime/json/pregenerated/jsoniq_functions.cpp (+0/-10) src/runtime/json/pregenerated/jsoniq_functions.h (+4/-1) src/runtime/spec/json/jsoniq_functions.xml (+8/-4) src/store/api/store.h (+0/-15) src/store/naive/CMakeLists.txt (+1/-1) src/store/naive/json_loader.cpp (+0/-307) src/store/naive/json_loader.h (+0/-80) src/store/naive/simple_store.cpp (+0/-17) src/store/naive/simple_store.h (+0/-6) src/util/ascii_util.cpp (+16/-0) src/util/ascii_util.h (+17/-0) src/util/json_parser.cpp (+27/-8) src/util/json_parser.h (+11/-2) src/util/stl_util.h (+12/-0) test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-numbers.xml.res (+3/-5) test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-object-05.xml.res (+1/-1) test/rbkt/ExpQueryResults/zorba/jsoniq/parse_json-09.xml.res (+1/-0) test/rbkt/ExpQueryResults/zorba/jsoniq/parse_json-10.xml.res (+1/-0) test/rbkt/Queries/zorba/json/json-jsonml_array-parse-01.xq (+1/-0) test/rbkt/Queries/zorba/json/json-jsonml_array-parse-02.xq (+1/-0) test/rbkt/Queries/zorba/json/json-jsonml_array-parse-03.xq (+1/-0) test/rbkt/Queries/zorba/json/json-jsonml_array-parse-04.xq (+23/-20) test/rbkt/Queries/zorba/json/json-jsonml_array-parse-05.xq (+2/-0) test/rbkt/Queries/zorba/json/json-jsonml_array-parse-06.xq (+1/-0) test/rbkt/Queries/zorba/json/json-jsonml_array-parse-wikipedia.xq (+1/-0) test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-01.xq (+1/-0) test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-02.xq (+1/-0) test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-03.xq (+1/-0) test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-indent-wikipedia.xq (+1/-0) test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-none-wikipedia.xq (+1/-0) test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-some-wikipedia.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-parse-array-01.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-parse-array-02.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-parse-array-03.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-parse-array-04.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-parse-array-05.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-parse-array-07.xq (+2/-0) test/rbkt/Queries/zorba/json/json-snelson-parse-empty.xq (+3/-1) test/rbkt/Queries/zorba/json/json-snelson-parse-example.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-parse-numbers.xq (+8/-7) test/rbkt/Queries/zorba/json/json-snelson-parse-object-01.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-parse-object-02.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-parse-object-05.xq (+4/-2) test/rbkt/Queries/zorba/json/json-snelson-parse-serialize.xq (+3/-1) test/rbkt/Queries/zorba/json/json-snelson-parse-uncommon-chars.xq (+3/-1) test/rbkt/Queries/zorba/json/json-snelson-parse-utf8-01.xq (+1/-1) test/rbkt/Queries/zorba/json/json-snelson-serialize-array-01.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-serialize-array-02.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-serialize-array-03.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-serialize-array-04.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-serialize-array-05.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-serialize-array-06.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-serialize-array-07.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-serialize-array-08.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-serialize-array-09.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-serialize-array-10.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-serialize-array-11.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-serialize-array-12.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-serialize-comment-node.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-serialize-indent-example.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-serialize-invalid-value-for-attribute.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-serialize-none-example.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-serialize-object-01.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-serialize-object-02.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-serialize-object-03.xq (+3/-2) test/rbkt/Queries/zorba/json/json-snelson-serialize-parse.xq (+2/-0) test/rbkt/Queries/zorba/json/json-snelson-serialize-some-example.xq (+1/-0) test/rbkt/Queries/zorba/json/json-snelson-serialize-type-value-missing.xq (+1/-0) test/rbkt/Queries/zorba/jsoniq/parse_json-09.xq (+5/-0) test/rbkt/Queries/zorba/jsoniq/parse_json-10.xq (+8/-0) |
||||
To merge this branch: | bzr merge lp:~paul-lucas/zorba/feature-json_strip_array | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ghislain Fourny | Approve | ||
Matthias Brantner | Approve | ||
Paul J. Lucas | Approve | ||
Review via email: mp+136826@code.launchpad.net |
Commit message
Added ability to strip the top-level array from a JSON stream.
Description of the change
Added ability to strip the top-level array from a JSON stream.
Paul J. Lucas (paul-lucas) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~paul-lucas/zorba/feature-json_strip_array into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job feature-
finished. The final status was:
6 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job feature-
All tests succeeded!
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 1 Approve.
Matthias Brantner (matthias-brantner) wrote : | # |
- why do we need to pop the entire stack in the destructor of the loader (shouldn't it be always empty)?
- can the huge number of catch clauses in the loader be reduced by only catching a base class without loss of semantics?
- changelog entry is missing (for the new feature and the two fixed bugs)
Matthias Brantner (matthias-brantner) wrote : | # |
I added Ghislain as a reviewer. He needs to make changes to the JSONiq spec and, hence, at least needs to agree on the name of the option.
Paul J. Lucas (paul-lucas) wrote : | # |
> - why do we need to pop the entire stack in the destructor of the loader
> (shouldn't it be always empty)?
It won't be empty if an exception is thrown.
> - can the huge number of catch clauses in the loader be reduced by only
> catching a base class without loss of semantics?
No.
Actually, I was going to open another bug after this was merged (since the bug existed before my changes). The old (and still current) code catches the exception and throws a new exception passing the existing what() message -- that's wrong since the what() message from the json::* exceptions is only in English (which is fine since json::* exceptions should never be seen by the user anyway).
There really need to be diagnostics entries in the XML file for all the error messages.
Also, why are all JSON parser errors squished into the single JNDY0021 error code? Error codes are free. Why not have one error code per parser error (just as I did with my JSON module)?
> - changelog entry is missing (for the new feature and the two fixed bugs)
What bugs?
> I added Ghislain as a reviewer. He needs to make changes to the JSONiq spec and,
> hence, at least needs to agree on the name of the option.
I was going to add him as a reviewer myself when I was "done" (which I'm not quite). I was trying to spare him the useless spam e-mail from launchpad until I was "done." So much for me trying to be nice.
- 11152. By Paul J. Lucas
-
Added ascii::
printable_ char(). - 11153. By Paul J. Lucas
-
Added mention of jsoniq-
strip-top- level-array. - 11154. By Paul J. Lucas
-
Comment addition.
- 11155. By Paul J. Lucas
-
Comment fix.
Matthias Brantner (matthias-brantner) wrote : | # |
>> - why do we need to pop the entire stack in the destructor of the loader
>> (shouldn't it be always empty)?
>
> It won't be empty if an exception is thrown.
Makes sense.
>
>> - can the huge number of catch clauses in the loader be reduced by only
>> catching a base class without loss of semantics?
>
> No.
>
> Actually, I was going to open another bug after this was merged (since the bug existed before my changes). The old (and still current) code catches the exception and throws a new exception passing the existing what() message -- that's wrong since the what() message from the json::* exceptions is only in English (which is fine since json::* exceptions should never be seen by the user anyway).
No, it didn't do that before. In the old json_loader.cpp, only parts of the message
were exposed. For example, the result of e.get_token().
>
> There really need to be diagnostics entries in the XML file for all the error messages.
>
> Also, why are all JSON parser errors squished into the single JNDY0021 error code? Error codes are free. Why not have one error code per parser error (just as I did with my JSON module)?
I don't think they are free from an XQuery point of view. There is no derivation of error codes
in XQuery. You can catch either one or all with one catch clause. Splitting JNDY0021 into
many error codes effectively means that the user has to catch all of them if he wants to
catch a parsing error. Does this make sense?
>
>> - changelog entry is missing (for the new feature and the two fixed bugs)
>
> What bugs?
https:/
the patch I appended to this bug, right?
>
>> I added Ghislain as a reviewer. He needs to make changes to the JSONiq spec and,
>> hence, at least needs to agree on the name of the option.
>
> I was going to add him as a reviewer myself when I was "done" (which I'm not quite). I was trying to spare him the useless spam e-mail from launchpad until I was "done." So much for me trying to be nice.
Sorry, I didn't know that you were not done, yet.
Matthias
- 11156. By Paul J. Lucas
-
Better illegal_escape printing of character.
Paul J. Lucas (paul-lucas) wrote : | # |
> > Actually, I was going to open another bug after this was merged (since the
> bug existed before my changes). The old (and still current) code catches the
> exception and throws a new exception passing the existing what() message --
> that's wrong since the what() message from the json::* exceptions is only in
> English (which is fine since json::* exceptions should never be seen by the
> user anyway).
> No, it didn't do that before.
Yes, it really did (and still does). The <value> for the error was/is simply $1 which means the entire error message came from the json::* exception as-is in English only.
> > What bugs?
> https:/
> you included
> the patch I appended to this bug, right?
I actually discovered the glaringly obvious bug independently and fixed it; however, your patch has the order different. Does it matter?
Paul J. Lucas (paul-lucas) wrote : | # |
BTW: as I mentioned in the other bug, I couldn't reproduce the error (at least it never dumped core) on Mac OS X, so I have no idea whether your/our patch fixed the bug or not.
- 11157. By Paul J. Lucas
-
Fixed English-only messages.
Paul J. Lucas (paul-lucas) wrote : | # |
I stand corrected: the English-only issue was of my own making. It's now fixed.
- 11158. By Paul J. Lucas
-
Updated ChangeLog.
Matthias Brantner (matthias-brantner) wrote : | # |
I have done some testing and discovered a memory leak. Essentially, the memory isn't released as the stream is processed. Specifically, the memory allocated in json_loader.cpp:46 and json_loader.cpp:49 is never released.
- 11159. By Paul J. Lucas
-
Fixed memory leak.
- 11160. By Paul J. Lucas
-
Comment addition.
Paul J. Lucas (paul-lucas) wrote : | # |
OK, I fixed the memory leak.
Matthias Brantner (matthias-brantner) : | # |
Ghislain Fourny (gislenius) wrote : | # |
Hi Paul,
Thanks for doing this. I like the parsing code.
1. Would it be possible to add tests to cover the new jsoniq-
2. I am wondering if the behaviour with both flags set should not be to strip all top-level arrays, not just the first one. For example:
jn:parse-json(
'[ 1, 2, 3 ][ 4, 5, 6 ]',
{
"jsoniq-
"jsoniq-
})
returns 1 2 3[4, 5, 6]
but I would expect 1 2 3 4 5 6.
3. I am under the impression that we use different terminologies in Zorba to describe the same behaviour ('skip', 'strip', I also saw 'chop' in a discussion). It would be nice if we could unify, not sure if still possible though.
I hope it helps!
Ghislain Fourny (gislenius) wrote : | # |
Hi Paul,
The segmentation fault on the query seems to no longer happen, which indicates that your fixed worked.
Ghislain Fourny (gislenius) wrote : | # |
s/fixed/fix/
- 11161. By Paul J. Lucas
-
Merge from trunk.
- 11162. By Paul J. Lucas
-
Comment clarification.
- 11163. By Paul J. Lucas
-
Stripping top-level array now works for multiple items.
Paul J. Lucas (paul-lucas) wrote : | # |
> 1. Would it be possible to add tests to cover the new jsoniq-
> array flag?
Done.
> 2. I am wondering if the behaviour with both flags set should not be to strip
> all top-level arrays, not just the first one. For example:
>
> jn:parse-json(
> '[ 1, 2, 3 ][ 4, 5, 6 ]',
> {
> "jsoniq-
> "jsoniq-
> })
>
> returns 1 2 3[4, 5, 6]
>
> but I would expect 1 2 3 4 5 6.
Done.
> 3. I am under the impression that we use different terminologies in Zorba to
> describe the same behaviour ('skip', 'strip', I also saw 'chop' in a
> discussion). It would be nice if we could unify, not sure if still possible
> though.
To me, "skip" and "strip" mean slightly different things:
* "skip" means to skip over unrelated items in something like a stream or list.
* "strip" means to remove possibly related items, e.g., the beginning '[' and ending ']' of a JSON array.
* I personally haven't seen "chop," but that means to remove something from the end only.
Ghislain Fourny (gislenius) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job feature-
All tests succeeded!
Preview Diff
1 | === modified file 'ChangeLog' |
2 | --- ChangeLog 2012-11-20 01:01:49 +0000 |
3 | +++ ChangeLog 2012-12-03 18:32:22 +0000 |
4 | @@ -7,6 +7,8 @@ |
5 | * (bug #1039284) Implemented jn:json-doc(). |
6 | * (bug #867363) Added http-uri-resolution feature to disable HTTP |
7 | when resolving URIs. |
8 | + * Can now specify jsoniq-strip-top-level-array option to parse-json() to |
9 | + strip the top-level array from JSON streams. |
10 | |
11 | Optimizations: |
12 | * Various optimizations in the implementation of the optimizer rules. |
13 | @@ -17,6 +19,8 @@ |
14 | * Fixed bug #868640 (Node lifetime is shorter than expected due to let |
15 | variable inlining) |
16 | * Fixed bug in castable expr when the target type is xs:QName. |
17 | + * Fixed bugs #1081626 (Segmentation fault in a side-effecting FLWOR), |
18 | + #1079488 (streaming segfault) |
19 | * Fixed bug #1062093 (bug in var reference iterators with an associated |
20 | position that is negative) |
21 | * Fixed bug #1061222 (bad message for errors in index key type declaration) |
22 | |
23 | === modified file 'modules/org/jsoniq/www/functions.xq' |
24 | --- modules/org/jsoniq/www/functions.xq 2012-10-08 12:09:36 +0000 |
25 | +++ modules/org/jsoniq/www/functions.xq 2012-12-03 18:32:22 +0000 |
26 | @@ -170,6 +170,7 @@ |
27 | : Allowed options are |
28 | : <ul> |
29 | : <li>jsoniq-multiple-top-level-items: allow parsing of sequences of JSON Objects and Arrays (boolean; default: true)</li> |
30 | + : <li>jsoniq-strip-top-level-array: if the top-level JSON item is an array, strip it and return its elements as multiple top-level items (boolean; default: false)</li> |
31 | : </ul> |
32 | : |
33 | : @error jerr:JNDY0021 if the given string is not valid JSON or |
34 | |
35 | === modified file 'modules/org/jsoniq/www/pregenerated/errors.xq' |
36 | --- modules/org/jsoniq/www/pregenerated/errors.xq 2012-10-09 17:37:56 +0000 |
37 | +++ modules/org/jsoniq/www/pregenerated/errors.xq 2012-12-03 18:32:22 +0000 |
38 | @@ -141,7 +141,7 @@ |
39 | declare variable $jerr:JNUP0019 as xs:QName := fn:QName($jerr:NS, "jerr:JNUP0019"); |
40 | |
41 | (:~ |
42 | - :It is a type error if the prefix is not a string or if the |
43 | + :It is a type error if the prefix is not a string or if the |
44 | : serialization parameters are not an element. |
45 | :) |
46 | declare variable $jerr:JNTY0023 as xs:QName := fn:QName($jerr:NS, "jerr:JNTY0023"); |
47 | |
48 | === modified file 'modules/w3c/pregenerated/xqt-errors.xq' |
49 | --- modules/w3c/pregenerated/xqt-errors.xq 2012-09-19 21:16:15 +0000 |
50 | +++ modules/w3c/pregenerated/xqt-errors.xq 2012-12-03 18:32:22 +0000 |
51 | @@ -1264,8 +1264,8 @@ |
52 | |
53 | (:~ |
54 | : |
55 | - : Retrieved resource contains octets that cannot be decoded into Unicode |
56 | - : using the specified encoding, the resulting characters are not |
57 | + : Retrieved resource contains octets that cannot be decoded into Unicode |
58 | + : using the specified encoding, the resulting characters are not |
59 | : permitted XML characters or requested encoding not supported |
60 | : |
61 | : @see http://www.w3.org/2005/xqt-errors |
62 | |
63 | === modified file 'src/compiler/parser/query_loc.h' |
64 | --- src/compiler/parser/query_loc.h 2012-09-19 21:16:15 +0000 |
65 | +++ src/compiler/parser/query_loc.h 2012-12-03 18:32:22 +0000 |
66 | @@ -17,9 +17,9 @@ |
67 | #ifndef ZORBA_QUERY_LOC_H |
68 | #define ZORBA_QUERY_LOC_H |
69 | |
70 | +#include <zorba/internal/ztd.h> |
71 | #include "zorbatypes/zstring.h" |
72 | |
73 | - |
74 | namespace zorba { |
75 | |
76 | namespace serialization |
77 | @@ -27,6 +27,8 @@ |
78 | class Archiver; |
79 | } |
80 | |
81 | +/////////////////////////////////////////////////////////////////////////////// |
82 | + |
83 | /** |
84 | * Class to save the query location of zorba elements that correspond to a code |
85 | * snipped in the query. |
86 | @@ -36,6 +38,7 @@ |
87 | */ |
88 | class QueryLoc |
89 | { |
90 | + typedef zorba::internal::ztd::explicit_bool explicit_bool; |
91 | public: |
92 | static QueryLoc null; |
93 | |
94 | @@ -79,21 +82,30 @@ |
95 | |
96 | bool equals(const QueryLoc& loc) const; |
97 | |
98 | - bool operator==(const QueryLoc& loc) const |
99 | - { |
100 | - return equals(loc); |
101 | - } |
102 | - |
103 | - bool operator<(const QueryLoc& loc) const |
104 | - { |
105 | - return theLineBegin < loc.getLineBegin(); |
106 | + operator explicit_bool::type() const { |
107 | + return explicit_bool::value_of( !equals( null ) ); |
108 | } |
109 | }; |
110 | |
111 | +inline bool operator==( QueryLoc const &q1, QueryLoc const &q2 ) { |
112 | + return q1.equals( q2 ); |
113 | +} |
114 | + |
115 | +inline bool operator!=( QueryLoc const &q1, QueryLoc const &q2 ) { |
116 | + return !(q1 == q2); |
117 | +} |
118 | + |
119 | +inline bool operator<( QueryLoc const &q1, QueryLoc const &q2 ) { |
120 | + return q1.getLineBegin() < q2.getLineBegin() |
121 | + || (q1.getLineBegin() == q2.getLineBegin() |
122 | + && q1.getColumnBegin() < q2.getColumnBegin()); |
123 | +} |
124 | |
125 | std::ostream& operator<< (std::ostream& aOstr, const QueryLoc& aQueryLoc); |
126 | |
127 | +/////////////////////////////////////////////////////////////////////////////// |
128 | + |
129 | } // namespace zorba |
130 | |
131 | -#endif |
132 | +#endif /* ZORBA_QUERY_LOC_H */ |
133 | /* vim:set et sw=2 ts=2: */ |
134 | |
135 | === modified file 'src/diagnostics/diagnostic_en.xml' |
136 | --- src/diagnostics/diagnostic_en.xml 2012-12-01 01:04:39 +0000 |
137 | +++ src/diagnostics/diagnostic_en.xml 2012-12-03 18:32:22 +0000 |
138 | @@ -1248,23 +1248,23 @@ |
139 | An argument to \c fn:deep-equal() contains a function item. |
140 | </comment> |
141 | <value>"$1": argument to fn:deep-equal() contains a function item</value> |
142 | - </diagnostic> |
143 | - |
144 | + </diagnostic> |
145 | + |
146 | <diagnostic code="FOUT1170"> |
147 | <comment> |
148 | Identifier cannot be used to retrive a resource containing text |
149 | </comment> |
150 | <value>"$1": error retrieving resource containing text</value> |
151 | </diagnostic> |
152 | - |
153 | + |
154 | <diagnostic code="FOUT1190"> |
155 | <comment> |
156 | - Retrieved resource contains octets that cannot be decoded into Unicode |
157 | - using the specified encoding, the resulting characters are not |
158 | + Retrieved resource contains octets that cannot be decoded into Unicode |
159 | + using the specified encoding, the resulting characters are not |
160 | permitted XML characters or requested encoding not supported |
161 | </comment> |
162 | <value>"$1": can not decode resource retrieved</value> |
163 | - </diagnostic> |
164 | + </diagnostic> |
165 | |
166 | <!--////////// XQuery Update Facility //////////////////////////////////--> |
167 | |
168 | @@ -1287,7 +1287,7 @@ |
169 | specified. |
170 | </comment> |
171 | <value>$1</value> |
172 | - |
173 | + |
174 | <entry key="CONCAT"> |
175 | <value>comma expression with updating and non-updating branches</value> |
176 | </entry> |
177 | @@ -1476,7 +1476,7 @@ |
178 | in the query are made effective. |
179 | </comment> |
180 | <value>$1${ 2}</value> |
181 | - |
182 | + |
183 | <entry key="AttributeName"> |
184 | <value>"$3": attribute with the same name already exists</value> |
185 | </entry> |
186 | @@ -1945,11 +1945,11 @@ |
187 | <diagnostic code="ZAPI0009" name="XQUERY_NOT_COMPILED_IN_DEBUG_MODE"> |
188 | <value>XQuery not compiled in debug mode</value> |
189 | </diagnostic> |
190 | - |
191 | + |
192 | <diagnostic code="ZAPI0011" name="ELEMENT_NOT_DECLARED"> |
193 | <value>"$1": undefined $2</value> |
194 | </diagnostic> |
195 | - |
196 | + |
197 | <diagnostic code="ZAPI0014" name="INVALID_ARGUMENT"> |
198 | <value>"$1": invalid argument${: 2}</value> |
199 | </diagnostic> |
200 | @@ -1997,7 +1997,7 @@ |
201 | <diagnostic code="ZAPI0029" name="REFERENCE_ALREADY_PRESENT"> |
202 | <value>"$1": reference already present in the store</value> |
203 | </diagnostic> |
204 | - |
205 | + |
206 | <diagnostic code="ZAPI0030" name="NO_CURRENT_REFERENCE"> |
207 | <value>node has no current reference</value> |
208 | </diagnostic> |
209 | @@ -2033,7 +2033,7 @@ |
210 | <diagnostic code="ZAPI0080" name="CANNOT_RETRIEVE_NODE_REFERENCE"> |
211 | <value>can not retrieve node-reference for a node that is not in a collection</value> |
212 | </diagnostic> |
213 | - |
214 | + |
215 | <diagnostic code="ZAPI0090" name="CANNOT_VALIDATE_NON_ROOT"> |
216 | <value>non root element cannot be validated in place</value> |
217 | </diagnostic> |
218 | @@ -2647,18 +2647,18 @@ |
219 | |
220 | <namespace prefix="jerr"> |
221 | |
222 | - <!--////////// JSONiq ///////////////////////////////////////////--> |
223 | + <!--////////// JSONiq //////////////////////////////////////////////////--> |
224 | |
225 | <diagnostic code="JNTY0002" if="defined(ZORBA_WITH_JSON)"> |
226 | <comment>It is a type error if the right-hand-side expression of a pair constructor does not return exactly one item.</comment> |
227 | <value>pair value returns no, or more than one, item</value> |
228 | </diagnostic> |
229 | - |
230 | + |
231 | <diagnostic code="JNDY0003" if="defined(ZORBA_WITH_JSON)"> |
232 | <comment>It is a dynamic error if two pairs in an object constructor or in a simple object union have the same name.</comment> |
233 | <value>"$1": pair with the same name already exists in object</value> |
234 | </diagnostic> |
235 | - |
236 | + |
237 | <diagnostic code="JNTY0004" if="defined(ZORBA_WITH_JSON)"> |
238 | <comment>It is a type error to call fn:data on a sequence containing an array or an object.</comment> |
239 | <value>can not atomize an $1 item: an $1 has probably been passed where an atomic value is expected (e.g., as a key, or to a function expecting an atomic item)</value> |
240 | @@ -2670,19 +2670,19 @@ |
241 | <value>"$1": duplicate pair to insert</value> |
242 | |
243 | </diagnostic> |
244 | - |
245 | + |
246 | <diagnostic code="JNUP0006" if="defined(ZORBA_WITH_JSON)"> |
247 | <comment>It is a dynamic error if upd:applyUpdates causes an object to contain two pairs with the same name.</comment> |
248 | |
249 | <value>"$1": pair to insert already exists in object</value> |
250 | |
251 | </diagnostic> |
252 | - |
253 | + |
254 | <diagnostic code="JNUP0007" if="defined(ZORBA_WITH_JSON)"> |
255 | <comment>It is a type error if, in an updating expression, an array selector cannot be cast to xs:integer or if an object selector cannot be cast to xs:string.</comment> |
256 | - |
257 | + |
258 | <value>"$1": wrong type for object/array selector in update expression</value> |
259 | - |
260 | + |
261 | <entry key="Object"> |
262 | <value>"$2": can not be promoted to type xs:string</value> |
263 | </entry> |
264 | @@ -2696,7 +2696,7 @@ |
265 | </entry> |
266 | |
267 | </diagnostic> |
268 | - |
269 | + |
270 | <diagnostic code="JNUP0008" if="defined(ZORBA_WITH_JSON)"> |
271 | <comment>It is a dynamic error if the target of a deleting or replacing expression is not an array or an object. |
272 | It is a dynamic error if the target of a renaming expression is not an object. |
273 | @@ -2719,22 +2719,22 @@ |
274 | </entry> |
275 | |
276 | </diagnostic> |
277 | - |
278 | + |
279 | <diagnostic code="JNUP0009" if="defined(ZORBA_WITH_JSON)"> |
280 | <comment>It is a dynamic error if a pending update list contains two replacing update primitives on the same object or array, and with the same selector.</comment> |
281 | <value>"$1": duplicate pair to replace</value> |
282 | </diagnostic> |
283 | - |
284 | + |
285 | <diagnostic code="JNUP0010" if="defined(ZORBA_WITH_JSON)"> |
286 | <comment>It is a dynamic error if a pending update list contains two renaming update primitives on the same object and with the same selector.</comment> |
287 | <value>"$1": duplicate pair to rename</value> |
288 | </diagnostic> |
289 | - |
290 | + |
291 | <diagnostic code="JNTY0011" if="defined(ZORBA_WITH_JSON)"> |
292 | <comment>It is a type error if the content sequence in a node constructor or in an XQUF insert or replace update expression contains an object or an array.</comment> |
293 | <value>JSON item cannot appear in content sequence of node constructor or updating expression</value> |
294 | </diagnostic> |
295 | - |
296 | + |
297 | <diagnostic code="JNSE0012" if="defined(ZORBA_WITH_JSON)"> |
298 | <comment>It is a dynamic error to serialize a sequence of less |
299 | or more than one item with the JSON output method if the |
300 | @@ -2770,7 +2770,7 @@ |
301 | <comment>It is a dynamic error if it is attempted to create a replace, delete or rename update primitive with a selector that cannot be resolved against the target array or object.</comment> |
302 | |
303 | <value>$1</value> |
304 | - |
305 | + |
306 | <entry key="Object"> |
307 | <value>"$2": selector cannot be resolved against supplied object</value> |
308 | </entry> |
309 | @@ -2779,32 +2779,30 @@ |
310 | <value>"$2": selector cannot be resolved against supplied array</value> |
311 | </entry> |
312 | </diagnostic> |
313 | - |
314 | + |
315 | <diagnostic code="JNUP0017" if="defined(ZORBA_WITH_JSON)"> |
316 | <comment> It is a dynamic error if the value in a replace expression is not exactly a single item.</comment> |
317 | <value>can not replace with less or more than an item</value> |
318 | </diagnostic> |
319 | - |
320 | + |
321 | <diagnostic code="JNTY0018" if="defined(ZORBA_WITH_JSON)"> |
322 | <comment>It is a dynamic error if there is not exactly one supplied parameter for an object or array selector.</comment> |
323 | - |
324 | + |
325 | <value>object or array selection needs exactly one parameter</value> |
326 | </diagnostic> |
327 | - |
328 | + |
329 | <diagnostic code="JNUP0019" if="defined(ZORBA_WITH_JSON)"> |
330 | <comment>It is a dynamic error if the content expression, in an object insert expression, does not evaluate to a sequence of objects.</comment> |
331 | - |
332 | + |
333 | <value>"$1": invalid type (content of insert expression must evaluate to a sequence of objects)</value> |
334 | </diagnostic> |
335 | - |
336 | + |
337 | <diagnostic code="JNTY0023" if="defined(ZORBA_WITH_JSON)"> |
338 | - <comment>It is a type error if the prefix is not a string or if the |
339 | + <comment>It is a type error if the prefix is not a string or if the |
340 | serialization parameters are not an element.</comment> |
341 | <value>$1: value of "$2" is not a $3</value> |
342 | </diagnostic> |
343 | |
344 | - <!--////////// JSONIQ ///////////////////////////////////////////--> |
345 | - |
346 | <diagnostic code="JNTY0024" if="defined(ZORBA_WITH_JSON)"> |
347 | <comment>objects or arrays don't have a string value</comment> |
348 | <value>$1 items do not have string value</value> |
349 | @@ -2818,7 +2816,32 @@ |
350 | <diagnostic code="JNDY0021" if="defined(ZORBA_WITH_JSON)"> |
351 | <comment>parser error raised by jn:parse-json</comment> |
352 | <value>$1</value> |
353 | + <entry key="IllegalCharacter_2"> |
354 | + <value>'$2': illegal JSON character</value> |
355 | + </entry> |
356 | + <entry key="IllegalCodepoint_2"> |
357 | + <value>"$2": illegal Unicode code-point</value> |
358 | + </entry> |
359 | + <entry key="IllegalEscape_2"> |
360 | + <value>'\\$2': illegal JSON character escape</value> |
361 | + </entry> |
362 | + <entry key="IllegalLiteral"> |
363 | + <value>illegal JSON literal</value> |
364 | + </entry> |
365 | + <entry key="IllegalNumber"> |
366 | + <value>illegal JSON number</value> |
367 | + </entry> |
368 | + <entry key="UnexpectedToken_2"> |
369 | + <value>"$2": unexpected JSON token</value> |
370 | + </entry> |
371 | + <entry key="UnterminatedString"> |
372 | + <value>unterminated JSON string</value> |
373 | + </entry> |
374 | + <entry key="UnexpectedExtraContent"> |
375 | + <value>unexpected extra content at the end of the document (consider using the jsoniq-multiple-top-level-items option)</value> |
376 | + </entry> |
377 | </diagnostic> |
378 | + |
379 | </namespace> |
380 | |
381 | <!--////////// Zorba Warnings ////////////////////////////////////////////--> |
382 | @@ -3011,7 +3034,7 @@ |
383 | <entry key="BadXMLDocument_2o"> |
384 | <value>malformed XML document${ at "2"}</value> |
385 | </entry> |
386 | - |
387 | + |
388 | <entry key="BadXMLNoOpeningTag"> |
389 | <value>closing tag without matching opening tag</value> |
390 | </entry> |
391 | @@ -3828,43 +3851,43 @@ |
392 | <entry key="JSONiq error"> |
393 | <value>JSONIQ error</value> |
394 | </entry> |
395 | - |
396 | + |
397 | <entry key="JSONiq type error"> |
398 | <value>JSONIQ type error</value> |
399 | </entry> |
400 | - |
401 | + |
402 | <entry key="JSONiq static error"> |
403 | <value>JSONIQ static error</value> |
404 | </entry> |
405 | - |
406 | + |
407 | <entry key="JSONiq dynamic error"> |
408 | <value>JSONIQ dynamic error</value> |
409 | </entry> |
410 | - |
411 | + |
412 | <entry key="JSONiq serialization error"> |
413 | <value>JSONIQ serialization error</value> |
414 | </entry> |
415 | - |
416 | + |
417 | <entry key="JSONiq warning"> |
418 | <value>JSONIQ warning</value> |
419 | </entry> |
420 | - |
421 | + |
422 | <entry key="JSONiq type warning"> |
423 | <value>JSONIQ type warning</value> |
424 | </entry> |
425 | - |
426 | + |
427 | <entry key="JSONiq static warning"> |
428 | <value>JSONIQ static warning</value> |
429 | </entry> |
430 | - |
431 | + |
432 | <entry key="JSONiq dynamic warning"> |
433 | <value>JSONIQ dynamic warning</value> |
434 | </entry> |
435 | - |
436 | + |
437 | <entry key="JSONiq serialization warning"> |
438 | <value>JSONIQ serialization warning</value> |
439 | </entry> |
440 | - |
441 | + |
442 | <entry key="dynamic error"> |
443 | <value>dynamic error</value> |
444 | </entry> |
445 | @@ -4012,74 +4035,42 @@ |
446 | <entry key="ParseFragmentOptionCombinationNotAllowed"> |
447 | <value>only one of the <schema-validate/>, <DTD-validate/> or <parse-external-parsed-entity/> options can be specified</value> |
448 | </entry> |
449 | - |
450 | + |
451 | <entry key="ParseFragmentInvalidOptions"> |
452 | <value>invalid options passed to the parse-xml:parse() function, the element must be in the schema target namespace</value> |
453 | </entry> |
454 | - |
455 | + |
456 | <entry key="ParseFragmentDoctypeNotAllowed"> |
457 | <value>a DOCTYPE declaration is not allowed</value> |
458 | </entry> |
459 | - |
460 | + |
461 | <entry key="ParseFragmentDoctypeNotAllowedHere"> |
462 | <value>a DOCTYPE declaration must appear before any element or text node, and at most once</value> |
463 | </entry> |
464 | - |
465 | + |
466 | <entry key="FormatNumberDuplicates"> |
467 | <value>: a sub-picture must not contain more than one of the "$3" sign</value> |
468 | </entry> |
469 | - |
470 | + |
471 | <entry key="FormatNumberGroupingAdjacentToDecimal"> |
472 | <value>: a sub-picture must not contain a grouping-separator-sign adjacent to a decimal-separator-sign</value> |
473 | </entry> |
474 | - |
475 | + |
476 | <entry key="FormatNumberIntegerPart"> |
477 | <value>: the integer part of a sub-picture must not contain a member of the decimal-digit-family that is followed by an optional-digit-sign</value> |
478 | </entry> |
479 | - |
480 | + |
481 | <entry key="FormatNumberFractionalPart"> |
482 | <value>: the fractional part of a sub-picture must not contain an optional-digit-sign that is followed by a member of the decimal-digit-family</value> |
483 | </entry> |
484 | - |
485 | + |
486 | <entry key="FormatNumberPercentPermille"> |
487 | <value>: a sub-picture must not contain more than one percent-sign or per-mille-sign, and it must not contain one of each</value> |
488 | </entry> |
489 | - |
490 | + |
491 | <entry key="FormatNumberAtLeastOneOptionalOrDecimal"> |
492 | <value>: a sub-picture must contain at least one character that is an optional-digit-sign or a member of the decimal-digit-family</value> |
493 | </entry> |
494 | - |
495 | - <entry key="JSON_ILLEGAL_CHARACTER"> |
496 | - <value>'$2': illegal JSON character${ at 3}</value> |
497 | - </entry> |
498 | - |
499 | - <entry key="JSON_ILLEGAL_CODEPOINT"> |
500 | - <value>"$2": illegal Unicode code-point${ at 3}</value> |
501 | - </entry> |
502 | - |
503 | - <entry key="JSON_ILLEGAL_ESCAPE"> |
504 | - <value>'\\$2': illegal JSON character escape${ at 3}</value> |
505 | - </entry> |
506 | - |
507 | - <entry key="JSON_ILLEGAL_LITERAL"> |
508 | - <value>illegal JSON literal${ at 2}</value> |
509 | - </entry> |
510 | - |
511 | - <entry key="JSON_ILLEGAL_NUMBER"> |
512 | - <value>illegal JSON number${ at 2}</value> |
513 | - </entry> |
514 | - |
515 | - <entry key="JSON_UNEXPECTED_TOKEN"> |
516 | - <value>"$2": unexpected JSON token${ at 3}</value> |
517 | - </entry> |
518 | - |
519 | - <entry key="JSON_UNTERMINATED_STRING"> |
520 | - <value>unterminated JSON string${ at 2}</value> |
521 | - </entry> |
522 | - |
523 | - <entry key="JSON_UNEXPECTED_EXTRA_CONTENT"> |
524 | - <value>unexpected extra content at the end of the document (consider using the jsoniq-multiple-top-level-items option)</value> |
525 | - </entry> |
526 | |
527 | <entry key="FUNCTION"> |
528 | <value>function</value> |
529 | |
530 | === modified file 'src/diagnostics/pregenerated/dict_en.cpp' |
531 | --- src/diagnostics/pregenerated/dict_en.cpp 2012-12-01 01:04:39 +0000 |
532 | +++ src/diagnostics/pregenerated/dict_en.cpp 2012-12-03 18:32:22 +0000 |
533 | @@ -611,6 +611,14 @@ |
534 | { "~HexBinaryMustBeEven", "HexBinary value must contain an even number of characters" }, |
535 | { "~IncompleteKeyInIndexBuild", "incomplete key during index build" }, |
536 | { "~IncompleteKeyInIndexRefresh", "incomplete key during index refresh" }, |
537 | + { "~JNDY0021_IllegalCharacter_2", "'$2': illegal JSON character" }, |
538 | + { "~JNDY0021_IllegalCodepoint_2", "\"$2\": illegal Unicode code-point" }, |
539 | + { "~JNDY0021_IllegalEscape_2", "'\\$2': illegal JSON character escape" }, |
540 | + { "~JNDY0021_IllegalLiteral", "illegal JSON literal" }, |
541 | + { "~JNDY0021_IllegalNumber", "illegal JSON number" }, |
542 | + { "~JNDY0021_UnexpectedExtraContent", "unexpected extra content at the end of the document (consider using the jsoniq-multiple-top-level-items option)" }, |
543 | + { "~JNDY0021_UnexpectedToken_2", "\"$2\": unexpected JSON token" }, |
544 | + { "~JNDY0021_UnterminatedString", "unterminated JSON string" }, |
545 | { "~JNUP0007_Array", "\"$2\": can not be promoted to type xs:integer" }, |
546 | { "~JNUP0007_Object", "\"$2\": can not be promoted to type xs:string" }, |
547 | { "~JNUP0007_ObjectArray", "\"$2\": can not be promoted to type xs:anyAtomicType" }, |
548 | @@ -621,14 +629,6 @@ |
549 | { "~JNUP0016_Object", "\"$2\": selector cannot be resolved against supplied object" }, |
550 | { "~JSON parser error", "JSON parser error" }, |
551 | { "~JSON serialization error", "JSON serialization error" }, |
552 | - { "~JSON_ILLEGAL_CHARACTER", "'$2': illegal JSON character${ at 3}" }, |
553 | - { "~JSON_ILLEGAL_CODEPOINT", "\"$2\": illegal Unicode code-point${ at 3}" }, |
554 | - { "~JSON_ILLEGAL_ESCAPE", "'\\$2': illegal JSON character escape${ at 3}" }, |
555 | - { "~JSON_ILLEGAL_LITERAL", "illegal JSON literal${ at 2}" }, |
556 | - { "~JSON_ILLEGAL_NUMBER", "illegal JSON number${ at 2}" }, |
557 | - { "~JSON_UNEXPECTED_EXTRA_CONTENT", "unexpected extra content at the end of the document (consider using the jsoniq-multiple-top-level-items option)" }, |
558 | - { "~JSON_UNEXPECTED_TOKEN", "\"$2\": unexpected JSON token${ at 3}" }, |
559 | - { "~JSON_UNTERMINATED_STRING", "unterminated JSON string${ at 2}" }, |
560 | { "~JSONiq dynamic error", "JSONIQ dynamic error" }, |
561 | { "~JSONiq dynamic warning", "JSONIQ dynamic warning" }, |
562 | { "~JSONiq error", "JSONIQ error" }, |
563 | |
564 | === modified file 'src/diagnostics/pregenerated/dict_zed_keys.h' |
565 | --- src/diagnostics/pregenerated/dict_zed_keys.h 2012-12-01 01:04:39 +0000 |
566 | +++ src/diagnostics/pregenerated/dict_zed_keys.h 2012-12-03 18:32:22 +0000 |
567 | @@ -72,6 +72,14 @@ |
568 | #define ZED_JNUP0008_ObjectArray "~JNUP0008_ObjectArray" |
569 | #define ZED_JNUP0016_Object "~JNUP0016_Object" |
570 | #define ZED_JNUP0016_Array "~JNUP0016_Array" |
571 | +#define ZED_JNDY0021_IllegalCharacter_2 "~JNDY0021_IllegalCharacter_2" |
572 | +#define ZED_JNDY0021_IllegalCodepoint_2 "~JNDY0021_IllegalCodepoint_2" |
573 | +#define ZED_JNDY0021_IllegalEscape_2 "~JNDY0021_IllegalEscape_2" |
574 | +#define ZED_JNDY0021_IllegalLiteral "~JNDY0021_IllegalLiteral" |
575 | +#define ZED_JNDY0021_IllegalNumber "~JNDY0021_IllegalNumber" |
576 | +#define ZED_JNDY0021_UnexpectedToken_2 "~JNDY0021_UnexpectedToken_2" |
577 | +#define ZED_JNDY0021_UnterminatedString "~JNDY0021_UnterminatedString" |
578 | +#define ZED_JNDY0021_UnexpectedExtraContent "~JNDY0021_UnexpectedExtraContent" |
579 | #define ZED_ZWST0005_RETURN_TYPE "~ZWST0005_RETURN_TYPE" |
580 | #define ZED_ZWST0005_PARAM_TYPE "~ZWST0005_PARAM_TYPE" |
581 | #define ZED_ZWST0005_UPDATING "~ZWST0005_UPDATING" |
582 | @@ -318,14 +326,6 @@ |
583 | #define ZED_FormatNumberFractionalPart "~FormatNumberFractionalPart" |
584 | #define ZED_FormatNumberPercentPermille "~FormatNumberPercentPermille" |
585 | #define ZED_FormatNumberAtLeastOneOptionalOrDecimal "~FormatNumberAtLeastOneOptionalOrDecimal" |
586 | -#define ZED_JSON_ILLEGAL_CHARACTER "~JSON_ILLEGAL_CHARACTER" |
587 | -#define ZED_JSON_ILLEGAL_CODEPOINT "~JSON_ILLEGAL_CODEPOINT" |
588 | -#define ZED_JSON_ILLEGAL_ESCAPE "~JSON_ILLEGAL_ESCAPE" |
589 | -#define ZED_JSON_ILLEGAL_LITERAL "~JSON_ILLEGAL_LITERAL" |
590 | -#define ZED_JSON_ILLEGAL_NUMBER "~JSON_ILLEGAL_NUMBER" |
591 | -#define ZED_JSON_UNEXPECTED_TOKEN "~JSON_UNEXPECTED_TOKEN" |
592 | -#define ZED_JSON_UNTERMINATED_STRING "~JSON_UNTERMINATED_STRING" |
593 | -#define ZED_JSON_UNEXPECTED_EXTRA_CONTENT "~JSON_UNEXPECTED_EXTRA_CONTENT" |
594 | #define ZED_FUNCTION "~FUNCTION" |
595 | #define ZED_ANNOTATION "~ANNOTATION" |
596 | |
597 | |
598 | === modified file 'src/runtime/CMakeLists.txt' |
599 | --- src/runtime/CMakeLists.txt 2012-10-16 14:30:02 +0000 |
600 | +++ src/runtime/CMakeLists.txt 2012-12-03 18:32:22 +0000 |
601 | @@ -175,6 +175,7 @@ |
602 | IF (ZORBA_WITH_JSON) |
603 | LIST(APPEND RUNTIME_SRCS |
604 | json/json_constructors.cpp |
605 | + json/json_loader.cpp |
606 | ) |
607 | HEADER_GROUP_SUBFOLDER(RUNTIME_SRCS json) |
608 | ENDIF (ZORBA_WITH_JSON) |
609 | |
610 | === modified file 'src/runtime/json/json_impl.cpp' |
611 | --- src/runtime/json/json_impl.cpp 2012-09-19 21:16:15 +0000 |
612 | +++ src/runtime/json/json_impl.cpp 2012-12-03 18:32:22 +0000 |
613 | @@ -24,8 +24,8 @@ |
614 | #include "store/api/item_factory.h" |
615 | #include "system/globalenv.h" |
616 | |
617 | +#include "util/ascii_util.h" |
618 | #include "util/mem_streambuf.h" |
619 | -#include "util/string_util.h" |
620 | |
621 | #include "jsonml_array.h" |
622 | #include "snelson.h" |
623 | @@ -105,9 +105,7 @@ |
624 | catch ( json::illegal_character const &e ) { |
625 | throw XQUERY_EXCEPTION( |
626 | zerr::ZJPE0001_ILLEGAL_CHARACTER, |
627 | - ERROR_PARAMS(zstring("#x") + |
628 | - BUILD_STRING(std::uppercase << std::hex |
629 | - << (static_cast<unsigned int>(e.get_char()) & 0xFF)) ), |
630 | + ERROR_PARAMS( ascii::printable_char( e.get_char() ) ), |
631 | ERROR_LOC( e.get_loc() ) |
632 | ); |
633 | } |
634 | |
635 | === added file 'src/runtime/json/json_loader.cpp' |
636 | --- src/runtime/json/json_loader.cpp 1970-01-01 00:00:00 +0000 |
637 | +++ src/runtime/json/json_loader.cpp 2012-12-03 18:32:22 +0000 |
638 | @@ -0,0 +1,277 @@ |
639 | +/* |
640 | + * Copyright 2006-2008 The FLWOR Foundation. |
641 | + * |
642 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
643 | + * you may not use this file except in compliance with the License. |
644 | + * You may obtain a copy of the License at |
645 | + * |
646 | + * http://www.apache.org/licenses/LICENSE-2.0 |
647 | + * |
648 | + * Unless required by applicable law or agreed to in writing, software |
649 | + * distributed under the License is distributed on an "AS IS" BASIS, |
650 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
651 | + * See the License for the specific language governing permissions and |
652 | + * limitations under the License. |
653 | + */ |
654 | + |
655 | +#include "stdafx.h" |
656 | +#include <zorba/config.h> |
657 | + |
658 | +#ifdef ZORBA_WITH_JSON |
659 | + |
660 | +// Zorba |
661 | +#include <store/api/item.h> |
662 | +#include <store/api/store.h> |
663 | +#include <zorba/store_consts.h> |
664 | + |
665 | +#include "context/static_context.h" |
666 | +#include "diagnostics/xquery_diagnostics.h" |
667 | +#include "store/api/item_factory.h" |
668 | +#include "system/globalenv.h" |
669 | +#include "zorbatypes/zstring.h" |
670 | + |
671 | +// local |
672 | +#include "json_loader.h" |
673 | + |
674 | +using namespace std; |
675 | + |
676 | +namespace zorba { |
677 | +namespace json { |
678 | + |
679 | +/////////////////////////////////////////////////////////////////////////////// |
680 | + |
681 | +loader::stack_element::stack_element( type t ) : type_( t ) { |
682 | + switch ( type_ ) { |
683 | + case array_type: |
684 | + array_ = new json_array_type; |
685 | + break; |
686 | + case object_type: |
687 | + object_ = new json_object_type; |
688 | + break; |
689 | + default: |
690 | + key_ = nullptr; |
691 | + break; |
692 | + } |
693 | +} |
694 | + |
695 | +/** |
696 | + * Destroys a %stack_element. We have this as an ordinary member function |
697 | + * rather than a destructor so that popping the stack and destroying an element |
698 | + * are distinct operations and can be called independently which comes in |
699 | + * handy. |
700 | + */ |
701 | +void loader::stack_element::destroy() { |
702 | + switch ( type_ ) { |
703 | + case array_type: |
704 | + delete array_; |
705 | + break; |
706 | + case object_type: |
707 | + delete object_; |
708 | + break; |
709 | + case key_type: |
710 | + key_->removeReference(); |
711 | + break; |
712 | + default: |
713 | + break; |
714 | + } |
715 | +} |
716 | + |
717 | +/////////////////////////////////////////////////////////////////////////////// |
718 | + |
719 | +loader::loader( istream &is, bool allow_multiple, bool strip_top_level_array ) : |
720 | + parser_( is, allow_multiple ), |
721 | + strip_top_level_array_( strip_top_level_array ), |
722 | + stripped_top_level_array_( false ) |
723 | +{ |
724 | +} |
725 | + |
726 | +loader::~loader() { |
727 | + clear_stack(); |
728 | +} |
729 | + |
730 | +void loader::add_value( store::Item_t const &value ) { |
731 | + stack_element top( stack_.top() ); |
732 | + switch ( top.type_ ) { |
733 | + case stack_element::array_type: |
734 | + top.array_->push_back( value ); |
735 | + break; |
736 | + case stack_element::object_type: |
737 | + // |
738 | + // value must be a string that's the name of the object's next key/value |
739 | + // pair. |
740 | + // |
741 | + push( stack_element::key_type ).key_ = value.getp(); |
742 | + value->addReference(); |
743 | + break; |
744 | + case stack_element::key_type: { |
745 | + // |
746 | + // Otherwise, the top of the stack must be a string which means that the |
747 | + // second-to-top must be an object awaiting a value associated with this |
748 | + // name. |
749 | + // |
750 | + stack_.pop(); |
751 | + stack_element &top2 = stack_.top(); |
752 | + assert( top2.type_ == stack_element::object_type ); |
753 | + top2.object_->keys_.push_back( top.key_ ); |
754 | + top2.object_->values_.push_back( value ); |
755 | + top.destroy(); |
756 | + break; |
757 | + } |
758 | + default: |
759 | + assert( false ); |
760 | + } |
761 | +} |
762 | + |
763 | +void loader::clear() { |
764 | + parser_.clear(); |
765 | + clear_stack(); |
766 | + stripped_top_level_array_ = false; |
767 | +} |
768 | + |
769 | +void loader::clear_stack() { |
770 | + while ( !stack_.empty() ) { |
771 | + stack_.top().destroy(); |
772 | + stack_.pop(); |
773 | + } |
774 | +} |
775 | + |
776 | +bool loader::next( store::Item_t *result ) { |
777 | + store::Item_t item; |
778 | + zstring s; |
779 | + json::token t; |
780 | + |
781 | + try { |
782 | + while ( parser_.next( &t ) ) { |
783 | + switch( t.get_type() ) { |
784 | + case '[': |
785 | + if ( strip_top_level_array_ && !stripped_top_level_array_ ) |
786 | + stripped_top_level_array_ = true; |
787 | + else |
788 | + push( stack_element::array_type ); |
789 | + continue; |
790 | + case '{': |
791 | + push( stack_element::object_type ); |
792 | + continue; |
793 | + case ']': |
794 | + if ( stack_.empty() && strip_top_level_array_ ) { |
795 | + stripped_top_level_array_ = false; |
796 | + continue; |
797 | + } |
798 | + case '}': { |
799 | + stack_element top( stack_.top() ); |
800 | + stack_.pop(); |
801 | + switch ( top.type_ ) { |
802 | + case stack_element::array_type: |
803 | + GENV_ITEMFACTORY->createJSONArray( item, *top.array_ ); |
804 | + break; |
805 | + case stack_element::object_type: |
806 | + GENV_ITEMFACTORY->createJSONObject( |
807 | + item, top.object_->keys_, top.object_->values_ |
808 | + ); |
809 | + break; |
810 | + default: |
811 | + assert( false ); |
812 | + } // switch |
813 | + top.destroy(); |
814 | + break; |
815 | + } |
816 | + case ':': |
817 | + case ',': |
818 | + continue; |
819 | + case token::number: |
820 | + s = t.get_value(); |
821 | + GENV_ITEMFACTORY->createJSONNumber( item, s ); |
822 | + break; |
823 | + case token::string: |
824 | + s = t.get_value(); |
825 | + GENV_ITEMFACTORY->createString( item, s ); |
826 | + break; |
827 | + case 'F': |
828 | + case 'T': |
829 | + GENV_ITEMFACTORY->createBoolean( item, t.get_type() == 'T' ); |
830 | + break; |
831 | + case token::json_null: |
832 | + GENV_ITEMFACTORY->createJSONNull( item ); |
833 | + break; |
834 | + default: |
835 | + assert( false ); |
836 | + } // switch |
837 | + |
838 | + if ( stack_.empty() ) { |
839 | + *result = item; |
840 | + return true; |
841 | + } |
842 | + add_value( item ); |
843 | + } // while |
844 | + return false; |
845 | + } // try |
846 | + catch ( json::illegal_character const &e ) { |
847 | + throw XQUERY_EXCEPTION( |
848 | + jerr::JNDY0021, |
849 | + ERROR_PARAMS( |
850 | + ZED( JNDY0021_IllegalCharacter_2 ), |
851 | + ascii::printable_char( e.get_char() ) |
852 | + ), |
853 | + ERROR_LOC( e.get_loc() ) |
854 | + ); |
855 | + } |
856 | + catch ( json::illegal_codepoint const &e ) { |
857 | + throw XQUERY_EXCEPTION( |
858 | + jerr::JNDY0021, |
859 | + ERROR_PARAMS( |
860 | + ZED( JNDY0021_IllegalCodepoint_2 ), |
861 | + e.get_codepoint() |
862 | + ), |
863 | + ERROR_LOC( e.get_loc() ) |
864 | + ); |
865 | + } |
866 | + catch ( json::illegal_escape const &e ) { |
867 | + throw XQUERY_EXCEPTION( |
868 | + jerr::JNDY0021, |
869 | + ERROR_PARAMS( |
870 | + ZED( JNDY0021_IllegalEscape_2 ), |
871 | + ascii::printable_char( e.get_escape() ) |
872 | + ), |
873 | + ERROR_LOC( e.get_loc() ) |
874 | + ); |
875 | + } |
876 | + catch ( json::illegal_literal const &e ) { |
877 | + throw XQUERY_EXCEPTION( |
878 | + jerr::JNDY0021, |
879 | + ERROR_PARAMS( ZED( JNDY0021_IllegalLiteral ) ), |
880 | + ERROR_LOC( e.get_loc() ) |
881 | + ); |
882 | + } |
883 | + catch ( json::illegal_number const &e ) { |
884 | + throw XQUERY_EXCEPTION( |
885 | + jerr::JNDY0021, |
886 | + ERROR_PARAMS( ZED( JNDY0021_IllegalNumber ) ), |
887 | + ERROR_LOC( e.get_loc() ) |
888 | + ); |
889 | + } |
890 | + catch ( json::unexpected_token const &e ) { |
891 | + throw XQUERY_EXCEPTION( |
892 | + jerr::JNDY0021, |
893 | + ERROR_PARAMS( |
894 | + ZED( JNDY0021_UnexpectedToken_2 ), |
895 | + e.get_token() |
896 | + ), |
897 | + ERROR_LOC( e.get_loc() ) |
898 | + ); |
899 | + } |
900 | + catch ( json::unterminated_string const &e ) { |
901 | + throw XQUERY_EXCEPTION( |
902 | + jerr::JNDY0021, |
903 | + ERROR_PARAMS( ZED( JNDY0021_UnterminatedString ) ), |
904 | + ERROR_LOC( e.get_loc() ) |
905 | + ); |
906 | + } |
907 | +} |
908 | + |
909 | +/////////////////////////////////////////////////////////////////////////////// |
910 | + |
911 | +} // namespace json |
912 | +} // namespace zorba |
913 | + |
914 | +#endif /* ZORBA_WITH_JSON */ |
915 | +/* vim:set et sw=2 ts=2: */ |
916 | |
917 | === added file 'src/runtime/json/json_loader.h' |
918 | --- src/runtime/json/json_loader.h 1970-01-01 00:00:00 +0000 |
919 | +++ src/runtime/json/json_loader.h 2012-12-03 18:32:22 +0000 |
920 | @@ -0,0 +1,139 @@ |
921 | +/* |
922 | + * Copyright 2006-2011 The FLWOR Foundation. |
923 | + * |
924 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
925 | + * you may not use this file except in compliance with the License. |
926 | + * You may obtain a copy of the License at |
927 | + * |
928 | + * http://www.apache.org/licenses/LICENSE-2.0 |
929 | + * |
930 | + * Unless required by applicable law or agreed to in writing, software |
931 | + * distributed under the License is distributed on an "AS IS" BASIS, |
932 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
933 | + * See the License for the specific language governing permissions and |
934 | + * limitations under the License. |
935 | + */ |
936 | + |
937 | +#ifndef ZORBA_JSON_LOADER_H |
938 | +#define ZORBA_JSON_LOADER_H |
939 | + |
940 | +// standard |
941 | +#include <istream> |
942 | +#include <new> |
943 | +#include <utility> /* for pair */ |
944 | +#include <vector> |
945 | + |
946 | +// Zorba |
947 | +#include "store/api/item.h" |
948 | +#include "util/json_parser.h" |
949 | +#include "zorbatypes/zstring.h" |
950 | + |
951 | +namespace zorba { |
952 | +namespace json { |
953 | + |
954 | +/////////////////////////////////////////////////////////////////////////////// |
955 | + |
956 | +class loader { |
957 | +public: |
958 | + typedef parser::line_type line_type; |
959 | + typedef parser::column_type column_type; |
960 | + |
961 | + /** |
962 | + * Constructs a %loader. |
963 | + * |
964 | + * @param is The istream to read from. |
965 | + * @param allow_multiple If \c true, allow multiple top-level JSON items to |
966 | + * be returned. |
967 | + * @param strip_top_level_array If \c true, strips the top-level array, if |
968 | + * any. |
969 | + */ |
970 | + loader( std::istream &is, bool allow_multiple = false, |
971 | + bool strip_top_level_array = false ); |
972 | + |
973 | + /** |
974 | + * Destroys this %loader. |
975 | + */ |
976 | + ~loader(); |
977 | + |
978 | + /** |
979 | + * Resets this %loader to its initial state. |
980 | + */ |
981 | + void clear(); |
982 | + |
983 | + /** |
984 | + * Gets the next Item, if any. |
985 | + * |
986 | + * @param result A pointer to the Item to receive the Item. |
987 | + * @return Returns \c true only if an Item was gotten. |
988 | + */ |
989 | + bool next( store::Item_t *result ); |
990 | + |
991 | + /** |
992 | + * Sets the file location. |
993 | + * |
994 | + * @param file The source file name. |
995 | + * @param line The source line number. |
996 | + * @param col The source column number. |
997 | + */ |
998 | + void set_loc( char const *file, line_type line, column_type col ) { |
999 | + parser_.set_loc( file, line, col ); |
1000 | + } |
1001 | + |
1002 | +private: |
1003 | + typedef std::vector<store::Item_t> json_array_type; |
1004 | + |
1005 | + struct json_object_type { |
1006 | + std::vector<store::Item_t> keys_; |
1007 | + std::vector<store::Item_t> values_; |
1008 | + }; |
1009 | + |
1010 | + struct stack_element { |
1011 | + enum type { |
1012 | + no_type, |
1013 | + array_type, |
1014 | + object_type, |
1015 | + key_type |
1016 | + }; |
1017 | + type const type_; |
1018 | + union { |
1019 | + json_array_type *array_; |
1020 | + json_object_type *object_; |
1021 | + store::Item *key_; |
1022 | + }; |
1023 | + |
1024 | + stack_element( type = no_type ); |
1025 | + void destroy(); |
1026 | + }; |
1027 | + |
1028 | + typedef std::stack<stack_element> stack_type; |
1029 | + stack_type stack_; |
1030 | + |
1031 | + void add_value( store::Item_t const& ); |
1032 | + void clear_stack(); |
1033 | + |
1034 | + stack_element& push( stack_element::type t ) { |
1035 | + // |
1036 | + // We push in this convoluted manner since we can't use C++11 rvalue |
1037 | + // references. |
1038 | + // |
1039 | + stack_.push( stack_element() ); |
1040 | + return *new( &stack_.top() ) stack_element( t ); |
1041 | + } |
1042 | + |
1043 | + parser parser_; |
1044 | + bool const strip_top_level_array_; |
1045 | + bool stripped_top_level_array_; |
1046 | +}; |
1047 | + |
1048 | +/////////////////////////////////////////////////////////////////////////////// |
1049 | + |
1050 | +} // namespace json |
1051 | +} // namespace zorba |
1052 | + |
1053 | +#endif /* ZORBA_JSON_LOADER_H */ |
1054 | +/* |
1055 | + * Local variables: |
1056 | + * mode: c++ |
1057 | + * End: |
1058 | + */ |
1059 | +/* vim:set et sw=2 ts=2: */ |
1060 | |
1061 | === modified file 'src/runtime/json/jsoniq_functions_impl.cpp' |
1062 | --- src/runtime/json/jsoniq_functions_impl.cpp 2012-11-07 17:48:17 +0000 |
1063 | +++ src/runtime/json/jsoniq_functions_impl.cpp 2012-12-03 18:32:22 +0000 |
1064 | @@ -55,10 +55,13 @@ |
1065 | #include <store/api/store.h> |
1066 | #include <store/api/copymode.h> |
1067 | |
1068 | -#include <util/uri_util.h> |
1069 | +#include "util/uri_util.h" |
1070 | + |
1071 | #include <zorba/store_consts.h> |
1072 | #include <zorbatypes/URI.h> |
1073 | |
1074 | +#include "json_loader.h" |
1075 | + |
1076 | |
1077 | namespace zorba { |
1078 | |
1079 | @@ -744,51 +747,59 @@ |
1080 | { |
1081 | PlanIteratorState::init(aState); |
1082 | theAllowMultiple = true; // default |
1083 | - theInputStream = 0; |
1084 | + theInputStream = nullptr; |
1085 | theGotOne = false; |
1086 | + loader_ = nullptr; |
1087 | } |
1088 | |
1089 | void |
1090 | JSONParseIteratorState::reset(PlanState& aState) |
1091 | { |
1092 | PlanIteratorState::reset(aState); |
1093 | - if (theInput == NULL && theInputStream) |
1094 | - { |
1095 | + if (theInput == NULL) { |
1096 | delete theInputStream; |
1097 | + theInputStream = nullptr; |
1098 | } |
1099 | + theGotOne = false; |
1100 | + delete loader_; |
1101 | + loader_ = nullptr; |
1102 | } |
1103 | |
1104 | JSONParseIteratorState::~JSONParseIteratorState() |
1105 | { |
1106 | - if (theInput == NULL && theInputStream) |
1107 | - { |
1108 | + if (theInput == NULL) |
1109 | delete theInputStream; |
1110 | - } |
1111 | + delete loader_; |
1112 | } |
1113 | |
1114 | -void |
1115 | -JSONParseIterator::processOptions( |
1116 | - const store::Item_t& aOptions, |
1117 | - bool& aAllowMultiple) const |
1118 | +bool JSONParseIterator::processBooleanOption( store::Item_t const &options, |
1119 | + char const *option_name, |
1120 | + bool *option_value ) const |
1121 | { |
1122 | - store::Item_t lOptionName, lOptionValue; |
1123 | - |
1124 | - zstring s("jsoniq-multiple-top-level-items"); |
1125 | - GENV_ITEMFACTORY->createString(lOptionName, s); |
1126 | - lOptionValue = aOptions->getObjectValue(lOptionName); |
1127 | - |
1128 | - if (lOptionValue != NULL) |
1129 | - { |
1130 | - store::SchemaTypeCode lType = lOptionValue->getTypeCode(); |
1131 | - if (!TypeOps::is_subtype(lType, store::XS_BOOLEAN)) |
1132 | - { |
1133 | - const TypeManager* tm = theSctx->get_typemanager(); |
1134 | - xqtref_t lType = tm->create_value_type(lOptionValue, loc); |
1135 | - RAISE_ERROR(jerr::JNTY0020, loc, |
1136 | - ERROR_PARAMS(lType->toSchemaString(), s, "xs:boolean")); |
1137 | + store::Item_t i_option_name; |
1138 | + zstring z_option_name( option_name ); |
1139 | + GENV_ITEMFACTORY->createString( i_option_name, z_option_name ); |
1140 | + store::Item_t i_option_value = options->getObjectValue( i_option_name ); |
1141 | + |
1142 | + if ( i_option_value ) { |
1143 | + store::SchemaTypeCode const option_type = i_option_value->getTypeCode(); |
1144 | + if ( !TypeOps::is_subtype( option_type, store::XS_BOOLEAN ) ) { |
1145 | + TypeManager const *const tm = theSctx->get_typemanager(); |
1146 | + xqtref_t const option_type = tm->create_value_type( i_option_value, loc ); |
1147 | + throw XQUERY_EXCEPTION( |
1148 | + jerr::JNTY0020, |
1149 | + ERROR_PARAMS( |
1150 | + option_type->toSchemaString(), |
1151 | + z_option_name, |
1152 | + "xs:boolean" |
1153 | + ), |
1154 | + ERROR_LOC( loc ) |
1155 | + ); |
1156 | } |
1157 | - aAllowMultiple = lOptionValue->getBooleanValue(); |
1158 | + *option_value = i_option_value->getBooleanValue(); |
1159 | + return true; |
1160 | } |
1161 | + return false; |
1162 | } |
1163 | |
1164 | bool |
1165 | @@ -797,6 +808,7 @@ |
1166 | PlanState& planState) const |
1167 | { |
1168 | store::Item_t lInput; |
1169 | + bool lStripTopLevelArray = false; |
1170 | |
1171 | JSONParseIteratorState* state; |
1172 | DEFAULT_STACK_INIT(JSONParseIteratorState, state, planState); |
1173 | @@ -807,7 +819,12 @@ |
1174 | { |
1175 | store::Item_t lOptions; |
1176 | consumeNext(lOptions, theChildren[1].getp(), planState); |
1177 | - processOptions(lOptions, state->theAllowMultiple); |
1178 | + processBooleanOption( |
1179 | + lOptions, "jsoniq-multiple-top-level-items", &state->theAllowMultiple |
1180 | + ); |
1181 | + processBooleanOption( |
1182 | + lOptions, "jsoniq-strip-top-level-array", &lStripTopLevelArray |
1183 | + ); |
1184 | } |
1185 | |
1186 | if (lInput->isStreamable()) |
1187 | @@ -818,59 +835,36 @@ |
1188 | else |
1189 | { |
1190 | // will be deleted in the state |
1191 | - state->theInputStream = new std::stringstream( |
1192 | - lInput->getStringValue().c_str()); |
1193 | - } |
1194 | - |
1195 | - while (true) |
1196 | - { |
1197 | - try |
1198 | - { |
1199 | - // streamable string or non-literal string |
1200 | - if (state->theInput != NULL || theRelativeLocation == QueryLoc::null) |
1201 | - { |
1202 | - result = GENV_STORE.parseJSON(*state->theInputStream, 0); |
1203 | - } |
1204 | - else |
1205 | - { |
1206 | - // pass the query location of the StringLiteral to the JSON |
1207 | - // parser such that it can give better error locations. |
1208 | - zorba::internal::diagnostic::location lLoc; |
1209 | - lLoc = ERROR_LOC(theRelativeLocation); |
1210 | - result = GENV_STORE.parseJSON(*state->theInputStream, &lLoc); |
1211 | - } |
1212 | - } |
1213 | - catch (zorba::XQueryException& e) |
1214 | - { |
1215 | - // rethrow with JNDY0021 |
1216 | - XQueryException xq = XQUERY_EXCEPTION( |
1217 | - jerr::JNDY0021, |
1218 | - ERROR_PARAMS(e.what()), |
1219 | - ERROR_LOC(loc)); |
1220 | - |
1221 | - // use location of e in case of literal string |
1222 | - if (!(theRelativeLocation == QueryLoc::null)) set_source(xq, e); |
1223 | - throw xq; |
1224 | - } |
1225 | - |
1226 | - if (result != NULL) |
1227 | - { |
1228 | - if (!state->theAllowMultiple && state->theGotOne) |
1229 | - { |
1230 | - RAISE_ERROR(jerr::JNDY0021, loc, |
1231 | - ERROR_PARAMS(ZED(JSON_UNEXPECTED_EXTRA_CONTENT))); |
1232 | - } |
1233 | - state->theGotOne = true; |
1234 | - STACK_PUSH(true, state); |
1235 | - continue; |
1236 | - } |
1237 | - else |
1238 | - { |
1239 | - break; |
1240 | - } |
1241 | + state->theInputStream = |
1242 | + new std::stringstream( lInput->getStringValue().c_str() ); |
1243 | + } |
1244 | + |
1245 | + state->loader_ = new json::loader( |
1246 | + *state->theInputStream, true, lStripTopLevelArray |
1247 | + ); |
1248 | + |
1249 | + if ( state->theInput == NULL && theRelativeLocation ) { |
1250 | + // pass the query location of the StringLiteral to the JSON |
1251 | + // parser such that it can give better error locations. |
1252 | + state->loader_->set_loc( |
1253 | + theRelativeLocation.getFilename().c_str(), |
1254 | + theRelativeLocation.getLineBegin(), |
1255 | + theRelativeLocation.getColumnBegin() |
1256 | + ); |
1257 | + } |
1258 | + |
1259 | + while ( state->loader_->next( &result ) ) { |
1260 | + if ( !state->theAllowMultiple && state->theGotOne ) { |
1261 | + throw XQUERY_EXCEPTION( |
1262 | + jerr::JNDY0021, |
1263 | + ERROR_PARAMS( ZED( JNDY0021_UnexpectedExtraContent ) ), |
1264 | + ERROR_LOC( loc ) |
1265 | + ); |
1266 | + } |
1267 | + state->theGotOne = true; |
1268 | + STACK_PUSH( true, state ); |
1269 | } |
1270 | } |
1271 | - |
1272 | STACK_END(state); |
1273 | } |
1274 | |
1275 | @@ -1606,6 +1600,30 @@ |
1276 | /******************************************************************************* |
1277 | |
1278 | ********************************************************************************/ |
1279 | + |
1280 | +void |
1281 | +JSONDocIteratorState::init(PlanState& aState) |
1282 | +{ |
1283 | + PlanIteratorState::init(aState); |
1284 | + theStream = nullptr; |
1285 | + theGotOne = false; |
1286 | + loader_ = nullptr; |
1287 | +} |
1288 | + |
1289 | +void |
1290 | +JSONDocIteratorState::reset(PlanState& aState) |
1291 | +{ |
1292 | + PlanIteratorState::reset(aState); |
1293 | + theGotOne = false; |
1294 | + delete loader_; |
1295 | + loader_ = nullptr; |
1296 | +} |
1297 | + |
1298 | +JSONDocIteratorState::~JSONDocIteratorState() |
1299 | +{ |
1300 | + delete loader_; |
1301 | +} |
1302 | + |
1303 | bool JSONDocIterator::nextImpl(store::Item_t& result, PlanState& planState) const |
1304 | { |
1305 | store::Item_t uriItem; |
1306 | @@ -1646,38 +1664,19 @@ |
1307 | } |
1308 | |
1309 | state->theGotOne = false; |
1310 | + state->loader_ = new json::loader( *state->theStream, true ); |
1311 | |
1312 | - while (true) |
1313 | + while ( state->loader_->next( &result ) ) |
1314 | { |
1315 | - try |
1316 | - { |
1317 | - result = GENV_STORE.parseJSON(*state->theStream, 0); |
1318 | - } |
1319 | - catch (zorba::XQueryException& e) |
1320 | - { |
1321 | - // rethrow with JNDY0021 |
1322 | - XQueryException xq = XQUERY_EXCEPTION( |
1323 | - jerr::JNDY0021, |
1324 | - ERROR_PARAMS(e.what()), |
1325 | - ERROR_LOC(loc)); |
1326 | - |
1327 | - // use location of e in case of literal string |
1328 | - throw xq; |
1329 | - } |
1330 | - if (result != NULL) |
1331 | - { |
1332 | - if (!state->theGotOne) |
1333 | - { |
1334 | - state->theGotOne = true; |
1335 | - STACK_PUSH(true, state); |
1336 | - } else { |
1337 | - RAISE_ERROR( |
1338 | - jerr::JNDY0021, |
1339 | - loc, |
1340 | - ERROR_PARAMS(ZED(JSON_UNEXPECTED_EXTRA_CONTENT))); |
1341 | - } |
1342 | + if (!state->theGotOne) |
1343 | + { |
1344 | + state->theGotOne = true; |
1345 | + STACK_PUSH(true, state); |
1346 | } else { |
1347 | - break; |
1348 | + RAISE_ERROR( |
1349 | + jerr::JNDY0021, |
1350 | + loc, |
1351 | + ERROR_PARAMS(ZED(JNDY0021_UnexpectedExtraContent))); |
1352 | } |
1353 | } |
1354 | } |
1355 | @@ -1686,6 +1685,6 @@ |
1356 | } |
1357 | |
1358 | } /* namespace zorba */ |
1359 | + |
1360 | +#endif /* ZORBA_WITH_JSON */ |
1361 | /* vim:set et sw=2 ts=2: */ |
1362 | - |
1363 | -#endif /* ZORBA_WITH_JSON */ |
1364 | |
1365 | === modified file 'src/runtime/json/pregenerated/jsoniq_functions.cpp' |
1366 | --- src/runtime/json/pregenerated/jsoniq_functions.cpp 2012-10-15 13:39:36 +0000 |
1367 | +++ src/runtime/json/pregenerated/jsoniq_functions.cpp 2012-12-03 18:32:22 +0000 |
1368 | @@ -384,16 +384,6 @@ |
1369 | |
1370 | JSONDocIteratorState::JSONDocIteratorState() {} |
1371 | |
1372 | -JSONDocIteratorState::~JSONDocIteratorState() {} |
1373 | - |
1374 | - |
1375 | -void JSONDocIteratorState::init(PlanState& planState) { |
1376 | - PlanIteratorState::init(planState); |
1377 | -} |
1378 | - |
1379 | -void JSONDocIteratorState::reset(PlanState& planState) { |
1380 | - PlanIteratorState::reset(planState); |
1381 | -} |
1382 | // </JSONDocIterator> |
1383 | |
1384 | |
1385 | |
1386 | === modified file 'src/runtime/json/pregenerated/jsoniq_functions.h' |
1387 | --- src/runtime/json/pregenerated/jsoniq_functions.h 2012-10-15 13:49:05 +0000 |
1388 | +++ src/runtime/json/pregenerated/jsoniq_functions.h 2012-12-03 18:32:22 +0000 |
1389 | @@ -30,6 +30,7 @@ |
1390 | #include "runtime/base/noarybase.h" |
1391 | #include "runtime/base/narybase.h" |
1392 | #include <context/uri_resolver.h> |
1393 | +#include "runtime/json/json_loader.h" |
1394 | |
1395 | |
1396 | namespace zorba { |
1397 | @@ -151,6 +152,7 @@ |
1398 | store::Item_t theInput; // |
1399 | std::istream* theInputStream; // |
1400 | bool theGotOne; // |
1401 | + json::loader* loader_; // |
1402 | |
1403 | JSONParseIteratorState(); |
1404 | |
1405 | @@ -185,7 +187,7 @@ |
1406 | virtual ~JSONParseIterator(); |
1407 | |
1408 | public: |
1409 | - void processOptions(const store::Item_t& aOptions, bool& aAllowMultiple) const; |
1410 | + bool processBooleanOption(const store::Item_t& options, char const* option_name, bool* option_value) const; |
1411 | void accept(PlanIterVisitor& v) const; |
1412 | |
1413 | bool nextImpl(store::Item_t& result, PlanState& aPlanState) const; |
1414 | @@ -468,6 +470,7 @@ |
1415 | std::auto_ptr<internal::Resource> theResource; // |
1416 | std::istream* theStream; // |
1417 | bool theGotOne; // |
1418 | + json::loader* loader_; // |
1419 | |
1420 | JSONDocIteratorState(); |
1421 | |
1422 | |
1423 | === modified file 'src/runtime/spec/json/jsoniq_functions.xml' |
1424 | --- src/runtime/spec/json/jsoniq_functions.xml 2012-10-15 13:49:05 +0000 |
1425 | +++ src/runtime/spec/json/jsoniq_functions.xml 2012-12-03 18:32:22 +0000 |
1426 | @@ -11,6 +11,7 @@ |
1427 | |
1428 | <zorba:header> |
1429 | <zorba:include form="Angle-bracket">context/uri_resolver.h</zorba:include> |
1430 | + <zorba:include form="Quoted">runtime/json/json_loader.h</zorba:include> |
1431 | </zorba:header> |
1432 | |
1433 | <!-- |
1434 | @@ -180,6 +181,7 @@ |
1435 | <zorba:member type="store::Item_t" name="theInput" brief=""/> |
1436 | <zorba:member type="std::istream*" name="theInputStream" brief=""/> |
1437 | <zorba:member type="bool" name="theGotOne"/> |
1438 | + <zorba:member type="json::loader*" name="loader_" brief=""/> |
1439 | </zorba:state> |
1440 | |
1441 | <zorba:constructor> |
1442 | @@ -188,9 +190,10 @@ |
1443 | |
1444 | <zorba:member type="QueryLoc" name="theRelativeLocation" /> |
1445 | |
1446 | - <zorba:method return="void" name="processOptions" const="true"> |
1447 | - <zorba:param type="const store::Item_t&" name="aOptions"/> |
1448 | - <zorba:param type="bool&" name="aAllowMultiple"/> |
1449 | + <zorba:method return="bool" name="processBooleanOption" const="true"> |
1450 | + <zorba:param type="const store::Item_t&" name="options"/> |
1451 | + <zorba:param type="char const*" name="option_name"/> |
1452 | + <zorba:param type="bool*" name="option_value"/> |
1453 | </zorba:method> |
1454 | |
1455 | </zorba:iterator> |
1456 | @@ -403,10 +406,11 @@ |
1457 | |
1458 | </zorba:function> |
1459 | |
1460 | - <zorba:state> |
1461 | + <zorba:state generateInit="false" generateReset="false" generateDestructor="false"> |
1462 | <zorba:member type="std::auto_ptr<internal::Resource>" name="theResource" brief=""/> |
1463 | <zorba:member type="std::istream*" name="theStream" brief=""/> |
1464 | <zorba:member type="bool" name="theGotOne" brief=""/> |
1465 | + <zorba:member type="json::loader*" name="loader_" brief=""/> |
1466 | </zorba:state> |
1467 | |
1468 | </zorba:iterator> |
1469 | |
1470 | === modified file 'src/store/api/store.h' |
1471 | --- src/store/api/store.h 2012-09-19 21:16:15 +0000 |
1472 | +++ src/store/api/store.h 2012-12-03 18:32:22 +0000 |
1473 | @@ -29,14 +29,6 @@ |
1474 | namespace zorba |
1475 | { |
1476 | |
1477 | -namespace internal |
1478 | -{ |
1479 | -namespace diagnostic |
1480 | -{ |
1481 | - class location; |
1482 | -} |
1483 | -} |
1484 | - |
1485 | SYNC_CODE(class Lock;) |
1486 | |
1487 | class TokenizerProvider; |
1488 | @@ -368,13 +360,6 @@ |
1489 | virtual TokenizerProvider const* getTokenizerProvider() const = 0; |
1490 | |
1491 | #endif /* ZORBA_NO_FULL_TEXT */ |
1492 | - |
1493 | -#ifdef ZORBA_WITH_JSON |
1494 | - virtual Item_t parseJSON( |
1495 | - std::istream& stream, |
1496 | - internal::diagnostic::location* relative_error_loc |
1497 | - ) = 0; |
1498 | -#endif |
1499 | }; |
1500 | |
1501 | } // namespace store |
1502 | |
1503 | === modified file 'src/store/naive/CMakeLists.txt' |
1504 | --- src/store/naive/CMakeLists.txt 2012-09-19 21:16:15 +0000 |
1505 | +++ src/store/naive/CMakeLists.txt 2012-12-03 18:32:22 +0000 |
1506 | @@ -60,7 +60,7 @@ |
1507 | IF (ZORBA_WITH_JSON) |
1508 | LIST(APPEND ZORBA_STORE_IMPL_SRCS |
1509 | json_items.cpp |
1510 | - json_loader.cpp |
1511 | ) |
1512 | ENDIF (ZORBA_WITH_JSON) |
1513 | |
1514 | +# vim:set et sw=2 ts=2: |
1515 | |
1516 | === removed file 'src/store/naive/json_loader.cpp' |
1517 | --- src/store/naive/json_loader.cpp 2012-10-08 12:09:36 +0000 |
1518 | +++ src/store/naive/json_loader.cpp 1970-01-01 00:00:00 +0000 |
1519 | @@ -1,307 +0,0 @@ |
1520 | -/* |
1521 | - * Copyright 2006-2011 The FLWOR Foundation. |
1522 | - * |
1523 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
1524 | - * you may not use this file except in compliance with the License. |
1525 | - * You may obtain a copy of the License at |
1526 | - * |
1527 | - * http://www.apache.org/licenses/LICENSE-2.0 |
1528 | - * |
1529 | - * Unless required by applicable law or agreed to in writing, software |
1530 | - * distributed under the License is distributed on an "AS IS" BASIS, |
1531 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
1532 | - * See the License for the specific language governing permissions and |
1533 | - * limitations under the License. |
1534 | - */ |
1535 | -#include "json_loader.h" |
1536 | -#include "util/json_parser.h" |
1537 | -#include "json_items.h" |
1538 | -#include "simple_item_factory.h" |
1539 | -#include "store_defs.h" |
1540 | -#include "simple_store.h" |
1541 | -#include "diagnostics/diagnostic.h" |
1542 | -#include <cassert> |
1543 | -#include <vector> |
1544 | - |
1545 | -namespace zorba |
1546 | -{ |
1547 | - |
1548 | -namespace simplestore |
1549 | -{ |
1550 | - |
1551 | -namespace json |
1552 | -{ |
1553 | - |
1554 | - |
1555 | -/****************************************************************************** |
1556 | - |
1557 | -*******************************************************************************/ |
1558 | -JSONLoader::JSONLoader( |
1559 | - std::istream& s, |
1560 | - internal::diagnostic::location* relative_error_loc |
1561 | - ) |
1562 | - : in(s), |
1563 | - theRelativeLoc(relative_error_loc) |
1564 | -{ |
1565 | -} |
1566 | - |
1567 | - |
1568 | -/****************************************************************************** |
1569 | - |
1570 | -*******************************************************************************/ |
1571 | -JSONLoader::~JSONLoader() |
1572 | -{ |
1573 | -} |
1574 | - |
1575 | -#define RAISE_JSON_ERROR_NO_PARAM(msg) \ |
1576 | - if (theRelativeLoc) \ |
1577 | - { \ |
1578 | - throw XQUERY_EXCEPTION( \ |
1579 | - jerr::JNDY0021, \ |
1580 | - ERROR_PARAMS( \ |
1581 | - ZED(msg), \ |
1582 | - "" \ |
1583 | - ), \ |
1584 | - ERROR_LOC(e.get_loc()) \ |
1585 | - ); \ |
1586 | - } \ |
1587 | - else \ |
1588 | - { \ |
1589 | - throw ZORBA_EXCEPTION( \ |
1590 | - jerr::JNDY0021, \ |
1591 | - ERROR_PARAMS( \ |
1592 | - ZED(msg), \ |
1593 | - BUILD_STRING(e.get_loc().line(), ", ", e.get_loc().column()) \ |
1594 | - ) \ |
1595 | - ); \ |
1596 | - } |
1597 | - |
1598 | -#define RAISE_JSON_ERROR_WITH_PARAM(msg, param) \ |
1599 | - if (theRelativeLoc) \ |
1600 | - { \ |
1601 | - throw XQUERY_EXCEPTION( \ |
1602 | - jerr::JNDY0021, \ |
1603 | - ERROR_PARAMS( \ |
1604 | - ZED(msg), \ |
1605 | - param, \ |
1606 | - "" \ |
1607 | - ), \ |
1608 | - ERROR_LOC(e.get_loc()) \ |
1609 | - ); \ |
1610 | - } \ |
1611 | - else \ |
1612 | - { \ |
1613 | - throw ZORBA_EXCEPTION( \ |
1614 | - jerr::JNDY0021, \ |
1615 | - ERROR_PARAMS( \ |
1616 | - ZED(msg), \ |
1617 | - param, \ |
1618 | - BUILD_STRING(e.get_loc().line(), ", ", e.get_loc().column()) \ |
1619 | - ) \ |
1620 | - ); \ |
1621 | - } |
1622 | - |
1623 | -/****************************************************************************** |
1624 | - |
1625 | -*******************************************************************************/ |
1626 | -store::Item_t |
1627 | -JSONLoader::next( ) |
1628 | -{ |
1629 | - using namespace zorba::json; |
1630 | - using namespace zorba::simplestore; |
1631 | - using namespace zorba::simplestore::json; |
1632 | - |
1633 | - try |
1634 | - { |
1635 | - BasicItemFactory& lFactory = GET_FACTORY(); |
1636 | - |
1637 | - JSONItem_t lRootItem; |
1638 | - |
1639 | - // stack of objects, arrays, and object pairs |
1640 | - std::vector<store::Item_t> lStack; |
1641 | - |
1642 | - parser lParser(in); |
1643 | - if (theRelativeLoc) |
1644 | - { |
1645 | - lParser.set_loc(theRelativeLoc->file(), theRelativeLoc->line(), theRelativeLoc->column()+1); |
1646 | - } |
1647 | - |
1648 | - token lToken; |
1649 | - |
1650 | - while (lParser.next(&lToken)) |
1651 | - { |
1652 | - switch (lToken.get_type()) |
1653 | - { |
1654 | - case token::begin_array: |
1655 | - lStack.push_back(new SimpleJSONArray()); |
1656 | - break; |
1657 | - |
1658 | - case token::begin_object: |
1659 | - lStack.push_back(new SimpleJSONObject()); |
1660 | - break; |
1661 | - |
1662 | - case token::end_array: |
1663 | - case token::end_object: |
1664 | - { |
1665 | - store::Item_t lItem = lStack.back(); |
1666 | - |
1667 | - lStack.pop_back(); |
1668 | - |
1669 | - if (lStack.empty()) |
1670 | - { |
1671 | - lRootItem = lItem.cast<JSONItem>(); |
1672 | - } |
1673 | - else |
1674 | - { |
1675 | - addValue(lStack, lItem); |
1676 | - } |
1677 | - |
1678 | - break; |
1679 | - } |
1680 | - case token::name_separator: |
1681 | - case token::value_separator: |
1682 | - break; |
1683 | - case token::string: |
1684 | - { |
1685 | - store::Item_t lValue; |
1686 | - zstring s = lToken.get_value(); |
1687 | - lFactory.createString(lValue, s); |
1688 | - |
1689 | - addValue(lStack, lValue); |
1690 | - break; |
1691 | - } |
1692 | - case token::number: |
1693 | - { |
1694 | - store::Item_t lValue; |
1695 | - zstring s = lToken.get_value(); |
1696 | - lFactory.createJSONNumber(lValue, s); |
1697 | - // todo check return type |
1698 | - addValue(lStack, lValue); |
1699 | - break; |
1700 | - } |
1701 | - case token::json_false: |
1702 | - { |
1703 | - store::Item_t lValue; |
1704 | - lFactory.createBoolean(lValue, false); |
1705 | - addValue(lStack, lValue); |
1706 | - break; |
1707 | - } |
1708 | - case token::json_true: |
1709 | - { |
1710 | - store::Item_t lValue; |
1711 | - lFactory.createBoolean(lValue, true); |
1712 | - addValue(lStack, lValue); |
1713 | - break; |
1714 | - } |
1715 | - case token::json_null: |
1716 | - { |
1717 | - store::Item_t lValue; |
1718 | - lFactory.createJSONNull(lValue); |
1719 | - addValue(lStack, lValue); |
1720 | - break; |
1721 | - } |
1722 | - default: |
1723 | - assert(false); |
1724 | - } |
1725 | - } |
1726 | - return lRootItem; |
1727 | - } |
1728 | - catch (zorba::json::unterminated_string& e) |
1729 | - { |
1730 | - RAISE_JSON_ERROR_NO_PARAM(JSON_UNTERMINATED_STRING) |
1731 | - } |
1732 | - catch (zorba::json::unexpected_token& e) |
1733 | - { |
1734 | - RAISE_JSON_ERROR_WITH_PARAM(JSON_UNEXPECTED_TOKEN, e.get_token()) |
1735 | - } |
1736 | - catch (zorba::json::illegal_number& e) |
1737 | - { |
1738 | - RAISE_JSON_ERROR_NO_PARAM(JSON_ILLEGAL_NUMBER) |
1739 | - } |
1740 | - catch (zorba::json::illegal_literal& e) |
1741 | - { |
1742 | - RAISE_JSON_ERROR_NO_PARAM(JSON_ILLEGAL_LITERAL) |
1743 | - } |
1744 | - catch (zorba::json::illegal_escape& e) |
1745 | - { |
1746 | - RAISE_JSON_ERROR_WITH_PARAM(JSON_ILLEGAL_ESCAPE, e.get_escape()) |
1747 | - } |
1748 | - catch (zorba::json::illegal_codepoint& e) |
1749 | - { |
1750 | - RAISE_JSON_ERROR_WITH_PARAM(JSON_ILLEGAL_CODEPOINT, e.get_codepoint()) |
1751 | - } |
1752 | - catch (zorba::json::illegal_character& e) |
1753 | - { |
1754 | - RAISE_JSON_ERROR_WITH_PARAM(JSON_ILLEGAL_CHARACTER, e.get_char()) |
1755 | - } |
1756 | - return NULL; |
1757 | -} |
1758 | -#undef RAISE_JSON_ERROR_WITH_PARAM |
1759 | -#undef RAISE_JSON_ERROR_NO_PARAM |
1760 | - |
1761 | -void |
1762 | -JSONLoader::addValue( |
1763 | - std::vector<store::Item_t>& aStack, |
1764 | - const store::Item_t& aValue) |
1765 | -{ |
1766 | - store::Item_t lLast = aStack.back(); |
1767 | - |
1768 | - JSONObject* lObject = dynamic_cast<JSONObject*>(lLast.getp()); |
1769 | - |
1770 | - if (lObject) |
1771 | - { |
1772 | - // if the top of the stack is an object, then |
1773 | - // the value must be a string which is the name |
1774 | - // of the object's next name/value pair |
1775 | - aStack.push_back(aValue); |
1776 | - return; |
1777 | - } |
1778 | - |
1779 | - JSONArray* lArray = dynamic_cast<JSONArray*>(lLast.getp()); |
1780 | - if (lArray) |
1781 | - { |
1782 | - // if the top of the stack is an array, then |
1783 | - // the value must be appended to it |
1784 | - lArray->push_back(aValue); |
1785 | - return; |
1786 | - } |
1787 | - |
1788 | - // Otherwise, the top of the stack must be a string, which means |
1789 | - // that the second-to-top must be an object awaiting a value associated with |
1790 | - // this name. |
1791 | - store::Item_t lString = aStack.back(); |
1792 | - aStack.pop_back(); |
1793 | - |
1794 | - lLast = aStack.back(); |
1795 | - |
1796 | - lObject = dynamic_cast<JSONObject*>(lLast.getp()); |
1797 | - |
1798 | - assert(lObject); |
1799 | - lObject->add(lString, aValue, false); |
1800 | -} |
1801 | - |
1802 | -template<typename T> T* |
1803 | -JSONLoader::cast(const JSONItem_t& j) |
1804 | -{ |
1805 | -#ifndef NDEBUG |
1806 | - T* t = dynamic_cast<T*>(j.getp()); |
1807 | - assert(t); |
1808 | -#else |
1809 | - T* t = static_cast<T*>(j.getp()); |
1810 | -#endif |
1811 | - return t; |
1812 | -} |
1813 | - |
1814 | -} /* namespace json */ |
1815 | - |
1816 | -} /* namespace simplestore */ |
1817 | - |
1818 | -} /* namespace zorba */ |
1819 | - |
1820 | -/* |
1821 | - * Local variables: |
1822 | - * mode: c++ |
1823 | - * End: |
1824 | - */ |
1825 | -/* vim:set et sw=2 ts=2: */ |
1826 | - |
1827 | |
1828 | === removed file 'src/store/naive/json_loader.h' |
1829 | --- src/store/naive/json_loader.h 2012-09-19 21:16:15 +0000 |
1830 | +++ src/store/naive/json_loader.h 1970-01-01 00:00:00 +0000 |
1831 | @@ -1,80 +0,0 @@ |
1832 | -/* |
1833 | - * Copyright 2006-2011 The FLWOR Foundation. |
1834 | - * |
1835 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
1836 | - * you may not use this file except in compliance with the License. |
1837 | - * You may obtain a copy of the License at |
1838 | - * |
1839 | - * http://www.apache.org/licenses/LICENSE-2.0 |
1840 | - * |
1841 | - * Unless required by applicable law or agreed to in writing, software |
1842 | - * distributed under the License is distributed on an "AS IS" BASIS, |
1843 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
1844 | - * See the License for the specific language governing permissions and |
1845 | - * limitations under the License. |
1846 | - */ |
1847 | -#ifndef ZORBA_SIMPLE_STORE_JSON_LOADER_H |
1848 | -#define ZORBA_SIMPLE_STORE_JSON_LOADER_H |
1849 | - |
1850 | -#include "common/common.h" |
1851 | -#include "shared_types.h" |
1852 | -#include "store/api/item.h" |
1853 | - |
1854 | -namespace zorba |
1855 | -{ |
1856 | - |
1857 | -namespace internal |
1858 | -{ |
1859 | -namespace diagnostic |
1860 | -{ |
1861 | - class location; |
1862 | -} |
1863 | -} |
1864 | - |
1865 | - |
1866 | -namespace simplestore |
1867 | -{ |
1868 | - |
1869 | -namespace json |
1870 | -{ |
1871 | - |
1872 | -class JSONLoader |
1873 | -{ |
1874 | -protected: |
1875 | - std::istream & in; |
1876 | - internal::diagnostic::location * theRelativeLoc; |
1877 | - |
1878 | -public: |
1879 | - JSONLoader( |
1880 | - std::istream& s, |
1881 | - internal::diagnostic::location* relative_error_loc); |
1882 | - |
1883 | - ~JSONLoader(); |
1884 | - |
1885 | - store::Item_t |
1886 | - next( ); |
1887 | - |
1888 | -private: |
1889 | - template<typename T> |
1890 | - static T* |
1891 | - cast(const JSONItem_t&); |
1892 | - |
1893 | - void |
1894 | - addValue(std::vector<store::Item_t>&, const store::Item_t&); |
1895 | - |
1896 | -}; /* class JSONLoader */ |
1897 | - |
1898 | - |
1899 | -} /* namespace json */ |
1900 | - |
1901 | -} /* namespace simplestore */ |
1902 | - |
1903 | -} /* namespace zorba */ |
1904 | - |
1905 | -#endif /* ZORBA_SIMPLE_STORE_JSON_LOADER_H */ |
1906 | -/* |
1907 | - * Local variables: |
1908 | - * mode: c++ |
1909 | - * End: |
1910 | - */ |
1911 | -/* vim:set et sw=2 ts=2: */ |
1912 | |
1913 | === modified file 'src/store/naive/simple_store.cpp' |
1914 | --- src/store/naive/simple_store.cpp 2012-10-08 12:09:36 +0000 |
1915 | +++ src/store/naive/simple_store.cpp 2012-12-03 18:32:22 +0000 |
1916 | @@ -35,10 +35,6 @@ |
1917 | #include <zorba/util/uuid.h> |
1918 | #include "zorbautils/string_util.h" |
1919 | |
1920 | -#ifdef ZORBA_WITH_JSON |
1921 | -#include "json_loader.h" |
1922 | -#endif |
1923 | - |
1924 | |
1925 | namespace zorba |
1926 | { |
1927 | @@ -419,18 +415,5 @@ |
1928 | } |
1929 | |
1930 | |
1931 | -#ifdef ZORBA_WITH_JSON |
1932 | -/******************************************************************************* |
1933 | - |
1934 | -********************************************************************************/ |
1935 | -store::Item_t SimpleStore::parseJSON( |
1936 | - std::istream& stream, |
1937 | - internal::diagnostic::location* relative_error_loc) |
1938 | -{ |
1939 | - json::JSONLoader lLoader(stream, relative_error_loc); |
1940 | - return lLoader.next(); |
1941 | -} |
1942 | -#endif /* ZORBA_WITH_JSON */ |
1943 | - |
1944 | } // namespace simplestore |
1945 | } // namespace zorba |
1946 | |
1947 | === modified file 'src/store/naive/simple_store.h' |
1948 | --- src/store/naive/simple_store.h 2012-09-19 21:16:15 +0000 |
1949 | +++ src/store/naive/simple_store.h 2012-12-03 18:32:22 +0000 |
1950 | @@ -113,12 +113,6 @@ |
1951 | bool assignReference(const store::Item* node, const zstring& reference); |
1952 | |
1953 | bool getNodeByReference(store::Item_t& result, const zstring& reference); |
1954 | - |
1955 | -#ifdef ZORBA_WITH_JSON |
1956 | - store::Item_t parseJSON( |
1957 | - std::istream& stream, |
1958 | - internal::diagnostic::location* relative_error_loc); |
1959 | -#endif |
1960 | }; |
1961 | |
1962 | } // namespace store |
1963 | |
1964 | === modified file 'src/util/ascii_util.cpp' |
1965 | --- src/util/ascii_util.cpp 2012-09-19 21:16:15 +0000 |
1966 | +++ src/util/ascii_util.cpp 2012-12-03 18:32:22 +0000 |
1967 | @@ -15,10 +15,15 @@ |
1968 | */ |
1969 | #include "stdafx.h" |
1970 | |
1971 | +// standard |
1972 | #include <cstring> |
1973 | +#include <iomanip> |
1974 | |
1975 | +// local |
1976 | #include "ascii_util.h" |
1977 | |
1978 | +using namespace std; |
1979 | + |
1980 | namespace zorba { |
1981 | namespace ascii { |
1982 | |
1983 | @@ -32,6 +37,17 @@ |
1984 | return true; |
1985 | } |
1986 | |
1987 | +ostream& printable_char( ostream &o, char c ) { |
1988 | + if ( ascii::is_print( c ) ) |
1989 | + o << c; |
1990 | + else { |
1991 | + ios::fmtflags const old_flags = o.flags(); |
1992 | + o << "#x" << uppercase << hex << (static_cast<unsigned>( c ) & 0xFF); |
1993 | + o.flags( old_flags ); |
1994 | + } |
1995 | + return o; |
1996 | +} |
1997 | + |
1998 | size_type remove_chars( char *s, size_type s_len, char const *chars ) { |
1999 | char *end = s + s_len; |
2000 | char *c; |
2001 | |
2002 | === modified file 'src/util/ascii_util.h' |
2003 | --- src/util/ascii_util.h 2012-09-19 21:16:15 +0000 |
2004 | +++ src/util/ascii_util.h 2012-12-03 18:32:22 +0000 |
2005 | @@ -17,11 +17,14 @@ |
2006 | #ifndef ZORBA_STRING_UTIL_ASCII_UTIL_H |
2007 | #define ZORBA_STRING_UTIL_ASCII_UTIL_H |
2008 | |
2009 | +// standard |
2010 | #include <algorithm> |
2011 | #include <cctype> |
2012 | #include <cstddef> |
2013 | #include <cstring> |
2014 | |
2015 | +// local |
2016 | +#include "omanip.h" |
2017 | #include "stl_util.h" |
2018 | |
2019 | namespace zorba { |
2020 | @@ -967,6 +970,20 @@ |
2021 | ////////// Miscellaneous ////////////////////////////////////////////////////// |
2022 | |
2023 | /** |
2024 | + * Prints the given character in a printable way: if \c is_print(c) is \c true, |
2025 | + * prints \a c as-is; otherwise prints \c #x followed by the hexadecimal value |
2026 | + * of the character. |
2027 | + * |
2028 | + * @param o The ostream to print to. |
2029 | + * @param c The \c char to print. |
2030 | + * @return Returns \a o. |
2031 | + */ |
2032 | +std::ostream& printable_char( std::ostream &o, char c ); |
2033 | + |
2034 | +// An ostream manipulator version of the above. |
2035 | +DEF_OMANIP1( printable_char, char ) |
2036 | + |
2037 | +/** |
2038 | * Reverses the characters in a string. |
2039 | * |
2040 | * @tparam InputStringType The input string type. |
2041 | |
2042 | === modified file 'src/util/json_parser.cpp' |
2043 | --- src/util/json_parser.cpp 2012-09-19 21:16:15 +0000 |
2044 | +++ src/util/json_parser.cpp 2012-12-03 18:32:22 +0000 |
2045 | @@ -15,6 +15,7 @@ |
2046 | */ |
2047 | |
2048 | #include "stdafx.h" |
2049 | + |
2050 | #include "diagnostics/assert.h" |
2051 | |
2052 | #include "ascii_util.h" |
2053 | @@ -23,7 +24,6 @@ |
2054 | #include "utf8_util.h" |
2055 | |
2056 | #define DEBUG_JSON_PARSER 0 |
2057 | - |
2058 | #if DEBUG_JSON_PARSER |
2059 | # include "indent.h" |
2060 | #endif /* DEBUG_JSON_PARSER */ |
2061 | @@ -79,7 +79,10 @@ |
2062 | } |
2063 | |
2064 | illegal_character::illegal_character( location const &loc, char c ) : |
2065 | - exception( loc, BUILD_STRING( '\'', c, "': illegal character" ) ), |
2066 | + exception( |
2067 | + loc, |
2068 | + BUILD_STRING( '\'', ascii::printable_char( c ), "': illegal character" ) |
2069 | + ), |
2070 | c_( c ) |
2071 | { |
2072 | } |
2073 | @@ -100,7 +103,12 @@ |
2074 | } |
2075 | |
2076 | illegal_escape::illegal_escape( location const &loc, char c ) : |
2077 | - exception( loc, BUILD_STRING( "\"\\", c, "\": illegal character escape" ) ), |
2078 | + exception( |
2079 | + loc, |
2080 | + BUILD_STRING( |
2081 | + "\"\\", ascii::printable_char( c ), "\": illegal character escape" |
2082 | + ) |
2083 | + ), |
2084 | esc_( c ) |
2085 | { |
2086 | } |
2087 | @@ -148,9 +156,7 @@ |
2088 | |
2089 | /////////////////////////////////////////////////////////////////////////////// |
2090 | |
2091 | -token::token() : |
2092 | - type_( none ) |
2093 | -{ |
2094 | +token::token() : type_( none ) { |
2095 | } |
2096 | |
2097 | ostream& operator<<( ostream &o, token::type tt ) { |
2098 | @@ -556,7 +562,20 @@ |
2099 | |
2100 | /////////////////////////////////////////////////////////////////////////////// |
2101 | |
2102 | -parser::parser( istream &in ) : lexer_( in ) { |
2103 | +parser::parser( std::istream &in, bool allow_multiple ) : |
2104 | + allow_multiple_( allow_multiple ), |
2105 | + lexer_( in ) |
2106 | +{ |
2107 | + init(); |
2108 | +} |
2109 | + |
2110 | +void parser::clear() { |
2111 | + peeked_token_.clear(); |
2112 | + ztd::clear_stack( state_stack_ ); |
2113 | + init(); |
2114 | +} |
2115 | + |
2116 | +void parser::init() { |
2117 | #if DEBUG_JSON_PARSER |
2118 | get_indent( cout ) = 0; |
2119 | #endif /* DEBUG_JSON_PARSER */ |
2120 | @@ -601,7 +620,7 @@ |
2121 | switch ( state_ ) { |
2122 | |
2123 | // <JSON> ::= <Array> | <Object> |
2124 | - case J0: PUSH_STATE( J1 ); |
2125 | + case J0: PUSH_STATE( allow_multiple_ ? J0 : J1 ); |
2126 | switch ( PEEK_TOKEN() ) { |
2127 | case token::begin_array : GOTO_STATE( A0 ); |
2128 | case token::begin_object: GOTO_STATE( O0 ); |
2129 | |
2130 | === modified file 'src/util/json_parser.h' |
2131 | --- src/util/json_parser.h 2012-09-19 21:16:15 +0000 |
2132 | +++ src/util/json_parser.h 2012-12-03 18:32:22 +0000 |
2133 | @@ -501,8 +501,15 @@ |
2134 | * Constructs a %parser on the given istream. |
2135 | * |
2136 | * @param in The istream to read from. |
2137 | - */ |
2138 | - parser( std::istream &in ); |
2139 | + * @param allow_multiple If \c true, allow multiple top-level JSON items. |
2140 | + */ |
2141 | + parser( std::istream &in, bool allow_multiple = false ); |
2142 | + |
2143 | + /** |
2144 | + * Resets this %parser to its almost-initial state. (It does not, however, |
2145 | + * reset the file location.) |
2146 | + */ |
2147 | + void clear(); |
2148 | |
2149 | /** |
2150 | * Gets the next token, if any. |
2151 | @@ -546,6 +553,7 @@ |
2152 | |
2153 | friend std::ostream& operator<<( std::ostream&, state ); |
2154 | |
2155 | + void init(); |
2156 | bool get_token( token* ); |
2157 | bool get_token_debug( int, token* ); |
2158 | bool matches_token( token::type, token* ); |
2159 | @@ -555,6 +563,7 @@ |
2160 | void require_token( token::type, token* ); |
2161 | void require_token_debug( int, token::type, token* ); |
2162 | |
2163 | + bool allow_multiple_; |
2164 | lexer lexer_; |
2165 | token peeked_token_; |
2166 | std::stack<state> state_stack_; |
2167 | |
2168 | === modified file 'src/util/stl_util.h' |
2169 | --- src/util/stl_util.h 2012-09-19 21:16:15 +0000 |
2170 | +++ src/util/stl_util.h 2012-12-03 18:32:22 +0000 |
2171 | @@ -155,6 +155,18 @@ |
2172 | /////////////////////////////////////////////////////////////////////////////// |
2173 | |
2174 | /** |
2175 | + * Clears the given stack. |
2176 | + * |
2177 | + * @tparam T The stack's \c value_type. |
2178 | + * @param s The stack to clear. |
2179 | + */ |
2180 | +template<typename T> inline |
2181 | +void clear_stack( std::stack<T> &s ) { |
2182 | + while ( !s.empty() ) |
2183 | + s.pop(); |
2184 | +} |
2185 | + |
2186 | +/** |
2187 | * A less-verbose way to determine whether the given map or set contains a |
2188 | * particular element. |
2189 | */ |
2190 | |
2191 | === renamed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-numbers-and-decimals.xml.res' => 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-numbers.xml.res' |
2192 | --- test/rbkt/ExpQueryResults/zorba/json/json-snelson-numbers-and-decimals.xml.res 2012-01-23 23:22:52 +0000 |
2193 | +++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-numbers.xml.res 2012-12-03 18:32:22 +0000 |
2194 | @@ -1,7 +1,5 @@ |
2195 | <json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery" type="object"> |
2196 | - <pair name="special-numbers" type="object"> |
2197 | - <pair name="decimal" type="number">2.89</pair> |
2198 | - <pair name="e" type="number">2E+6</pair> |
2199 | - <pair name="negative" type="number">-1.89</pair> |
2200 | - </pair> |
2201 | + <pair name="decimal" type="number">2.89</pair> |
2202 | + <pair name="e" type="number">2E+6</pair> |
2203 | + <pair name="negative" type="number">-1.89</pair> |
2204 | </json> |
2205 | |
2206 | === renamed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-null-handling.xml.res' => 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-object-05.xml.res' |
2207 | --- test/rbkt/ExpQueryResults/zorba/json/json-snelson-null-handling.xml.res 2012-01-23 23:22:52 +0000 |
2208 | +++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-object-05.xml.res 2012-12-03 18:32:22 +0000 |
2209 | @@ -1,3 +1,3 @@ |
2210 | <json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery" type="object"> |
2211 | - <pair name="web-app" type="null"/> |
2212 | + <pair name="a" type="null"/> |
2213 | </json> |
2214 | |
2215 | === renamed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-uncommon-chars.xml.res' => 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-uncommon-chars.xml.res' |
2216 | === renamed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-utf-8.xml.res' => 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-utf8-01.xml.res' |
2217 | === added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/parse_json-09.xml.res' |
2218 | --- test/rbkt/ExpQueryResults/zorba/jsoniq/parse_json-09.xml.res 1970-01-01 00:00:00 +0000 |
2219 | +++ test/rbkt/ExpQueryResults/zorba/jsoniq/parse_json-09.xml.res 2012-12-03 18:32:22 +0000 |
2220 | @@ -0,0 +1,1 @@ |
2221 | +1 2 |
2222 | |
2223 | === added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/parse_json-10.xml.res' |
2224 | --- test/rbkt/ExpQueryResults/zorba/jsoniq/parse_json-10.xml.res 1970-01-01 00:00:00 +0000 |
2225 | +++ test/rbkt/ExpQueryResults/zorba/jsoniq/parse_json-10.xml.res 2012-12-03 18:32:22 +0000 |
2226 | @@ -0,0 +1,1 @@ |
2227 | +1 2 3 4 |
2228 | |
2229 | === modified file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-01.xq' |
2230 | --- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-01.xq 2011-12-23 06:21:58 +0000 |
2231 | +++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-01.xq 2012-12-03 18:32:22 +0000 |
2232 | @@ -6,4 +6,5 @@ |
2233 | <json-format value="JsonML-array"/> |
2234 | </options> |
2235 | return json:parse( $json, $options ) |
2236 | + |
2237 | (: vim:set et sw=2 ts=2: :) |
2238 | |
2239 | === modified file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-02.xq' |
2240 | --- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-02.xq 2011-12-23 06:21:58 +0000 |
2241 | +++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-02.xq 2012-12-03 18:32:22 +0000 |
2242 | @@ -11,4 +11,5 @@ |
2243 | <json-format value="JsonML-array"/> |
2244 | </options> |
2245 | return json:parse( $json, $options ) |
2246 | + |
2247 | (: vim:set et sw=2 ts=2: :) |
2248 | |
2249 | === modified file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-03.xq' |
2250 | --- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-03.xq 2011-12-23 06:21:58 +0000 |
2251 | +++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-03.xq 2012-12-03 18:32:22 +0000 |
2252 | @@ -15,4 +15,5 @@ |
2253 | <json-format value="JsonML-array"/> |
2254 | </options> |
2255 | return json:parse( $json, $options ) |
2256 | + |
2257 | (: vim:set et sw=2 ts=2: :) |
2258 | |
2259 | === modified file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-04.xq' |
2260 | --- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-04.xq 2012-01-23 23:22:52 +0000 |
2261 | +++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-04.xq 2012-12-03 18:32:22 +0000 |
2262 | @@ -1,27 +1,30 @@ |
2263 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; |
2264 | |
2265 | -let $json := '["ul", |
2266 | - ["li", |
2267 | - { "style" : "color:red" }, |
2268 | - "First Item" |
2269 | - ], |
2270 | - ["li", |
2271 | - { |
2272 | - "title" : "Some hover text.", |
2273 | - "style" : "color:green" |
2274 | - }, |
2275 | - "Second Item" |
2276 | - ], |
2277 | - ["li", |
2278 | - ["span", |
2279 | - { "class" : "code-example-third" }, |
2280 | - "Third" |
2281 | - ], |
2282 | - " Item" |
2283 | - ] |
2284 | -]' |
2285 | +let $json := ' |
2286 | + [ "ul", |
2287 | + [ "li", |
2288 | + { "style" : "color:red" }, |
2289 | + "First Item" |
2290 | + ], |
2291 | + [ "li", |
2292 | + { |
2293 | + "title" : "Some hover text.", |
2294 | + "style" : "color:green" |
2295 | + }, |
2296 | + "Second Item" |
2297 | + ], |
2298 | + [ "li", |
2299 | + [ "span", |
2300 | + { "class" : "code-example-third" }, |
2301 | + "Third" |
2302 | + ], |
2303 | + " Item" |
2304 | + ] |
2305 | + ]' |
2306 | let $options := |
2307 | <options xmlns="http://www.zorba-xquery.com/modules/converters/json-options"> |
2308 | <json-format value="JsonML-array"/> |
2309 | </options> |
2310 | return json:parse( $json, $options ) |
2311 | + |
2312 | +(: vim:se et sw=2 ts=2: :) |
2313 | |
2314 | === modified file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-05.xq' |
2315 | --- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-05.xq 2012-01-23 23:22:52 +0000 |
2316 | +++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-05.xq 2012-12-03 18:32:22 +0000 |
2317 | @@ -64,3 +64,5 @@ |
2318 | <json-format value="JsonML-array"/> |
2319 | </options> |
2320 | return json:parse( $json, $options ) |
2321 | + |
2322 | +(: vim:se et sw=2 ts=2: :) |
2323 | |
2324 | === modified file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-06.xq' |
2325 | --- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-06.xq 2012-01-24 01:28:36 +0000 |
2326 | +++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-06.xq 2012-12-03 18:32:22 +0000 |
2327 | @@ -7,4 +7,5 @@ |
2328 | <json-format value="JsonML-array"/> |
2329 | </options> |
2330 | return json:parse( <a/>, $options ) |
2331 | + |
2332 | (: vim:set et sw=2 ts=2: :) |
2333 | |
2334 | === modified file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-wikipedia.xq' |
2335 | --- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-wikipedia.xq 2011-12-23 06:21:58 +0000 |
2336 | +++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-wikipedia.xq 2012-12-03 18:32:22 +0000 |
2337 | @@ -20,4 +20,5 @@ |
2338 | <json-format value="JsonML-array"/> |
2339 | </options> |
2340 | return json:parse( $json, $options ) |
2341 | + |
2342 | (: vim:set et sw=2 ts=2: :) |
2343 | |
2344 | === modified file 'test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-01.xq' |
2345 | --- test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-01.xq 2011-12-23 06:21:58 +0000 |
2346 | +++ test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-01.xq 2012-12-03 18:32:22 +0000 |
2347 | @@ -7,4 +7,5 @@ |
2348 | <json-format value="JsonML-array"/> |
2349 | </options> |
2350 | return json:serialize( $json, $options ) |
2351 | + |
2352 | (: vim:set et sw=2 ts=2: :) |
2353 | |
2354 | === modified file 'test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-02.xq' |
2355 | --- test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-02.xq 2011-12-23 06:21:58 +0000 |
2356 | +++ test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-02.xq 2012-12-03 18:32:22 +0000 |
2357 | @@ -10,4 +10,5 @@ |
2358 | <json-format value="JsonML-array"/> |
2359 | </options> |
2360 | return json:serialize( $json, $options ) |
2361 | + |
2362 | (: vim:set et sw=2 ts=2: :) |
2363 | |
2364 | === modified file 'test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-03.xq' |
2365 | --- test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-03.xq 2011-12-23 06:21:58 +0000 |
2366 | +++ test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-03.xq 2012-12-03 18:32:22 +0000 |
2367 | @@ -7,4 +7,5 @@ |
2368 | <json-format value="JsonML-array"/> |
2369 | </options> |
2370 | return json:serialize( $json, $options ) |
2371 | + |
2372 | (: vim:set et sw=2 ts=2: :) |
2373 | |
2374 | === modified file 'test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-indent-wikipedia.xq' |
2375 | --- test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-indent-wikipedia.xq 2011-12-28 05:41:00 +0000 |
2376 | +++ test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-indent-wikipedia.xq 2012-12-03 18:32:22 +0000 |
2377 | @@ -17,4 +17,5 @@ |
2378 | <whitespace value="indent"/> |
2379 | </options> |
2380 | return json:serialize( $json, $options ) |
2381 | + |
2382 | (: vim:set et sw=2 ts=2: :) |
2383 | |
2384 | === modified file 'test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-none-wikipedia.xq' |
2385 | --- test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-none-wikipedia.xq 2011-12-28 05:41:00 +0000 |
2386 | +++ test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-none-wikipedia.xq 2012-12-03 18:32:22 +0000 |
2387 | @@ -16,4 +16,5 @@ |
2388 | <json-format value="JsonML-array"/> |
2389 | </options> |
2390 | return json:serialize( $json, $options ) |
2391 | + |
2392 | (: vim:set et sw=2 ts=2: :) |
2393 | |
2394 | === modified file 'test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-some-wikipedia.xq' |
2395 | --- test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-some-wikipedia.xq 2011-12-28 05:41:00 +0000 |
2396 | +++ test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-some-wikipedia.xq 2012-12-03 18:32:22 +0000 |
2397 | @@ -17,4 +17,5 @@ |
2398 | <whitespace value="some"/> |
2399 | </options> |
2400 | return json:serialize( $json, $options ) |
2401 | + |
2402 | (: vim:set et sw=2 ts=2: :) |
2403 | |
2404 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-parse-array-01.xq' |
2405 | --- test/rbkt/Queries/zorba/json/json-snelson-parse-array-01.xq 2012-09-19 21:16:15 +0000 |
2406 | +++ test/rbkt/Queries/zorba/json/json-snelson-parse-array-01.xq 2012-12-03 18:32:22 +0000 |
2407 | @@ -2,4 +2,5 @@ |
2408 | |
2409 | let $json := '[ true ]' |
2410 | return json:parse( $json ) |
2411 | + |
2412 | (: vim:set et sw=2 ts=2: :) |
2413 | |
2414 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-parse-array-02.xq' |
2415 | --- test/rbkt/Queries/zorba/json/json-snelson-parse-array-02.xq 2012-09-19 21:16:15 +0000 |
2416 | +++ test/rbkt/Queries/zorba/json/json-snelson-parse-array-02.xq 2012-12-03 18:32:22 +0000 |
2417 | @@ -2,4 +2,5 @@ |
2418 | |
2419 | let $json := '[ false ]' |
2420 | return json:parse( $json ) |
2421 | + |
2422 | (: vim:set et sw=2 ts=2: :) |
2423 | |
2424 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-parse-array-03.xq' |
2425 | --- test/rbkt/Queries/zorba/json/json-snelson-parse-array-03.xq 2012-09-19 21:16:15 +0000 |
2426 | +++ test/rbkt/Queries/zorba/json/json-snelson-parse-array-03.xq 2012-12-03 18:32:22 +0000 |
2427 | @@ -2,4 +2,5 @@ |
2428 | |
2429 | let $json := '[ null ]' |
2430 | return json:parse( $json ) |
2431 | + |
2432 | (: vim:set et sw=2 ts=2: :) |
2433 | |
2434 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-parse-array-04.xq' |
2435 | --- test/rbkt/Queries/zorba/json/json-snelson-parse-array-04.xq 2012-09-19 21:16:15 +0000 |
2436 | +++ test/rbkt/Queries/zorba/json/json-snelson-parse-array-04.xq 2012-12-03 18:32:22 +0000 |
2437 | @@ -2,4 +2,5 @@ |
2438 | |
2439 | let $json := '[ 1 ]' |
2440 | return json:parse( $json ) |
2441 | + |
2442 | (: vim:set et sw=2 ts=2: :) |
2443 | |
2444 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-parse-array-05.xq' |
2445 | --- test/rbkt/Queries/zorba/json/json-snelson-parse-array-05.xq 2012-09-19 21:16:15 +0000 |
2446 | +++ test/rbkt/Queries/zorba/json/json-snelson-parse-array-05.xq 2012-12-03 18:32:22 +0000 |
2447 | @@ -2,4 +2,5 @@ |
2448 | |
2449 | let $json := '[ 1, 2 ]' |
2450 | return json:parse( $json ) |
2451 | + |
2452 | (: vim:set et sw=2 ts=2: :) |
2453 | |
2454 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-parse-array-07.xq' |
2455 | --- test/rbkt/Queries/zorba/json/json-snelson-parse-array-07.xq 2012-01-26 01:47:19 +0000 |
2456 | +++ test/rbkt/Queries/zorba/json/json-snelson-parse-array-07.xq 2012-12-03 18:32:22 +0000 |
2457 | @@ -3,3 +3,5 @@ |
2458 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; |
2459 | |
2460 | json:parse( '[ [ 11, 12 ], [ 21, 22 ] ]' ) |
2461 | + |
2462 | +(: vim:se et sw=2 ts=2: :) |
2463 | |
2464 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-parse-empty.xq' |
2465 | --- test/rbkt/Queries/zorba/json/json-snelson-parse-empty.xq 2012-01-24 01:28:36 +0000 |
2466 | +++ test/rbkt/Queries/zorba/json/json-snelson-parse-empty.xq 2012-12-03 18:32:22 +0000 |
2467 | @@ -2,4 +2,6 @@ |
2468 | |
2469 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; |
2470 | |
2471 | -json:parse(<a/>) |
2472 | +json:parse( <a/> ) |
2473 | + |
2474 | +(: vim:se et sw=2 ts=2: :) |
2475 | |
2476 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-parse-example.xq' |
2477 | --- test/rbkt/Queries/zorba/json/json-snelson-parse-example.xq 2012-09-19 21:16:15 +0000 |
2478 | +++ test/rbkt/Queries/zorba/json/json-snelson-parse-example.xq 2012-12-03 18:32:22 +0000 |
2479 | @@ -17,4 +17,5 @@ |
2480 | } |
2481 | ' |
2482 | return json:parse( $json ) |
2483 | + |
2484 | (: vim:set et sw=2 ts=2: :) |
2485 | |
2486 | === renamed file 'test/rbkt/Queries/zorba/json/json-snelson-numbers-and-decimals.xq' => 'test/rbkt/Queries/zorba/json/json-snelson-parse-numbers.xq' |
2487 | --- test/rbkt/Queries/zorba/json/json-snelson-numbers-and-decimals.xq 2012-01-23 23:22:52 +0000 |
2488 | +++ test/rbkt/Queries/zorba/json/json-snelson-parse-numbers.xq 2012-12-03 18:32:22 +0000 |
2489 | @@ -1,10 +1,11 @@ |
2490 | -(: json:parse testing numbers and decimals :) |
2491 | +(: json:parse testing numbers :) |
2492 | |
2493 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; |
2494 | |
2495 | -json:parse('{ "special-numbers": { |
2496 | - "decimal": 2.89, |
2497 | - "e": 2E+6, |
2498 | - "negative": -1.89 |
2499 | - } |
2500 | - }') |
2501 | +json:parse( '{ |
2502 | + "decimal": 2.89, |
2503 | + "e": 2E+6, |
2504 | + "negative": -1.89 |
2505 | +}' ) |
2506 | + |
2507 | +(: vim:se et sw=2 ts=2: :) |
2508 | |
2509 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-parse-object-01.xq' |
2510 | --- test/rbkt/Queries/zorba/json/json-snelson-parse-object-01.xq 2012-09-19 21:16:15 +0000 |
2511 | +++ test/rbkt/Queries/zorba/json/json-snelson-parse-object-01.xq 2012-12-03 18:32:22 +0000 |
2512 | @@ -2,4 +2,5 @@ |
2513 | |
2514 | let $json := '{ "a" : 1 }' |
2515 | return json:parse( $json ) |
2516 | + |
2517 | (: vim:set et sw=2 ts=2: :) |
2518 | |
2519 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-parse-object-02.xq' |
2520 | --- test/rbkt/Queries/zorba/json/json-snelson-parse-object-02.xq 2012-09-19 21:16:15 +0000 |
2521 | +++ test/rbkt/Queries/zorba/json/json-snelson-parse-object-02.xq 2012-12-03 18:32:22 +0000 |
2522 | @@ -2,4 +2,5 @@ |
2523 | |
2524 | let $json := '{ "a" : 1, "b" : 2 }' |
2525 | return json:parse( $json ) |
2526 | + |
2527 | (: vim:set et sw=2 ts=2: :) |
2528 | |
2529 | === renamed file 'test/rbkt/Queries/zorba/json/json-snelson-null-handling.xq' => 'test/rbkt/Queries/zorba/json/json-snelson-parse-object-05.xq' |
2530 | --- test/rbkt/Queries/zorba/json/json-snelson-null-handling.xq 2012-01-23 23:22:52 +0000 |
2531 | +++ test/rbkt/Queries/zorba/json/json-snelson-parse-object-05.xq 2012-12-03 18:32:22 +0000 |
2532 | @@ -1,5 +1,7 @@ |
2533 | -(: json:parse testing null handling :) |
2534 | +(: json:parse testing null as a key value :) |
2535 | |
2536 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; |
2537 | |
2538 | -json:parse('{ "web-app": null }') |
2539 | +json:parse( '{ "a" : null }' ) |
2540 | + |
2541 | +(: vim:set et sw=2 ts=2: :) |
2542 | |
2543 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-parse-serialize.xq' |
2544 | --- test/rbkt/Queries/zorba/json/json-snelson-parse-serialize.xq 2012-01-23 23:22:52 +0000 |
2545 | +++ test/rbkt/Queries/zorba/json/json-snelson-parse-serialize.xq 2012-12-03 18:32:22 +0000 |
2546 | @@ -5,4 +5,6 @@ |
2547 | <pair name="html" type="string"><b>bold</b></pair> |
2548 | </json>; |
2549 | |
2550 | -json:parse(json:serialize($json-element)) |
2551 | +json:parse( json:serialize( $json-element ) ) |
2552 | + |
2553 | +(: vim:se et sw=2 ts=2: :) |
2554 | |
2555 | === renamed file 'test/rbkt/Queries/zorba/json/json-snelson-uncommon-chars.xq' => 'test/rbkt/Queries/zorba/json/json-snelson-parse-uncommon-chars.xq' |
2556 | --- test/rbkt/Queries/zorba/json/json-snelson-uncommon-chars.xq 2012-01-23 23:22:52 +0000 |
2557 | +++ test/rbkt/Queries/zorba/json/json-snelson-parse-uncommon-chars.xq 2012-12-03 18:32:22 +0000 |
2558 | @@ -2,4 +2,6 @@ |
2559 | |
2560 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; |
2561 | |
2562 | -json:parse('{ "web-app": "!_\"-\\?*.$+" }') |
2563 | +json:parse( '{ "web-app" : "!_\"-\\?*.$+" }' ) |
2564 | + |
2565 | +(: vim:se et sw=2 ts=2: :) |
2566 | |
2567 | === renamed file 'test/rbkt/Queries/zorba/json/json-snelson-utf-8.xq' => 'test/rbkt/Queries/zorba/json/json-snelson-parse-utf8-01.xq' |
2568 | --- test/rbkt/Queries/zorba/json/json-snelson-utf-8.xq 2012-01-23 23:22:52 +0000 |
2569 | +++ test/rbkt/Queries/zorba/json/json-snelson-parse-utf8-01.xq 2012-12-03 18:32:22 +0000 |
2570 | @@ -2,4 +2,4 @@ |
2571 | |
2572 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; |
2573 | |
2574 | -json:parse('{"mdash": "–"}') |
2575 | +json:parse( '{ "mdash": "–" }' ) |
2576 | |
2577 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-01.xq' |
2578 | --- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-01.xq 2012-09-19 21:16:15 +0000 |
2579 | +++ test/rbkt/Queries/zorba/json/json-snelson-serialize-array-01.xq 2012-12-03 18:32:22 +0000 |
2580 | @@ -5,4 +5,5 @@ |
2581 | <item type="boolean">true</item> |
2582 | </json> |
2583 | return json:serialize( $json ) |
2584 | + |
2585 | (: vim:set et sw=2 ts=2: :) |
2586 | |
2587 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-02.xq' |
2588 | --- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-02.xq 2011-12-22 04:01:56 +0000 |
2589 | +++ test/rbkt/Queries/zorba/json/json-snelson-serialize-array-02.xq 2012-12-03 18:32:22 +0000 |
2590 | @@ -5,4 +5,5 @@ |
2591 | <item type="boolean">false</item> |
2592 | </json> |
2593 | return json:serialize( $json ) |
2594 | + |
2595 | (: vim:set et sw=2 ts=2: :) |
2596 | |
2597 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-03.xq' |
2598 | --- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-03.xq 2011-12-22 04:01:56 +0000 |
2599 | +++ test/rbkt/Queries/zorba/json/json-snelson-serialize-array-03.xq 2012-12-03 18:32:22 +0000 |
2600 | @@ -5,4 +5,5 @@ |
2601 | <item type="null"/> |
2602 | </json> |
2603 | return json:serialize( $json ) |
2604 | + |
2605 | (: vim:set et sw=2 ts=2: :) |
2606 | |
2607 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-04.xq' |
2608 | --- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-04.xq 2011-12-22 04:01:56 +0000 |
2609 | +++ test/rbkt/Queries/zorba/json/json-snelson-serialize-array-04.xq 2012-12-03 18:32:22 +0000 |
2610 | @@ -5,4 +5,5 @@ |
2611 | <item type="number">1</item> |
2612 | </json> |
2613 | return json:serialize( $json ) |
2614 | + |
2615 | (: vim:set et sw=2 ts=2: :) |
2616 | |
2617 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-05.xq' |
2618 | --- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-05.xq 2011-12-22 04:01:56 +0000 |
2619 | +++ test/rbkt/Queries/zorba/json/json-snelson-serialize-array-05.xq 2012-12-03 18:32:22 +0000 |
2620 | @@ -6,4 +6,5 @@ |
2621 | <item type="number">2</item> |
2622 | </json> |
2623 | return json:serialize( $json ) |
2624 | + |
2625 | (: vim:set et sw=2 ts=2: :) |
2626 | |
2627 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-06.xq' |
2628 | --- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-06.xq 2011-12-22 04:56:34 +0000 |
2629 | +++ test/rbkt/Queries/zorba/json/json-snelson-serialize-array-06.xq 2012-12-03 18:32:22 +0000 |
2630 | @@ -5,4 +5,5 @@ |
2631 | <foo type="boolean">true</foo> |
2632 | </json> |
2633 | return json:serialize( $json ) |
2634 | + |
2635 | (: vim:set et sw=2 ts=2: :) |
2636 | |
2637 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-07.xq' |
2638 | --- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-07.xq 2011-12-22 04:56:34 +0000 |
2639 | +++ test/rbkt/Queries/zorba/json/json-snelson-serialize-array-07.xq 2012-12-03 18:32:22 +0000 |
2640 | @@ -5,4 +5,5 @@ |
2641 | <item type="boolean">foo</item> |
2642 | </json> |
2643 | return json:serialize( $json ) |
2644 | + |
2645 | (: vim:set et sw=2 ts=2: :) |
2646 | |
2647 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-08.xq' |
2648 | --- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-08.xq 2011-12-22 04:56:34 +0000 |
2649 | +++ test/rbkt/Queries/zorba/json/json-snelson-serialize-array-08.xq 2012-12-03 18:32:22 +0000 |
2650 | @@ -5,4 +5,5 @@ |
2651 | <item>false</item> |
2652 | </json> |
2653 | return json:serialize( $json ) |
2654 | + |
2655 | (: vim:set et sw=2 ts=2: :) |
2656 | |
2657 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-09.xq' |
2658 | --- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-09.xq 2011-12-22 04:56:34 +0000 |
2659 | +++ test/rbkt/Queries/zorba/json/json-snelson-serialize-array-09.xq 2012-12-03 18:32:22 +0000 |
2660 | @@ -5,4 +5,5 @@ |
2661 | <item type="bool">false</item> |
2662 | </json> |
2663 | return json:serialize( $json ) |
2664 | + |
2665 | (: vim:set et sw=2 ts=2: :) |
2666 | |
2667 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-10.xq' |
2668 | --- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-10.xq 2011-12-22 04:56:34 +0000 |
2669 | +++ test/rbkt/Queries/zorba/json/json-snelson-serialize-array-10.xq 2012-12-03 18:32:22 +0000 |
2670 | @@ -5,4 +5,5 @@ |
2671 | hello |
2672 | </json> |
2673 | return json:serialize( $json ) |
2674 | + |
2675 | (: vim:set et sw=2 ts=2: :) |
2676 | |
2677 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-11.xq' |
2678 | --- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-11.xq 2011-12-22 04:56:34 +0000 |
2679 | +++ test/rbkt/Queries/zorba/json/json-snelson-serialize-array-11.xq 2012-12-03 18:32:22 +0000 |
2680 | @@ -5,4 +5,5 @@ |
2681 | <item type="boolean"><foo/></item> |
2682 | </json> |
2683 | return json:serialize( $json ) |
2684 | + |
2685 | (: vim:set et sw=2 ts=2: :) |
2686 | |
2687 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-12.xq' |
2688 | --- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-12.xq 2012-01-26 04:43:56 +0000 |
2689 | +++ test/rbkt/Queries/zorba/json/json-snelson-serialize-array-12.xq 2012-12-03 18:32:22 +0000 |
2690 | @@ -8,4 +8,5 @@ |
2691 | <item type="boolean">true</item> |
2692 | </json> |
2693 | return json:serialize( $json ) |
2694 | + |
2695 | (: vim:set et sw=2 ts=2: :) |
2696 | |
2697 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-comment-node.xq' |
2698 | --- test/rbkt/Queries/zorba/json/json-snelson-serialize-comment-node.xq 2012-01-23 23:22:52 +0000 |
2699 | +++ test/rbkt/Queries/zorba/json/json-snelson-serialize-comment-node.xq 2012-12-03 18:32:22 +0000 |
2700 | @@ -2,4 +2,5 @@ |
2701 | |
2702 | let $json := <!--comment--> |
2703 | return json:serialize( $json ) |
2704 | + |
2705 | (: vim:set et sw=2 ts=2: :) |
2706 | |
2707 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-indent-example.xq' |
2708 | --- test/rbkt/Queries/zorba/json/json-snelson-serialize-indent-example.xq 2011-12-28 05:41:00 +0000 |
2709 | +++ test/rbkt/Queries/zorba/json/json-snelson-serialize-indent-example.xq 2012-12-03 18:32:22 +0000 |
2710 | @@ -21,4 +21,5 @@ |
2711 | <whitespace value="indent"/> |
2712 | </options> |
2713 | return json:serialize( $json, $options ) |
2714 | + |
2715 | (: vim:set et sw=2 ts=2: :) |
2716 | |
2717 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-invalid-value-for-attribute.xq' |
2718 | --- test/rbkt/Queries/zorba/json/json-snelson-serialize-invalid-value-for-attribute.xq 2012-01-23 23:22:52 +0000 |
2719 | +++ test/rbkt/Queries/zorba/json/json-snelson-serialize-invalid-value-for-attribute.xq 2012-12-03 18:32:22 +0000 |
2720 | @@ -5,4 +5,5 @@ |
2721 | <pair name="a" type="nothing">a</pair> |
2722 | </json> |
2723 | return json:serialize( $json ) |
2724 | + |
2725 | (: vim:set et sw=2 ts=2: :) |
2726 | |
2727 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-none-example.xq' |
2728 | --- test/rbkt/Queries/zorba/json/json-snelson-serialize-none-example.xq 2011-12-28 05:41:00 +0000 |
2729 | +++ test/rbkt/Queries/zorba/json/json-snelson-serialize-none-example.xq 2012-12-03 18:32:22 +0000 |
2730 | @@ -16,4 +16,5 @@ |
2731 | </pair> |
2732 | </json> |
2733 | return json:serialize( $json ) |
2734 | + |
2735 | (: vim:set et sw=2 ts=2: :) |
2736 | |
2737 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-object-01.xq' |
2738 | --- test/rbkt/Queries/zorba/json/json-snelson-serialize-object-01.xq 2011-12-22 04:01:56 +0000 |
2739 | +++ test/rbkt/Queries/zorba/json/json-snelson-serialize-object-01.xq 2012-12-03 18:32:22 +0000 |
2740 | @@ -5,4 +5,5 @@ |
2741 | <pair name="a" type="number">1</pair> |
2742 | </json> |
2743 | return json:serialize( $json ) |
2744 | + |
2745 | (: vim:set et sw=2 ts=2: :) |
2746 | |
2747 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-object-02.xq' |
2748 | --- test/rbkt/Queries/zorba/json/json-snelson-serialize-object-02.xq 2011-12-22 04:01:56 +0000 |
2749 | +++ test/rbkt/Queries/zorba/json/json-snelson-serialize-object-02.xq 2012-12-03 18:32:22 +0000 |
2750 | @@ -6,4 +6,5 @@ |
2751 | <pair name="b" type="number">2</pair> |
2752 | </json> |
2753 | return json:serialize( $json ) |
2754 | + |
2755 | (: vim:set et sw=2 ts=2: :) |
2756 | |
2757 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-object-03.xq' |
2758 | --- test/rbkt/Queries/zorba/json/json-snelson-serialize-object-03.xq 2012-01-23 23:22:52 +0000 |
2759 | +++ test/rbkt/Queries/zorba/json/json-snelson-serialize-object-03.xq 2012-12-03 18:32:22 +0000 |
2760 | @@ -4,9 +4,10 @@ |
2761 | |
2762 | let $json := |
2763 | <json type="object"> |
2764 | - <!--comment--> |
2765 | + <!--comment--> |
2766 | <pair name="a" type="number">1</pair> |
2767 | - <!--comment--> |
2768 | + <!--comment--> |
2769 | </json> |
2770 | return json:serialize( $json ) |
2771 | + |
2772 | (: vim:set et sw=2 ts=2: :) |
2773 | |
2774 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-parse.xq' |
2775 | --- test/rbkt/Queries/zorba/json/json-snelson-serialize-parse.xq 2012-01-26 04:43:56 +0000 |
2776 | +++ test/rbkt/Queries/zorba/json/json-snelson-serialize-parse.xq 2012-12-03 18:32:22 +0000 |
2777 | @@ -3,3 +3,5 @@ |
2778 | declare variable $json-value := '{ "key" : "value" }'; |
2779 | |
2780 | json:serialize( json:parse( $json-value ) ) |
2781 | + |
2782 | +(: vim:se et sw=2 ts=2: :) |
2783 | |
2784 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-some-example.xq' |
2785 | --- test/rbkt/Queries/zorba/json/json-snelson-serialize-some-example.xq 2011-12-28 05:41:00 +0000 |
2786 | +++ test/rbkt/Queries/zorba/json/json-snelson-serialize-some-example.xq 2012-12-03 18:32:22 +0000 |
2787 | @@ -21,4 +21,5 @@ |
2788 | <whitespace value="some"/> |
2789 | </options> |
2790 | return json:serialize( $json, $options ) |
2791 | + |
2792 | (: vim:set et sw=2 ts=2: :) |
2793 | |
2794 | === modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-type-value-missing.xq' |
2795 | --- test/rbkt/Queries/zorba/json/json-snelson-serialize-type-value-missing.xq 2012-01-23 23:22:52 +0000 |
2796 | +++ test/rbkt/Queries/zorba/json/json-snelson-serialize-type-value-missing.xq 2012-12-03 18:32:22 +0000 |
2797 | @@ -5,4 +5,5 @@ |
2798 | <pair name="a">a</pair> |
2799 | </json> |
2800 | return json:serialize( $json ) |
2801 | + |
2802 | (: vim:set et sw=2 ts=2: :) |
2803 | |
2804 | === added file 'test/rbkt/Queries/zorba/jsoniq/parse_json-09.xq' |
2805 | --- test/rbkt/Queries/zorba/jsoniq/parse_json-09.xq 1970-01-01 00:00:00 +0000 |
2806 | +++ test/rbkt/Queries/zorba/jsoniq/parse_json-09.xq 2012-12-03 18:32:22 +0000 |
2807 | @@ -0,0 +1,5 @@ |
2808 | +let $json := '[ 1, 2 ]' |
2809 | +let $options := { "jsoniq-strip-top-level-array" : true } |
2810 | +return jn:parse-json( $json, $options ) |
2811 | + |
2812 | +(: vim:set et sw=2 ts=2: :) |
2813 | |
2814 | === added file 'test/rbkt/Queries/zorba/jsoniq/parse_json-10.xq' |
2815 | --- test/rbkt/Queries/zorba/jsoniq/parse_json-10.xq 1970-01-01 00:00:00 +0000 |
2816 | +++ test/rbkt/Queries/zorba/jsoniq/parse_json-10.xq 2012-12-03 18:32:22 +0000 |
2817 | @@ -0,0 +1,8 @@ |
2818 | +let $json := '[ 1, 2 ][ 3, 4 ]' |
2819 | +let $options := { |
2820 | + "jsoniq-multiple-top-level-items" : true, |
2821 | + "jsoniq-strip-top-level-array" : true |
2822 | +} |
2823 | +return jn:parse-json( $json, $options ) |
2824 | + |
2825 | +(: vim:set et sw=2 ts=2: :) |
Validation queue starting for merge proposal. zorbatest. lambda. nu:8080/ remotequeue/ feature- json_strip_ array-2012- 11-29T01- 38-00.341Z/ log.html
Log at: http://