Merge lp:~zorba-coders/zorba/feature-jsonml_object into lp:zorba
- feature-jsonml_object
- Merge into trunk
Proposed by
Paul J. Lucas
Status: | Merged |
---|---|
Approved by: | Paul J. Lucas |
Approved revision: | 11678 |
Merged at revision: | 11675 |
Proposed branch: | lp:~zorba-coders/zorba/feature-jsonml_object |
Merge into: | lp:zorba |
Diff against target: |
1808 lines (+1130/-130) 60 files modified
ChangeLog (+5/-0) include/zorba/pregenerated/diagnostic_list.h (+2/-0) modules/json/CMakeLists.txt (+1/-1) modules/json/json-xml.xq (+87/-31) modules/pregenerated/zorba-errors.xq (+5/-1) src/diagnostics/diagnostic_en.xml (+16/-0) src/diagnostics/pregenerated/diagnostic_list.cpp (+3/-0) src/diagnostics/pregenerated/dict_en.cpp (+5/-0) src/diagnostics/pregenerated/dict_zed_keys.h (+4/-0) src/runtime/CMakeLists.txt (+1/-0) src/runtime/json/common.cpp (+44/-0) src/runtime/json/common.h (+2/-0) src/runtime/json/json_impl.cpp (+10/-5) src/runtime/json/jsonml_array.cpp (+45/-86) src/runtime/json/jsonml_array.h (+0/-4) src/runtime/json/jsonml_common.cpp (+87/-0) src/runtime/json/jsonml_common.h (+33/-0) src/runtime/json/jsonml_object.cpp (+273/-0) src/runtime/json/jsonml_object.h (+36/-0) src/zorbautils/CMakeLists.txt (+1/-0) src/zorbautils/store_util.cpp (+46/-0) src/zorbautils/store_util.h (+67/-0) test/rbkt/ExpQueryResults/zorba/json/json-jmla-x2j-03.xml.res (+6/-1) test/rbkt/ExpQueryResults/zorba/json/json-jmla-x2j-wikipedia.xml.res (+6/-1) test/rbkt/ExpQueryResults/zorba/json/json-jmlo-j2x-01.xml.res (+1/-0) test/rbkt/ExpQueryResults/zorba/json/json-jmlo-j2x-02.xml.res (+4/-0) test/rbkt/ExpQueryResults/zorba/json/json-jmlo-j2x-03.xml.res (+1/-0) test/rbkt/ExpQueryResults/zorba/json/json-jmlo-j2x-04.xml.res (+6/-0) test/rbkt/ExpQueryResults/zorba/json/json-jmlo-j2x-05.xml.res (+14/-0) test/rbkt/ExpQueryResults/zorba/json/json-jmlo-j2x-wikipedia.xml.res (+10/-0) test/rbkt/ExpQueryResults/zorba/json/json-jmlo-x2j-01.xml.res (+4/-0) test/rbkt/ExpQueryResults/zorba/json/json-jmlo-x2j-02.xml.res (+10/-0) test/rbkt/ExpQueryResults/zorba/json/json-jmlo-x2j-03.xml.res (+7/-0) test/rbkt/ExpQueryResults/zorba/json/json-jmlo-x2j-wikipedia.xml.res (+28/-0) test/rbkt/Queries/zorba/json/json-jmla-x2j-01.spec (+1/-0) test/rbkt/Queries/zorba/json/json-jmla-x2j-02.spec (+1/-0) test/rbkt/Queries/zorba/json/json-jmla-x2j-03.spec (+1/-0) test/rbkt/Queries/zorba/json/json-jmla-x2j-wikipedia.spec (+1/-0) test/rbkt/Queries/zorba/json/json-jmlo-j2x-01.xq (+13/-0) test/rbkt/Queries/zorba/json/json-jmlo-j2x-02.xq (+16/-0) test/rbkt/Queries/zorba/json/json-jmlo-j2x-03.xq (+16/-0) test/rbkt/Queries/zorba/json/json-jmlo-j2x-04.spec (+1/-0) test/rbkt/Queries/zorba/json/json-jmlo-j2x-04.xq (+34/-0) test/rbkt/Queries/zorba/json/json-jmlo-j2x-05.spec (+1/-0) test/rbkt/Queries/zorba/json/json-jmlo-j2x-05.xq (+58/-0) test/rbkt/Queries/zorba/json/json-jmlo-j2x-06.spec (+1/-0) test/rbkt/Queries/zorba/json/json-jmlo-j2x-06.xq (+9/-0) test/rbkt/Queries/zorba/json/json-jmlo-j2x-07.spec (+1/-0) test/rbkt/Queries/zorba/json/json-jmlo-j2x-07.xq (+7/-0) test/rbkt/Queries/zorba/json/json-jmlo-j2x-08.spec (+1/-0) test/rbkt/Queries/zorba/json/json-jmlo-j2x-08.xq (+7/-0) test/rbkt/Queries/zorba/json/json-jmlo-j2x-wikipedia.xq (+44/-0) test/rbkt/Queries/zorba/json/json-jmlo-x2j-01.spec (+1/-0) test/rbkt/Queries/zorba/json/json-jmlo-x2j-01.xq (+7/-0) test/rbkt/Queries/zorba/json/json-jmlo-x2j-02.spec (+1/-0) test/rbkt/Queries/zorba/json/json-jmlo-x2j-02.xq (+11/-0) test/rbkt/Queries/zorba/json/json-jmlo-x2j-03.spec (+1/-0) test/rbkt/Queries/zorba/json/json-jmlo-x2j-03.xq (+8/-0) test/rbkt/Queries/zorba/json/json-jmlo-x2j-wikipedia.spec (+1/-0) test/rbkt/Queries/zorba/json/json-jmlo-x2j-wikipedia.xq (+17/-0) |
To merge this branch: | bzr merge lp:~zorba-coders/zorba/feature-jsonml_object |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Matthias Brantner | Approve | ||
Paul J. Lucas | Approve | ||
Review via email: mp+198858@code.launchpad.net |
Commit message
Added support for the JsonML "object form" (even though there is no such thing).
Description of the change
Added support for the JsonML "object form" (even though there is no such thing).
To post a comment you must log in.
Revision history for this message
Paul J. Lucas (paul-lucas) : | # |
review:
Approve
Revision history for this message
Matthias Brantner (matthias-brantner) : | # |
review:
Approve
- 11679. By Paul J. Lucas
-
Updated ChangeLog.
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : | # |
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue succeeded - proposal merged!
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'ChangeLog' |
2 | --- ChangeLog 2013-10-01 22:39:42 +0000 |
3 | +++ ChangeLog 2013-12-13 15:32:04 +0000 |
4 | @@ -1,5 +1,10 @@ |
5 | Zorba - The XQuery Processor |
6 | |
7 | +version 3.1 |
8 | + |
9 | +New Features: |
10 | + * The json-xml module now supports the "object form" of JsonML (even though |
11 | + there really isn't such a thing). |
12 | |
13 | version 3.0 |
14 | |
15 | |
16 | === modified file 'include/zorba/pregenerated/diagnostic_list.h' |
17 | --- include/zorba/pregenerated/diagnostic_list.h 2013-10-15 23:27:57 +0000 |
18 | +++ include/zorba/pregenerated/diagnostic_list.h 2013-12-13 15:32:04 +0000 |
19 | @@ -879,6 +879,8 @@ |
20 | |
21 | extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJ2X0001_JSONML_ARRAY_BAD_JSON; |
22 | |
23 | +extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJ2X0002_JSONML_OBJECT_BAD_JSON; |
24 | + |
25 | } // namespace zerr |
26 | |
27 | namespace jerr { |
28 | |
29 | === modified file 'modules/json/CMakeLists.txt' |
30 | --- modules/json/CMakeLists.txt 2013-08-28 04:15:48 +0000 |
31 | +++ modules/json/CMakeLists.txt 2013-12-13 15:32:04 +0000 |
32 | @@ -12,7 +12,7 @@ |
33 | # See the License for the specific language governing permissions and |
34 | # limitations under the License. |
35 | |
36 | -DECLARE_ZORBA_MODULE(FILE json-xml.xq VERSION 1.0 |
37 | +DECLARE_ZORBA_MODULE(FILE json-xml.xq VERSION 1.1 |
38 | URI "http://zorba.io/modules/json-xml") |
39 | |
40 | DECLARE_ZORBA_MODULE(FILE json-csv.jq VERSION 1.0 |
41 | |
42 | === modified file 'modules/json/json-xml.xq' |
43 | --- modules/json/json-xml.xq 2013-09-26 23:15:11 +0000 |
44 | +++ modules/json/json-xml.xq 2013-12-13 15:32:04 +0000 |
45 | @@ -41,7 +41,7 @@ |
46 | : "phoneNumbers" : [ "212 732-1234", "646 123-4567" ] |
47 | : } |
48 | : </pre> |
49 | - : would be represented as: |
50 | + : would be represented in XML as: |
51 | : <pre class="ace-static" ace-mode="xquery"> |
52 | : <json type="object"> |
53 | : <pair name="firstName" type="string">John</pair> |
54 | @@ -76,7 +76,7 @@ |
55 | : ] |
56 | : ] |
57 | : </pre> |
58 | - : would be represented as: |
59 | + : would be represented in XML as: |
60 | : <pre class="ace-static" ace-mode="xquery"> |
61 | : <person created="2006-11-11T19:23" modified="2006-12-31T23:59"> |
62 | : <firstName>Robert</firstName> |
63 | @@ -89,6 +89,29 @@ |
64 | : </address> |
65 | : </person> |
66 | : </pre> |
67 | + : This module also implements the "object form" of JsonML |
68 | + : (<a href="http://www.jsonml.org/syntax/">even though there is no "object form" of JsonML</a>). |
69 | + : For example: |
70 | + : <pre class="ace-static" ace-mode="java"> |
71 | + : { |
72 | + : "tagName" : "person", |
73 | + : "created" : "2006-11-11T19:23", |
74 | + : "modified" : "2006-12-31T23:59", |
75 | + : "childNodes" : [ |
76 | + : { "tagName" : "firstName", "childNodes" : [ "Robert" ] }, |
77 | + : { "tagName" : "lastName", "childNodes" : [ "Smith" ] }, |
78 | + : { "tagName" : "address", |
79 | + : "type" : home", |
80 | + : "childNodes" : [ |
81 | + : { "tagName" : "street", "childNodes" : [ "12345 Sixth Ave" ] }, |
82 | + : { "tagName" : "city", "childNodes" : [ "Anytown" ] }, |
83 | + : { "tagName" : "state", "childNodes" : [ "CA" ] }, |
84 | + : { "tagName" : "postalCode", "childNodes" : [ "98765-4321" ] } |
85 | + : ] |
86 | + : } |
87 | + : ] |
88 | + : } |
89 | + : </pre> |
90 | : |
91 | : @author Paul J. Lucas |
92 | : @project Zorba/Data Converters/JSON |
93 | @@ -99,21 +122,35 @@ |
94 | declare namespace zerr = "http://zorba.io/errors"; |
95 | |
96 | declare namespace ver = "http://zorba.io/options/versioning"; |
97 | -declare option ver:module-version "1.0"; |
98 | +declare option ver:module-version "1.1"; |
99 | |
100 | (:~ |
101 | : Converts JSON data into an XDM instance using one of the representations |
102 | - : described above.<p/> |
103 | + : described above. |
104 | : |
105 | : @param $json The JSON data. |
106 | - : @param $options The JSON conversion options, for example: |
107 | - : <pre> |
108 | - : { "json-format" : "JsonML-array" } |
109 | - : </pre> |
110 | + : @param $options The options to use: |
111 | + : <dl> |
112 | + : <dt><code>json-format</code></dt> |
113 | + : <dd> |
114 | + : Specifies the format that <code>$json</code> is in; one of: |
115 | + : <code>JsonML-array</code>, |
116 | + : <code>JsonML-object</code>, |
117 | + : or |
118 | + : <code>Snelson</code>. |
119 | + : Additionally, |
120 | + : <code>JsonML</code> is a synonym for <code>JsonML-array</code>. |
121 | + : default: <code>Snelson</code>. |
122 | + : </dd> |
123 | + : </dl> |
124 | : @return said XDM instance. |
125 | + : @error zerr:ZJSE0001 if <code>$json</code> is not an element node. |
126 | + : @error zerr:ZJ2X0001 if <code>$json</code> is invalid JsonML (array form). |
127 | + : @error zerr:ZJ2X0002 if <code>$json</code> is invalid JsonML (object form). |
128 | : @example test/rbkt/Queries/zorba/json/json-snelson-j2x-array-01.xq |
129 | : @example test/rbkt/Queries/zorba/json/json-snelson-j2x-object-01.xq |
130 | : @example test/rbkt/Queries/zorba/json/json-jmla-j2x-01.xq |
131 | + : @example test/rbkt/Queries/zorba/json/json-jmlo-j2x-01.xq |
132 | :) |
133 | declare function jx:json-to-xml( $json as json-item()?, $options as object() ) |
134 | as element(*,xs:untyped)? |
135 | @@ -123,10 +160,13 @@ |
136 | |
137 | (:~ |
138 | : Converts JSON data into an XDM instance using the Snelson representation |
139 | - : described above.<p/> |
140 | + : described above. |
141 | : |
142 | : @param $json The JSON data. |
143 | : @return said XDM instance. |
144 | + : @error zerr:ZJSE0001 if <code>$json</code> is not an element node. |
145 | + : @error zerr:ZJ2X0001 if <code>$json</code> is invalid JsonML (array form). |
146 | + : @error zerr:ZJ2X0002 if <code>$json</code> is invalid JsonML (object form). |
147 | : @example test/rbkt/Queries/zorba/json/json-snelson-j2x-array-01.xq |
148 | : @example test/rbkt/Queries/zorba/json/json-snelson-j2x-object-01.xq |
149 | : @example test/rbkt/Queries/zorba/json/json-jmla-j2x-01.xq |
150 | @@ -139,23 +179,36 @@ |
151 | |
152 | (:~ |
153 | : Converts XML data into a JSON item using one of the respresentations |
154 | - : described above.<p/> |
155 | + : described above. |
156 | : |
157 | : @param $xml The XML data to convert. |
158 | - : @param $options The conversion options, for example: |
159 | - : <pre> |
160 | - : { "json-format" : "JsonML-array" } |
161 | - : </pre> |
162 | + : @param $options The options to use: |
163 | + : <dl> |
164 | + : <dt><code>json-format</code></dt> |
165 | + : <dd> |
166 | + : Specifies the format that <code>$xml</code> is to be converted into; |
167 | + : one of: |
168 | + : <code>JsonML-array</code>, |
169 | + : <code>JsonML-object</code>, |
170 | + : or |
171 | + : <code>Snelson</code>. |
172 | + : Additionally, |
173 | + : <code>JsonML</code> is a synonym for <code>JsonML-array</code>. |
174 | + : default: <code>JsonML-array</code>. |
175 | + : </dd> |
176 | + : </dl> |
177 | : @return said JSON items. |
178 | - : @error zerr:ZJSE0001 if $xml is not a document or element node. |
179 | - : @error zerr:ZJSE0002 if $xml contains an element that is missing a required |
180 | - : attribute. |
181 | - : @error zerr:ZJSE0003 if $xml contains an attribute having an illegal value. |
182 | - : @error zerr:ZJSE0004 if $xml contains an illegal element. |
183 | + : @error zerr:ZJSE0001 if <code>$xml</code> is not a document or element node. |
184 | + : @error zerr:ZJSE0002 if <code>$xml</code> contains an element that is |
185 | + : missing a required attribute. |
186 | + : @error zerr:ZJSE0003 if <code>$xml</code> contains an attribute having an |
187 | + : illegal value. |
188 | + : @error zerr:ZJSE0004 if <code>$xml</code> contains an illegal element. |
189 | : type. |
190 | - : @error zerr:ZJSE0007 if $xml contains an element that is missing a required |
191 | - : value. |
192 | - : @error zerr:ZJSE0008 if $xml contains an illegal value for a JSON type. |
193 | + : @error zerr:ZJSE0007 if <code>$xml</code> contains an element that is |
194 | + : missing a required value. |
195 | + : @error zerr:ZJSE0008 if <code>$xml</code> contains an illegal value for a |
196 | + : JSON type. |
197 | : @example test/rbkt/Queries/zorba/json/json-snelson-x2j-array-01.xq |
198 | : @example test/rbkt/Queries/zorba/json/json-snelson-x2j-object-01.xq |
199 | : @example test/rbkt/Queries/zorba/json/json-jmla-x2j-01.xq |
200 | @@ -168,22 +221,25 @@ |
201 | |
202 | (:~ |
203 | : Converts XML data into a JSON item using the Snelson representation |
204 | - : described above.<p/> |
205 | + : described above. |
206 | : |
207 | : @param $xml The XML data to convert. |
208 | : @return said JSON items. |
209 | - : @error zerr:ZJSE0001 if $xml is not a document or element node. |
210 | - : @error zerr:ZJSE0002 if $xml contains an element that is missing a required |
211 | - : attribute. |
212 | - : @error zerr:ZJSE0003 if $xml contains an attribute having an illegal value. |
213 | - : @error zerr:ZJSE0004 if $xml contains an illegal element. |
214 | + : @error zerr:ZJSE0001 if <code>$xml</code> is not a document or element node. |
215 | + : @error zerr:ZJSE0002 if <code>$xml</code> contains an element that is |
216 | + : missing a required attribute. |
217 | + : @error zerr:ZJSE0003 if <code>$xml</code> contains an attribute having an |
218 | + : illegal value. |
219 | + : @error zerr:ZJSE0004 if <code>$xml</code> contains an illegal element. |
220 | : type. |
221 | - : @error zerr:ZJSE0007 if $xml contains an element that is missing a required |
222 | - : value. |
223 | - : @error zerr:ZJSE0008 if $xml contains an illegal value for a JSON type. |
224 | + : @error zerr:ZJSE0007 if <code>$xml</code> contains an element that is |
225 | + : missing a required value. |
226 | + : @error zerr:ZJSE0008 if <code>$xml</code> contains an illegal value for a |
227 | + : JSON type. |
228 | : @example test/rbkt/Queries/zorba/json/json-snelson-x2j-array-01.xq |
229 | : @example test/rbkt/Queries/zorba/json/json-snelson-x2j-object-01.xq |
230 | : @example test/rbkt/Queries/zorba/json/json-jmla-x2j-01.xq |
231 | + : @example test/rbkt/Queries/zorba/json/json-jmlo-x2j-01.xq |
232 | :) |
233 | declare function jx:xml-to-json( $xml as item()* ) |
234 | as json-item()* |
235 | |
236 | === modified file 'modules/pregenerated/zorba-errors.xq' |
237 | --- modules/pregenerated/zorba-errors.xq 2013-10-15 23:27:57 +0000 |
238 | +++ modules/pregenerated/zorba-errors.xq 2013-12-13 15:32:04 +0000 |
239 | @@ -970,4 +970,8 @@ |
240 | |
241 | (:~ |
242 | :) |
243 | -declare variable $zerr:ZJ2X0001 as xs:QName := fn:QName($zerr:NS, "zerr:ZJ2X0001"); |
244 | \ No newline at end of file |
245 | +declare variable $zerr:ZJ2X0001 as xs:QName := fn:QName($zerr:NS, "zerr:ZJ2X0001"); |
246 | + |
247 | +(:~ |
248 | +:) |
249 | +declare variable $zerr:ZJ2X0002 as xs:QName := fn:QName($zerr:NS, "zerr:ZJ2X0002"); |
250 | \ No newline at end of file |
251 | |
252 | === modified file 'src/diagnostics/diagnostic_en.xml' |
253 | --- src/diagnostics/diagnostic_en.xml 2013-10-16 21:47:22 +0000 |
254 | +++ src/diagnostics/diagnostic_en.xml 2013-12-13 15:32:04 +0000 |
255 | @@ -3275,6 +3275,22 @@ |
256 | </entry> |
257 | </diagnostic> |
258 | |
259 | + <diagnostic code="ZJ2X0002" name="JSONML_OBJECT_BAD_JSON"> |
260 | + <value>JsonML (object form) $1</value> |
261 | + <entry key="childNodesArrayRequired"> |
262 | + <value>"childNodes" key must have array value</value> |
263 | + </entry> |
264 | + <entry key="ObjectRequired"> |
265 | + <value>must start with object</value> |
266 | + </entry> |
267 | + <entry key="BadElement"> |
268 | + <value>array must not have a "$2" element</value> |
269 | + </entry> |
270 | + <entry key="tagNameRequired"> |
271 | + <value>must contain a "tagName" key</value> |
272 | + </entry> |
273 | + </diagnostic> |
274 | + |
275 | </namespace> |
276 | |
277 | <namespace prefix="jerr"> |
278 | |
279 | === modified file 'src/diagnostics/pregenerated/diagnostic_list.cpp' |
280 | --- src/diagnostics/pregenerated/diagnostic_list.cpp 2013-10-15 23:27:57 +0000 |
281 | +++ src/diagnostics/pregenerated/diagnostic_list.cpp 2013-12-13 15:32:04 +0000 |
282 | @@ -1298,6 +1298,9 @@ |
283 | ZorbaErrorCode ZJ2X0001_JSONML_ARRAY_BAD_JSON( "ZJ2X0001" ); |
284 | |
285 | |
286 | +ZorbaErrorCode ZJ2X0002_JSONML_OBJECT_BAD_JSON( "ZJ2X0002" ); |
287 | + |
288 | + |
289 | } // namespace zerr |
290 | |
291 | namespace jerr { |
292 | |
293 | === modified file 'src/diagnostics/pregenerated/dict_en.cpp' |
294 | --- src/diagnostics/pregenerated/dict_en.cpp 2013-10-16 22:17:33 +0000 |
295 | +++ src/diagnostics/pregenerated/dict_en.cpp 2013-12-13 15:32:04 +0000 |
296 | @@ -409,6 +409,7 @@ |
297 | { "ZGDB0001", "" }, |
298 | #endif |
299 | { "ZJ2X0001", "JsonML (array form) $1" }, |
300 | + { "ZJ2X0002", "JsonML (object form) $1" }, |
301 | { "ZJPE0001", "'$1': illegal JSON character" }, |
302 | { "ZJPE0002", "\"$1\": illegal Unicode code-point" }, |
303 | { "ZJPE0003", "'\\\\$1': illegal JSON character escape" }, |
304 | @@ -997,6 +998,10 @@ |
305 | { "~ZJ2X0001_BadElement", "array must not have a \"$2\" element" }, |
306 | { "~ZJ2X0001_EmptyArray", "array must not be empty" }, |
307 | { "~ZJ2X0001_UnexpectedObject", "allows an object only for the 2nd element" }, |
308 | + { "~ZJ2X0002_BadElement", "array must not have a \"$2\" element" }, |
309 | + { "~ZJ2X0002_ObjectRequired", "must start with object" }, |
310 | + { "~ZJ2X0002_childNodesArrayRequired", "\"childNodes\" key must have array value" }, |
311 | + { "~ZJ2X0002_tagNameRequired", "must contain a \"tagName\" key" }, |
312 | { "~ZSTR0060_ForCollection_3", "for collection \"$3\"" }, |
313 | { "~ZSTR0060_ForSequence", "for sequence" }, |
314 | { "~ZWST0005_PARAM_TYPE", "type of parameter $3 is $4 which is not a subtype of xs:anyAtomicType" }, |
315 | |
316 | === modified file 'src/diagnostics/pregenerated/dict_zed_keys.h' |
317 | --- src/diagnostics/pregenerated/dict_zed_keys.h 2013-09-19 23:43:00 +0000 |
318 | +++ src/diagnostics/pregenerated/dict_zed_keys.h 2013-12-13 15:32:04 +0000 |
319 | @@ -173,6 +173,10 @@ |
320 | #define ZED_ZJ2X0001_Bad1stElement "~ZJ2X0001_Bad1stElement" |
321 | #define ZED_ZJ2X0001_BadElement "~ZJ2X0001_BadElement" |
322 | #define ZED_ZJ2X0001_UnexpectedObject "~ZJ2X0001_UnexpectedObject" |
323 | +#define ZED_ZJ2X0002_childNodesArrayRequired "~ZJ2X0002_childNodesArrayRequired" |
324 | +#define ZED_ZJ2X0002_ObjectRequired "~ZJ2X0002_ObjectRequired" |
325 | +#define ZED_ZJ2X0002_BadElement "~ZJ2X0002_BadElement" |
326 | +#define ZED_ZJ2X0002_tagNameRequired "~ZJ2X0002_tagNameRequired" |
327 | #define ZED_JNUP0007_Object "~JNUP0007_Object" |
328 | #define ZED_JNUP0007_Array "~JNUP0007_Array" |
329 | #define ZED_JNUP0007_ObjectArray "~JNUP0007_ObjectArray" |
330 | |
331 | === modified file 'src/runtime/CMakeLists.txt' |
332 | --- src/runtime/CMakeLists.txt 2013-10-01 22:39:42 +0000 |
333 | +++ src/runtime/CMakeLists.txt 2013-12-13 15:32:04 +0000 |
334 | @@ -130,6 +130,7 @@ |
335 | indexing/index_ddl.cpp |
336 | json/common.cpp |
337 | json/jsonml_array.cpp |
338 | + json/jsonml_object.cpp |
339 | json/snelson.cpp |
340 | numerics/NumericsImpl.cpp |
341 | numerics/format_integer.cpp |
342 | |
343 | === modified file 'src/runtime/json/common.cpp' |
344 | --- src/runtime/json/common.cpp 2013-07-24 23:15:02 +0000 |
345 | +++ src/runtime/json/common.cpp 2013-12-13 15:32:04 +0000 |
346 | @@ -17,7 +17,9 @@ |
347 | |
348 | #include <zorba/xquery_exception.h> |
349 | |
350 | +#include "store/api/item_factory.h" |
351 | #include "store/api/iterator.h" |
352 | +#include "system/globalenv.h" |
353 | |
354 | #include "common.h" |
355 | |
356 | @@ -44,6 +46,48 @@ |
357 | return found; |
358 | } |
359 | |
360 | +bool x2j_map_atomic( store::Item_t const &xml_item, store::Item_t *json_item ) { |
361 | + if ( xml_item->isAtomic() ) { |
362 | + switch ( xml_item->getTypeCode() ) { |
363 | + case store::JS_NULL: |
364 | + case store::XS_BOOLEAN: |
365 | + case store::XS_BYTE: |
366 | + case store::XS_DECIMAL: |
367 | + case store::XS_DOUBLE: |
368 | + case store::XS_ENTITY: |
369 | + case store::XS_FLOAT: |
370 | + case store::XS_ID: |
371 | + case store::XS_IDREF: |
372 | + case store::XS_INT: |
373 | + case store::XS_INTEGER: |
374 | + case store::XS_LONG: |
375 | + case store::XS_NAME: |
376 | + case store::XS_NCNAME: |
377 | + case store::XS_NEGATIVE_INTEGER: |
378 | + case store::XS_NMTOKEN: |
379 | + case store::XS_NON_NEGATIVE_INTEGER: |
380 | + case store::XS_NON_POSITIVE_INTEGER: |
381 | + case store::XS_NORMALIZED_STRING: |
382 | + case store::XS_POSITIVE_INTEGER: |
383 | + case store::XS_SHORT: |
384 | + case store::XS_STRING: |
385 | + case store::XS_TOKEN: |
386 | + case store::XS_UNSIGNED_BYTE: |
387 | + case store::XS_UNSIGNED_INT: |
388 | + case store::XS_UNSIGNED_LONG: |
389 | + case store::XS_UNSIGNED_SHORT: |
390 | + *json_item = xml_item; |
391 | + break; |
392 | + default: |
393 | + zstring s( xml_item->getStringValue() ); |
394 | + GENV_ITEMFACTORY->createString( *json_item, s ); |
395 | + break; |
396 | + } // switch |
397 | + return true; |
398 | + } // if |
399 | + return false; |
400 | +} |
401 | + |
402 | /////////////////////////////////////////////////////////////////////////////// |
403 | |
404 | #if ZORBA_DEBUG_JSON |
405 | |
406 | === modified file 'src/runtime/json/common.h' |
407 | --- src/runtime/json/common.h 2013-07-24 23:15:02 +0000 |
408 | +++ src/runtime/json/common.h 2013-12-13 15:32:04 +0000 |
409 | @@ -69,6 +69,8 @@ |
410 | set_data( *xe, je.get_loc() ); |
411 | } |
412 | |
413 | +bool x2j_map_atomic( store::Item_t const &xml_item, store::Item_t *json_item ); |
414 | + |
415 | /////////////////////////////////////////////////////////////////////////////// |
416 | |
417 | #define IN_STATE(S) ztd::top_stack_equals( state_stack, (S) ) |
418 | |
419 | === modified file 'src/runtime/json/json_impl.cpp' |
420 | --- src/runtime/json/json_impl.cpp 2013-07-29 23:55:03 +0000 |
421 | +++ src/runtime/json/json_impl.cpp 2013-12-13 15:32:04 +0000 |
422 | @@ -29,6 +29,7 @@ |
423 | #include "util/stream_util.h" |
424 | |
425 | #include "jsonml_array.h" |
426 | +#include "jsonml_object.h" |
427 | #include "snelson.h" |
428 | |
429 | using namespace std; |
430 | @@ -71,12 +72,14 @@ |
431 | result = nullptr; |
432 | |
433 | { // local scope |
434 | - options_type::mapped_type const &format = options[ "json-format" ]; |
435 | - ZORBA_ASSERT( !format.empty() ); |
436 | - if ( format == "Snelson" ) |
437 | + options_type::mapped_type const &format_opt = options[ "json-format" ]; |
438 | + ZORBA_ASSERT( !format_opt.empty() ); |
439 | + if ( format_opt == "Snelson" ) |
440 | snelson::json_to_xml( item, &result ); |
441 | - else if ( format == "JsonML-array" ) |
442 | + else if ( format_opt == "JsonML" || format_opt == "JsonML-array" ) |
443 | jsonml_array::json_to_xml( item, &result ); |
444 | + else if ( format_opt == "JsonML-object" ) |
445 | + jsonml_object::json_to_xml( item, &result ); |
446 | else |
447 | ZORBA_ASSERT( false ); |
448 | } // local scope |
449 | @@ -108,8 +111,10 @@ |
450 | case store::StoreConsts::elementNode: |
451 | if ( format_opt == "Snelson" ) |
452 | snelson::xml_to_json( xml_item, &result ); |
453 | - else if ( format_opt == "JsonML-array" ) |
454 | + else if ( format_opt == "JsonML" || format_opt == "JsonML-array" ) |
455 | jsonml_array::xml_to_json( xml_item, &result ); |
456 | + else if ( format_opt == "JsonML-object" ) |
457 | + jsonml_object::xml_to_json( xml_item, &result ); |
458 | else |
459 | ZORBA_ASSERT( false ); |
460 | break; |
461 | |
462 | === modified file 'src/runtime/json/jsonml_array.cpp' |
463 | --- src/runtime/json/jsonml_array.cpp 2013-08-25 14:31:39 +0000 |
464 | +++ src/runtime/json/jsonml_array.cpp 2013-12-13 15:32:04 +0000 |
465 | @@ -27,43 +27,50 @@ |
466 | #include "types/root_typemanager.h" |
467 | #include "types/typeops.h" |
468 | #include "util/stl_util.h" |
469 | +#include "zorbautils/store_util.h" |
470 | |
471 | +#include "common.h" |
472 | #include "jsonml_array.h" |
473 | +#include "jsonml_common.h" |
474 | |
475 | -// JsonML grammar |
476 | -// Source: http://www.ibm.com/developerworks/library/x-jsonml/#N10138 |
477 | +// JsonML ("array form") grammar. |
478 | +// Source: http://www.jsonml.org/syntax/ |
479 | // |
480 | // element |
481 | -// = '[' tag-name ',' attributes ',' element-list ']' |
482 | -// | '[' tag-name ',' attributes ']' |
483 | -// | '[' tag-name ',' element-list ']' |
484 | -// | '[' tag-name ']' |
485 | -// | json-string |
486 | -// ; |
487 | +// = '[' tag-name ',' attributes ',' element-list ']' |
488 | +// | '[' tag-name ',' attributes ']' |
489 | +// | '[' tag-name ',' element-list ']' |
490 | +// | '[' tag-name ']' |
491 | +// | string |
492 | +// ; |
493 | // tag-name |
494 | -// = json-string |
495 | -// ; |
496 | +// = string |
497 | +// ; |
498 | // attributes |
499 | -// = '{' attribute-list '}' |
500 | -// | '{' '}' |
501 | -// ; |
502 | +// = '{' attribute-list '}' |
503 | +// | '{' '}' |
504 | +// ; |
505 | // attribute-list |
506 | -// = attribute ',' attribute-list |
507 | -// | attribute |
508 | -// ; |
509 | +// = attribute ',' attribute-list |
510 | +// | attribute |
511 | +// ; |
512 | // attribute |
513 | -// = attribute-name ':' attribute-value |
514 | -// ; |
515 | +// = attribute-name ':' attribute-value |
516 | +// ; |
517 | // attribute-name |
518 | -// = json-string |
519 | -// ; |
520 | +// = string |
521 | +// ; |
522 | // attribute-value |
523 | -// = json-string |
524 | -// ; |
525 | +// = string |
526 | +// | number |
527 | +// | 'true' |
528 | +// | 'false' |
529 | +// | 'null' |
530 | +// ; |
531 | // element-list |
532 | -// = element ',' element-list |
533 | -// | element |
534 | -// ; |
535 | +// = element ',' element-list |
536 | +// | element |
537 | +// ; |
538 | |
539 | using namespace std; |
540 | |
541 | @@ -175,67 +182,21 @@ |
542 | |
543 | /////////////////////////////////////////////////////////////////////////////// |
544 | |
545 | -static bool x2j_map_atomic_item( store::Item_t const &xml_item, |
546 | - store::Item_t *json_item ) { |
547 | - if ( xml_item->isAtomic() ) { |
548 | - switch ( xml_item->getTypeCode() ) { |
549 | - case store::JS_NULL: |
550 | - case store::XS_BOOLEAN: |
551 | - case store::XS_BYTE: |
552 | - case store::XS_DECIMAL: |
553 | - case store::XS_DOUBLE: |
554 | - case store::XS_ENTITY: |
555 | - case store::XS_FLOAT: |
556 | - case store::XS_ID: |
557 | - case store::XS_IDREF: |
558 | - case store::XS_INT: |
559 | - case store::XS_INTEGER: |
560 | - case store::XS_LONG: |
561 | - case store::XS_NAME: |
562 | - case store::XS_NCNAME: |
563 | - case store::XS_NEGATIVE_INTEGER: |
564 | - case store::XS_NMTOKEN: |
565 | - case store::XS_NON_NEGATIVE_INTEGER: |
566 | - case store::XS_NON_POSITIVE_INTEGER: |
567 | - case store::XS_NORMALIZED_STRING: |
568 | - case store::XS_POSITIVE_INTEGER: |
569 | - case store::XS_SHORT: |
570 | - case store::XS_STRING: |
571 | - case store::XS_TOKEN: |
572 | - case store::XS_UNSIGNED_BYTE: |
573 | - case store::XS_UNSIGNED_INT: |
574 | - case store::XS_UNSIGNED_LONG: |
575 | - case store::XS_UNSIGNED_SHORT: |
576 | - *json_item = xml_item; |
577 | - break; |
578 | - default: |
579 | - zstring s( xml_item->getStringValue() ); |
580 | - GENV_ITEMFACTORY->createString( *json_item, s ); |
581 | - break; |
582 | - } // switch |
583 | - return true; |
584 | - } // if |
585 | - return false; |
586 | -} |
587 | - |
588 | static void x2j_attributes( store::Item_t const &element, |
589 | store::Item_t *json_item ) { |
590 | ZORBA_ASSERT( json_item ); |
591 | |
592 | - store::Item_t att_item, item; |
593 | + store::Item_t att_item; |
594 | vector<store::Item_t> keys, values; |
595 | |
596 | store::Iterator_t i( element->getAttributes() ); |
597 | i->open(); |
598 | while ( i->next( att_item ) ) { |
599 | - zstring att_name( name_of( att_item ) ); |
600 | - if ( att_name == "xmlns" ) |
601 | - continue; |
602 | - GENV_ITEMFACTORY->createString( item, att_name ); |
603 | - keys.push_back( item ); |
604 | - zstring att_value( att_item->getStringValue() ); |
605 | - GENV_ITEMFACTORY->createString( item, att_value ); |
606 | - values.push_back( item ); |
607 | + zstring const att_name( name_of( att_item ) ); |
608 | + if ( att_name != "xmlns" ) { |
609 | + push_back( &keys, att_name ); |
610 | + push_back( &values, att_item->getStringValue() ); |
611 | + } |
612 | } // while |
613 | i->close(); |
614 | if ( !keys.empty() ) |
615 | @@ -247,13 +208,13 @@ |
616 | store::Item_t *json_item ); |
617 | |
618 | static void x2j_children( store::Item_t const &parent, |
619 | - vector<store::Item_t> *elements ) { |
620 | - ZORBA_ASSERT( elements ); |
621 | + vector<store::Item_t> *children ) { |
622 | + ZORBA_ASSERT( children ); |
623 | store::Iterator_t i( parent->getChildren() ); |
624 | i->open(); |
625 | store::Item_t child_item, temp_item; |
626 | while ( i->next( child_item ) ) { |
627 | - if ( !x2j_map_atomic_item( child_item, &temp_item ) ) { |
628 | + if ( !x2j_map_atomic( child_item, &temp_item ) ) { |
629 | if ( !child_item->isNode() ) |
630 | throw XQUERY_EXCEPTION( |
631 | zerr::ZJ2X0001_JSONML_ARRAY_BAD_JSON, |
632 | @@ -272,7 +233,7 @@ |
633 | continue; |
634 | } // switch |
635 | } // if |
636 | - elements->push_back( temp_item ); |
637 | + children->push_back( temp_item ); |
638 | } // while |
639 | i->close(); |
640 | } |
641 | @@ -280,14 +241,12 @@ |
642 | static void x2j_element( store::Item_t const &element, |
643 | store::Item_t *json_item ) { |
644 | ZORBA_ASSERT( json_item ); |
645 | - store::Item_t name_item, attributes_item; |
646 | + store::Item_t attributes_item; |
647 | vector<store::Item_t> elements; |
648 | |
649 | - zstring name( name_of( element ) ); |
650 | - GENV_ITEMFACTORY->createString( name_item, name ); |
651 | - elements.push_back( name_item ); |
652 | + push_back( &elements, name_of( element ) ); |
653 | x2j_attributes( element, &attributes_item ); |
654 | - if ( !attributes_item.isNull() ) |
655 | + if ( !!attributes_item ) |
656 | elements.push_back( attributes_item ); |
657 | x2j_children( element, &elements ); |
658 | GENV_ITEMFACTORY->createJSONArray( *json_item, elements ); |
659 | |
660 | === modified file 'src/runtime/json/jsonml_array.h' |
661 | --- src/runtime/json/jsonml_array.h 2013-07-26 05:36:22 +0000 |
662 | +++ src/runtime/json/jsonml_array.h 2013-12-13 15:32:04 +0000 |
663 | @@ -18,12 +18,8 @@ |
664 | #ifndef ZORBA_RUNTIME_JSON_JSONML_ARRAY_H |
665 | #define ZORBA_RUNTIME_JSON_JSONML_ARRAY_H |
666 | |
667 | -#include <iostream> |
668 | - |
669 | #include "store/api/item.h" |
670 | |
671 | -#include "common.h" |
672 | - |
673 | namespace zorba { |
674 | namespace jsonml_array { |
675 | |
676 | |
677 | === added file 'src/runtime/json/jsonml_common.cpp' |
678 | --- src/runtime/json/jsonml_common.cpp 1970-01-01 00:00:00 +0000 |
679 | +++ src/runtime/json/jsonml_common.cpp 2013-12-13 15:32:04 +0000 |
680 | @@ -0,0 +1,87 @@ |
681 | +/* |
682 | + * Copyright 2006-2011 The FLWOR Foundation. |
683 | + * |
684 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
685 | + * you may not use this file except in compliance with the License. |
686 | + * You may obtain a copy of the License at |
687 | + * |
688 | + * http://www.apache.org/licenses/LICENSE-2.0 |
689 | + * |
690 | + * Unless required by applicable law or agreed to in writing, software |
691 | + * distributed under the License is distributed on an "AS IS" BASIS, |
692 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
693 | + * See the License for the specific language governing permissions and |
694 | + * limitations under the License. |
695 | + */ |
696 | +#include "stdafx.h" |
697 | + |
698 | +#include "store/api/item_factory.h" |
699 | + |
700 | +#include "jsonml_common.h" |
701 | + |
702 | +using namespace std; |
703 | + |
704 | +namespace zorba { |
705 | + |
706 | +/////////////////////////////////////////////////////////////////////////////// |
707 | + |
708 | +bool x2j_map_atomic( store::Item_t const &xml_item, store::Item_t *json_item ) { |
709 | + if ( xml_item->isAtomic() ) { |
710 | + switch ( xml_item->getTypeCode() ) { |
711 | + case store::JS_NULL: |
712 | + case store::XS_BOOLEAN: |
713 | + case store::XS_BYTE: |
714 | + case store::XS_DECIMAL: |
715 | + case store::XS_DOUBLE: |
716 | + case store::XS_ENTITY: |
717 | + case store::XS_FLOAT: |
718 | + case store::XS_ID: |
719 | + case store::XS_IDREF: |
720 | + case store::XS_INT: |
721 | + case store::XS_INTEGER: |
722 | + case store::XS_LONG: |
723 | + case store::XS_NAME: |
724 | + case store::XS_NCNAME: |
725 | + case store::XS_NEGATIVE_INTEGER: |
726 | + case store::XS_NMTOKEN: |
727 | + case store::XS_NON_NEGATIVE_INTEGER: |
728 | + case store::XS_NON_POSITIVE_INTEGER: |
729 | + case store::XS_NORMALIZED_STRING: |
730 | + case store::XS_POSITIVE_INTEGER: |
731 | + case store::XS_SHORT: |
732 | + case store::XS_STRING: |
733 | + case store::XS_TOKEN: |
734 | + case store::XS_UNSIGNED_BYTE: |
735 | + case store::XS_UNSIGNED_INT: |
736 | + case store::XS_UNSIGNED_LONG: |
737 | + case store::XS_UNSIGNED_SHORT: |
738 | + *json_item = xml_item; |
739 | + break; |
740 | + default: |
741 | + zstring s( xml_item->getStringValue() ); |
742 | + GENV_ITEMFACTORY->createString( *json_item, s ); |
743 | + break; |
744 | + } // switch |
745 | + return true; |
746 | + } // if |
747 | + return false; |
748 | +} |
749 | + |
750 | +/////////////////////////////////////////////////////////////////////////////// |
751 | + |
752 | +#if ZORBA_DEBUG_JSON |
753 | + |
754 | +ostream& operator<<( ostream &o, parse_state s ) { |
755 | + static char const *const string_of[] = { |
756 | + "in_array", |
757 | + "in_object" |
758 | + }; |
759 | + return o << string_of[ s ]; |
760 | +} |
761 | + |
762 | +#endif /* ZORBA_DEBUG_JSON */ |
763 | + |
764 | +/////////////////////////////////////////////////////////////////////////////// |
765 | + |
766 | +} // namespace zorba |
767 | +/* vim:set et sw=2 ts=2: */ |
768 | |
769 | === added file 'src/runtime/json/jsonml_common.h' |
770 | --- src/runtime/json/jsonml_common.h 1970-01-01 00:00:00 +0000 |
771 | +++ src/runtime/json/jsonml_common.h 2013-12-13 15:32:04 +0000 |
772 | @@ -0,0 +1,33 @@ |
773 | +/* |
774 | + * Copyright 2006-2011 The FLWOR Foundation. |
775 | + * |
776 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
777 | + * you may not use this file except in compliance with the License. |
778 | + * You may obtain a copy of the License at |
779 | + * |
780 | + * http://www.apache.org/licenses/LICENSE-2.0 |
781 | + * |
782 | + * Unless required by applicable law or agreed to in writing, software |
783 | + * distributed under the License is distributed on an "AS IS" BASIS, |
784 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
785 | + * See the License for the specific language governing permissions and |
786 | + * limitations under the License. |
787 | + */ |
788 | + |
789 | +#ifndef ZORBA_RUNTIME_JSON_JSONML_COMMON_H |
790 | +#define ZORBA_RUNTIME_JSON_JSONML_COMMON_H |
791 | + |
792 | +// Zorba |
793 | +#include "store/api/item.h" |
794 | + |
795 | +namespace zorba { |
796 | + |
797 | +/////////////////////////////////////////////////////////////////////////////// |
798 | + |
799 | +bool x2j_map_atomic( store::Item_t const &xml_item, store::Item_t *json_item ); |
800 | + |
801 | +/////////////////////////////////////////////////////////////////////////////// |
802 | + |
803 | +} // namespace zorba |
804 | +#endif /* ZORBA_RUNTIME_JSON_JSONML_COMMON_H */ |
805 | +/* vim:set et sw=2 ts=2: */ |
806 | |
807 | === added file 'src/runtime/json/jsonml_object.cpp' |
808 | --- src/runtime/json/jsonml_object.cpp 1970-01-01 00:00:00 +0000 |
809 | +++ src/runtime/json/jsonml_object.cpp 2013-12-13 15:32:04 +0000 |
810 | @@ -0,0 +1,273 @@ |
811 | +/* |
812 | + * Copyright 2006-2011 The FLWOR Foundation. |
813 | + * |
814 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
815 | + * you may not use this file except in compliance with the License. |
816 | + * You may obtain a copy of the License at |
817 | + * |
818 | + * http://www.apache.org/licenses/LICENSE-2.0 |
819 | + * |
820 | + * Unless required by applicable law or agreed to in writing, software |
821 | + * distributed under the License is distributed on an "AS IS" BASIS, |
822 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
823 | + * See the License for the specific language governing permissions and |
824 | + * limitations under the License. |
825 | + */ |
826 | +#include "stdafx.h" |
827 | + |
828 | +#include <sstream> |
829 | + |
830 | +#include <zorba/diagnostic_list.h> |
831 | +#include <zorba/internal/cxx_util.h> |
832 | +#include <zorba/store_consts.h> |
833 | + |
834 | +#include "runtime/json/json.h" |
835 | +#include "store/api/item_factory.h" |
836 | +#include "system/globalenv.h" |
837 | +#include "types/root_typemanager.h" |
838 | +#include "types/typeops.h" |
839 | +#include "util/stl_util.h" |
840 | +#include "zorbautils/store_util.h" |
841 | + |
842 | +#include "common.h" |
843 | +#include "jsonml_common.h" |
844 | +#include "jsonml_object.h" |
845 | + |
846 | +// JsonML ("object form") grammar. |
847 | +// |
848 | +// Note: there is no "object form" of JsonML. In a JSON user group thread [1], |
849 | +// Douglas Crockford incorrectly used the term "JsonML" to describe two |
850 | +// variants: the "array form" and "object form." This was a misuse of the term |
851 | +// JsonML which has always *only* stood to mean what Crockford referred to as |
852 | +// the "array form." |
853 | +// |
854 | +// [1]: <http://groups.yahoo.com/neo/groups/json/conversations/topics/1115> |
855 | +// |
856 | +// element |
857 | +// = '{' tag-name ',' attribute-list ',' elements '}' |
858 | +// | '{' tag-name ',' attribute-list '}' |
859 | +// | '{' tag-name ',' elements '}' |
860 | +// | '{' tag-name '}' |
861 | +// ; |
862 | +// tag-name |
863 | +// "tagName" ':' string |
864 | +// ; |
865 | +// attribute-list |
866 | +// = attribute ',' attribute-list |
867 | +// | attribute |
868 | +// ; |
869 | +// attribute |
870 | +// = attribute-name ':' attribute-value |
871 | +// ; |
872 | +// attribute-name |
873 | +// = string |
874 | +// ; |
875 | +// attribute-value |
876 | +// = string |
877 | +// | number |
878 | +// | 'true' |
879 | +// | 'false' |
880 | +// | 'null' |
881 | +// ; |
882 | +// elements |
883 | +// = "childNodes" : '[' element-list ']' |
884 | +// = "childNodes" : '[' ']' |
885 | +// ; |
886 | +// element-list |
887 | +// = element ',' element-list |
888 | +// = element |
889 | +// ; |
890 | + |
891 | +using namespace std; |
892 | + |
893 | +namespace zorba { |
894 | +namespace jsonml_object { |
895 | + |
896 | +/////////////////////////////////////////////////////////////////////////////// |
897 | + |
898 | +// forward declaration |
899 | +static store::Item_t j2x_object( store::Item_t const &object_item, |
900 | + store::Item *parent_xml_item ); |
901 | + |
902 | +static void j2x_array( store::Item_t const &array_item, |
903 | + store::Item *parent_xml_item ) { |
904 | + store::Item_t item, junk_item; |
905 | + zstring value_str; |
906 | + |
907 | + store::Iterator_t i( array_item->getArrayValues() ); |
908 | + i->open(); |
909 | + while ( i->next( item ) ) { |
910 | + switch ( item->getKind() ) { |
911 | + case store::Item::ATOMIC: |
912 | + value_str = item->getStringValue(); |
913 | + GENV_ITEMFACTORY->createTextNode( |
914 | + junk_item, parent_xml_item, value_str |
915 | + ); |
916 | + break; |
917 | + case store::Item::OBJECT: |
918 | + j2x_object( item, parent_xml_item ); |
919 | + break; |
920 | + default: |
921 | + throw XQUERY_EXCEPTION( |
922 | + zerr::ZJ2X0002_JSONML_OBJECT_BAD_JSON, |
923 | + ERROR_PARAMS( ZED( ZJ2X0002_BadElement ), item->getKind() ) |
924 | + ); |
925 | + } // switch |
926 | + } // while |
927 | + i->close(); |
928 | +} |
929 | + |
930 | +static store::Item_t j2x_object( store::Item_t const &object_item, |
931 | + store::Item *parent_xml_item ) { |
932 | + zstring base_uri; |
933 | + store::NsBindings ns_bindings; |
934 | + store::Item_t element_name, key_item, type_name, xml_item; |
935 | + |
936 | + store::Item_t name_item( get_json_value( object_item, "tagName" ) ); |
937 | + if ( !name_item ) |
938 | + throw XQUERY_EXCEPTION( |
939 | + zerr::ZJ2X0002_JSONML_OBJECT_BAD_JSON, |
940 | + ERROR_PARAMS( ZED( ZJ2X0002_tagNameRequired ) ) |
941 | + ); |
942 | + GENV_ITEMFACTORY->createQName( |
943 | + element_name, "", "", name_item->getStringValue() |
944 | + ); |
945 | + type_name = GENV_TYPESYSTEM.XS_UNTYPED_QNAME; |
946 | + GENV_ITEMFACTORY->createElementNode( |
947 | + xml_item, parent_xml_item, |
948 | + element_name, type_name, false, false, ns_bindings, base_uri |
949 | + ); |
950 | + |
951 | + store::Iterator_t k( object_item->getObjectKeys() ); |
952 | + k->open(); |
953 | + while ( k->next( key_item ) ) { |
954 | + zstring const key_str( key_item->getStringValue() ); |
955 | + if ( key_str == "tagName" ) |
956 | + continue; // already handled |
957 | + store::Item_t value_item( object_item->getObjectValue( key_item ) ); |
958 | + if ( key_str == "childNodes" ) { |
959 | + if ( value_item->getKind() != store::Item::ARRAY ) |
960 | + throw XQUERY_EXCEPTION( |
961 | + zerr::ZJ2X0002_JSONML_OBJECT_BAD_JSON, |
962 | + ERROR_PARAMS( ZED( ZJ2X0002_childNodesArrayRequired ) ) |
963 | + ); |
964 | + j2x_array( value_item, xml_item.get() ); |
965 | + } else { |
966 | + store::Item_t att_name, junk_item; |
967 | + GENV_ITEMFACTORY->createQName( att_name, "", "", key_str ); |
968 | + type_name = GENV_TYPESYSTEM.XS_UNTYPED_QNAME; |
969 | + GENV_ITEMFACTORY->createAttributeNode( |
970 | + junk_item, xml_item, att_name, type_name, value_item |
971 | + ); |
972 | + } |
973 | + } // while |
974 | + k->close(); |
975 | + return xml_item; |
976 | +} |
977 | + |
978 | +void json_to_xml( store::Item_t const &json_item, store::Item_t *xml_item ) { |
979 | + ZORBA_ASSERT( xml_item ); |
980 | + switch ( json_item->getKind() ) { |
981 | + case store::Item::ARRAY: |
982 | + throw XQUERY_EXCEPTION( |
983 | + zerr::ZJ2X0002_JSONML_OBJECT_BAD_JSON, |
984 | + ERROR_PARAMS( ZED( ZJ2X0002_ObjectRequired ) ) |
985 | + ); |
986 | + case store::Item::OBJECT: |
987 | + *xml_item = j2x_object( json_item, nullptr ); |
988 | + break; |
989 | + default: |
990 | + ZORBA_ASSERT( false ); |
991 | + } |
992 | +} |
993 | + |
994 | +/////////////////////////////////////////////////////////////////////////////// |
995 | + |
996 | +static void x2j_attributes( store::Item_t const &element, |
997 | + vector<store::Item_t> *keys, |
998 | + vector<store::Item_t> *values ) { |
999 | + ZORBA_ASSERT( keys ); |
1000 | + ZORBA_ASSERT( values ); |
1001 | + |
1002 | + store::Iterator_t i( element->getAttributes() ); |
1003 | + store::Item_t att_item; |
1004 | + i->open(); |
1005 | + while ( i->next( att_item ) ) { |
1006 | + zstring const name( name_of( att_item ) ); |
1007 | + if ( name != "xmlns" ) { |
1008 | + push_back( keys, name ); |
1009 | + push_back( values, att_item->getStringValue() ); |
1010 | + } |
1011 | + } // while |
1012 | + i->close(); |
1013 | +} |
1014 | + |
1015 | +// forward declaration |
1016 | +static void x2j_element( store::Item_t const &element, |
1017 | + store::Item_t *json_item ); |
1018 | + |
1019 | +static void x2j_children( store::Item_t const &parent, |
1020 | + vector<store::Item_t> *children ) { |
1021 | + ZORBA_ASSERT( children ); |
1022 | + store::Iterator_t i( parent->getChildren() ); |
1023 | + i->open(); |
1024 | + store::Item_t child_item, temp_item; |
1025 | + while ( i->next( child_item ) ) { |
1026 | + if ( !x2j_map_atomic( child_item, &temp_item ) ) { |
1027 | + if ( !child_item->isNode() ) |
1028 | + throw XQUERY_EXCEPTION( |
1029 | + zerr::ZJ2X0002_JSONML_OBJECT_BAD_JSON, |
1030 | + ERROR_PARAMS( ZED( ZJ2X0002_BadElement ), child_item->getKind() ) |
1031 | + ); |
1032 | + switch ( child_item->getNodeKind() ) { |
1033 | + case store::StoreConsts::elementNode: |
1034 | + x2j_element( child_item, &temp_item ); |
1035 | + break; |
1036 | + case store::StoreConsts::textNode: { |
1037 | + zstring s( child_item->getStringValue() ); |
1038 | + GENV_ITEMFACTORY->createString( temp_item, s ); |
1039 | + break; |
1040 | + } |
1041 | + default: |
1042 | + continue; |
1043 | + } // switch |
1044 | + } // if |
1045 | + children->push_back( temp_item ); |
1046 | + } // while |
1047 | + i->close(); |
1048 | +} |
1049 | + |
1050 | +static void x2j_element( store::Item_t const &element, |
1051 | + store::Item_t *json_item ) { |
1052 | + ZORBA_ASSERT( json_item ); |
1053 | + vector<store::Item_t> keys, values, children; |
1054 | + |
1055 | + push_back( &keys, "tagName" ); |
1056 | + push_back( &values, name_of( element ) ); |
1057 | + x2j_attributes( element, &keys, &values ); |
1058 | + x2j_children( element, &children ); |
1059 | + if ( !children.empty() ) { |
1060 | + push_back( &keys, "childNodes" ); |
1061 | + store::Item_t temp; |
1062 | + GENV_ITEMFACTORY->createJSONArray( temp, children ); |
1063 | + values.push_back( temp ); |
1064 | + } |
1065 | + GENV_ITEMFACTORY->createJSONObject( *json_item, keys, values ); |
1066 | +} |
1067 | + |
1068 | +void xml_to_json( store::Item_t const &xml_item, store::Item_t *json_item ) { |
1069 | + ZORBA_ASSERT( json_item ); |
1070 | + switch ( xml_item->getNodeKind() ) { |
1071 | + case store::StoreConsts::elementNode: |
1072 | + x2j_element( xml_item, json_item ); |
1073 | + break; |
1074 | + default: |
1075 | + throw XQUERY_EXCEPTION( zerr::ZJSE0001_NOT_ELEMENT_NODE ); |
1076 | + } |
1077 | +} |
1078 | + |
1079 | +/////////////////////////////////////////////////////////////////////////////// |
1080 | + |
1081 | +} // namespace jsonml_object |
1082 | +} // namespace zorba |
1083 | +/* vim:set et sw=2 ts=2: */ |
1084 | |
1085 | === added file 'src/runtime/json/jsonml_object.h' |
1086 | --- src/runtime/json/jsonml_object.h 1970-01-01 00:00:00 +0000 |
1087 | +++ src/runtime/json/jsonml_object.h 2013-12-13 15:32:04 +0000 |
1088 | @@ -0,0 +1,36 @@ |
1089 | +/* |
1090 | + * Copyright 2006-2011 The FLWOR Foundation. |
1091 | + * |
1092 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
1093 | + * you may not use this file except in compliance with the License. |
1094 | + * You may obtain a copy of the License at |
1095 | + * |
1096 | + * http://www.apache.org/licenses/LICENSE-2.0 |
1097 | + * |
1098 | + * Unless required by applicable law or agreed to in writing, software |
1099 | + * distributed under the License is distributed on an "AS IS" BASIS, |
1100 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
1101 | + * See the License for the specific language governing permissions and |
1102 | + * limitations under the License. |
1103 | + */ |
1104 | +#include "stdafx.h" |
1105 | + |
1106 | +#ifndef ZORBA_RUNTIME_JSON_JSONML_OBJECT_H |
1107 | +#define ZORBA_RUNTIME_JSON_JSONML_OBJECT_H |
1108 | + |
1109 | +#include "store/api/item.h" |
1110 | + |
1111 | +namespace zorba { |
1112 | +namespace jsonml_object { |
1113 | + |
1114 | +/////////////////////////////////////////////////////////////////////////////// |
1115 | + |
1116 | +void json_to_xml( store::Item_t const &json_item, store::Item_t *xml_item ); |
1117 | +void xml_to_json( store::Item_t const &xml_item, store::Item_t *json_item ); |
1118 | + |
1119 | +/////////////////////////////////////////////////////////////////////////////// |
1120 | + |
1121 | +} // namespace jsonml_object |
1122 | +} // namespace zorba |
1123 | +#endif /* ZORBA_RUNTIME_JSON_JSONML_OBJECT_H */ |
1124 | +/* vim:set et sw=2 ts=2: */ |
1125 | |
1126 | === modified file 'src/zorbautils/CMakeLists.txt' |
1127 | --- src/zorbautils/CMakeLists.txt 2013-06-11 23:38:49 +0000 |
1128 | +++ src/zorbautils/CMakeLists.txt 2013-12-13 15:32:04 +0000 |
1129 | @@ -23,6 +23,7 @@ |
1130 | lock.cpp |
1131 | runnable.cpp |
1132 | synchronous_logger.cpp |
1133 | + store_util.cpp |
1134 | string_util.cpp) |
1135 | |
1136 | IF (ZORBA_WITH_LIBXML2_SAX) |
1137 | |
1138 | === added file 'src/zorbautils/store_util.cpp' |
1139 | --- src/zorbautils/store_util.cpp 1970-01-01 00:00:00 +0000 |
1140 | +++ src/zorbautils/store_util.cpp 2013-12-13 15:32:04 +0000 |
1141 | @@ -0,0 +1,46 @@ |
1142 | +/* |
1143 | + * Copyright 2006-2013 The FLWOR Foundation. |
1144 | + * |
1145 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
1146 | + * you may not use this file except in compliance with the License. |
1147 | + * You may obtain a copy of the License at |
1148 | + * |
1149 | + * http://www.apache.org/licenses/LICENSE-2.0 |
1150 | + * |
1151 | + * Unless required by applicable law or agreed to in writing, software |
1152 | + * distributed under the License is distributed on an "AS IS" BASIS, |
1153 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
1154 | + * See the License for the specific language governing permissions and |
1155 | + * limitations under the License. |
1156 | + */ |
1157 | + |
1158 | +#include "store/api/item_factory.h" |
1159 | +#include "system/globalenv.h" |
1160 | + |
1161 | +#include "store_util.h" |
1162 | + |
1163 | +using namespace std; |
1164 | + |
1165 | +namespace zorba { |
1166 | + |
1167 | +/////////////////////////////////////////////////////////////////////////////// |
1168 | + |
1169 | +store::Item_t get_json_value( store::Item_t const &json_object, |
1170 | + char const *key ) { |
1171 | + zstring s( key ); |
1172 | + store::Item_t key_item; |
1173 | + GENV_ITEMFACTORY->createString( key_item, s ); |
1174 | + return json_object->getObjectValue( key_item ); |
1175 | +} |
1176 | + |
1177 | +void push_back( vector<store::Item_t> *v, char const *s ) { |
1178 | + zstring s2( s ); |
1179 | + store::Item_t item; |
1180 | + GENV_ITEMFACTORY->createString( item, s2 ); |
1181 | + v->push_back( item ); |
1182 | +} |
1183 | + |
1184 | +/////////////////////////////////////////////////////////////////////////////// |
1185 | + |
1186 | +} // namespace zorba |
1187 | +/* vim:set et sw=2 ts=2: */ |
1188 | |
1189 | === added file 'src/zorbautils/store_util.h' |
1190 | --- src/zorbautils/store_util.h 1970-01-01 00:00:00 +0000 |
1191 | +++ src/zorbautils/store_util.h 2013-12-13 15:32:04 +0000 |
1192 | @@ -0,0 +1,67 @@ |
1193 | +/* |
1194 | + * Copyright 2006-2013 The FLWOR Foundation. |
1195 | + * |
1196 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
1197 | + * you may not use this file except in compliance with the License. |
1198 | + * You may obtain a copy of the License at |
1199 | + * |
1200 | + * http://www.apache.org/licenses/LICENSE-2.0 |
1201 | + * |
1202 | + * Unless required by applicable law or agreed to in writing, software |
1203 | + * distributed under the License is distributed on an "AS IS" BASIS, |
1204 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
1205 | + * See the License for the specific language governing permissions and |
1206 | + * limitations under the License. |
1207 | + */ |
1208 | + |
1209 | +#pragma once |
1210 | +#ifndef ZORBA_STORE_UTIL_H |
1211 | +#define ZORBA_STORE_UTIL_H |
1212 | + |
1213 | +#include <vector> |
1214 | + |
1215 | +#include <zorba/internal/ztd.h> |
1216 | + |
1217 | +#include "store/api/item.h" |
1218 | + |
1219 | +namespace zorba { |
1220 | + |
1221 | +/////////////////////////////////////////////////////////////////////////////// |
1222 | + |
1223 | +/** |
1224 | + * Convenience function for getting the value for the given key of a JSON |
1225 | + * object. |
1226 | + * |
1227 | + * @param json_object The JSON object to get the value from. |
1228 | + * @param key The key to get the value for. |
1229 | + * @return Returns said value. |
1230 | + */ |
1231 | +store::Item_t get_json_value( store::Item_t const &json_object, |
1232 | + char const *key ); |
1233 | + |
1234 | +/** |
1235 | + * Pushes a newly created string Item onto the back of the given vector. |
1236 | + * |
1237 | + * @param v A pointer to the vector to push the new Item onto the back of. |
1238 | + * @param s The string to create the string Item from. |
1239 | + */ |
1240 | +void push_back( std::vector<store::Item_t> *v, char const *s ); |
1241 | + |
1242 | +/** |
1243 | + * Pushes a newly created string Item onto the back of the given vector. |
1244 | + * |
1245 | + * @tparam The stiring type. |
1246 | + * @param v A pointer to the vector to push the new Item onto the back of. |
1247 | + * @param s The string to create the string Item from. |
1248 | + */ |
1249 | +template<class StringType> inline |
1250 | +typename std::enable_if<ZORBA_HAS_C_STR(StringType),void>::type |
1251 | +push_back( std::vector<store::Item_t> *v, StringType const &s ) { |
1252 | + push_back( v, s.c_str() ); |
1253 | +} |
1254 | + |
1255 | +/////////////////////////////////////////////////////////////////////////////// |
1256 | + |
1257 | +} // namespace zorba |
1258 | +#endif /* ZORBA_STORE_UTIL_H */ |
1259 | +/* vim:set et sw=2 ts=2: */ |
1260 | |
1261 | === modified file 'test/rbkt/ExpQueryResults/zorba/json/json-jmla-x2j-03.xml.res' |
1262 | --- test/rbkt/ExpQueryResults/zorba/json/json-jmla-x2j-03.xml.res 2013-07-25 03:41:28 +0000 |
1263 | +++ test/rbkt/ExpQueryResults/zorba/json/json-jmla-x2j-03.xml.res 2013-12-13 15:32:04 +0000 |
1264 | @@ -1,1 +1,6 @@ |
1265 | -[ "file", { "dir" : "/tmp", "name" : "foo", "size" : "1234", "modified" : "2006-12-31T23:59" } ] |
1266 | +[ "file", { |
1267 | + "dir" : "/tmp", |
1268 | + "name" : "foo", |
1269 | + "size" : "1234", |
1270 | + "modified" : "2006-12-31T23:59" |
1271 | +} ] |
1272 | |
1273 | === modified file 'test/rbkt/ExpQueryResults/zorba/json/json-jmla-x2j-wikipedia.xml.res' |
1274 | --- test/rbkt/ExpQueryResults/zorba/json/json-jmla-x2j-wikipedia.xml.res 2013-07-25 03:41:28 +0000 |
1275 | +++ test/rbkt/ExpQueryResults/zorba/json/json-jmla-x2j-wikipedia.xml.res 2013-12-13 15:32:04 +0000 |
1276 | @@ -1,1 +1,6 @@ |
1277 | -[ "person", { "created" : "2006-11-11T19:23", "modified" : "2006-12-31T23:59" }, [ "firstName", "Robert" ], [ "lastName", "Smith" ], [ "address", { "type" : "home" }, [ "street", "12345 Sixth Ave" ], [ "city", "Anytown" ], [ "state", "CA" ], [ "postalCode", "98765-4321" ] ] ] |
1278 | +[ "person", { |
1279 | + "created" : "2006-11-11T19:23", |
1280 | + "modified" : "2006-12-31T23:59" |
1281 | +}, [ "firstName", "Robert" ], [ "lastName", "Smith" ], [ "address", { |
1282 | + "type" : "home" |
1283 | +}, [ "street", "12345 Sixth Ave" ], [ "city", "Anytown" ], [ "state", "CA" ], [ "postalCode", "98765-4321" ] ] ] |
1284 | |
1285 | === added file 'test/rbkt/ExpQueryResults/zorba/json/json-jmlo-j2x-01.xml.res' |
1286 | --- test/rbkt/ExpQueryResults/zorba/json/json-jmlo-j2x-01.xml.res 1970-01-01 00:00:00 +0000 |
1287 | +++ test/rbkt/ExpQueryResults/zorba/json/json-jmlo-j2x-01.xml.res 2013-12-13 15:32:04 +0000 |
1288 | @@ -0,0 +1,1 @@ |
1289 | +<li>list item</li> |
1290 | |
1291 | === added file 'test/rbkt/ExpQueryResults/zorba/json/json-jmlo-j2x-02.xml.res' |
1292 | --- test/rbkt/ExpQueryResults/zorba/json/json-jmlo-j2x-02.xml.res 1970-01-01 00:00:00 +0000 |
1293 | +++ test/rbkt/ExpQueryResults/zorba/json/json-jmlo-j2x-02.xml.res 2013-12-13 15:32:04 +0000 |
1294 | @@ -0,0 +1,4 @@ |
1295 | +<ul> |
1296 | + <li>list item 1</li> |
1297 | + <li>list item 2</li> |
1298 | +</ul> |
1299 | |
1300 | === added file 'test/rbkt/ExpQueryResults/zorba/json/json-jmlo-j2x-03.xml.res' |
1301 | --- test/rbkt/ExpQueryResults/zorba/json/json-jmlo-j2x-03.xml.res 1970-01-01 00:00:00 +0000 |
1302 | +++ test/rbkt/ExpQueryResults/zorba/json/json-jmlo-j2x-03.xml.res 2013-12-13 15:32:04 +0000 |
1303 | @@ -0,0 +1,1 @@ |
1304 | +<file dir="/tmp" name="foo" size="1234" modified="2006-12-31T23:59"/> |
1305 | |
1306 | === added file 'test/rbkt/ExpQueryResults/zorba/json/json-jmlo-j2x-04.xml.res' |
1307 | --- test/rbkt/ExpQueryResults/zorba/json/json-jmlo-j2x-04.xml.res 1970-01-01 00:00:00 +0000 |
1308 | +++ test/rbkt/ExpQueryResults/zorba/json/json-jmlo-j2x-04.xml.res 2013-12-13 15:32:04 +0000 |
1309 | @@ -0,0 +1,6 @@ |
1310 | +<ul> |
1311 | + <li style="color:red">First Item</li> |
1312 | + <li title="Some hover text." style="color:green">Second Item</li> |
1313 | + <li> |
1314 | + <span class="code-example-third">Third</span> Item</li> |
1315 | +</ul> |
1316 | |
1317 | === added file 'test/rbkt/ExpQueryResults/zorba/json/json-jmlo-j2x-05.xml.res' |
1318 | --- test/rbkt/ExpQueryResults/zorba/json/json-jmlo-j2x-05.xml.res 1970-01-01 00:00:00 +0000 |
1319 | +++ test/rbkt/ExpQueryResults/zorba/json/json-jmlo-j2x-05.xml.res 2013-12-13 15:32:04 +0000 |
1320 | @@ -0,0 +1,14 @@ |
1321 | +<table class="MyTable" style="background-color:yellow"> |
1322 | + <tr> |
1323 | + <td class="MyTD" style="border:1px solid black">#550758</td> |
1324 | + <td class="MyTD" style="background-color:red">Example text here</td> |
1325 | + </tr> |
1326 | + <tr> |
1327 | + <td class="MyTD" style="border:1px solid black">#993101</td> |
1328 | + <td class="MyTD" style="background-color:green">127624015</td> |
1329 | + </tr> |
1330 | + <tr> |
1331 | + <td class="MyTD" style="border:1px solid black">#E33D87</td> |
1332 | + <td class="MyTD" style="background-color:blue"> <span style="background-color:maroon">©</span> </td> |
1333 | + </tr> |
1334 | +</table> |
1335 | |
1336 | === added file 'test/rbkt/ExpQueryResults/zorba/json/json-jmlo-j2x-wikipedia.xml.res' |
1337 | --- test/rbkt/ExpQueryResults/zorba/json/json-jmlo-j2x-wikipedia.xml.res 1970-01-01 00:00:00 +0000 |
1338 | +++ test/rbkt/ExpQueryResults/zorba/json/json-jmlo-j2x-wikipedia.xml.res 2013-12-13 15:32:04 +0000 |
1339 | @@ -0,0 +1,10 @@ |
1340 | +<person created="2006-11-11T19:23" modified="2006-12-31T23:59"> |
1341 | + <firstName>Robert</firstName> |
1342 | + <lastName>Smith</lastName> |
1343 | + <address type="home"> |
1344 | + <street>12345 Sixth Ave</street> |
1345 | + <city>Anytown</city> |
1346 | + <state>CA</state> |
1347 | + <postalCode>98765-4321</postalCode> |
1348 | + </address> |
1349 | +</person> |
1350 | |
1351 | === added file 'test/rbkt/ExpQueryResults/zorba/json/json-jmlo-x2j-01.xml.res' |
1352 | --- test/rbkt/ExpQueryResults/zorba/json/json-jmlo-x2j-01.xml.res 1970-01-01 00:00:00 +0000 |
1353 | +++ test/rbkt/ExpQueryResults/zorba/json/json-jmlo-x2j-01.xml.res 2013-12-13 15:32:04 +0000 |
1354 | @@ -0,0 +1,4 @@ |
1355 | +{ |
1356 | + "tagName" : "li", |
1357 | + "childNodes" : [ "list item" ] |
1358 | +} |
1359 | |
1360 | === added file 'test/rbkt/ExpQueryResults/zorba/json/json-jmlo-x2j-02.xml.res' |
1361 | --- test/rbkt/ExpQueryResults/zorba/json/json-jmlo-x2j-02.xml.res 1970-01-01 00:00:00 +0000 |
1362 | +++ test/rbkt/ExpQueryResults/zorba/json/json-jmlo-x2j-02.xml.res 2013-12-13 15:32:04 +0000 |
1363 | @@ -0,0 +1,10 @@ |
1364 | +{ |
1365 | + "tagName" : "ul", |
1366 | + "childNodes" : [ { |
1367 | + "tagName" : "li", |
1368 | + "childNodes" : [ "list item 1" ] |
1369 | + }, { |
1370 | + "tagName" : "li", |
1371 | + "childNodes" : [ "list item 2" ] |
1372 | + } ] |
1373 | +} |
1374 | |
1375 | === added file 'test/rbkt/ExpQueryResults/zorba/json/json-jmlo-x2j-03.xml.res' |
1376 | --- test/rbkt/ExpQueryResults/zorba/json/json-jmlo-x2j-03.xml.res 1970-01-01 00:00:00 +0000 |
1377 | +++ test/rbkt/ExpQueryResults/zorba/json/json-jmlo-x2j-03.xml.res 2013-12-13 15:32:04 +0000 |
1378 | @@ -0,0 +1,7 @@ |
1379 | +{ |
1380 | + "tagName" : "file", |
1381 | + "dir" : "/tmp", |
1382 | + "name" : "foo", |
1383 | + "size" : "1234", |
1384 | + "modified" : "2006-12-31T23:59" |
1385 | +} |
1386 | |
1387 | === added file 'test/rbkt/ExpQueryResults/zorba/json/json-jmlo-x2j-wikipedia.xml.res' |
1388 | --- test/rbkt/ExpQueryResults/zorba/json/json-jmlo-x2j-wikipedia.xml.res 1970-01-01 00:00:00 +0000 |
1389 | +++ test/rbkt/ExpQueryResults/zorba/json/json-jmlo-x2j-wikipedia.xml.res 2013-12-13 15:32:04 +0000 |
1390 | @@ -0,0 +1,28 @@ |
1391 | +{ |
1392 | + "tagName" : "person", |
1393 | + "created" : "2006-11-11T19:23", |
1394 | + "modified" : "2006-12-31T23:59", |
1395 | + "childNodes" : [ { |
1396 | + "tagName" : "firstName", |
1397 | + "childNodes" : [ "Robert" ] |
1398 | + }, { |
1399 | + "tagName" : "lastName", |
1400 | + "childNodes" : [ "Smith" ] |
1401 | + }, { |
1402 | + "tagName" : "address", |
1403 | + "type" : "home", |
1404 | + "childNodes" : [ { |
1405 | + "tagName" : "street", |
1406 | + "childNodes" : [ "12345 Sixth Ave" ] |
1407 | + }, { |
1408 | + "tagName" : "city", |
1409 | + "childNodes" : [ "Anytown" ] |
1410 | + }, { |
1411 | + "tagName" : "state", |
1412 | + "childNodes" : [ "CA" ] |
1413 | + }, { |
1414 | + "tagName" : "postalCode", |
1415 | + "childNodes" : [ "98765-4321" ] |
1416 | + } ] |
1417 | + } ] |
1418 | +} |
1419 | |
1420 | === added file 'test/rbkt/Queries/zorba/json/json-jmla-x2j-01.spec' |
1421 | --- test/rbkt/Queries/zorba/json/json-jmla-x2j-01.spec 1970-01-01 00:00:00 +0000 |
1422 | +++ test/rbkt/Queries/zorba/json/json-jmla-x2j-01.spec 2013-12-13 15:32:04 +0000 |
1423 | @@ -0,0 +1,1 @@ |
1424 | +Serialization: indent=yes |
1425 | |
1426 | === added file 'test/rbkt/Queries/zorba/json/json-jmla-x2j-02.spec' |
1427 | --- test/rbkt/Queries/zorba/json/json-jmla-x2j-02.spec 1970-01-01 00:00:00 +0000 |
1428 | +++ test/rbkt/Queries/zorba/json/json-jmla-x2j-02.spec 2013-12-13 15:32:04 +0000 |
1429 | @@ -0,0 +1,1 @@ |
1430 | +Serialization: indent=yes |
1431 | |
1432 | === added file 'test/rbkt/Queries/zorba/json/json-jmla-x2j-03.spec' |
1433 | --- test/rbkt/Queries/zorba/json/json-jmla-x2j-03.spec 1970-01-01 00:00:00 +0000 |
1434 | +++ test/rbkt/Queries/zorba/json/json-jmla-x2j-03.spec 2013-12-13 15:32:04 +0000 |
1435 | @@ -0,0 +1,1 @@ |
1436 | +Serialization: indent=yes |
1437 | |
1438 | === added file 'test/rbkt/Queries/zorba/json/json-jmla-x2j-wikipedia.spec' |
1439 | --- test/rbkt/Queries/zorba/json/json-jmla-x2j-wikipedia.spec 1970-01-01 00:00:00 +0000 |
1440 | +++ test/rbkt/Queries/zorba/json/json-jmla-x2j-wikipedia.spec 2013-12-13 15:32:04 +0000 |
1441 | @@ -0,0 +1,1 @@ |
1442 | +Serialization: indent=yes |
1443 | |
1444 | === added file 'test/rbkt/Queries/zorba/json/json-jmlo-j2x-01.xq' |
1445 | --- test/rbkt/Queries/zorba/json/json-jmlo-j2x-01.xq 1970-01-01 00:00:00 +0000 |
1446 | +++ test/rbkt/Queries/zorba/json/json-jmlo-j2x-01.xq 2013-12-13 15:32:04 +0000 |
1447 | @@ -0,0 +1,13 @@ |
1448 | +(: Simple JsonML (object form) :) |
1449 | + |
1450 | +import module namespace jx = "http://zorba.io/modules/json-xml"; |
1451 | + |
1452 | +let $json := |
1453 | + { |
1454 | + "tagName": "li", |
1455 | + "childNodes" : [ "list item" ] |
1456 | + } |
1457 | +let $options := { "json-format" : "JsonML-object" } |
1458 | +return jx:json-to-xml( $json, $options ) |
1459 | + |
1460 | +(: vim:set et sw=2 ts=2: :) |
1461 | |
1462 | === added file 'test/rbkt/Queries/zorba/json/json-jmlo-j2x-02.xq' |
1463 | --- test/rbkt/Queries/zorba/json/json-jmlo-j2x-02.xq 1970-01-01 00:00:00 +0000 |
1464 | +++ test/rbkt/Queries/zorba/json/json-jmlo-j2x-02.xq 2013-12-13 15:32:04 +0000 |
1465 | @@ -0,0 +1,16 @@ |
1466 | +(: Multi-level JsonML (object form) :) |
1467 | + |
1468 | +import module namespace jx = "http://zorba.io/modules/json-xml"; |
1469 | + |
1470 | +let $json := |
1471 | + { |
1472 | + "tagName" : "ul", |
1473 | + "childNodes" : [ |
1474 | + { "tagName" : "li", "childNodes" : [ "list item 1" ] }, |
1475 | + { "tagName" : "li", "childNodes" : [ "list item 2" ] } |
1476 | + ] |
1477 | + } |
1478 | +let $options := { "json-format" : "JsonML-object" } |
1479 | +return jx:json-to-xml( $json, $options ) |
1480 | + |
1481 | +(: vim:set et sw=2 ts=2: :) |
1482 | |
1483 | === added file 'test/rbkt/Queries/zorba/json/json-jmlo-j2x-03.xq' |
1484 | --- test/rbkt/Queries/zorba/json/json-jmlo-j2x-03.xq 1970-01-01 00:00:00 +0000 |
1485 | +++ test/rbkt/Queries/zorba/json/json-jmlo-j2x-03.xq 2013-12-13 15:32:04 +0000 |
1486 | @@ -0,0 +1,16 @@ |
1487 | +(: JsonML (object form) with attributes :) |
1488 | + |
1489 | +import module namespace jx = "http://zorba.io/modules/json-xml"; |
1490 | + |
1491 | +let $json := |
1492 | + { |
1493 | + "tagName" : "file", |
1494 | + "dir" : "/tmp", |
1495 | + "name" : "foo", |
1496 | + "size" : 1234, |
1497 | + "modified" : "2006-12-31T23:59" |
1498 | + } |
1499 | +let $options := { "json-format" : "JsonML-object" } |
1500 | +return jx:json-to-xml( $json, $options ) |
1501 | + |
1502 | +(: vim:set et sw=2 ts=2: :) |
1503 | |
1504 | === added file 'test/rbkt/Queries/zorba/json/json-jmlo-j2x-04.spec' |
1505 | --- test/rbkt/Queries/zorba/json/json-jmlo-j2x-04.spec 1970-01-01 00:00:00 +0000 |
1506 | +++ test/rbkt/Queries/zorba/json/json-jmlo-j2x-04.spec 2013-12-13 15:32:04 +0000 |
1507 | @@ -0,0 +1,1 @@ |
1508 | +Comparison: Fragment |
1509 | |
1510 | === added file 'test/rbkt/Queries/zorba/json/json-jmlo-j2x-04.xq' |
1511 | --- test/rbkt/Queries/zorba/json/json-jmlo-j2x-04.xq 1970-01-01 00:00:00 +0000 |
1512 | +++ test/rbkt/Queries/zorba/json/json-jmlo-j2x-04.xq 2013-12-13 15:32:04 +0000 |
1513 | @@ -0,0 +1,34 @@ |
1514 | +import module namespace jx = "http://zorba.io/modules/json-xml"; |
1515 | + |
1516 | +let $json := |
1517 | + { |
1518 | + "tagName" : "ul", |
1519 | + "childNodes" : [ |
1520 | + { |
1521 | + "tagName" : "li", |
1522 | + "style" : "color:red", |
1523 | + "childNodes" : [ "First Item" ] |
1524 | + }, |
1525 | + { |
1526 | + "tagName" : "li", |
1527 | + "title" : "Some hover text.", |
1528 | + "style" : "color:green", |
1529 | + "childNodes" : [ "Second Item" ] |
1530 | + }, |
1531 | + { |
1532 | + "tagName" : "li", |
1533 | + "childNodes" : [ |
1534 | + { |
1535 | + "tagName" : "span", |
1536 | + "class" : "code-example-third", |
1537 | + "childNodes" : [ "Third" ] |
1538 | + }, |
1539 | + " Item" |
1540 | + ] |
1541 | + } |
1542 | + ] |
1543 | + } |
1544 | +let $options := { "json-format" : "JsonML-object" } |
1545 | +return jx:json-to-xml( $json, $options ) |
1546 | + |
1547 | +(: vim:se et sw=2 ts=2: :) |
1548 | |
1549 | === added file 'test/rbkt/Queries/zorba/json/json-jmlo-j2x-05.spec' |
1550 | --- test/rbkt/Queries/zorba/json/json-jmlo-j2x-05.spec 1970-01-01 00:00:00 +0000 |
1551 | +++ test/rbkt/Queries/zorba/json/json-jmlo-j2x-05.spec 2013-12-13 15:32:04 +0000 |
1552 | @@ -0,0 +1,1 @@ |
1553 | +Comparison: Fragment |
1554 | |
1555 | === added file 'test/rbkt/Queries/zorba/json/json-jmlo-j2x-05.xq' |
1556 | --- test/rbkt/Queries/zorba/json/json-jmlo-j2x-05.xq 1970-01-01 00:00:00 +0000 |
1557 | +++ test/rbkt/Queries/zorba/json/json-jmlo-j2x-05.xq 2013-12-13 15:32:04 +0000 |
1558 | @@ -0,0 +1,58 @@ |
1559 | +jsoniq version "1.0"; |
1560 | + |
1561 | +import module namespace jx = "http://zorba.io/modules/json-xml"; |
1562 | + |
1563 | +let $j := |
1564 | + { |
1565 | + "tagName" : "table", |
1566 | + "class" : "MyTable", |
1567 | + "style" : "background-color:yellow", |
1568 | + "childNodes" : [ { |
1569 | + "tagName" : "tr", |
1570 | + "childNodes" : [ { |
1571 | + "tagName" : "td", |
1572 | + "class" : "MyTD", |
1573 | + "style" : "border:1px solid black", |
1574 | + "childNodes" : [ "#550758" ] |
1575 | + }, { |
1576 | + "tagName" : "td", |
1577 | + "class" : "MyTD", |
1578 | + "style" : "background-color:red", |
1579 | + "childNodes" : [ "Example text here" ] |
1580 | + } ] |
1581 | + }, { |
1582 | + "tagName" : "tr", |
1583 | + "childNodes" : [ { |
1584 | + "tagName" : "td", |
1585 | + "class" : "MyTD", |
1586 | + "style" : "border:1px solid black", |
1587 | + "childNodes" : [ "#993101" ] |
1588 | + }, { |
1589 | + "tagName" : "td", |
1590 | + "class" : "MyTD", |
1591 | + "style" : "background-color:green", |
1592 | + "childNodes" : [ "127624015" ] |
1593 | + } ] |
1594 | + }, { |
1595 | + "tagName" : "tr", |
1596 | + "childNodes" : [ { |
1597 | + "tagName" : "td", |
1598 | + "class" : "MyTD", |
1599 | + "style" : "border:1px solid black", |
1600 | + "childNodes" : [ "#E33D87" ] |
1601 | + }, { |
1602 | + "tagName" : "td", |
1603 | + "class" : "MyTD", |
1604 | + "style" : "background-color:blue", |
1605 | + "childNodes" : [ " ", { |
1606 | + "tagName" : "span", |
1607 | + "style" : "background-color:maroon", |
1608 | + "childNodes" : [ "\u00A9" ] |
1609 | + }, " " ] |
1610 | + } ] |
1611 | + } ] |
1612 | + } |
1613 | +let $options := { "json-format" : "JsonML-object" } |
1614 | +return jx:json-to-xml( $j, $options ) |
1615 | + |
1616 | +(: vim:se et sw=2 ts=2: :) |
1617 | |
1618 | === added file 'test/rbkt/Queries/zorba/json/json-jmlo-j2x-06.spec' |
1619 | --- test/rbkt/Queries/zorba/json/json-jmlo-j2x-06.spec 1970-01-01 00:00:00 +0000 |
1620 | +++ test/rbkt/Queries/zorba/json/json-jmlo-j2x-06.spec 2013-12-13 15:32:04 +0000 |
1621 | @@ -0,0 +1,1 @@ |
1622 | +Error: http://zorba.io/errors:ZJ2X0002 |
1623 | |
1624 | === added file 'test/rbkt/Queries/zorba/json/json-jmlo-j2x-06.xq' |
1625 | --- test/rbkt/Queries/zorba/json/json-jmlo-j2x-06.xq 1970-01-01 00:00:00 +0000 |
1626 | +++ test/rbkt/Queries/zorba/json/json-jmlo-j2x-06.xq 2013-12-13 15:32:04 +0000 |
1627 | @@ -0,0 +1,9 @@ |
1628 | +(: try parsing an empty value :) |
1629 | + |
1630 | +import module namespace jx = "http://zorba.io/modules/json-xml"; |
1631 | + |
1632 | +let $json := { } |
1633 | +let $options := { "json-format" : "JsonML-object" } |
1634 | +return jx:json-to-xml( $json, $options ) |
1635 | + |
1636 | +(: vim:set et sw=2 ts=2: :) |
1637 | |
1638 | === added file 'test/rbkt/Queries/zorba/json/json-jmlo-j2x-07.spec' |
1639 | --- test/rbkt/Queries/zorba/json/json-jmlo-j2x-07.spec 1970-01-01 00:00:00 +0000 |
1640 | +++ test/rbkt/Queries/zorba/json/json-jmlo-j2x-07.spec 2013-12-13 15:32:04 +0000 |
1641 | @@ -0,0 +1,1 @@ |
1642 | +Error: http://zorba.io/errors:ZJ2X0002 |
1643 | |
1644 | === added file 'test/rbkt/Queries/zorba/json/json-jmlo-j2x-07.xq' |
1645 | --- test/rbkt/Queries/zorba/json/json-jmlo-j2x-07.xq 1970-01-01 00:00:00 +0000 |
1646 | +++ test/rbkt/Queries/zorba/json/json-jmlo-j2x-07.xq 2013-12-13 15:32:04 +0000 |
1647 | @@ -0,0 +1,7 @@ |
1648 | +import module namespace jx = "http://zorba.io/modules/json-xml"; |
1649 | + |
1650 | +let $json := [ "args", "<div><span>foo:</span> parse</div>" ] |
1651 | +let $options := { "json-format" : "JsonML-object" } |
1652 | +return jx:json-to-xml( $json, $options ) |
1653 | + |
1654 | +(: vim:set et sw=2 ts=2: :) |
1655 | |
1656 | === added file 'test/rbkt/Queries/zorba/json/json-jmlo-j2x-08.spec' |
1657 | --- test/rbkt/Queries/zorba/json/json-jmlo-j2x-08.spec 1970-01-01 00:00:00 +0000 |
1658 | +++ test/rbkt/Queries/zorba/json/json-jmlo-j2x-08.spec 2013-12-13 15:32:04 +0000 |
1659 | @@ -0,0 +1,1 @@ |
1660 | +Error: http://zorba.io/errors:ZJ2X0002 |
1661 | |
1662 | === added file 'test/rbkt/Queries/zorba/json/json-jmlo-j2x-08.xq' |
1663 | --- test/rbkt/Queries/zorba/json/json-jmlo-j2x-08.xq 1970-01-01 00:00:00 +0000 |
1664 | +++ test/rbkt/Queries/zorba/json/json-jmlo-j2x-08.xq 2013-12-13 15:32:04 +0000 |
1665 | @@ -0,0 +1,7 @@ |
1666 | +import module namespace jx = "http://zorba.io/modules/json-xml"; |
1667 | + |
1668 | +let $json := { "x" : "x" } |
1669 | +let $options := { "json-format" : "JsonML-object" } |
1670 | +return jx:json-to-xml( $json, $options ) |
1671 | + |
1672 | +(: vim:set et sw=2 ts=2: :) |
1673 | |
1674 | === added file 'test/rbkt/Queries/zorba/json/json-jmlo-j2x-wikipedia.xq' |
1675 | --- test/rbkt/Queries/zorba/json/json-jmlo-j2x-wikipedia.xq 1970-01-01 00:00:00 +0000 |
1676 | +++ test/rbkt/Queries/zorba/json/json-jmlo-j2x-wikipedia.xq 2013-12-13 15:32:04 +0000 |
1677 | @@ -0,0 +1,44 @@ |
1678 | +import module namespace jx = "http://zorba.io/modules/json-xml"; |
1679 | + |
1680 | +let $json := |
1681 | + { |
1682 | + "tagName" : "person", |
1683 | + "created" : "2006-11-11T19:23", |
1684 | + "modified" : "2006-12-31T23:59", |
1685 | + "childNodes" : [ |
1686 | + { |
1687 | + "tagName" : "firstName", |
1688 | + "childNodes" : [ "Robert" ] |
1689 | + }, |
1690 | + { |
1691 | + "tagName" : "lastName", |
1692 | + "childNodes" : [ "Smith" ] |
1693 | + }, |
1694 | + { |
1695 | + "tagName" : "address", |
1696 | + "type" : "home", |
1697 | + "childNodes" : [ |
1698 | + { |
1699 | + "tagName" : "street", |
1700 | + "childNodes" : [ "12345 Sixth Ave" ] |
1701 | + }, |
1702 | + { |
1703 | + "tagName" : "city", |
1704 | + "childNodes" : [ "Anytown" ] |
1705 | + }, |
1706 | + { |
1707 | + "tagName" : "state", |
1708 | + "childNodes" : [ "CA" ] |
1709 | + }, |
1710 | + { |
1711 | + "tagName" : "postalCode", |
1712 | + "childNodes" : [ "98765-4321" ] |
1713 | + } |
1714 | + ] |
1715 | + } |
1716 | + ] |
1717 | + } |
1718 | +let $options := { "json-format" : "JsonML-object" } |
1719 | +return jx:json-to-xml( $json, $options ) |
1720 | + |
1721 | +(: vim:set et sw=2 ts=2: :) |
1722 | |
1723 | === added file 'test/rbkt/Queries/zorba/json/json-jmlo-x2j-01.spec' |
1724 | --- test/rbkt/Queries/zorba/json/json-jmlo-x2j-01.spec 1970-01-01 00:00:00 +0000 |
1725 | +++ test/rbkt/Queries/zorba/json/json-jmlo-x2j-01.spec 2013-12-13 15:32:04 +0000 |
1726 | @@ -0,0 +1,1 @@ |
1727 | +Serialization: indent=yes |
1728 | |
1729 | === added file 'test/rbkt/Queries/zorba/json/json-jmlo-x2j-01.xq' |
1730 | --- test/rbkt/Queries/zorba/json/json-jmlo-x2j-01.xq 1970-01-01 00:00:00 +0000 |
1731 | +++ test/rbkt/Queries/zorba/json/json-jmlo-x2j-01.xq 2013-12-13 15:32:04 +0000 |
1732 | @@ -0,0 +1,7 @@ |
1733 | +import module namespace jx = "http://zorba.io/modules/json-xml"; |
1734 | + |
1735 | +let $xml := <li>list item</li> |
1736 | +let $options := { "json-format" : "JsonML-object" } |
1737 | +return jx:xml-to-json( $xml, $options ) |
1738 | + |
1739 | +(: vim:set et sw=2 ts=2: :) |
1740 | |
1741 | === added file 'test/rbkt/Queries/zorba/json/json-jmlo-x2j-02.spec' |
1742 | --- test/rbkt/Queries/zorba/json/json-jmlo-x2j-02.spec 1970-01-01 00:00:00 +0000 |
1743 | +++ test/rbkt/Queries/zorba/json/json-jmlo-x2j-02.spec 2013-12-13 15:32:04 +0000 |
1744 | @@ -0,0 +1,1 @@ |
1745 | +Serialization: indent=yes |
1746 | |
1747 | === added file 'test/rbkt/Queries/zorba/json/json-jmlo-x2j-02.xq' |
1748 | --- test/rbkt/Queries/zorba/json/json-jmlo-x2j-02.xq 1970-01-01 00:00:00 +0000 |
1749 | +++ test/rbkt/Queries/zorba/json/json-jmlo-x2j-02.xq 2013-12-13 15:32:04 +0000 |
1750 | @@ -0,0 +1,11 @@ |
1751 | +import module namespace jx = "http://zorba.io/modules/json-xml"; |
1752 | + |
1753 | +let $xml := |
1754 | + <ul> |
1755 | + <li>list item 1</li> |
1756 | + <li>list item 2</li> |
1757 | + </ul> |
1758 | +let $options := { "json-format" : "JsonML-object" } |
1759 | +return jx:xml-to-json( $xml, $options ) |
1760 | + |
1761 | +(: vim:set et sw=2 ts=2: :) |
1762 | |
1763 | === added file 'test/rbkt/Queries/zorba/json/json-jmlo-x2j-03.spec' |
1764 | --- test/rbkt/Queries/zorba/json/json-jmlo-x2j-03.spec 1970-01-01 00:00:00 +0000 |
1765 | +++ test/rbkt/Queries/zorba/json/json-jmlo-x2j-03.spec 2013-12-13 15:32:04 +0000 |
1766 | @@ -0,0 +1,1 @@ |
1767 | +Serialization: indent=yes |
1768 | |
1769 | === added file 'test/rbkt/Queries/zorba/json/json-jmlo-x2j-03.xq' |
1770 | --- test/rbkt/Queries/zorba/json/json-jmlo-x2j-03.xq 1970-01-01 00:00:00 +0000 |
1771 | +++ test/rbkt/Queries/zorba/json/json-jmlo-x2j-03.xq 2013-12-13 15:32:04 +0000 |
1772 | @@ -0,0 +1,8 @@ |
1773 | +import module namespace jx = "http://zorba.io/modules/json-xml"; |
1774 | + |
1775 | +let $xml := |
1776 | + <file dir="/tmp" name="foo" size="1234" modified="2006-12-31T23:59"/> |
1777 | +let $options := { "json-format" : "JsonML-object" } |
1778 | +return jx:xml-to-json( $xml, $options ) |
1779 | + |
1780 | +(: vim:set et sw=2 ts=2: :) |
1781 | |
1782 | === added file 'test/rbkt/Queries/zorba/json/json-jmlo-x2j-wikipedia.spec' |
1783 | --- test/rbkt/Queries/zorba/json/json-jmlo-x2j-wikipedia.spec 1970-01-01 00:00:00 +0000 |
1784 | +++ test/rbkt/Queries/zorba/json/json-jmlo-x2j-wikipedia.spec 2013-12-13 15:32:04 +0000 |
1785 | @@ -0,0 +1,1 @@ |
1786 | +Serialization: indent=yes |
1787 | |
1788 | === added file 'test/rbkt/Queries/zorba/json/json-jmlo-x2j-wikipedia.xq' |
1789 | --- test/rbkt/Queries/zorba/json/json-jmlo-x2j-wikipedia.xq 1970-01-01 00:00:00 +0000 |
1790 | +++ test/rbkt/Queries/zorba/json/json-jmlo-x2j-wikipedia.xq 2013-12-13 15:32:04 +0000 |
1791 | @@ -0,0 +1,17 @@ |
1792 | +import module namespace jx = "http://zorba.io/modules/json-xml"; |
1793 | + |
1794 | +let $xml := |
1795 | + <person created="2006-11-11T19:23" modified="2006-12-31T23:59"> |
1796 | + <firstName>Robert</firstName> |
1797 | + <lastName>Smith</lastName> |
1798 | + <address type="home"> |
1799 | + <street>12345 Sixth Ave</street> |
1800 | + <city>Anytown</city> |
1801 | + <state>CA</state> |
1802 | + <postalCode>98765-4321</postalCode> |
1803 | + </address> |
1804 | + </person> |
1805 | +let $options := { "json-format" : "JsonML-object" } |
1806 | +return jx:xml-to-json( $xml, $options ) |
1807 | + |
1808 | +(: vim:set et sw=2 ts=2: :) |
Validation queue starting for the following merge proposals: /code.launchpad .net/~zorba- coders/ zorba/feature- jsonml_ object/ +merge/ 198858
https:/
Progress dashboard at http:// jenkins. lambda. nu/view/ ValidationQueue