Merge lp:~zorba-coders/zorba/csv2 into lp:zorba

Proposed by Paul J. Lucas on 2013-08-29
Status: Merged
Approved by: Paul J. Lucas on 2013-08-29
Approved revision: 11663
Merged at revision: 11625
Proposed branch: lp:~zorba-coders/zorba/csv2
Merge into: lp:zorba
Diff against target: 4258 lines
To merge this branch: bzr merge lp:~zorba-coders/zorba/csv2
Reviewer Review Type Date Requested Status
Chris Hillery 2013-09-10 Approve on 2013-09-16
Matthias Brantner 2013-08-29 Approve on 2013-08-29
Paul J. Lucas Approve on 2013-08-29
Review via email: mp+182786@code.launchpad.net

Commit Message

New CSV module for JSON.

Description of the Change

New CSV module for JSON.

To post a comment you must log in.
Paul J. Lucas (paul-lucas) :
review: Approve
lp:~zorba-coders/zorba/csv2 updated on 2013-08-29
11664. By Paul J. Lucas on 2013-08-29

JSON lexer now has option to return false instead of throwing an exception.

11665. By Paul J. Lucas on 2013-08-29

Added comment.

review: Approve
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue starting for the following merge proposals:
https://code.launchpad.net/~zorba-coders/zorba/csv2/+merge/182786

Progress dashboard at http://jenkins.lambda.nu/view/ValidationQueue

Zorba Build Bot (zorba-buildbot) wrote :

Validation queue result for https://code.launchpad.net/~zorba-coders/zorba/csv2/+merge/182786

Stage "TestZorbaUbuntu" failed.
7 tests failed (8452 total tests run).

Check test results at http://jenkins.lambda.nu/job/TestZorbaUbuntu/256/testReport/ to view the results.

lp:~zorba-coders/zorba/csv2 updated on 2013-09-09
11666. By Paul J. Lucas on 2013-08-30

Added @author.

11667. By Paul J. Lucas on 2013-08-30

s/txt/csv/

11668. By Paul J. Lucas on 2013-09-09

Windows line endings.

11669. By Paul J. Lucas on 2013-09-09

Merge from trunk.

Chris Hillery (ceejatec) wrote :

The most recent thinking regarding error codes for core modules (I admit this has been a moving target) is that they should follow the same rules as non-core modules: they should be in the same namespace as the module, and they should use English localnames. So, eg. not zerr:ZCSV0001, but csv:INVALID_OPTION.

review: Needs Fixing
lp:~zorba-coders/zorba/csv2 updated on 2013-09-16
11670. By Paul J. Lucas on 2013-09-12

Merge from trunk.

11671. By Paul J. Lucas on 2013-09-13

Merge from trunk.

11672. By Paul J. Lucas on 2013-09-16

Merge from trunk.

11673. By Paul J. Lucas on 2013-09-16

Now using errors local to the module.

Chris Hillery (ceejatec) :
review: Approve
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue result for https://code.launchpad.net/~zorba-coders/zorba/csv2/+merge/182786

Stage "ZorbaVQ" failed.

Check console output at http://jenkins.lambda.nu/job/ZorbaVQ/390/console to view the results.

Zorba Build Bot (zorba-buildbot) wrote :

Validation queue starting for the following merge proposals:
https://code.launchpad.net/~zorba-coders/zorba/csv2/+merge/182786

Progress dashboard at http://jenkins.lambda.nu/view/ValidationQueue

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-09-12 08:04:27 +0000
3+++ ChangeLog 2013-09-16 19:47:46 +0000
4@@ -45,6 +45,7 @@
5 * Fixed bug #1189636 (transcoding hexBinary streambuf)
6 * Fixed bug in hoisting through try-catch expr
7 * Fixed bug #1162631 (format-integer 'w' format of negative numbers)
8+ * Fixed bug #1189840 (Need JSONiq CSV module)
9 * Fixed bug #1217140 (Support XQuery 3.0 item-separator serialization parameter)
10 * Fixed bug #942171 (file module to allow for arbitrary encodings)
11 * Fixed bug #1192285 (Have JSON token know number subtype)
12
13=== modified file 'include/zorba/internal/pregenerated/qnames.h'
14--- include/zorba/internal/pregenerated/qnames.h 2013-09-13 23:06:50 +0000
15+++ include/zorba/internal/pregenerated/qnames.h 2013-09-16 19:47:46 +0000
16@@ -70,12 +70,24 @@
17 zorba::diagnostic::kind kind() const;
18 };
19
20+class ZORBA_DLL_PUBLIC ZorbaCSVErrorQName :
21+ public FixedQName<ZorbaCSVErrorQName,char const*>
22+{
23+ typedef FixedQName<ZorbaCSVErrorQName,char const*> base_type;
24+public:
25+ static char const NAMESPACE[];
26+ static char const PREFIX[];
27+ ZorbaCSVErrorQName( char const *localname ) : base_type( localname ) { }
28+ zorba::diagnostic::kind kind() const;
29+};
30+
31 } // namespace internal
32
33 typedef internal::SystemDiagnostic<internal::XQueryErrorQName> XQueryErrorCode;
34 typedef internal::SystemDiagnostic<internal::JSONiqErrorQName> JSONiqErrorCode;
35 typedef internal::SystemDiagnostic<internal::ZorbaErrorQName> ZorbaErrorCode;
36 typedef internal::SystemDiagnostic<internal::ZorbaWarningQName> ZorbaWarningCode;
37+typedef internal::SystemDiagnostic<internal::ZorbaCSVErrorQName> ZorbaCSVErrorCode;
38
39 } // namespace zorba
40 #endif /* ZORBA_INTERNAL_QNAMES_H */
41
42=== modified file 'include/zorba/pregenerated/diagnostic_list.h'
43--- include/zorba/pregenerated/diagnostic_list.h 2013-09-13 23:06:50 +0000
44+++ include/zorba/pregenerated/diagnostic_list.h 2013-09-16 19:47:46 +0000
45@@ -966,6 +966,16 @@
46 extern ZORBA_DLL_PUBLIC ZorbaWarningCode ZWST0009_COMMON_LANGUAGE_WARNING;
47
48 } // namespace zwarn
49+
50+namespace csv {
51+
52+extern ZORBA_DLL_PUBLIC ZorbaCSVErrorCode INVALID_OPTION;
53+
54+extern ZORBA_DLL_PUBLIC ZorbaCSVErrorCode MISSING_VALUE;
55+
56+extern ZORBA_DLL_PUBLIC ZorbaCSVErrorCode EXTRA_VALUE;
57+
58+} // namespace csv
59 } // namespace zorba
60 #endif /* ZORBA_DIAGNOSTIC_LIST_API_H */
61 /*
62
63=== modified file 'modules/json/CMakeLists.txt'
64--- modules/json/CMakeLists.txt 2013-07-10 09:41:45 +0000
65+++ modules/json/CMakeLists.txt 2013-09-16 19:47:46 +0000
66@@ -14,3 +14,8 @@
67
68 DECLARE_ZORBA_MODULE(FILE json-xml.xq VERSION 1.0
69 URI "http://zorba.io/modules/json-xml")
70+
71+DECLARE_ZORBA_MODULE(FILE json-csv.jq VERSION 1.0
72+ URI "http://zorba.io/modules/json-csv")
73+
74+# vim:set et sw=2 ts=2:
75
76=== added file 'modules/json/json-csv.jq'
77--- modules/json/json-csv.jq 1970-01-01 00:00:00 +0000
78+++ modules/json/json-csv.jq 2013-09-16 19:47:46 +0000
79@@ -0,0 +1,360 @@
80+jsoniq version "1.0";
81+
82+(:
83+ : Copyright 2006-2011 The FLWOR Foundation.
84+ :
85+ : Licensed under the Apache License, Version 2.0 (the "License");
86+ : you may not use this file except in compliance with the License.
87+ : You may obtain a copy of the License at
88+ :
89+ : http://www.apache.org/licenses/LICENSE-2.0
90+ :
91+ : Unless required by applicable law or agreed to in writing, software
92+ : distributed under the License is distributed on an "AS IS" BASIS,
93+ : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
94+ : See the License for the specific language governing permissions and
95+ : limitations under the License.
96+ :)
97+
98+(:===========================================================================:)
99+
100+(:~
101+ : This module provides an API for parsing and serializing CSV (comma-separated
102+ : values) files.
103+ : See RFC 4180,
104+ : "Common Format and MIME Type for Comma-Separated Values (CSV) Files."
105+ :
106+ : @author Paul J. Lucas
107+ : @project Zorba/CSV
108+ :)
109+
110+module namespace csv = "http://zorba.io/modules/json-csv";
111+
112+declare namespace ver = "http://zorba.io/options/versioning";
113+declare option ver:module-version "1.0";
114+
115+(:===========================================================================:)
116+
117+(:~
118+ : Parses a CSV (comma-separated values) string using the given options.
119+ : A newline (U+000A), optionally preceeded by a carriage-return (U+000D),
120+ : terminates lines, aka, "records."
121+ : <p/>
122+ : Quoted values are always considered strings;
123+ : unquoted values are attempted to be cast to other types, e.g., integer
124+ : (unless the <code>cast-unquoted-values</code> option is <code>false</code>).
125+ : Casting is attempted in the following order:
126+ : integer, decimal, double, and boolean.
127+ : If casting fails, the value is considered a string.
128+ : Header field names are always considered strings even if unquoted.
129+ : <p/>
130+ : In addition to the "normal" values of
131+ : <code>true</code> and <code>false</code> for boolean,
132+ : <code>T</code> and <code>Y</code> are also considered "true"
133+ : and <code>F</code> and <code>N</code> are also considered "false."
134+ :
135+ : @param $csv The CSV string to parse.
136+ : @param $options The options to use:
137+ : <dl>
138+ : <dt><code>cast-unquoted-values</code></dt>
139+ : <dd>
140+ : Whether to attempt to cast unquoted values to
141+ : integer, decimal, double, or boolean;
142+ : default: <code>true</code>.
143+ : </dd>
144+ : <dt><code>extra-name</code></dt>
145+ : <dd>
146+ : The field name for extra values, if any;
147+ : default: none (error <code>csv:EXTRA_VALUE</code> is raised).
148+ : If this option is given and a line contains one or more extra values
149+ : (that is, values that have no corresponding field names),
150+ : then the extra values are assigned as the values
151+ : for fields having <code>extra-name</code> as their names.
152+ : <p/>
153+ : If <code>extra-name</code> contains a <code>#</code> (U+0023),
154+ : then the <code>#</code> is substituted with the field number
155+ : (where field numbers start at 1).
156+ : If <code>extra-name</code> does not contains a <code>#</code>,
157+ : then the field number is appended.
158+ : </dd>
159+ : <dt><code>field-names</code></dt>
160+ : <dd>
161+ : A JSON array of strings denoting field names;
162+ : default: none.
163+ : If this option is given, then the first CSV line is assumed not to be
164+ : a header line; if omitted, then the first CSV line is assumed to be a
165+ : header line and the field names are taken from this line.
166+ : </dd>
167+ : <dt><code>missing-value</code></dt>
168+ : <dd>
169+ : What should happen when a missing value is detected;
170+ : default: <code>"null"</code>.
171+ : A "missing" value is one of:
172+ : <ul>
173+ : <li>Two consecutive <code>separator</code> characters.</li>
174+ : <li>A <code>separator</code> character as either the first
175+ : or last character on a line.</li>
176+ : <li>Fewer values than the number of field names.</li>
177+ : </ul>
178+ : When a missing value is detected,
179+ : the value of this option determines what happens:
180+ : <dl>
181+ : <dt><code>"error"</code></dt>
182+ : <dd>Error <code>csv:MISSING_VALUE</code> is raised.</dd>
183+ : <dt><code>"omit"</code></dt>
184+ : <dd>Both the value and its key are omitted from the result
185+ : object.</dd>
186+ : <dt><code>"null"</code></dt>
187+ : <dd>The value is set to <code>null</code>.</dd>
188+ : </dl>
189+ : </dd>
190+ : <dt><code>quote-char</code></dt>
191+ : <dd>
192+ : The single ASCII character that may be used to quote values;
193+ : default: <code>"</code> (U+0022).
194+ : </dd>
195+ : <dt><code>quote-escape</code></dt>
196+ : <dd>
197+ : The single ASCII character used to escape <code>quote-char</code>;
198+ : default: same as <code>quote-char</code>.
199+ : If <code>quote-escape</code> equals <code>quote-char</code>,
200+ : it means that <code>quote-char</code> must be doubled to escape it.
201+ : If <code>quote-escape</code> does not equal <code>quote-char</code>,
202+ : it means that <code>quote-escape</code> is used to escape
203+ : <code>quote-char</code>.
204+ : For example, a <code>quote-char</code> of <code>"</code> (U+0022)
205+ : and a <code>quote-escape</code> of <code>\</code> (U+005C) means that
206+ : quotes will be escaped by <code>\"</code>.
207+ : </dd>
208+ : <dt><code>separator</code></dt>
209+ : <dd>
210+ : The single ASCII character used to separate values;
211+ : default: <code>,</code> (U+002C).
212+ : </dd>
213+ : </dl>
214+ : @return a sequence of zero or more JSON objects where each key is a field
215+ : name and each value is a parsed value.
216+ : @error csv:INVALID_OPTION if the <code>quote-char</code>,
217+ : <code>quote-escape</code>, or <code>separator</code> option is given
218+ : and it's not a single ASCII character.
219+ : @error csv:MISSING_VALUE if a missing value is detected and the
220+ : <code>missing-value</code> option is "<code>error</code>".
221+ : @error csv:EXTRA_VALUE if an extra value is detected and the
222+ : <code>extra-name</code> option is not set.
223+ :)
224+declare function csv:parse( $csv as string, $options as object() )
225+ as object()* external;
226+
227+(:~
228+ : Parses a CSV (comma-separated values) string using the default options.
229+ : A newline (U+000A), optionally preceeded by a carriage-return (U+000D),
230+ : terminates lines, aka, "records."
231+ : <p/>
232+ : Quoted values are always considered strings;
233+ : unquoted values are attempted to be cast to other types, e.g., integer
234+ : (unless the <code>cast-unquoted-values</code> option is <code>false</code>).
235+ : Casting is attempted in the following order:
236+ : integer, decimal, double, and boolean.
237+ : If casting fails, the value is considered a string.
238+ : Header field names are always considered strings even if unquoted.
239+ : <p/>
240+ : In addition to the "normal" values of
241+ : <code>true</code> and <code>false</code> for boolean,
242+ : <code>T</code> and <code>Y</code> are also considered "true"
243+ : and <code>F</code> and <code>N</code> are also considered "false."
244+ : <p/>
245+ : The default options are:
246+ : <dl>
247+ : <dt><code>cast-unquoted-values</code></dt>
248+ : <dd>
249+ : Whether to attempt to cast unquoted values to
250+ : integer, decimal, double, or boolean;
251+ : default: <code>true</code>.
252+ : </dd>
253+ : <dt><code>extra-name</code></dt>
254+ : <dd>
255+ : The field name for extra values, if any;
256+ : default: none (error <code>csv:EXTRA_VALUE</code> is raised).
257+ : </dd>
258+ : <dt><code>field-names</code></dt>
259+ : <dd>
260+ : A JSON array of strings denoting field names;
261+ : default: none.
262+ : The first CSV line is assumed to be a header line
263+ : and the field names are taken from this line.
264+ : </dd>
265+ : <dt><code>missing-value</code></dt>
266+ : <dd>
267+ : What should happen when a missing value is detected;
268+ : default: <code>"null"</code>.
269+ : A "missing" value is one of:
270+ : <ul>
271+ : <li>Two consecutive <code>quote-char</code> characters.</li>
272+ : <li>A <code>quote-char</code> character as either the first
273+ : or last character on a line.</li>
274+ : <li>Fewer values than the number of field names.</li>
275+ : </ul>
276+ : When a missing value is detected,
277+ : the value is set to <code>null</code>.
278+ : </dd>
279+ : <dt><code>quote-char</code></dt>
280+ : <dd>
281+ : The single ASCII character that may be used to quote values;
282+ : default: <code>"</code> (U+0022).
283+ : </dd>
284+ : <dt><code>quote-escape</code></dt>
285+ : <dd>
286+ : The single ASCII character used to escape <code>quote-char</code>;
287+ : default: same as <code>quote-char</code>.
288+ : This means that an escaped quote is doubled as <code>""</code>.
289+ : </dd>
290+ : <dt><code>separator</code></dt>
291+ : <dd>
292+ : The single ASCII character used to separate values;
293+ : default: <code>,</code> (U+002C).
294+ : </dd>
295+ : </dl>
296+ :
297+ : @param $csv The CSV string to parse.
298+ : @return a sequence of zero or more JSON objects where each key is a field
299+ : name and each value is a parsed value.
300+ : @error csv:EXTRA_VALUE if an extra value is detected.
301+ :)
302+declare function csv:parse( $csv as string )
303+ as object()*
304+{
305+ csv:parse( $csv, {} )
306+};
307+
308+(:~
309+ : Serializes a sequence of JSON objects as CSV (comma-separated values) using
310+ : the given options.
311+ :
312+ : @param $obj The sequence of JSON objects to serialize.
313+ : @param $options The options to use:
314+ : <dl>
315+ : <dt><code>field-names</code></dt>
316+ : <dd>
317+ : A JSON array of strings denoting field names;
318+ : default: none.
319+ : If this option is not set,
320+ : the field names are taken from the first JSON object
321+ : and the order of the fields is implementation dependent.
322+ : If this option is set,
323+ : the fields are serielized in the order they are in the array.
324+ : In either case,
325+ : every JSON object must have the same keys as the first object.
326+ : </dd>
327+ : <dt><code>serialize-boolean-as</code></dt>
328+ : <dd>
329+ : What strings to serialize <code>true</code> and <code>false</code> as;
330+ : default: <code>true</code> and <code>false</code>.
331+ : This must be a sub-object with the two keys
332+ : <code>"true"</code> and <code>"false"</code>, e.g.:
333+ : <code>{ "true" : "Y", "false" : "N" }</code>.
334+ : </dd>
335+ : <dt><code>serialize-header</code></dt>
336+ : <dd>
337+ : Whether a header line is included;
338+ : default: <code>true</code>.
339+ : If <code>true</code>,
340+ : the first string result is the header line
341+ : comprised of all the objects' keys' names;
342+ : if <code>false</code>,
343+ : the heder line is not returned.
344+ : </dd>
345+ : <dt><code>serialize-null-as</code></dt>
346+ : <dd>
347+ : What string to serialize JSON <code>null</code> values as;
348+ : default: <code>null</code>.
349+ : </dd>
350+ : <dt><code>quote-char</code></dt>
351+ : <dd>
352+ : The single ASCII character that may be used to quote values;
353+ : default: <code>"</code> (U+0022).
354+ : </dd>
355+ : <dt><code>quote-escape</code></dt>
356+ : <dd>
357+ : The single ASCII character used to escape <code>quote-char</code>;
358+ : default: same as <code>quote-char</code>.
359+ : If <code>quote-escape</code> equals <code>quote-char</code>,
360+ : it means that <code>quote-char</code> must be doubled to escape it.
361+ : If <code>quote-escape</code> does not equal <code>quote-char</code>,
362+ : it means that <code>quote-escape</code> is used to escape
363+ : <code>quote-char</code>.
364+ : For example, a <code>quote-char</code> of <code>"</code> (U+0022)
365+ : and a <code>quote-escape</code> of <code>\</code> (U+005C) means that
366+ : quotes will be escaped by <code>\"</code>.
367+ : </dd>
368+ : <dt><code>separator</code></dt>
369+ : <dd>
370+ : The single ASCII character used to separate values;
371+ : default: <code>,</code> (U+002C).
372+ : </dd>
373+ : </dl>
374+ : @return a sequence of strings where each string corresponds to a JSON
375+ : object, aka, "record."
376+ :)
377+declare function csv:serialize( $obj as object()*, $options as object() )
378+ as string* external;
379+
380+(:~
381+ : Serializes a sequence of JSON objects as CSV (comma-separated values) using
382+ : the default options.
383+ : The default options are:
384+ : <dl>
385+ : <dt><code>field-names</code></dt>
386+ : <dd>
387+ : A JSON array of strings denoting field names;
388+ : default: none.
389+ : The field names are taken from the first JSON object
390+ : and the order of the fields is implementation dependent.
391+ : </dd>
392+ : <dt><code>serialize-boolean-as</code></dt>
393+ : <dd>
394+ : What strings to serialize <code>true</code> and <code>false</code> as;
395+ : default: <code>true</code> and <code>false</code>.
396+ : </dd>
397+ : <dt><code>serialize-header</code></dt>
398+ : <dd>
399+ : Whether a header line is included;
400+ : default: <code>true</code>.
401+ : The first string result is the header line
402+ : comprised of all the objects' keys' names.
403+ : </dd>
404+ : <dt><code>serialize-null-as</code></dt>
405+ : <dd>
406+ : What string to serialize JSON <code>null</code> values as;
407+ : default: <code>null</code>.
408+ : </dd>
409+ : <dt><code>quote-char</code></dt>
410+ : <dd>
411+ : The single ASCII character that may be used to quote values;
412+ : default: <code>"</code> (U+0022).
413+ : </dd>
414+ : <dt><code>quote-escape</code></dt>
415+ : <dd>
416+ : The single ASCII character used to escape <code>quote-char</code>;
417+ : default: same as <code>quote-char</code>.
418+ : This means that <code>quote-char</code> is doubled to escape it.
419+ : </dd>
420+ : <dt><code>separator</code></dt>
421+ : <dd>
422+ : The single ASCII character used to separate values;
423+ : default: <code>,</code> (U+002C).
424+ : </dd>
425+ : </dl>
426+ :
427+ : @param $obj The sequence of JSON objects to serialize.
428+ : @return a sequence of strings where each string corresponds to a JSON
429+ : object, aka, "record."
430+ :)
431+declare function csv:serialize( $obj as object()* )
432+ as string*
433+{
434+ csv:serialize( $obj, {} )
435+};
436+
437+(:===========================================================================:)
438+
439+(: vim:set syntax=xquery et sw=2 ts=2: :)
440
441=== modified file 'src/context/static_context.cpp'
442--- src/context/static_context.cpp 2013-09-09 09:05:18 +0000
443+++ src/context/static_context.cpp 2013-09-16 19:47:46 +0000
444@@ -359,7 +359,11 @@
445 "http://zorba.io/modules/base64";
446
447 const char*
448-static_context::ZORBA_JSON_FN_NS =
449+static_context::ZORBA_JSON_CSV_FN_NS =
450+"http://zorba.io/modules/json-csv";
451+
452+const char*
453+static_context::ZORBA_JSON_XML_FN_NS =
454 "http://zorba.io/modules/json-xml";
455
456 const char*
457@@ -555,7 +559,8 @@
458
459 ns == ZORBA_URI_FN_NS ||
460
461- ns == ZORBA_JSON_FN_NS ||
462+ ns == ZORBA_JSON_CSV_FN_NS ||
463+ ns == ZORBA_JSON_XML_FN_NS ||
464 ns == ZORBA_FETCH_FN_NS ||
465 ns == ZORBA_NODE_FN_NS ||
466 ns == ZORBA_ITEM_FN_NS ||
467@@ -616,7 +621,8 @@
468 {
469 return (ns == ZORBA_MATH_FN_NS ||
470 ns == ZORBA_INTROSP_SCTX_FN_NS ||
471- ns == ZORBA_JSON_FN_NS ||
472+ ns == ZORBA_JSON_CSV_FN_NS ||
473+ ns == ZORBA_JSON_XML_FN_NS ||
474 ns == ZORBA_XQDOC_FN_NS ||
475 ns == ZORBA_URI_FN_NS ||
476 ns == ZORBA_RANDOM_FN_NS ||
477
478=== modified file 'src/context/static_context.h'
479--- src/context/static_context.h 2013-09-09 09:05:18 +0000
480+++ src/context/static_context.h 2013-09-16 19:47:46 +0000
481@@ -520,7 +520,8 @@
482 static const char* ZORBA_MATH_FN_NS;
483 static const char* ZORBA_BASE64_FN_NS;
484
485- static const char* ZORBA_JSON_FN_NS;
486+ static const char* ZORBA_JSON_CSV_FN_NS;
487+ static const char* ZORBA_JSON_XML_FN_NS;
488
489 static const char* ZORBA_REFERENCE_FN_NS;
490 static const char* ZORBA_NODEPOS_FN_NS;
491
492=== modified file 'src/diagnostics/diagnostic_en.xml'
493--- src/diagnostics/diagnostic_en.xml 2013-09-02 20:58:31 +0000
494+++ src/diagnostics/diagnostic_en.xml 2013-09-16 19:47:46 +0000
495@@ -3638,6 +3638,42 @@
496
497 </namespace>
498
499+ <!--////////// CSV Module Errors //////////////////////////////////////////-->
500+
501+ <namespace prefix="csv">
502+
503+ <diagnostic code="INVALID_OPTION">
504+ <value>${"1": }invalid value for "$2" option${; 3}</value>
505+ <entry key="MustBeASCIIChar">
506+ <value>must be single ASCII character</value>
507+ </entry>
508+ <entry key="MustBeTrueFalse">
509+ <value>must be sub-object with "true" and "false" keys</value>
510+ </entry>
511+ <entry key="MustBeBoolean">
512+ <value>must be boolean</value>
513+ </entry>
514+ <entry key="MustBeString">
515+ <value>must be string</value>
516+ </entry>
517+ </diagnostic>
518+
519+ <diagnostic code="MISSING_VALUE">
520+ <value>$1</value>
521+ <entry key="Default">
522+ <value>"$2": missing value detected for this field on line $3</value>
523+ </entry>
524+ <entry key="EmptyHeader">
525+ <value>empty header value detected on line 1</value>
526+ </entry>
527+ </diagnostic>
528+
529+ <diagnostic code="EXTRA_VALUE">
530+ <value>"$1": extra value detected on line $2</value>
531+ </diagnostic>
532+
533+ </namespace>
534+
535 <!--////////// Subvalues /////////////////////////////////////////////////-->
536
537 <subvalues>
538
539=== modified file 'src/diagnostics/diagnostic_namespaces.xml'
540--- src/diagnostics/diagnostic_namespaces.xml 2013-09-14 00:39:50 +0000
541+++ src/diagnostics/diagnostic_namespaces.xml 2013-09-16 19:47:46 +0000
542@@ -61,5 +61,8 @@
543 <namespace prefix="zwarn" uri="ZORBA_WARN_NS"
544 class-prefix="ZorbaWarning" kind-function="standard"/>
545
546+ <namespace prefix="csv" uri="http://zorba.io/modules/json-csv"
547+ class-prefix="ZorbaCSVError" kind-function="unknown"/>
548+
549 </diagnostic-namespaces>
550 <!-- vim:set et sw=2 ts=2: -->
551
552=== modified file 'src/diagnostics/pregenerated/diagnostic_list.cpp'
553--- src/diagnostics/pregenerated/diagnostic_list.cpp 2013-09-02 20:58:31 +0000
554+++ src/diagnostics/pregenerated/diagnostic_list.cpp 2013-09-16 19:47:46 +0000
555@@ -1425,6 +1425,19 @@
556
557 } // namespace zwarn
558
559+namespace csv {
560+
561+ZorbaCSVErrorCode INVALID_OPTION( "INVALID_OPTION" );
562+
563+
564+ZorbaCSVErrorCode MISSING_VALUE( "MISSING_VALUE" );
565+
566+
567+ZorbaCSVErrorCode EXTRA_VALUE( "EXTRA_VALUE" );
568+
569+
570+} // namespace csv
571+
572 } // namespace zorba
573 /*
574 * Local variables:
575
576=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
577--- src/diagnostics/pregenerated/dict_en.cpp 2013-09-02 20:58:31 +0000
578+++ src/diagnostics/pregenerated/dict_en.cpp 2013-09-16 19:47:46 +0000
579@@ -28,6 +28,7 @@
580 namespace dict {
581
582 extern entry const dict_en[] = {
583+ { "EXTRA_VALUE", "\"$1\": extra value detected on line $2" },
584 { "FOAR0001", "division by zero" },
585 { "FOAR0002", "numeric operation overflow/underflow${: 1}" },
586 { "FOCA0001", "\"$1\": value too large for decimal" },
587@@ -99,6 +100,7 @@
588 #if !defined(ZORBA_NO_FULL_TEXT)
589 { "FTST0019", "\"$1\": match option specified more than once" },
590 #endif
591+ { "INVALID_OPTION", "${\"1\": }invalid value for \"$2\" option${; 3}" },
592 { "JNDY0003", "\"$1\": pair with the same name already exists in object" },
593 { "JNDY0021", "$1" },
594 { "JNSE0012", "can not serialize multiple top-level items as JSON" },
595@@ -122,6 +124,7 @@
596 { "JNUP0016", "$1" },
597 { "JNUP0017", "can not replace with less or more than an item" },
598 { "JNUP0019", "\"$1\": invalid type (content of insert expression must evaluate to a sequence of objects)" },
599+ { "MISSING_VALUE", "$1" },
600 { "SENR0001", "\"$1\": can not serialize $2" },
601 { "SEPM0004", "doctype-system parameter, or standalone parameter with a value other than \"omit\", specified" },
602 { "SEPM0009", "omit-xml-declaration parameter is \"yes\" and $1" },
603@@ -649,6 +652,10 @@
604 { "~GoodValuesAreXMLEtc", "valid values are: xml, html, xhtml, text, binary, json, jsoniq" },
605 { "~GoodValuesAreYesNo", "valid values are: yes, no" },
606 { "~GoodValuesAreYesNoOmit", "valid values are: yes, no, omit" },
607+ { "~INVALID_OPTION_MustBeASCIIChar", "must be single ASCII character" },
608+ { "~INVALID_OPTION_MustBeBoolean", "must be boolean" },
609+ { "~INVALID_OPTION_MustBeString", "must be string" },
610+ { "~INVALID_OPTION_MustBeTrueFalse", "must be sub-object with \"true\" and \"false\" keys" },
611 { "~InData", "in data" },
612 { "~IncompleteKeyInIndexBuild", "incomplete key during index build" },
613 { "~IncompleteKeyInIndexRefresh", "incomplete key during index refresh" },
614@@ -669,6 +676,8 @@
615 { "~JNUP0016_Array", "\"$2\": selector cannot be resolved against supplied array" },
616 { "~JNUP0016_Object", "\"$2\": selector cannot be resolved against supplied object" },
617 { "~LibModVersionMismatch_3", "XQuery library version can not be imported by a $3 version module" },
618+ { "~MISSING_VALUE_Default", "\"$2\": missing value detected for this field on line $3" },
619+ { "~MISSING_VALUE_EmptyHeader", "empty header value detected on line 1" },
620 { "~ModuleNotFound", "module not found" },
621 { "~MustBeAbsoluteURI", "must be absolute" },
622 { "~NoAttrNodesInDocument", "document node must not contain attribute nodes" },
623
624=== modified file 'src/diagnostics/pregenerated/dict_zed_keys.h'
625--- src/diagnostics/pregenerated/dict_zed_keys.h 2013-08-14 02:10:00 +0000
626+++ src/diagnostics/pregenerated/dict_zed_keys.h 2013-09-16 19:47:46 +0000
627@@ -209,6 +209,12 @@
628 #define ZED_ZWST0009_JSONIQ_EMPTY_SEQUENCE "~ZWST0009_JSONIQ_EMPTY_SEQUENCE"
629 #define ZED_ZWST0009_OBJECT_KEY_NOT_QUOTED "~ZWST0009_OBJECT_KEY_NOT_QUOTED"
630 #define ZED_ZWST0009_AXIS_STEP "~ZWST0009_AXIS_STEP"
631+#define ZED_INVALID_OPTION_MustBeASCIIChar "~INVALID_OPTION_MustBeASCIIChar"
632+#define ZED_INVALID_OPTION_MustBeTrueFalse "~INVALID_OPTION_MustBeTrueFalse"
633+#define ZED_INVALID_OPTION_MustBeBoolean "~INVALID_OPTION_MustBeBoolean"
634+#define ZED_INVALID_OPTION_MustBeString "~INVALID_OPTION_MustBeString"
635+#define ZED_MISSING_VALUE_Default "~MISSING_VALUE_Default"
636+#define ZED_MISSING_VALUE_EmptyHeader "~MISSING_VALUE_EmptyHeader"
637 #define ZED_AllMatchesHasExcludes "~AllMatchesHasExcludes"
638 #define ZED_AlreadySpecified "~AlreadySpecified"
639 #define ZED_AppliedAt "~AppliedAt"
640
641=== modified file 'src/diagnostics/pregenerated/qnames.cpp'
642--- src/diagnostics/pregenerated/qnames.cpp 2013-09-14 00:37:25 +0000
643+++ src/diagnostics/pregenerated/qnames.cpp 2013-09-16 19:47:46 +0000
644@@ -54,6 +54,13 @@
645 return get_standard_error_kind( localname() );
646 }
647
648+char const ZorbaCSVErrorQName::NAMESPACE[] = "http://zorba.io/modules/json-csv";
649+char const ZorbaCSVErrorQName::PREFIX[] = "csv";
650+
651+zorba::diagnostic::kind ZorbaCSVErrorQName::kind() const {
652+ return zorba::diagnostic::UNKNOWN_KIND;
653+}
654+
655 } // namespace internal
656 } // namespace zorba
657 /*
658
659=== modified file 'src/functions/library.cpp'
660--- src/functions/library.cpp 2013-07-02 21:32:23 +0000
661+++ src/functions/library.cpp 2013-09-16 19:47:46 +0000
662@@ -34,6 +34,7 @@
663 #include "functions/func_booleans_impl.h"
664 #include "functions/func_collections.h"
665 #include "functions/func_context.h"
666+#include "functions/func_csv.h"
667 #include "functions/func_datetime.h"
668 #include "functions/func_documents.h"
669 #include "functions/func_durations_dates_times.h"
670@@ -119,6 +120,7 @@
671 populate_context_booleans_impl(sctx);
672 populate_context_collections(sctx);
673 populate_context_context(sctx);
674+ populate_context_csv(sctx);
675 populate_context_datetime(sctx);
676 populate_context_durations_dates_times(sctx);
677 populate_context_durations_dates_times_impl(sctx);
678
679=== added file 'src/functions/pregenerated/func_csv.cpp'
680--- src/functions/pregenerated/func_csv.cpp 1970-01-01 00:00:00 +0000
681+++ src/functions/pregenerated/func_csv.cpp 2013-09-16 19:47:46 +0000
682@@ -0,0 +1,87 @@
683+/*
684+ * Copyright 2006-2012 The FLWOR Foundation.
685+ *
686+ * Licensed under the Apache License, Version 2.0 (the "License");
687+ * you may not use this file except in compliance with the License.
688+ * You may obtain a copy of the License at
689+ *
690+ * http://www.apache.org/licenses/LICENSE-2.0
691+ *
692+ * Unless required by applicable law or agreed to in writing, software
693+ * distributed under the License is distributed on an "AS IS" BASIS,
694+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
695+ * See the License for the specific language governing permissions and
696+ * limitations under the License.
697+ */
698+
699+// ******************************************
700+// * *
701+// * THIS IS A GENERATED FILE. DO NOT EDIT! *
702+// * SEE .xml FILE WITH SAME NAME *
703+// * *
704+// ******************************************
705+
706+
707+#include "stdafx.h"
708+#include "runtime/csv/csv.h"
709+#include "functions/func_csv.h"
710+
711+
712+namespace zorba{
713+
714+
715+
716+PlanIter_t fn_zorba_csv_parse::codegen(
717+ CompilerCB*,
718+ static_context* sctx,
719+ const QueryLoc& loc,
720+ std::vector<PlanIter_t>& argv,
721+ expr& ann) const
722+{
723+ return new CsvParseIterator(sctx, loc, argv);
724+}
725+
726+PlanIter_t fn_zorba_csv_serialize::codegen(
727+ CompilerCB*,
728+ static_context* sctx,
729+ const QueryLoc& loc,
730+ std::vector<PlanIter_t>& argv,
731+ expr& ann) const
732+{
733+ return new CsvSerializeIterator(sctx, loc, argv);
734+}
735+
736+void populate_context_csv(static_context* sctx)
737+{
738+
739+
740+ {
741+ DECL_WITH_KIND(sctx, fn_zorba_csv_parse,
742+ (createQName("http://zorba.io/modules/json-csv","","parse"),
743+ GENV_TYPESYSTEM.STRING_TYPE_ONE,
744+ GENV_TYPESYSTEM.JSON_OBJECT_TYPE_ONE,
745+ GENV_TYPESYSTEM.JSON_OBJECT_TYPE_STAR),
746+ FunctionConsts::FN_ZORBA_CSV_PARSE_2);
747+
748+ }
749+
750+
751+
752+
753+ {
754+ DECL_WITH_KIND(sctx, fn_zorba_csv_serialize,
755+ (createQName("http://zorba.io/modules/json-csv","","serialize"),
756+ GENV_TYPESYSTEM.JSON_OBJECT_TYPE_STAR,
757+ GENV_TYPESYSTEM.JSON_OBJECT_TYPE_ONE,
758+ GENV_TYPESYSTEM.STRING_TYPE_STAR),
759+ FunctionConsts::FN_ZORBA_CSV_SERIALIZE_2);
760+
761+ }
762+
763+}
764+
765+
766+}
767+
768+
769+
770
771=== added file 'src/functions/pregenerated/func_csv.h'
772--- src/functions/pregenerated/func_csv.h 1970-01-01 00:00:00 +0000
773+++ src/functions/pregenerated/func_csv.h 2013-09-16 19:47:46 +0000
774@@ -0,0 +1,79 @@
775+/*
776+ * Copyright 2006-2012 The FLWOR Foundation.
777+ *
778+ * Licensed under the Apache License, Version 2.0 (the "License");
779+ * you may not use this file except in compliance with the License.
780+ * You may obtain a copy of the License at
781+ *
782+ * http://www.apache.org/licenses/LICENSE-2.0
783+ *
784+ * Unless required by applicable law or agreed to in writing, software
785+ * distributed under the License is distributed on an "AS IS" BASIS,
786+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
787+ * See the License for the specific language governing permissions and
788+ * limitations under the License.
789+ */
790+
791+// ******************************************
792+// * *
793+// * THIS IS A GENERATED FILE. DO NOT EDIT! *
794+// * SEE .xml FILE WITH SAME NAME *
795+// * *
796+// ******************************************
797+
798+
799+#ifndef ZORBA_FUNCTIONS_CSV_H
800+#define ZORBA_FUNCTIONS_CSV_H
801+
802+
803+#include "common/shared_types.h"
804+#include "functions/function_impl.h"
805+
806+
807+namespace zorba {
808+
809+
810+void populate_context_csv(static_context* sctx);
811+
812+
813+
814+
815+//fn-zorba-csv:parse
816+class fn_zorba_csv_parse : public function
817+{
818+public:
819+ fn_zorba_csv_parse(const signature& sig, FunctionConsts::FunctionKind kind)
820+ :
821+ function(sig, kind)
822+ {
823+
824+ }
825+
826+ CODEGEN_DECL();
827+};
828+
829+
830+//fn-zorba-csv:serialize
831+class fn_zorba_csv_serialize : public function
832+{
833+public:
834+ fn_zorba_csv_serialize(const signature& sig, FunctionConsts::FunctionKind kind)
835+ :
836+ function(sig, kind)
837+ {
838+
839+ }
840+
841+ CODEGEN_DECL();
842+};
843+
844+
845+} //namespace zorba
846+
847+
848+#endif
849+/*
850+ * Local variables:
851+ * mode: c++
852+ * End:
853+ */
854
855=== modified file 'src/functions/pregenerated/function_enum.h'
856--- src/functions/pregenerated/function_enum.h 2013-08-24 23:38:45 +0000
857+++ src/functions/pregenerated/function_enum.h 2013-09-16 19:47:46 +0000
858@@ -143,6 +143,8 @@
859 FN_POSITION_0,
860 FN_LAST_0,
861 FN_STATIC_BASE_URI_0,
862+ FN_ZORBA_CSV_PARSE_2,
863+ FN_ZORBA_CSV_SERIALIZE_2,
864 FN_ZORBA_DATETIME_CURRENT_DATE_0,
865 FN_ZORBA_DATETIME_CURRENT_DATETIME_0,
866 FN_ZORBA_DATETIME_CURRENT_TIME_0,
867
868=== modified file 'src/runtime/CMakeLists.txt'
869--- src/runtime/CMakeLists.txt 2013-06-15 02:57:08 +0000
870+++ src/runtime/CMakeLists.txt 2013-09-16 19:47:46 +0000
871@@ -152,6 +152,8 @@
872 json/json_loader.cpp
873 )
874
875+ADD_SRC_SUBFOLDER(RUNTIME_SRCS csv CSV_SRCS)
876+
877 IF(NOT ZORBA_NO_FULL_TEXT)
878 ADD_SRC_SUBFOLDER(RUNTIME_SRCS full_text FULLTEXT_SRCS)
879 ENDIF(NOT ZORBA_NO_FULL_TEXT)
880
881=== added directory 'src/runtime/csv'
882=== added file 'src/runtime/csv/CMakeLists.txt'
883--- src/runtime/csv/CMakeLists.txt 1970-01-01 00:00:00 +0000
884+++ src/runtime/csv/CMakeLists.txt 2013-09-16 19:47:46 +0000
885@@ -0,0 +1,19 @@
886+# Copyright 2006-2008 The FLWOR Foundation.
887+#
888+# Licensed under the Apache License, Version 2.0 (the "License");
889+# you may not use this file except in compliance with the License.
890+# You may obtain a copy of the License at
891+#
892+# http://www.apache.org/licenses/LICENSE-2.0
893+#
894+# Unless required by applicable law or agreed to in writing, software
895+# distributed under the License is distributed on an "AS IS" BASIS,
896+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
897+# See the License for the specific language governing permissions and
898+# limitations under the License.
899+
900+SET(CSV_SRCS
901+ csv_impl.cpp
902+ )
903+
904+# vim:set et sw=2 ts=2:
905
906=== added file 'src/runtime/csv/csv_impl.cpp'
907--- src/runtime/csv/csv_impl.cpp 1970-01-01 00:00:00 +0000
908+++ src/runtime/csv/csv_impl.cpp 2013-09-16 19:47:46 +0000
909@@ -0,0 +1,620 @@
910+/*
911+ * Copyright 2006-2008 The FLWOR Foundation.
912+ *
913+ * Licensed under the Apache License, Version 2.0 (the "License");
914+ * you may not use this file except in compliance with the License.
915+ * You may obtain a copy of the License at
916+ *
917+ * http://www.apache.org/licenses/LICENSE-2.0
918+ *
919+ * Unless required by applicable law or agreed to in writing, software
920+ * distributed under the License is distributed on an "AS IS" BASIS,
921+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
922+ * See the License for the specific language governing permissions and
923+ * limitations under the License.
924+ */
925+
926+#include "stdafx.h"
927+
928+#include <algorithm>
929+#include <iterator>
930+#include <set>
931+#include <sstream>
932+
933+#include <zorba/config.h>
934+#include <zorba/internal/cxx_util.h>
935+#include <zorba/diagnostic_list.h>
936+#include <zorba/store_consts.h>
937+
938+#include "runtime/csv/csv.h"
939+#include "store/api/item_factory.h"
940+#include "system/globalenv.h"
941+#include "types/casting.h"
942+#include "types/root_typemanager.h"
943+#include "types/typeops.h"
944+#include "util/ascii_util.h"
945+#include "util/json_parser.h"
946+#include "util/stl_util.h"
947+#include "zorbatypes/decimal.h"
948+#include "zorbatypes/float.h"
949+#include "zorbatypes/integer.h"
950+
951+#include "csv_util.h"
952+
953+using namespace std;
954+
955+namespace zorba {
956+
957+///////////////////////////////////////////////////////////////////////////////
958+
959+#define IS_ATOMIC_TYPE(ITEM,TYPE) \
960+ ( (ITEM)->isAtomic() && TypeOps::is_subtype( (ITEM)->getTypeCode(), store::TYPE ) )
961+
962+#define IS_JSON_NULL(ITEM) \
963+ ( (ITEM)->isAtomic() && (ITEM)->getTypeCode() == store::JS_NULL )
964+
965+static bool get_opt( store::Item_t const &object, char const *opt_name,
966+ store::Item_t *result ) {
967+ store::Item_t key_item;
968+ zstring s( opt_name );
969+ GENV_ITEMFACTORY->createString( key_item, s );
970+ *result = object->getObjectValue( key_item );
971+ return !result->isNull();
972+}
973+
974+static bool get_bool_opt( store::Item_t const &object,
975+ char const *opt_name, bool *result,
976+ QueryLoc const &loc ) {
977+ store::Item_t opt_item;
978+ if ( get_opt( object, opt_name, &opt_item ) ) {
979+ if ( !IS_ATOMIC_TYPE( opt_item, XS_BOOLEAN ) )
980+ throw XQUERY_EXCEPTION(
981+ csv::INVALID_OPTION,
982+ ERROR_PARAMS(
983+ opt_item->getStringValue(),
984+ opt_name,
985+ ZED( INVALID_OPTION_MustBeBoolean )
986+ ),
987+ ERROR_LOC( loc )
988+ );
989+ *result = opt_item->getBooleanValue();
990+ return true;
991+ }
992+ return false;
993+}
994+
995+static bool get_char_opt( store::Item_t const &object,
996+ char const *opt_name, char *result,
997+ QueryLoc const &loc ) {
998+ store::Item_t opt_item;
999+ if ( get_opt( object, opt_name, &opt_item ) ) {
1000+ zstring const value( opt_item->getStringValue() );
1001+ if ( !IS_ATOMIC_TYPE( opt_item, XS_STRING ) ||
1002+ value.size() != 1 || !ascii::is_ascii( value[0] ) ) {
1003+ throw XQUERY_EXCEPTION(
1004+ csv::INVALID_OPTION,
1005+ ERROR_PARAMS( value, opt_name, ZED( INVALID_OPTION_MustBeASCIIChar ) ),
1006+ ERROR_LOC( loc )
1007+ );
1008+ }
1009+ *result = value[0];
1010+ return true;
1011+ }
1012+ return false;
1013+}
1014+
1015+static bool get_string_opt( store::Item_t const &object,
1016+ char const *opt_name, zstring *result,
1017+ QueryLoc const &loc ) {
1018+ store::Item_t opt_item;
1019+ if ( get_opt( object, opt_name, &opt_item ) ) {
1020+ if ( !IS_ATOMIC_TYPE( opt_item, XS_STRING ) )
1021+ throw XQUERY_EXCEPTION(
1022+ csv::INVALID_OPTION,
1023+ ERROR_PARAMS(
1024+ opt_item->getStringValue(),
1025+ opt_name,
1026+ ZED( INVALID_OPTION_MustBeString )
1027+ ),
1028+ ERROR_LOC( loc )
1029+ );
1030+ opt_item->getStringValue2( *result );
1031+ return true;
1032+ }
1033+ return false;
1034+}
1035+
1036+static json::type parse_json( zstring const &s, json::token *ptoken ) {
1037+ mem_streambuf buf( (char*)s.data(), s.size() );
1038+ istringstream iss;
1039+ iss.ios::rdbuf( &buf );
1040+ json::lexer lex( iss );
1041+ return lex.next( ptoken, false ) ?
1042+ json::map_type( ptoken->get_type() ) : json::none;
1043+}
1044+
1045+///////////////////////////////////////////////////////////////////////////////
1046+
1047+void CsvParseIterator::set_input( store::Item_t const &item,
1048+ CsvParseIteratorState *state ) const {
1049+ if ( item->isStreamable() )
1050+ state->csv_.set_stream( item->getStream() );
1051+ else {
1052+ item->getStringValue2( state->string_ );
1053+ state->mem_streambuf_.set( state->string_.data(), state->string_.size() );
1054+ state->iss_.ios::rdbuf( &state->mem_streambuf_ );
1055+ state->csv_.set_stream( state->iss_ );
1056+ }
1057+}
1058+
1059+void CsvParseIterator::set_options( store::Item_t const &item,
1060+ CsvParseIteratorState *state ) const {
1061+ store::Item_t opt_item;
1062+ char opt_char;
1063+ zstring value;
1064+
1065+ get_bool_opt( item, "cast-unquoted-values", &state->cast_unquoted_, loc );
1066+ get_string_opt( item, "extra-name", &state->extra_name_, loc );
1067+ if ( get_opt( item, "field-names", &opt_item ) ) {
1068+ store::Iterator_t i( opt_item->getArrayValues() );
1069+ i->open();
1070+ store::Item_t name_item;
1071+ while ( i->next( name_item ) )
1072+ state->keys_.push_back( name_item );
1073+ i->close();
1074+ }
1075+ if ( get_string_opt( item, "missing-value", &value, loc ) ) {
1076+ if ( value == "error" )
1077+ state->missing_ = missing::error;
1078+ else if ( value == "omit" )
1079+ state->missing_ = missing::omit;
1080+ else if ( value == "null" )
1081+ state->missing_ = missing::null;
1082+ else
1083+ ZORBA_ASSERT( false ); // should be caught by JSON schema
1084+ }
1085+ if ( get_char_opt( item, "quote-char", &opt_char, loc ) ) {
1086+ state->csv_.set_quote( opt_char );
1087+ state->csv_.set_quote_esc( opt_char );
1088+ }
1089+ if ( get_char_opt( item, "quote-escape", &opt_char, loc ) )
1090+ state->csv_.set_quote_esc( opt_char );
1091+ if ( get_char_opt( item, "separator", &opt_char, loc ) )
1092+ state->csv_.set_separator( opt_char );
1093+}
1094+
1095+bool CsvParseIterator::count( store::Item_t &result,
1096+ PlanState &plan_state ) const {
1097+ unsigned long count = 0;
1098+ bool eol;
1099+ store::Item_t item;
1100+ zstring value;
1101+
1102+ CsvParseIteratorState *state;
1103+ DEFAULT_STACK_INIT( CsvParseIteratorState, state, plan_state );
1104+
1105+ // $csv as string
1106+ consumeNext( item, theChildren[0], plan_state );
1107+ set_input( item, state );
1108+
1109+ // $options as object()
1110+ consumeNext( item, theChildren[1], plan_state );
1111+ set_options( item, state );
1112+
1113+ while ( state->csv_.next_value( &value, &eol ) )
1114+ if ( eol )
1115+ ++count;
1116+
1117+ if ( state->keys_.empty() && count ) {
1118+ //
1119+ // If keys_ is empty, it means that the "field-names" option wasn't
1120+ // specified; hence, the first line of the file is assumed to be a header
1121+ // line. A header line shouldn't count as a real record to be skipped, so
1122+ // decrement the count by 1 to compensate.
1123+ //
1124+ --count;
1125+ }
1126+
1127+ STACK_PUSH(
1128+ GENV_ITEMFACTORY->createInteger( result, xs_integer( count ) ),
1129+ state
1130+ );
1131+ STACK_END( state );
1132+}
1133+
1134+bool CsvParseIterator::skip( int64_t count, PlanState &plan_state ) const {
1135+ bool eol;
1136+ store::Item_t item;
1137+ vector<store::Item_t> keys;
1138+ zstring value;
1139+
1140+ CsvParseIteratorState *const state = StateTraitsImpl<CsvParseIteratorState>::
1141+ getState( plan_state, theStateOffset );
1142+
1143+ // $csv as string
1144+ consumeNext( item, theChildren[0], plan_state );
1145+ set_input( item, state );
1146+
1147+ // $options as object()
1148+ consumeNext( item, theChildren[1], plan_state );
1149+ set_options( item, state );
1150+
1151+ if ( state->keys_.empty() ) {
1152+ //
1153+ // If keys_ is empty, it means that the "field-names" option wasn't
1154+ // specified; hence, the first line of the file is assumed to be a header
1155+ // line. A header line shouldn't count as a real record to be skipped, so
1156+ // bump up the count by 1 to compensate.
1157+ //
1158+ ++count;
1159+ }
1160+
1161+ //
1162+ // Since we called consumeNext() here and consumed the arguments, we have to
1163+ // use the already-consumed arguments (stored in the iterator's state) in
1164+ // nextImpl() and not call consumeNext() there. Set a flag to indicate this.
1165+ //
1166+ state->skip_called_ = true;
1167+
1168+ while ( count-- > 0 ) {
1169+ while ( true ) {
1170+ if ( !state->csv_.next_value( &value, &eol ) )
1171+ return false;
1172+ if ( state->keys_.empty() ) {
1173+ if ( value.empty() ) {
1174+ //
1175+ // Header field names can never be empty.
1176+ //
1177+ throw XQUERY_EXCEPTION(
1178+ csv::MISSING_VALUE,
1179+ ERROR_PARAMS( ZED( MISSING_VALUE_EmptyHeader ) ),
1180+ ERROR_LOC( loc )
1181+ );
1182+ }
1183+ GENV_ITEMFACTORY->createString( item, value );
1184+ keys.push_back( item );
1185+ }
1186+ if ( eol ) {
1187+ if ( state->keys_.empty() ) {
1188+ //
1189+ // The first line of values are taken to be the header field names.
1190+ //
1191+ state->keys_.swap( keys );
1192+ }
1193+ break;
1194+ }
1195+ } // while ( true )
1196+ } // while ( count-- > 0 )
1197+ return true;
1198+}
1199+
1200+bool CsvParseIterator::nextImpl( store::Item_t &result,
1201+ PlanState &plan_state ) const {
1202+ unsigned field_no = 0;
1203+ store::Item_t item;
1204+ vector<store::Item_t> keys_copy, values;
1205+ set<unsigned> keys_omit;
1206+ zstring value;
1207+ bool eol, quoted, swap_keys = false;
1208+
1209+ CsvParseIteratorState *state;
1210+ DEFAULT_STACK_INIT( CsvParseIteratorState, state, plan_state );
1211+
1212+ if ( !state->skip_called_ ) {
1213+ // $csv as string
1214+ consumeNext( item, theChildren[0], plan_state );
1215+ set_input( item, state );
1216+
1217+ // $options as object()
1218+ consumeNext( item, theChildren[1], plan_state );
1219+ set_options( item, state );
1220+ }
1221+
1222+ while ( state->csv_.next_value( &value, &eol, &quoted ) ) {
1223+ if ( state->keys_.size() && values.size() == state->keys_.size() &&
1224+ state->extra_name_.empty() ) {
1225+ //
1226+ // We've already max'd out on the number of values for a record and the
1227+ // "extra-name" option wasn't specified.
1228+ //
1229+ throw XQUERY_EXCEPTION(
1230+ csv::EXTRA_VALUE,
1231+ ERROR_PARAMS( value, state->line_no_ ),
1232+ ERROR_LOC( loc )
1233+ );
1234+ }
1235+
1236+ item = nullptr;
1237+ if ( value.empty() ) {
1238+ if ( state->keys_.empty() ) {
1239+ //
1240+ // Header field names can never be empty.
1241+ //
1242+ throw XQUERY_EXCEPTION(
1243+ csv::MISSING_VALUE,
1244+ ERROR_PARAMS( ZED( MISSING_VALUE_EmptyHeader ) ),
1245+ ERROR_LOC( loc )
1246+ );
1247+ }
1248+ if ( quoted )
1249+ GENV_ITEMFACTORY->createString( item, value );
1250+ else
1251+ switch ( state->missing_ ) {
1252+ case missing::error:
1253+ goto missing_error;
1254+ case missing::null:
1255+ GENV_ITEMFACTORY->createJSONNull( item );
1256+ break;
1257+ case missing::omit:
1258+ keys_omit.insert( field_no );
1259+ break;
1260+ }
1261+ } else if ( state->cast_unquoted_ && !quoted && !state->keys_.empty() ) {
1262+ if ( value == "T" || value == "Y" )
1263+ GENV_ITEMFACTORY->createBoolean( item, true );
1264+ else if ( value == "F" || value == "N" )
1265+ GENV_ITEMFACTORY->createBoolean( item, false );
1266+ else {
1267+ json::token t;
1268+ switch ( parse_json( value, &t ) ) {
1269+ case json::boolean:
1270+ GENV_ITEMFACTORY->createBoolean( item, value[0] == 't' );
1271+ break;
1272+ case json::null:
1273+ GENV_ITEMFACTORY->createJSONNull( item );
1274+ break;
1275+ case json::number:
1276+ switch ( t.get_numeric_type() ) {
1277+ case json::token::integer:
1278+ GENV_ITEMFACTORY->createInteger( item, xs_integer( value ) );
1279+ break;
1280+ case json::token::decimal:
1281+ GENV_ITEMFACTORY->createDecimal( item, xs_decimal( value ) );
1282+ break;
1283+ case json::token::floating_point:
1284+ GENV_ITEMFACTORY->createDouble( item, xs_double( value ) );
1285+ break;
1286+ default:
1287+ ZORBA_ASSERT( false );
1288+ }
1289+ break;
1290+ default:
1291+ GENV_ITEMFACTORY->createString( item, value );
1292+ } // switch
1293+ } // else
1294+ } else {
1295+ GENV_ITEMFACTORY->createString( item, value );
1296+ }
1297+
1298+ if ( !item.isNull() )
1299+ values.push_back( item );
1300+
1301+ if ( eol ) {
1302+ if ( state->keys_.empty() ) {
1303+ //
1304+ // The first line of values are taken to be the header field names.
1305+ //
1306+ state->keys_.swap( values );
1307+ } else {
1308+ if ( values.size() < state->keys_.size() ) {
1309+ //
1310+ // At least one value is missing.
1311+ //
1312+ switch ( state->missing_ ) {
1313+ case missing::error:
1314+ //
1315+ // We don't actually know which field is missing; we know only
1316+ // that there's at least one less field than there should be.
1317+ //
1318+ field_no = values.size();
1319+ goto missing_error;
1320+ case missing::null:
1321+ GENV_ITEMFACTORY->createJSONNull( item );
1322+ while ( values.size() < state->keys_.size() )
1323+ values.push_back( item );
1324+ break;
1325+ case missing::omit:
1326+ //
1327+ // We have to remove the keys for those fields that should be
1328+ // omitted temporarily.
1329+ //
1330+ if ( keys_omit.empty() ) {
1331+ //
1332+ // The last field is the one that's missing and there's no
1333+ // trailing ',' (which is why keys_omit is empty).
1334+ //
1335+ keys_copy = state->keys_;
1336+ state->keys_.pop_back();
1337+ } else {
1338+ for ( unsigned i = 0; i < state->keys_.size(); ++i )
1339+ if ( !ztd::contains( keys_omit, i ) )
1340+ keys_copy.push_back( state->keys_[i] );
1341+ keys_copy.swap( state->keys_ );
1342+ }
1343+ swap_keys = true;
1344+ break;
1345+ }
1346+ } else if ( values.size() > state->keys_.size() ) {
1347+ //
1348+ // There's at least one extra value: add in extra fields for keys
1349+ // temporarily.
1350+ //
1351+ keys_copy = state->keys_;
1352+ zstring::size_type const num_pos = state->extra_name_.find( '#' );
1353+ for ( unsigned f = state->keys_.size() +1; f <= values.size(); ++f ) {
1354+ ascii::itoa_buf_type buf;
1355+ ascii::itoa( f, buf );
1356+ zstring extra_name( state->extra_name_ );
1357+ if ( num_pos != zstring::npos )
1358+ extra_name.replace( num_pos, 1, buf );
1359+ else
1360+ extra_name += buf;
1361+ GENV_ITEMFACTORY->createString( item, extra_name );
1362+ state->keys_.push_back( item );
1363+ }
1364+ swap_keys = true;
1365+ }
1366+
1367+ GENV_ITEMFACTORY->createJSONObject( result, state->keys_, values );
1368+ if ( swap_keys ) {
1369+ //
1370+ // Put the original set of field names (keys) back the way it was.
1371+ //
1372+ keys_copy.swap( state->keys_ );
1373+ }
1374+ STACK_PUSH( true, state );
1375+ } // else
1376+ ++state->line_no_, field_no = 0;
1377+ continue;
1378+ } // if ( eol )
1379+ ++field_no;
1380+ } // while
1381+
1382+ STACK_END( state );
1383+
1384+missing_error:
1385+ throw XQUERY_EXCEPTION(
1386+ csv::MISSING_VALUE,
1387+ ERROR_PARAMS(
1388+ ZED( MISSING_VALUE_Default ),
1389+ state->keys_[ field_no ]->getStringValue(),
1390+ state->line_no_
1391+ ),
1392+ ERROR_LOC( loc )
1393+ );
1394+}
1395+
1396+///////////////////////////////////////////////////////////////////////////////
1397+
1398+bool CsvSerializeIterator::nextImpl( store::Item_t &result,
1399+ PlanState &plan_state ) const {
1400+ char char_opt;
1401+ bool do_header, separator;
1402+ store::Item_t item, opt_item;
1403+ zstring line, value;
1404+
1405+ CsvSerializeIteratorState *state;
1406+ DEFAULT_STACK_INIT( CsvSerializeIteratorState, state, plan_state );
1407+
1408+ // $options as object()
1409+ consumeNext( item, theChildren[1], plan_state );
1410+ if ( get_opt( item, "field-names", &opt_item ) ) {
1411+ store::Iterator_t i( opt_item->getArrayValues() );
1412+ i->open();
1413+ store::Item_t name_item;
1414+ while ( i->next( name_item ) )
1415+ state->keys_.push_back( name_item );
1416+ i->close();
1417+ }
1418+ if ( !get_char_opt( item, "quote-char", &state->quote_, loc ) )
1419+ state->quote_ = '"';
1420+ if ( get_char_opt( item, "quote-escape", &char_opt, loc ) ) {
1421+ state->quote_esc_ = char_opt;
1422+ state->quote_esc_ += state->quote_;
1423+ } else
1424+ state->quote_esc_.assign( 2, state->quote_ );
1425+ if ( !get_bool_opt( item, "serialize-header", &do_header, loc ) )
1426+ do_header = true;
1427+ if ( !get_char_opt( item, "separator", &state->separator_, loc ) )
1428+ state->separator_ = ',';
1429+ if ( !get_string_opt( item, "serialize-null-as", &state->null_string_, loc ) )
1430+ state->null_string_ = "null";
1431+ if ( get_opt( item, "serialize-boolean-as", &opt_item ) ) {
1432+ if ( !get_string_opt( opt_item, "false", &state->boolean_string_[0], loc )
1433+ || !get_string_opt( opt_item, "true", &state->boolean_string_[1], loc ) )
1434+ throw XQUERY_EXCEPTION(
1435+ csv::INVALID_OPTION,
1436+ ERROR_PARAMS(
1437+ "", "serialize-boolea-as",
1438+ ZED( INVALID_OPTION_MustBeTrueFalse )
1439+ ),
1440+ ERROR_LOC( loc )
1441+ );
1442+ } else
1443+ state->boolean_string_[0] = "false", state->boolean_string_[1] = "true";
1444+
1445+ state->must_quote_ = state->separator_;
1446+ state->must_quote_ += state->quote_;
1447+ state->must_quote_ += "\r\n";
1448+
1449+ if ( state->keys_.empty() ) {
1450+ //
1451+ // We have to take the header field names from the first item, but we have
1452+ // to save the first item to return its values later.
1453+ //
1454+ if ( consumeNext( state->header_item_, theChildren[0], plan_state ) ) {
1455+ store::Iterator_t i( state->header_item_->getObjectKeys() );
1456+ i->open();
1457+ while ( i->next( item ) )
1458+ state->keys_.push_back( item );
1459+ i->close();
1460+ }
1461+ }
1462+
1463+ if ( do_header ) {
1464+ separator = false;
1465+ FOR_EACH( vector<store::Item_t>, key, state->keys_ ) {
1466+ if ( separator )
1467+ line += state->separator_;
1468+ else
1469+ separator = true;
1470+ line += (*key)->getStringValue();
1471+ }
1472+ line += "\r\n";
1473+ GENV_ITEMFACTORY->createString( result, line );
1474+ STACK_PUSH( true, state );
1475+ }
1476+
1477+ if ( !state->header_item_.isNull() ) {
1478+ //
1479+ // We consumed the first item above to get the field names for the header
1480+ // since they weren't given. However, we must still return the first
1481+ // item's values as the first "real" result, so set "item" to
1482+ // "header_item_" and jump into the while loop below but skipping the call
1483+ // to consumeNext().
1484+ //
1485+ item = state->header_item_;
1486+ goto skip_consumeNext;
1487+ }
1488+
1489+ while ( consumeNext( item, theChildren[0], plan_state ) ) {
1490+skip_consumeNext:
1491+ line.clear();
1492+ separator = false;
1493+ FOR_EACH( vector<store::Item_t>, key, state->keys_ ) {
1494+ if ( separator )
1495+ line += state->separator_;
1496+ else
1497+ separator = true;
1498+ store::Item_t const value_item( item->getObjectValue( *key ) );
1499+ if ( !value_item.isNull() ) {
1500+ if ( IS_ATOMIC_TYPE( value_item, XS_BOOLEAN ) )
1501+ line += state->boolean_string_[ value_item->getBooleanValue() ];
1502+ else if ( IS_JSON_NULL( value_item ) )
1503+ line += state->null_string_;
1504+ else {
1505+ value_item->getStringValue2( value );
1506+ bool const quote =
1507+ value.find_first_of( state->must_quote_ ) != zstring::npos;
1508+ if ( quote )
1509+ line += state->quote_;
1510+ ascii::replace_all( value, state->quote_, state->quote_esc_ );
1511+ line += value;
1512+ if ( quote )
1513+ line += state->quote_;
1514+ }
1515+ }
1516+ } // for
1517+ line += "\r\n";
1518+ GENV_ITEMFACTORY->createString( result, line );
1519+ STACK_PUSH( true, state );
1520+ } // while
1521+
1522+ STACK_END( state );
1523+}
1524+
1525+///////////////////////////////////////////////////////////////////////////////
1526+
1527+} // namespace zorba
1528+
1529+/* vim:set et sw=2 ts=2: */
1530
1531=== added file 'src/runtime/csv/csv_util.h'
1532--- src/runtime/csv/csv_util.h 1970-01-01 00:00:00 +0000
1533+++ src/runtime/csv/csv_util.h 2013-09-16 19:47:46 +0000
1534@@ -0,0 +1,36 @@
1535+/*
1536+ * Copyright 2006-2008 The FLWOR Foundation.
1537+ *
1538+ * Licensed under the Apache License, Version 2.0 (the "License");
1539+ * you may not use this file except in compliance with the License.
1540+ * You may obtain a copy of the License at
1541+ *
1542+ * http://www.apache.org/licenses/LICENSE-2.0
1543+ *
1544+ * Unless required by applicable law or agreed to in writing, software
1545+ * distributed under the License is distributed on an "AS IS" BASIS,
1546+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1547+ * See the License for the specific language governing permissions and
1548+ * limitations under the License.
1549+ */
1550+
1551+#ifndef ZORBA_CSV_UTIL_H
1552+#define ZORBA_CSV_UTIL_H
1553+
1554+namespace zorba {
1555+
1556+///////////////////////////////////////////////////////////////////////////////
1557+
1558+namespace missing {
1559+ enum type {
1560+ null,
1561+ omit,
1562+ error
1563+ };
1564+}
1565+
1566+///////////////////////////////////////////////////////////////////////////////
1567+
1568+} // namespace zorba
1569+#endif /* ZORBA_CSV_UTIL_H */
1570+/* vim:set et sw=2 ts=2: */
1571
1572=== added directory 'src/runtime/csv/pregenerated'
1573=== added file 'src/runtime/csv/pregenerated/csv.cpp'
1574--- src/runtime/csv/pregenerated/csv.cpp 1970-01-01 00:00:00 +0000
1575+++ src/runtime/csv/pregenerated/csv.cpp 2013-09-16 19:47:46 +0000
1576@@ -0,0 +1,123 @@
1577+/*
1578+ * Copyright 2006-2012 The FLWOR Foundation.
1579+ *
1580+ * Licensed under the Apache License, Version 2.0 (the "License");
1581+ * you may not use this file except in compliance with the License.
1582+ * You may obtain a copy of the License at
1583+ *
1584+ * http://www.apache.org/licenses/LICENSE-2.0
1585+ *
1586+ * Unless required by applicable law or agreed to in writing, software
1587+ * distributed under the License is distributed on an "AS IS" BASIS,
1588+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1589+ * See the License for the specific language governing permissions and
1590+ * limitations under the License.
1591+ */
1592+
1593+// ******************************************
1594+// * *
1595+// * THIS IS A GENERATED FILE. DO NOT EDIT! *
1596+// * SEE .xml FILE WITH SAME NAME *
1597+// * *
1598+// ******************************************
1599+
1600+#include "stdafx.h"
1601+#include "zorbatypes/rchandle.h"
1602+#include "zorbatypes/zstring.h"
1603+#include "runtime/visitors/planiter_visitor.h"
1604+#include "runtime/csv/csv.h"
1605+#include "system/globalenv.h"
1606+
1607+
1608+#include "store/api/iterator.h"
1609+
1610+namespace zorba {
1611+
1612+// <CsvParseIterator>
1613+SERIALIZABLE_CLASS_VERSIONS(CsvParseIterator)
1614+
1615+void CsvParseIterator::serialize(::zorba::serialization::Archiver& ar)
1616+{
1617+ serialize_baseclass(ar,
1618+ (NaryBaseIterator<CsvParseIterator, CsvParseIteratorState>*)this);
1619+}
1620+
1621+
1622+void CsvParseIterator::accept(PlanIterVisitor& v) const
1623+{
1624+ v.beginVisit(*this);
1625+
1626+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
1627+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
1628+ for ( ; lIter != lEnd; ++lIter ){
1629+ (*lIter)->accept(v);
1630+ }
1631+
1632+ v.endVisit(*this);
1633+}
1634+
1635+CsvParseIterator::~CsvParseIterator() {}
1636+
1637+CsvParseIteratorState::CsvParseIteratorState() {}
1638+
1639+CsvParseIteratorState::~CsvParseIteratorState() {}
1640+
1641+
1642+void CsvParseIteratorState::init(PlanState& planState) {
1643+ PlanIteratorState::init(planState);
1644+ cast_unquoted_ = true;
1645+ line_no_ = 1;
1646+ missing_ = missing::null;
1647+ skip_called_ = false;
1648+}
1649+
1650+void CsvParseIteratorState::reset(PlanState& planState) {
1651+ PlanIteratorState::reset(planState);
1652+ cast_unquoted_ = true;
1653+ line_no_ = 1;
1654+ missing_ = missing::null;
1655+ skip_called_ = false;
1656+}
1657+// </CsvParseIterator>
1658+
1659+
1660+// <CsvSerializeIterator>
1661+SERIALIZABLE_CLASS_VERSIONS(CsvSerializeIterator)
1662+
1663+void CsvSerializeIterator::serialize(::zorba::serialization::Archiver& ar)
1664+{
1665+ serialize_baseclass(ar,
1666+ (NaryBaseIterator<CsvSerializeIterator, CsvSerializeIteratorState>*)this);
1667+}
1668+
1669+
1670+void CsvSerializeIterator::accept(PlanIterVisitor& v) const
1671+{
1672+ v.beginVisit(*this);
1673+
1674+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
1675+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
1676+ for ( ; lIter != lEnd; ++lIter ){
1677+ (*lIter)->accept(v);
1678+ }
1679+
1680+ v.endVisit(*this);
1681+}
1682+
1683+CsvSerializeIterator::~CsvSerializeIterator() {}
1684+
1685+CsvSerializeIteratorState::CsvSerializeIteratorState() {}
1686+
1687+CsvSerializeIteratorState::~CsvSerializeIteratorState() {}
1688+
1689+
1690+void CsvSerializeIteratorState::reset(PlanState& planState) {
1691+ PlanIteratorState::reset(planState);
1692+}
1693+// </CsvSerializeIterator>
1694+
1695+
1696+
1697+}
1698+
1699+
1700
1701=== added file 'src/runtime/csv/pregenerated/csv.h'
1702--- src/runtime/csv/pregenerated/csv.h 1970-01-01 00:00:00 +0000
1703+++ src/runtime/csv/pregenerated/csv.h 2013-09-16 19:47:46 +0000
1704@@ -0,0 +1,154 @@
1705+/*
1706+ * Copyright 2006-2012 The FLWOR Foundation.
1707+ *
1708+ * Licensed under the Apache License, Version 2.0 (the "License");
1709+ * you may not use this file except in compliance with the License.
1710+ * You may obtain a copy of the License at
1711+ *
1712+ * http://www.apache.org/licenses/LICENSE-2.0
1713+ *
1714+ * Unless required by applicable law or agreed to in writing, software
1715+ * distributed under the License is distributed on an "AS IS" BASIS,
1716+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1717+ * See the License for the specific language governing permissions and
1718+ * limitations under the License.
1719+ */
1720+
1721+// ******************************************
1722+// * *
1723+// * THIS IS A GENERATED FILE. DO NOT EDIT! *
1724+// * SEE .xml FILE WITH SAME NAME *
1725+// * *
1726+// ******************************************
1727+#ifndef ZORBA_RUNTIME_CSV_CSV_H
1728+#define ZORBA_RUNTIME_CSV_CSV_H
1729+
1730+
1731+#include "common/shared_types.h"
1732+
1733+
1734+
1735+#include "runtime/base/narybase.h"
1736+#include <sstream>
1737+#include <vector>
1738+#include "runtime/csv/csv_util.h"
1739+#include "util/csv_parser.h"
1740+#include "util/mem_streambuf.h"
1741+#include "zorbatypes/zstring.h"
1742+
1743+
1744+namespace zorba {
1745+
1746+/**
1747+ *
1748+ * Author:
1749+ */
1750+class CsvParseIteratorState : public PlanIteratorState
1751+{
1752+public:
1753+ bool cast_unquoted_; //
1754+ csv_parser csv_; //
1755+ zstring extra_name_; //
1756+ std::istringstream iss_; //
1757+ std::vector<store::Item_t> keys_; //
1758+ unsigned line_no_; //
1759+ mem_streambuf mem_streambuf_; //
1760+ missing::type missing_; //
1761+ bool skip_called_; //
1762+ zstring string_; //
1763+
1764+ CsvParseIteratorState();
1765+
1766+ ~CsvParseIteratorState();
1767+
1768+ void init(PlanState&);
1769+ void reset(PlanState&);
1770+};
1771+
1772+class CsvParseIterator : public NaryBaseIterator<CsvParseIterator, CsvParseIteratorState>
1773+{
1774+public:
1775+ SERIALIZABLE_CLASS(CsvParseIterator);
1776+
1777+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(CsvParseIterator,
1778+ NaryBaseIterator<CsvParseIterator, CsvParseIteratorState>);
1779+
1780+ void serialize( ::zorba::serialization::Archiver& ar);
1781+
1782+ CsvParseIterator(
1783+ static_context* sctx,
1784+ const QueryLoc& loc,
1785+ std::vector<PlanIter_t>& children)
1786+ :
1787+ NaryBaseIterator<CsvParseIterator, CsvParseIteratorState>(sctx, loc, children)
1788+ {}
1789+
1790+ virtual ~CsvParseIterator();
1791+
1792+public:
1793+ bool count(store::Item_t& result, PlanState& planState) const;
1794+ bool skip(int64_t count, PlanState& planState) const;
1795+ void set_input(store::Item_t const& item, CsvParseIteratorState* state) const;
1796+ void set_options(store::Item_t const& item, CsvParseIteratorState* state) const;
1797+ void accept(PlanIterVisitor& v) const;
1798+
1799+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
1800+};
1801+
1802+
1803+/**
1804+ *
1805+ * Author:
1806+ */
1807+class CsvSerializeIteratorState : public PlanIteratorState
1808+{
1809+public:
1810+ zstring boolean_string_[2]; //
1811+ store::Item_t header_item_; //
1812+ std::vector<store::Item_t> keys_; //
1813+ zstring must_quote_; //
1814+ zstring null_string_; //
1815+ char quote_; //
1816+ zstring quote_esc_; //
1817+ char separator_; //
1818+
1819+ CsvSerializeIteratorState();
1820+
1821+ ~CsvSerializeIteratorState();
1822+
1823+ void reset(PlanState&);
1824+};
1825+
1826+class CsvSerializeIterator : public NaryBaseIterator<CsvSerializeIterator, CsvSerializeIteratorState>
1827+{
1828+public:
1829+ SERIALIZABLE_CLASS(CsvSerializeIterator);
1830+
1831+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(CsvSerializeIterator,
1832+ NaryBaseIterator<CsvSerializeIterator, CsvSerializeIteratorState>);
1833+
1834+ void serialize( ::zorba::serialization::Archiver& ar);
1835+
1836+ CsvSerializeIterator(
1837+ static_context* sctx,
1838+ const QueryLoc& loc,
1839+ std::vector<PlanIter_t>& children)
1840+ :
1841+ NaryBaseIterator<CsvSerializeIterator, CsvSerializeIteratorState>(sctx, loc, children)
1842+ {}
1843+
1844+ virtual ~CsvSerializeIterator();
1845+
1846+ void accept(PlanIterVisitor& v) const;
1847+
1848+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
1849+};
1850+
1851+
1852+}
1853+#endif
1854+/*
1855+ * Local variables:
1856+ * mode: c++
1857+ * End:
1858+ */
1859
1860=== modified file 'src/runtime/errors_and_diagnostics/other_diagnostics_impl.cpp'
1861--- src/runtime/errors_and_diagnostics/other_diagnostics_impl.cpp 2013-02-07 17:24:36 +0000
1862+++ src/runtime/errors_and_diagnostics/other_diagnostics_impl.cpp 2013-09-16 19:47:46 +0000
1863@@ -84,6 +84,19 @@
1864 theFunctionArity = arity;
1865 }
1866
1867+bool
1868+FunctionTraceIterator::count(store::Item_t &result, PlanState &plan_state) const
1869+{
1870+ return theChildren[0]->count(result, plan_state);
1871+}
1872+
1873+bool
1874+FunctionTraceIterator::skip( int64_t count, PlanState &plan_state ) const
1875+{
1876+ return theChildren[0]->skip(count, plan_state);
1877+}
1878+
1879+
1880 /*******************************************************************************
1881 Diagnostics iterators: read-line
1882 ********************************************************************************/
1883
1884=== modified file 'src/runtime/errors_and_diagnostics/pregenerated/other_diagnostics.h'
1885--- src/runtime/errors_and_diagnostics/pregenerated/other_diagnostics.h 2013-03-05 23:11:50 +0000
1886+++ src/runtime/errors_and_diagnostics/pregenerated/other_diagnostics.h 2013-09-16 19:47:46 +0000
1887@@ -140,6 +140,8 @@
1888 void setFunctionCallLocation(const QueryLoc& aFunctionLocation);
1889 void setFunctionLocation(const QueryLoc& aFunctionLocation);
1890 void setFunctionArity(unsigned int arity);
1891+ bool count(store::Item_t& result, PlanState& planState) const;
1892+ bool skip(int64_t count, PlanState& planState) const;
1893 void accept(PlanIterVisitor& v) const;
1894
1895 bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
1896
1897=== modified file 'src/runtime/json/jsonml_array.cpp'
1898--- src/runtime/json/jsonml_array.cpp 2013-07-29 23:56:38 +0000
1899+++ src/runtime/json/jsonml_array.cpp 2013-09-16 19:47:46 +0000
1900@@ -19,6 +19,7 @@
1901
1902 #include <zorba/diagnostic_list.h>
1903 #include <zorba/internal/cxx_util.h>
1904+#include <zorba/store_consts.h>
1905
1906 #include "runtime/json/json.h"
1907 #include "store/api/item_factory.h"
1908
1909=== modified file 'src/runtime/json/snelson.cpp'
1910--- src/runtime/json/snelson.cpp 2013-08-16 22:10:33 +0000
1911+++ src/runtime/json/snelson.cpp 2013-09-16 19:47:46 +0000
1912@@ -20,6 +20,7 @@
1913
1914 #include <zorba/diagnostic_list.h>
1915 #include <zorba/internal/cxx_util.h>
1916+#include <zorba/store_consts.h>
1917
1918 #include "runtime/json/json.h"
1919 #include "store/api/item_factory.h"
1920
1921=== modified file 'src/runtime/numerics/format_number.cpp'
1922--- src/runtime/numerics/format_number.cpp 2013-06-18 02:28:10 +0000
1923+++ src/runtime/numerics/format_number.cpp 2013-09-16 19:47:46 +0000
1924@@ -28,7 +28,6 @@
1925 #include "store/api/item_factory.h"
1926 #include "system/globalenv.h"
1927 #include "types/casting.h"
1928-#include "types/typeconstants.h"
1929 #include "types/typeops.h"
1930 #include "util/xml_util.h"
1931 #include "zorbatypes/float.h"
1932
1933=== modified file 'src/runtime/pregenerated/iterator_enum.h'
1934--- src/runtime/pregenerated/iterator_enum.h 2013-08-24 23:38:45 +0000
1935+++ src/runtime/pregenerated/iterator_enum.h 2013-09-16 19:47:46 +0000
1936@@ -72,6 +72,8 @@
1937 TYPE_CurrentTimeIterator,
1938 TYPE_ImplicitTimezoneIterator,
1939 TYPE_DefaultCollationIterator,
1940+ TYPE_CsvParseIterator,
1941+ TYPE_CsvSerializeIterator,
1942 TYPE_CurrentDate,
1943 TYPE_CurrentDateTime,
1944 TYPE_CurrentTime,
1945
1946=== added directory 'src/runtime/spec/csv'
1947=== added file 'src/runtime/spec/csv/csv.xml'
1948--- src/runtime/spec/csv/csv.xml 1970-01-01 00:00:00 +0000
1949+++ src/runtime/spec/csv/csv.xml 2013-09-16 19:47:46 +0000
1950@@ -0,0 +1,86 @@
1951+<?xml version="1.0" encoding="UTF-8"?>
1952+
1953+<zorba:iterators
1954+ xmlns:zorba="http://www.zorba-xquery.com"
1955+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1956+ xsi:schemaLocation="http://www.zorba-xquery.com ../runtime.xsd">
1957+
1958+<zorba:header>
1959+ <zorba:include form="Angle-bracket">sstream</zorba:include>
1960+ <zorba:include form="Angle-bracket">vector</zorba:include>
1961+ <zorba:include form="Quoted">runtime/csv/csv_util.h</zorba:include>
1962+ <zorba:include form="Quoted">util/csv_parser.h</zorba:include>
1963+ <zorba:include form="Quoted">util/mem_streambuf.h</zorba:include>
1964+ <zorba:include form="Quoted">zorbatypes/zstring.h</zorba:include>
1965+</zorba:header>
1966+
1967+<zorba:source>
1968+ <zorba:include form="Quoted">store/api/iterator.h</zorba:include>
1969+</zorba:source>
1970+
1971+<!--========================================================================-->
1972+
1973+<zorba:iterator name="CsvParseIterator" arity="nary">
1974+ <zorba:function>
1975+ <zorba:signature localname="parse" prefix="fn-zorba-csv">
1976+ <zorba:param>xs:string</zorba:param>
1977+ <zorba:param>object()</zorba:param>
1978+ <zorba:output>object()*</zorba:output>
1979+ </zorba:signature>
1980+ </zorba:function>
1981+ <zorba:state generateInit="true" generateReset="true">
1982+ <zorba:member type="bool" name="cast_unquoted_" defaultValue="true"/>
1983+ <zorba:member type="csv_parser" name="csv_"/>
1984+ <zorba:member type="zstring" name="extra_name_"/>
1985+ <zorba:member type="std::istringstream" name="iss_"/>
1986+ <zorba:member type="std::vector&lt;store::Item_t&gt;" name="keys_"/>
1987+ <zorba:member type="unsigned" name="line_no_" defaultValue="1"/>
1988+ <zorba:member type="mem_streambuf" name="mem_streambuf_"/>
1989+ <zorba:member type="missing::type" name="missing_" defaultValue="missing::null"/>
1990+ <zorba:member type="bool" name="skip_called_" defaultValue="false"/>
1991+ <zorba:member type="zstring" name="string_"/>
1992+ </zorba:state>
1993+ <zorba:method name="count" const="true" return="bool">
1994+ <zorba:param name="result" type="store::Item_t&amp;"/>
1995+ <zorba:param name="planState" type="PlanState&amp;"/>
1996+ </zorba:method>
1997+ <zorba:method name="skip" const="true" return="bool">
1998+ <zorba:param name="count" type="int64_t"/>
1999+ <zorba:param name="planState" type="PlanState&amp;"/>
2000+ </zorba:method>
2001+ <zorba:method name="set_input" return="void" const="true">
2002+ <zorba:param type="store::Item_t const&amp;" name="item"/>
2003+ <zorba:param type="CsvParseIteratorState*" name="state"/>
2004+ </zorba:method>
2005+ <zorba:method name="set_options" return="void" const="true">
2006+ <zorba:param type="store::Item_t const&amp;" name="item"/>
2007+ <zorba:param type="CsvParseIteratorState*" name="state"/>
2008+ </zorba:method>
2009+</zorba:iterator>
2010+
2011+<!--========================================================================-->
2012+
2013+<zorba:iterator name="CsvSerializeIterator" arity="nary">
2014+ <zorba:function>
2015+ <zorba:signature localname="serialize" prefix="fn-zorba-csv">
2016+ <zorba:param>object()*</zorba:param>
2017+ <zorba:param>object()</zorba:param>
2018+ <zorba:output>xs:string*</zorba:output>
2019+ </zorba:signature>
2020+ </zorba:function>
2021+ <zorba:state generateInit="use-default">
2022+ <zorba:member type="zstring" name="boolean_string_[2]"/>
2023+ <zorba:member type="store::Item_t" name="header_item_"/>
2024+ <zorba:member type="std::vector&lt;store::Item_t&gt;" name="keys_"/>
2025+ <zorba:member type="zstring" name="must_quote_"/>
2026+ <zorba:member type="zstring" name="null_string_"/>
2027+ <zorba:member type="char" name="quote_"/>
2028+ <zorba:member type="zstring" name="quote_esc_"/>
2029+ <zorba:member type="char" name="separator_"/>
2030+ </zorba:state>
2031+</zorba:iterator>
2032+
2033+<!--========================================================================-->
2034+
2035+</zorba:iterators>
2036+<!-- vim:set et sw=2 ts=2: -->
2037
2038=== modified file 'src/runtime/spec/errors_and_diagnostics/other_diagnostics.xml'
2039--- src/runtime/spec/errors_and_diagnostics/other_diagnostics.xml 2013-02-07 17:24:36 +0000
2040+++ src/runtime/spec/errors_and_diagnostics/other_diagnostics.xml 2013-09-16 19:47:46 +0000
2041@@ -109,6 +109,17 @@
2042 <zorba:param type="unsigned int" name="arity" />
2043 </zorba:method>
2044
2045+ <zorba:method name="count" const="true" return="bool">
2046+ <zorba:param name="result" type="store::Item_t&amp;"/>
2047+ <zorba:param name="planState" type="PlanState&amp;"/>
2048+ </zorba:method>
2049+
2050+ <zorba:method name="skip" const="true" return="bool">
2051+ <zorba:param name="count" type="int64_t"/>
2052+ <zorba:param name="planState" type="PlanState&amp;"/>
2053+ </zorba:method>
2054+
2055+
2056 </zorba:iterator>
2057
2058 </zorba:iterators>
2059
2060=== modified file 'src/runtime/spec/mappings.xml'
2061--- src/runtime/spec/mappings.xml 2013-09-02 20:43:22 +0000
2062+++ src/runtime/spec/mappings.xml 2013-09-16 19:47:46 +0000
2063@@ -114,8 +114,12 @@
2064 define="ZORBA_URI_FN_NS"
2065 prefix="fn-zorba-uri"/>
2066
2067+ <zorba:namespace uri="http://zorba.io/modules/json-csv"
2068+ define="ZORBA_JSON_CSV_FN_NS"
2069+ prefix="fn-zorba-csv"/>
2070+
2071 <zorba:namespace uri="http://zorba.io/modules/json-xml"
2072- define="ZORBA_JSON_FN_NS"
2073+ define="ZORBA_JSON_XML_FN_NS"
2074 prefix="fn-zorba-json"/>
2075
2076 <zorba:namespace uri="http://www.zorba-xquery.com/modules/fetch"
2077
2078=== modified file 'src/runtime/visitors/pregenerated/planiter_visitor.h'
2079--- src/runtime/visitors/pregenerated/planiter_visitor.h 2013-08-24 23:38:45 +0000
2080+++ src/runtime/visitors/pregenerated/planiter_visitor.h 2013-09-16 19:47:46 +0000
2081@@ -134,6 +134,10 @@
2082
2083 class DefaultCollationIterator;
2084
2085+ class CsvParseIterator;
2086+
2087+ class CsvSerializeIterator;
2088+
2089 class CurrentDate;
2090
2091 class CurrentDateTime;
2092@@ -913,6 +917,12 @@
2093 virtual void beginVisit ( const DefaultCollationIterator& ) = 0;
2094 virtual void endVisit ( const DefaultCollationIterator& ) = 0;
2095
2096+ virtual void beginVisit ( const CsvParseIterator& ) = 0;
2097+ virtual void endVisit ( const CsvParseIterator& ) = 0;
2098+
2099+ virtual void beginVisit ( const CsvSerializeIterator& ) = 0;
2100+ virtual void endVisit ( const CsvSerializeIterator& ) = 0;
2101+
2102 virtual void beginVisit ( const CurrentDate& ) = 0;
2103 virtual void endVisit ( const CurrentDate& ) = 0;
2104
2105
2106=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp'
2107--- src/runtime/visitors/pregenerated/printer_visitor.cpp 2013-08-24 23:38:45 +0000
2108+++ src/runtime/visitors/pregenerated/printer_visitor.cpp 2013-09-16 19:47:46 +0000
2109@@ -41,6 +41,7 @@
2110 #include "runtime/booleans/booleans.h"
2111 #include "runtime/collections/collections.h"
2112 #include "runtime/context/context.h"
2113+#include "runtime/csv/csv.h"
2114 #include "runtime/datetime/datetime.h"
2115 #include "runtime/debug/debug_iterator.h"
2116 #include "runtime/durations_dates_times/durations_dates_times.h"
2117@@ -706,6 +707,34 @@
2118 // </DefaultCollationIterator>
2119
2120
2121+// <CsvParseIterator>
2122+void PrinterVisitor::beginVisit ( const CsvParseIterator& a) {
2123+ thePrinter.startBeginVisit("CsvParseIterator", ++theId);
2124+ printCommons( &a, theId );
2125+ thePrinter.endBeginVisit( theId );
2126+}
2127+
2128+void PrinterVisitor::endVisit ( const CsvParseIterator& ) {
2129+ thePrinter.startEndVisit();
2130+ thePrinter.endEndVisit();
2131+}
2132+// </CsvParseIterator>
2133+
2134+
2135+// <CsvSerializeIterator>
2136+void PrinterVisitor::beginVisit ( const CsvSerializeIterator& a) {
2137+ thePrinter.startBeginVisit("CsvSerializeIterator", ++theId);
2138+ printCommons( &a, theId );
2139+ thePrinter.endBeginVisit( theId );
2140+}
2141+
2142+void PrinterVisitor::endVisit ( const CsvSerializeIterator& ) {
2143+ thePrinter.startEndVisit();
2144+ thePrinter.endEndVisit();
2145+}
2146+// </CsvSerializeIterator>
2147+
2148+
2149 // <CurrentDate>
2150 void PrinterVisitor::beginVisit ( const CurrentDate& a) {
2151 thePrinter.startBeginVisit("CurrentDate", ++theId);
2152
2153=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.h'
2154--- src/runtime/visitors/pregenerated/printer_visitor.h 2013-08-24 23:38:45 +0000
2155+++ src/runtime/visitors/pregenerated/printer_visitor.h 2013-09-16 19:47:46 +0000
2156@@ -203,6 +203,12 @@
2157 void beginVisit( const DefaultCollationIterator& );
2158 void endVisit ( const DefaultCollationIterator& );
2159
2160+ void beginVisit( const CsvParseIterator& );
2161+ void endVisit ( const CsvParseIterator& );
2162+
2163+ void beginVisit( const CsvSerializeIterator& );
2164+ void endVisit ( const CsvSerializeIterator& );
2165+
2166 void beginVisit( const CurrentDate& );
2167 void endVisit ( const CurrentDate& );
2168
2169
2170=== modified file 'src/util/CMakeLists.txt'
2171--- src/util/CMakeLists.txt 2013-08-02 14:55:29 +0000
2172+++ src/util/CMakeLists.txt 2013-09-16 19:47:46 +0000
2173@@ -14,6 +14,7 @@
2174
2175 SET(UTIL_SRCS
2176 ascii_util.cpp
2177+ csv_parser.cpp
2178 dynamic_bitset.cpp
2179 error_util.cpp
2180 fs_util.cpp
2181
2182=== modified file 'src/util/ascii_util.h'
2183--- src/util/ascii_util.h 2013-05-09 00:48:27 +0000
2184+++ src/util/ascii_util.h 2013-09-16 19:47:46 +0000
2185@@ -677,6 +677,43 @@
2186 * @tparam StringType The string type.
2187 * @param s The string to modify.
2188 * @param from The substring to replace.
2189+ * @param from_len The length of \a from.
2190+ * @param to The substring to replace with.
2191+ * @return Returns \c true only if at least one replacement is performed.
2192+ */
2193+template<class StringType,class ToStringType> inline
2194+typename std::enable_if<ZORBA_IS_STRING(StringType)
2195+ && ZORBA_IS_STRING(ToStringType),
2196+ bool>::type
2197+replace_all( StringType &s,
2198+ char const *from, typename StringType::size_type from_len,
2199+ ToStringType const &to ) {
2200+ return replace_all( s, from, from_len, to.data(), to.size() );
2201+}
2202+
2203+/**
2204+ * Replaces all occurrences of a character with a string.
2205+ *
2206+ * @tparam StringType The string type.
2207+ * @param s The string to modify.
2208+ * @param from The character to replace.
2209+ * @param to The substring to replace with.
2210+ * @return Returns \c true only if at least one replacement is performed.
2211+ */
2212+template<class StringType,class ToStringType> inline
2213+typename std::enable_if<ZORBA_IS_STRING(StringType)
2214+ && ZORBA_IS_STRING(ToStringType),
2215+ bool>::type
2216+replace_all( StringType &s, char from, ToStringType const &to ) {
2217+ return replace_all( s, &from, 1, to.data(), to.size() );
2218+}
2219+
2220+/**
2221+ * Replaces all occurrences of one substring with another.
2222+ *
2223+ * @tparam StringType The string type.
2224+ * @param s The string to modify.
2225+ * @param from The substring to replace.
2226 * @param to The substring to replace with.
2227 * @return Returns \c true only if at least one replacement is performed.
2228 */
2229
2230=== added file 'src/util/csv_parser.cpp'
2231--- src/util/csv_parser.cpp 1970-01-01 00:00:00 +0000
2232+++ src/util/csv_parser.cpp 2013-09-16 19:47:46 +0000
2233@@ -0,0 +1,85 @@
2234+/*
2235+ * Copyright 2006-2008 The FLWOR Foundation.
2236+ *
2237+ * Licensed under the Apache License, Version 2.0 (the "License");
2238+ * you may not use this file except in compliance with the License.
2239+ * You may obtain a copy of the License at
2240+ *
2241+ * http://www.apache.org/licenses/LICENSE-2.0
2242+ *
2243+ * Unless required by applicable law or agreed to in writing, software
2244+ * distributed under the License is distributed on an "AS IS" BASIS,
2245+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2246+ * See the License for the specific language governing permissions and
2247+ * limitations under the License.
2248+ */
2249+
2250+#include "csv_parser.h"
2251+
2252+namespace zorba {
2253+
2254+///////////////////////////////////////////////////////////////////////////////
2255+
2256+bool csv_parser::next_value( zstring *value, bool *eol, bool *quoted ) const {
2257+ value->clear();
2258+ char c;
2259+ bool in_quote = false;
2260+ bool is_quoted = false;
2261+
2262+ while ( is_->get( c ) ) {
2263+ if ( in_quote ) {
2264+ if ( quote_esc_ == quote_ ) { // ""
2265+ if ( c == quote_ ) {
2266+ c = is_->peek();
2267+ if ( is_->good() ) {
2268+ if ( c != quote_ ) {
2269+ in_quote = false;
2270+ continue;
2271+ }
2272+ is_->get();
2273+ }
2274+ }
2275+ } else { // \"
2276+ if ( c == quote_ ) {
2277+ in_quote = false;
2278+ continue;
2279+ }
2280+ if ( c == quote_esc_ && !is_->get( c ) )
2281+ break;
2282+ }
2283+ } else {
2284+ if ( c == quote_ ) {
2285+ in_quote = is_quoted = true;
2286+ continue;
2287+ }
2288+ if ( c == sep_ ) {
2289+ *eol = false;
2290+ goto return_true;
2291+ }
2292+ switch ( c ) {
2293+ case '\r':
2294+ if ( ((c = is_->peek()), is_->good()) && c == '\n' )
2295+ is_->get();
2296+ // no break;
2297+ case '\n':
2298+ *eol = true;
2299+ goto return_true;
2300+ } // switch
2301+ } // else
2302+ *value += c;
2303+ } // while
2304+
2305+ if ( value->empty() )
2306+ return false;
2307+
2308+ *eol = true;
2309+return_true:
2310+ if ( quoted )
2311+ *quoted = is_quoted;
2312+ return true;
2313+}
2314+
2315+///////////////////////////////////////////////////////////////////////////////
2316+
2317+} // namespace zorba
2318+/* vim:set et sw=2 ts=2: */
2319
2320=== added file 'src/util/csv_parser.h'
2321--- src/util/csv_parser.h 1970-01-01 00:00:00 +0000
2322+++ src/util/csv_parser.h 2013-09-16 19:47:46 +0000
2323@@ -0,0 +1,154 @@
2324+/*
2325+ * Copyright 2006-2008 The FLWOR Foundation.
2326+ *
2327+ * Licensed under the Apache License, Version 2.0 (the "License");
2328+ * you may not use this file except in compliance with the License.
2329+ * You may obtain a copy of the License at
2330+ *
2331+ * http://www.apache.org/licenses/LICENSE-2.0
2332+ *
2333+ * Unless required by applicable law or agreed to in writing, software
2334+ * distributed under the License is distributed on an "AS IS" BASIS,
2335+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2336+ * See the License for the specific language governing permissions and
2337+ * limitations under the License.
2338+ */
2339+
2340+#ifndef ZORBA_CSV_H
2341+#define ZORBA_CSV_H
2342+
2343+#include <zorba/internal/cxx_util.h>
2344+
2345+#include "zorbatypes/zstring.h"
2346+
2347+namespace zorba {
2348+
2349+///////////////////////////////////////////////////////////////////////////////
2350+
2351+/**
2352+ * Parses a CSV (Comma-Separated Values) stream.
2353+ * See RFC 4180: "Common Format and MIME Type for Comma-Separated Values (CSV)
2354+ * Files."
2355+ */
2356+class csv_parser {
2357+public:
2358+ /**
2359+ * Constructs a %csv_parser.
2360+ *
2361+ * @param sep The value separator to use.
2362+ * @param quote The quote character to use. (The quote escape is a doubling
2363+ * of this character.)
2364+ */
2365+ csv_parser( char sep = ',', char quote = '"' ) {
2366+ is_ = 0;
2367+ sep_ = sep;
2368+ quote_ = quote_esc_ = quote;
2369+ }
2370+
2371+ /**
2372+ * Constructs a %csv_parser.
2373+ *
2374+ * @param sep The value separator to use.
2375+ * @param quote The quote character to use.
2376+ * @param quote_esc The quote-escape character to use. If it matches
2377+ * \a quote, then a quote is escaped by doubling it.
2378+ */
2379+ csv_parser( char sep, char quote, char quote_esc ) {
2380+ is_ = 0;
2381+ sep_ = sep;
2382+ quote_ = quote;
2383+ quote_esc_ = quote_esc;
2384+ }
2385+
2386+ /**
2387+ * Constructs a %csv_parser.
2388+ *
2389+ * @param is The istream to read from.
2390+ * @param sep The value separator to use.
2391+ * @param quote The quote character to use. (The quote escape is a doubling
2392+ * of this character.)
2393+ */
2394+ csv_parser( std::istream &is, char sep = ',', char quote = '"' ) {
2395+ is_ = &is;
2396+ sep_ = sep;
2397+ quote_ = quote_esc_ = quote;
2398+ }
2399+
2400+ /**
2401+ * Constructs a %csv_parser.
2402+ *
2403+ * @param is The istream to read from.
2404+ * @param sep The value separator to use.
2405+ * @param quote The quote character to use.
2406+ * @param quote_esc The quote-escape character to use. If it matches
2407+ * \a quote, then a quote is escaped by doubling it.
2408+ */
2409+ csv_parser( std::istream &is, char sep, char quote, char quote_esc ) {
2410+ is_ = &is;
2411+ sep_ = sep;
2412+ quote_ = quote;
2413+ quote_esc_ = quote_esc;
2414+ }
2415+
2416+ /**
2417+ * Parses the next value.
2418+ *
2419+ * @param value A pointer to the string to receive the next value.
2420+ * @param eol Set to \c true only when \a value is set to the last value on a
2421+ * line.
2422+ * @param quoted If not \c null, set to \c true only when \a value was
2423+ * quoted.
2424+ * @return Returns \c true only if a value was parsed; \c false otherwise.
2425+ */
2426+ bool next_value( zstring *value, bool *eol, bool *quoted = nullptr ) const;
2427+
2428+ /**
2429+ * Sets the quote character to use.
2430+ *
2431+ * @param quote The quote character to use.
2432+ */
2433+ void set_quote( char quote ) {
2434+ quote_ = quote;
2435+ }
2436+
2437+ /**
2438+ * Sets the quote-escape character to use. If it matches the quote
2439+ * character, en a quote is escaped by doubling it.
2440+ *
2441+ * @param quote_esc The quote-escape character to use.
2442+ */
2443+ void set_quote_esc( char quote_esc ) {
2444+ quote_esc_ = quote_esc;
2445+ }
2446+
2447+ /**
2448+ * Sets the value-separator character to use.
2449+ *
2450+ * @param sep The value separator character to use.
2451+ */
2452+ void set_separator( char sep ) {
2453+ sep_ = sep;
2454+ }
2455+
2456+ /**
2457+ * Sets the istream to read from.
2458+ *
2459+ * @param is The istream to read from.
2460+ */
2461+ void set_stream( std::istream &is ) {
2462+ is_ = &is;
2463+ }
2464+
2465+private:
2466+ std::istream *is_;
2467+ char quote_;
2468+ char quote_esc_;
2469+ char sep_;
2470+};
2471+
2472+///////////////////////////////////////////////////////////////////////////////
2473+
2474+} // namespace std
2475+
2476+#endif /* ZORBA_CSV_H */
2477+/* vim:set et sw=2 ts=2: */
2478
2479=== modified file 'src/util/json_parser.cpp'
2480--- src/util/json_parser.cpp 2013-07-15 15:09:19 +0000
2481+++ src/util/json_parser.cpp 2013-09-16 19:47:46 +0000
2482@@ -234,7 +234,7 @@
2483 return false;
2484 }
2485
2486-bool lexer::next( token *t ) {
2487+bool lexer::next( token *t, bool throw_exceptions ) {
2488 while ( true ) {
2489 set_cur_loc();
2490 char c;
2491@@ -253,7 +253,8 @@
2492 //
2493 location::line_type const quote_line = cur_loc_.line();
2494 location::column_type const quote_col = cur_loc_.column();
2495- parse_string( &t->value_ );
2496+ if ( !parse_string( &t->value_, throw_exceptions ) )
2497+ return false;
2498 t->type_ = token::string;
2499 t->loc_.set(
2500 cur_loc_.file(), quote_line, quote_col, prev_line_, prev_col_
2501@@ -270,17 +271,25 @@
2502 case '6':
2503 case '7':
2504 case '8':
2505- case '9':
2506- t->numeric_type_ = parse_number( c, &t->value_ );
2507+ case '9': {
2508+ token::numeric_type nt;
2509+ if ( !(nt = parse_number( c, &t->value_, throw_exceptions )) )
2510+ return false;
2511+ t->numeric_type_ = nt;
2512 t->type_ = token::number;
2513 set_loc_range( &t->loc_ );
2514 return true;
2515- case 'f': // false
2516- case 'n': // null
2517- case 't': // true
2518- t->type_ = parse_literal( c, &t->value_ );
2519+ }
2520+ case 'f': // false
2521+ case 'n': // null
2522+ case 't': { // true
2523+ token::type tt;
2524+ if ( !(tt = parse_literal( c, &t->value_, throw_exceptions )) )
2525+ return false;
2526+ t->type_ = tt;
2527 set_loc_range( &t->loc_ );
2528 return true;
2529+ }
2530 case '[':
2531 case '{':
2532 case ']':
2533@@ -291,12 +300,15 @@
2534 t->loc_ = cur_loc_;
2535 return true;
2536 default:
2537- throw illegal_character( cur_loc_, c );
2538+ if ( throw_exceptions )
2539+ throw illegal_character( cur_loc_, c );
2540+ return false;
2541 }
2542 } // while
2543 }
2544
2545-unicode::code_point lexer::parse_codepoint() {
2546+bool lexer::parse_codepoint( unicode::code_point *result,
2547+ bool throw_exceptions ) {
2548 static char const hex_digits[] = "0123456789ABCDEF";
2549
2550 char c;
2551@@ -307,10 +319,10 @@
2552 unicode::code_point cp = 0;
2553 for ( int i = 1; i <= 4; ++i ) {
2554 if ( !get_char( &c ) )
2555- throw illegal_codepoint( set_cur_loc_end( false ), cp_string );
2556+ goto error_set_cur_loc_end_false;
2557 cp_string += c;
2558 if ( !ascii::is_xdigit( c ) )
2559- throw illegal_codepoint( set_cur_loc_end(), cp_string );
2560+ goto error_set_cur_loc_end;
2561 c = ascii::to_upper( c );
2562 char const *const p = std::strchr( hex_digits, c );
2563 assert( p );
2564@@ -319,38 +331,49 @@
2565
2566 if ( unicode::is_high_surrogate( cp ) ) {
2567 if ( high_surrogate )
2568- throw illegal_codepoint( set_cur_loc_end(), cp_string );
2569+ goto error_set_cur_loc_end;
2570 //
2571 // It's easier to parse the \u for the low surrogate here rather than
2572 // trying to manage state in parse_string().
2573 //
2574 if ( !get_char( &c ) )
2575- throw illegal_codepoint( set_cur_loc_end( false ), cp_string );
2576+ goto error_set_cur_loc_end_false;
2577 cp_string += c;
2578- if ( c != '\\' )
2579- throw illegal_codepoint( set_cur_loc_end(), cp_string );
2580- if ( !get_char( &c ) )
2581- throw illegal_codepoint( set_cur_loc_end(), cp_string );
2582+ if ( c != '\\' || !get_char( &c ) )
2583+ goto error_set_cur_loc_end;
2584 cp_string += c;
2585 if ( c != 'u' )
2586- throw illegal_codepoint( set_cur_loc_end(), cp_string );
2587+ goto error_set_cur_loc_end;
2588
2589 high_surrogate = cp;
2590 continue;
2591 }
2592 if ( unicode::is_low_surrogate( cp ) ) {
2593 if ( !high_surrogate )
2594- throw illegal_codepoint( set_cur_loc_end(), cp_string );
2595- return unicode::convert_surrogate( high_surrogate, cp );
2596+ goto error_set_cur_loc_end;
2597+ *result = unicode::convert_surrogate( high_surrogate, cp );
2598+ return true;
2599 }
2600 if ( high_surrogate )
2601- throw illegal_codepoint( set_cur_loc_end(), cp_string );
2602-
2603- return cp;
2604- }
2605+ goto error_set_cur_loc_end;
2606+
2607+ *result = cp;
2608+ return true;
2609+ } // while
2610+
2611+error_set_cur_loc_end:
2612+ if ( throw_exceptions )
2613+ throw illegal_codepoint( set_cur_loc_end(), cp_string );
2614+ return false;
2615+
2616+error_set_cur_loc_end_false:
2617+ if ( throw_exceptions )
2618+ throw illegal_codepoint( set_cur_loc_end( false ), cp_string );
2619+ return false;
2620 }
2621
2622-token::type lexer::parse_literal( char first_c, token::value_type *value ) {
2623+token::type lexer::parse_literal( char first_c, token::value_type *value,
2624+ bool throw_exceptions ) {
2625 static token::value_type const false_value( "false" );
2626 static token::value_type const null_value ( "null" );
2627 static token::value_type const true_value ( "true" );
2628@@ -366,18 +389,31 @@
2629 char c;
2630 for ( char const *s = value->c_str(); *++s; ) {
2631 if ( !get_char( &c ) )
2632- throw illegal_literal( set_cur_loc_end( false ) );
2633+ goto error_set_cur_loc_end_false;
2634 if ( c != *s )
2635- throw illegal_literal( set_cur_loc_end() );
2636+ goto error_set_cur_loc_end;
2637 }
2638 if ( peek_char( &c ) && (ascii::is_alnum( c ) || c == '_') )
2639+ goto error_set_cur_loc_end_false;
2640+
2641+ return tt;
2642+
2643+error_set_cur_loc_end:
2644+ if ( throw_exceptions )
2645+ throw illegal_literal( set_cur_loc_end() );
2646+ return token::none;
2647+
2648+error_set_cur_loc_end_false:
2649+ if ( throw_exceptions )
2650 throw illegal_literal( set_cur_loc_end( false ) );
2651-
2652- return tt;
2653+ return token::none;
2654 }
2655
2656 token::numeric_type lexer::parse_number( char first_c,
2657- token::value_type *value ) {
2658+ token::value_type *value,
2659+ bool throw_exceptions ) {
2660+ token::numeric_type numeric_type;
2661+
2662 value->clear();
2663
2664 // <number> ::= [-] <int> [<frac>] [<exp>]
2665@@ -385,23 +421,25 @@
2666 if ( c == '-' ) {
2667 *value += c;
2668 if ( !get_char( &c ) )
2669- throw illegal_number( set_cur_loc_end( false ) );
2670+ goto error_set_cur_loc_end_false;
2671 }
2672
2673 // <int> := '0' | <1-9> <digit>*
2674 if ( !ascii::is_digit( c ) )
2675- throw illegal_number( set_cur_loc_end() );
2676+ goto error_set_cur_loc_end;
2677 *value += c;
2678- token::numeric_type numeric_type = token::integer;
2679+ numeric_type = token::integer;
2680 if ( c == '0' ) {
2681 if ( !peek_char( &c ) )
2682 goto done;
2683+ if ( ascii::is_alnum( c ) )
2684+ goto error_set_cur_loc_end_false;
2685 } else {
2686 while ( true ) {
2687 if ( !peek_char( &c ) )
2688 goto done;
2689 if ( ascii::is_alpha( c ) && c != 'e' && c != 'E' )
2690- throw illegal_number( set_cur_loc_end( false ) );
2691+ goto error_set_cur_loc_end_false;
2692 if ( !ascii::is_digit( c ) )
2693 break;
2694 get_char( &c );
2695@@ -414,16 +452,16 @@
2696 get_char( &c );
2697 *value += c;
2698 if ( !get_char( &c ) )
2699- throw illegal_number( set_cur_loc_end( false ) );
2700+ goto error_set_cur_loc_end_false;
2701 if ( !ascii::is_digit( c ) )
2702- throw illegal_number( set_cur_loc_end() );
2703+ goto error_set_cur_loc_end;
2704 *value += c;
2705 numeric_type = token::decimal;
2706 while ( true ) {
2707 if ( !peek_char( &c ) )
2708 goto done;
2709 if ( ascii::is_alpha( c ) && c != 'e' && c != 'E' )
2710- throw illegal_number( set_cur_loc_end( false ) );
2711+ goto error_set_cur_loc_end_false;
2712 if ( !ascii::is_digit( c ) )
2713 break;
2714 get_char( &c );
2715@@ -438,21 +476,21 @@
2716 get_char( &c );
2717 *value += c;
2718 if ( !get_char( &c ) )
2719- throw illegal_number( set_cur_loc_end( false ) );
2720+ goto error_set_cur_loc_end_false;
2721 if ( c == '+' || c == '-' ) {
2722 *value += c;
2723 if ( !get_char( &c ) )
2724- throw illegal_number( set_cur_loc_end( false ) );
2725+ goto error_set_cur_loc_end_false;
2726 }
2727 if ( !ascii::is_digit( c ) )
2728- throw illegal_number( set_cur_loc_end() );
2729+ goto error_set_cur_loc_end;
2730 *value += c;
2731 numeric_type = token::floating_point;
2732 while ( true ) {
2733 if ( !peek_char( &c ) )
2734 goto done;
2735 if ( ascii::is_alpha( c ) )
2736- throw illegal_number( set_cur_loc_end( false ) );
2737+ goto error_set_cur_loc_end_false;
2738 if ( !ascii::is_digit( c ) )
2739 break;
2740 get_char( &c );
2741@@ -462,9 +500,19 @@
2742
2743 done:
2744 return numeric_type;
2745+
2746+error_set_cur_loc_end:
2747+ if ( throw_exceptions )
2748+ throw illegal_number( set_cur_loc_end() );
2749+ return token::non_numeric;
2750+
2751+error_set_cur_loc_end_false:
2752+ if ( throw_exceptions )
2753+ throw illegal_number( set_cur_loc_end( false ) );
2754+ return token::non_numeric;
2755 }
2756
2757-void lexer::parse_string( token::value_type *value ) {
2758+bool lexer::parse_string( token::value_type *value, bool throw_exceptions ) {
2759 value->clear();
2760 bool got_backslash = false;
2761 location start_loc( cur_loc_ );
2762@@ -478,8 +526,11 @@
2763 set_cur_loc();
2764
2765 char c;
2766- if ( !get_char( &c ) )
2767- throw unterminated_string( set_loc_end( &start_loc, line_, col_ ) );
2768+ if ( !get_char( &c ) ) {
2769+ if ( throw_exceptions )
2770+ throw unterminated_string( set_loc_end( &start_loc, line_, col_ ) );
2771+ return false;
2772+ }
2773 if ( got_backslash ) {
2774 got_backslash = false;
2775 switch ( c ) {
2776@@ -503,11 +554,17 @@
2777 case 't':
2778 *value += '\t';
2779 break;
2780- case 'u':
2781- utf8::encode( parse_codepoint(), value );
2782+ case 'u': {
2783+ unicode::code_point cp;
2784+ if ( !parse_codepoint( &cp, throw_exceptions ) )
2785+ return false;
2786+ utf8::encode( cp, value );
2787 break;
2788+ }
2789 default:
2790- throw illegal_escape( set_cur_loc_end(), c );
2791+ if ( throw_exceptions )
2792+ throw illegal_escape( set_cur_loc_end(), c );
2793+ return false;
2794 }
2795 continue;
2796 }
2797@@ -517,7 +574,7 @@
2798 got_backslash = true;
2799 break;
2800 case '"':
2801- return;
2802+ return true;
2803 default:
2804 *value += c;
2805 }
2806
2807=== modified file 'src/util/json_parser.h'
2808--- src/util/json_parser.h 2013-07-15 15:09:19 +0000
2809+++ src/util/json_parser.h 2013-09-16 19:47:46 +0000
2810@@ -484,10 +484,12 @@
2811 * Gets the next token, if any.
2812 *
2813 * @param result A pointer to the token to get into.
2814+ * @param throw_exceptions If \c true and there is a lexical error, throws an
2815+ * exception; if \c false, returns \c false.
2816 * @return Returns \c true only if there was a next token.
2817- * @throws exception upon error.
2818+ * @throws exception upon error unless \a throw_exceptions is \c false.
2819 */
2820- bool next( token *result );
2821+ bool next( token *result, bool throw_exceptions = true );
2822
2823 /**
2824 * Sets the file location.
2825@@ -501,10 +503,11 @@
2826 private:
2827 bool get_char( char* );
2828 bool peek_char( char* );
2829- unicode::code_point parse_codepoint();
2830- token::type parse_literal( char, token::value_type* );
2831- token::numeric_type parse_number( char, token::value_type* );
2832- void parse_string( token::value_type* );
2833+ bool parse_codepoint( unicode::code_point *cp, bool throw_exceptions );
2834+ token::type parse_literal( char, token::value_type*, bool throw_exceptions );
2835+ token::numeric_type parse_number( char, token::value_type*,
2836+ bool throw_exceptions );
2837+ bool parse_string( token::value_type*, bool throw_exceptions );
2838 void set_cur_loc();
2839 location& set_cur_loc_end( bool prev = true );
2840 void set_loc_range( location* );
2841@@ -514,6 +517,7 @@
2842 line_type line_, prev_line_;
2843 column_type col_, prev_col_;
2844 location cur_loc_;
2845+ bool throw_exceptions_;
2846 };
2847
2848 ///////////////////////////////////////////////////////////////////////////////
2849
2850=== added directory 'test/rbkt/ExpQueryResults/zorba/csv'
2851=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-parse-01.xml.res'
2852--- test/rbkt/ExpQueryResults/zorba/csv/csv-parse-01.xml.res 1970-01-01 00:00:00 +0000
2853+++ test/rbkt/ExpQueryResults/zorba/csv/csv-parse-01.xml.res 2013-09-16 19:47:46 +0000
2854@@ -0,0 +1,17 @@
2855+{
2856+ "first" : "one",
2857+ "second" : "two",
2858+ "third" : "three"
2859+}{
2860+ "first" : "quoted",
2861+ "second" : "embedded \" quote",
2862+ "third" : "embedded\r\nnewline"
2863+}{
2864+ "first" : "\" leading quote",
2865+ "second" : "",
2866+ "third" : "trailing quote \""
2867+}{
2868+ "first" : "last",
2869+ "second" : "three",
2870+ "third" : "fields"
2871+}
2872
2873=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-parse-cast-01.xml.res'
2874--- test/rbkt/ExpQueryResults/zorba/csv/csv-parse-cast-01.xml.res 1970-01-01 00:00:00 +0000
2875+++ test/rbkt/ExpQueryResults/zorba/csv/csv-parse-cast-01.xml.res 2013-09-16 19:47:46 +0000
2876@@ -0,0 +1,8 @@
2877+{
2878+ "string" : "foo",
2879+ "integer" : 42,
2880+ "decimal" : 98.6,
2881+ "double" : 10000,
2882+ "boolean" : false,
2883+ "null" : null
2884+}
2885
2886=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-parse-cast-unquoted-01.xml.res'
2887--- test/rbkt/ExpQueryResults/zorba/csv/csv-parse-cast-unquoted-01.xml.res 1970-01-01 00:00:00 +0000
2888+++ test/rbkt/ExpQueryResults/zorba/csv/csv-parse-cast-unquoted-01.xml.res 2013-09-16 19:47:46 +0000
2889@@ -0,0 +1,8 @@
2890+{
2891+ "string" : "foo",
2892+ "integer" : "42",
2893+ "decimal" : "98.6",
2894+ "double" : "1E4",
2895+ "boolean" : "false",
2896+ "null" : "null"
2897+}
2898
2899=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-parse-count-01.xml.res'
2900--- test/rbkt/ExpQueryResults/zorba/csv/csv-parse-count-01.xml.res 1970-01-01 00:00:00 +0000
2901+++ test/rbkt/ExpQueryResults/zorba/csv/csv-parse-count-01.xml.res 2013-09-16 19:47:46 +0000
2902@@ -0,0 +1,1 @@
2903+4
2904
2905=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-parse-count-02.xml.res'
2906--- test/rbkt/ExpQueryResults/zorba/csv/csv-parse-count-02.xml.res 1970-01-01 00:00:00 +0000
2907+++ test/rbkt/ExpQueryResults/zorba/csv/csv-parse-count-02.xml.res 2013-09-16 19:47:46 +0000
2908@@ -0,0 +1,1 @@
2909+4
2910
2911=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-parse-extra-name-01.xml.res'
2912--- test/rbkt/ExpQueryResults/zorba/csv/csv-parse-extra-name-01.xml.res 1970-01-01 00:00:00 +0000
2913+++ test/rbkt/ExpQueryResults/zorba/csv/csv-parse-extra-name-01.xml.res 2013-09-16 19:47:46 +0000
2914@@ -0,0 +1,10 @@
2915+{
2916+ "first" : "one",
2917+ "second" : "two",
2918+ "third" : "three",
2919+ "field4" : "four"
2920+}{
2921+ "first" : "last",
2922+ "second" : "three",
2923+ "third" : "fields"
2924+}
2925
2926=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-parse-extra-name-02.xml.res'
2927--- test/rbkt/ExpQueryResults/zorba/csv/csv-parse-extra-name-02.xml.res 1970-01-01 00:00:00 +0000
2928+++ test/rbkt/ExpQueryResults/zorba/csv/csv-parse-extra-name-02.xml.res 2013-09-16 19:47:46 +0000
2929@@ -0,0 +1,10 @@
2930+{
2931+ "first" : "one",
2932+ "second" : "two",
2933+ "third" : "three",
2934+ "field-4" : "four"
2935+}{
2936+ "first" : "last",
2937+ "second" : "three",
2938+ "third" : "fields"
2939+}
2940
2941=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-parse-field-names-01.xml.res'
2942--- test/rbkt/ExpQueryResults/zorba/csv/csv-parse-field-names-01.xml.res 1970-01-01 00:00:00 +0000
2943+++ test/rbkt/ExpQueryResults/zorba/csv/csv-parse-field-names-01.xml.res 2013-09-16 19:47:46 +0000
2944@@ -0,0 +1,17 @@
2945+{
2946+ "first" : "one",
2947+ "second" : "two",
2948+ "third" : "three"
2949+}{
2950+ "first" : "quoted",
2951+ "second" : "embedded \" quote",
2952+ "third" : "embedded\r\nnewline"
2953+}{
2954+ "first" : "\" leading quote",
2955+ "second" : "",
2956+ "third" : "trailing quote \""
2957+}{
2958+ "first" : "last",
2959+ "second" : "three",
2960+ "third" : "fields"
2961+}
2962
2963=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-parse-missing-omit-01.xml.res'
2964--- test/rbkt/ExpQueryResults/zorba/csv/csv-parse-missing-omit-01.xml.res 1970-01-01 00:00:00 +0000
2965+++ test/rbkt/ExpQueryResults/zorba/csv/csv-parse-missing-omit-01.xml.res 2013-09-16 19:47:46 +0000
2966@@ -0,0 +1,8 @@
2967+{
2968+ "second" : "two",
2969+ "third" : "three"
2970+}{
2971+ "first" : "last",
2972+ "second" : "three",
2973+ "third" : "fields"
2974+}
2975
2976=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-parse-missing-omit-02.xml.res'
2977--- test/rbkt/ExpQueryResults/zorba/csv/csv-parse-missing-omit-02.xml.res 1970-01-01 00:00:00 +0000
2978+++ test/rbkt/ExpQueryResults/zorba/csv/csv-parse-missing-omit-02.xml.res 2013-09-16 19:47:46 +0000
2979@@ -0,0 +1,8 @@
2980+{
2981+ "first" : "one",
2982+ "third" : "three"
2983+}{
2984+ "first" : "last",
2985+ "second" : "three",
2986+ "third" : "fields"
2987+}
2988
2989=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-parse-missing-omit-03.xml.res'
2990--- test/rbkt/ExpQueryResults/zorba/csv/csv-parse-missing-omit-03.xml.res 1970-01-01 00:00:00 +0000
2991+++ test/rbkt/ExpQueryResults/zorba/csv/csv-parse-missing-omit-03.xml.res 2013-09-16 19:47:46 +0000
2992@@ -0,0 +1,8 @@
2993+{
2994+ "first" : "one",
2995+ "second" : "two"
2996+}{
2997+ "first" : "last",
2998+ "second" : "three",
2999+ "third" : "fields"
3000+}
3001
3002=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-parse-missing-omit-04.xml.res'
3003--- test/rbkt/ExpQueryResults/zorba/csv/csv-parse-missing-omit-04.xml.res 1970-01-01 00:00:00 +0000
3004+++ test/rbkt/ExpQueryResults/zorba/csv/csv-parse-missing-omit-04.xml.res 2013-09-16 19:47:46 +0000
3005@@ -0,0 +1,8 @@
3006+{
3007+ "first" : "one",
3008+ "second" : "two"
3009+}{
3010+ "first" : "last",
3011+ "second" : "three",
3012+ "third" : "fields"
3013+}
3014
3015=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-parse-quote-char-01.xml.res'
3016--- test/rbkt/ExpQueryResults/zorba/csv/csv-parse-quote-char-01.xml.res 1970-01-01 00:00:00 +0000
3017+++ test/rbkt/ExpQueryResults/zorba/csv/csv-parse-quote-char-01.xml.res 2013-09-16 19:47:46 +0000
3018@@ -0,0 +1,17 @@
3019+{
3020+ "first" : "one",
3021+ "second" : "two",
3022+ "third" : "three"
3023+}{
3024+ "first" : "quoted",
3025+ "second" : "embedded ' quote",
3026+ "third" : "embedded\r\nnewline"
3027+}{
3028+ "first" : "' leading quote",
3029+ "second" : "",
3030+ "third" : "trailing quote '"
3031+}{
3032+ "first" : "last",
3033+ "second" : "three",
3034+ "third" : "fields"
3035+}
3036
3037=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-parse-quote-escape-01.xml.res'
3038--- test/rbkt/ExpQueryResults/zorba/csv/csv-parse-quote-escape-01.xml.res 1970-01-01 00:00:00 +0000
3039+++ test/rbkt/ExpQueryResults/zorba/csv/csv-parse-quote-escape-01.xml.res 2013-09-16 19:47:46 +0000
3040@@ -0,0 +1,17 @@
3041+{
3042+ "first" : "one",
3043+ "second" : "two",
3044+ "third" : "three"
3045+}{
3046+ "first" : "quoted",
3047+ "second" : "embedded \" quote",
3048+ "third" : "embedded\r\nnewline"
3049+}{
3050+ "first" : "\" leading quote",
3051+ "second" : "",
3052+ "third" : "trailing quote \""
3053+}{
3054+ "first" : "last",
3055+ "second" : "three",
3056+ "third" : "fields"
3057+}
3058
3059=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-parse-separator-01.xml.res'
3060--- test/rbkt/ExpQueryResults/zorba/csv/csv-parse-separator-01.xml.res 1970-01-01 00:00:00 +0000
3061+++ test/rbkt/ExpQueryResults/zorba/csv/csv-parse-separator-01.xml.res 2013-09-16 19:47:46 +0000
3062@@ -0,0 +1,17 @@
3063+{
3064+ "first" : "one",
3065+ "second" : "two",
3066+ "third" : "three"
3067+}{
3068+ "first" : "quoted",
3069+ "second" : "embedded \" quote",
3070+ "third" : "embedded\r\nnewline"
3071+}{
3072+ "first" : "\" leading quote",
3073+ "second" : "",
3074+ "third" : "trailing quote \""
3075+}{
3076+ "first" : "last",
3077+ "second" : "three",
3078+ "third" : "fields"
3079+}
3080
3081=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-parse-skip-01.xml.res'
3082--- test/rbkt/ExpQueryResults/zorba/csv/csv-parse-skip-01.xml.res 1970-01-01 00:00:00 +0000
3083+++ test/rbkt/ExpQueryResults/zorba/csv/csv-parse-skip-01.xml.res 2013-09-16 19:47:46 +0000
3084@@ -0,0 +1,13 @@
3085+{
3086+ "first" : "quoted",
3087+ "second" : "embedded \" quote",
3088+ "third" : "embedded\r\nnewline"
3089+}{
3090+ "first" : "\" leading quote",
3091+ "second" : "",
3092+ "third" : "trailing quote \""
3093+}{
3094+ "first" : "last",
3095+ "second" : "three",
3096+ "third" : "fields"
3097+}
3098
3099=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-parse-skip-02.xml.res'
3100--- test/rbkt/ExpQueryResults/zorba/csv/csv-parse-skip-02.xml.res 1970-01-01 00:00:00 +0000
3101+++ test/rbkt/ExpQueryResults/zorba/csv/csv-parse-skip-02.xml.res 2013-09-16 19:47:46 +0000
3102@@ -0,0 +1,9 @@
3103+{
3104+ "first" : "\" leading quote",
3105+ "second" : "",
3106+ "third" : "trailing quote \""
3107+}{
3108+ "first" : "last",
3109+ "second" : "three",
3110+ "third" : "fields"
3111+}
3112
3113=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-parse-skip-03.xml.res'
3114--- test/rbkt/ExpQueryResults/zorba/csv/csv-parse-skip-03.xml.res 1970-01-01 00:00:00 +0000
3115+++ test/rbkt/ExpQueryResults/zorba/csv/csv-parse-skip-03.xml.res 2013-09-16 19:47:46 +0000
3116@@ -0,0 +1,5 @@
3117+{
3118+ "first" : "\" leading quote",
3119+ "second" : "",
3120+ "third" : "trailing quote \""
3121+}
3122
3123=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-01.xml.res'
3124--- test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-01.xml.res 1970-01-01 00:00:00 +0000
3125+++ test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-01.xml.res 2013-09-16 19:47:46 +0000
3126@@ -0,0 +1,4 @@
3127+first,second,third
3128+one,two,three
3129+four,"embedded "" quote","embedded
3130+newline"
3131
3132=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-boolean-01.xml.res'
3133--- test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-boolean-01.xml.res 1970-01-01 00:00:00 +0000
3134+++ test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-boolean-01.xml.res 2013-09-16 19:47:46 +0000
3135@@ -0,0 +1,2 @@
3136+b1,b2
3137+T,F
3138
3139=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-header-01.xml.res'
3140--- test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-header-01.xml.res 1970-01-01 00:00:00 +0000
3141+++ test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-header-01.xml.res 2013-09-16 19:47:46 +0000
3142@@ -0,0 +1,2 @@
3143+one
3144+two
3145
3146=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-null-01.xml.res'
3147--- test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-null-01.xml.res 1970-01-01 00:00:00 +0000
3148+++ test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-null-01.xml.res 2013-09-16 19:47:46 +0000
3149@@ -0,0 +1,2 @@
3150+foo,bar,baz
3151+f,null,b
3152
3153=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-null-02.xml.res'
3154--- test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-null-02.xml.res 1970-01-01 00:00:00 +0000
3155+++ test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-null-02.xml.res 2013-09-16 19:47:46 +0000
3156@@ -0,0 +1,2 @@
3157+bar
3158+null
3159
3160=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-null-03.xml.res'
3161--- test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-null-03.xml.res 1970-01-01 00:00:00 +0000
3162+++ test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-null-03.xml.res 2013-09-16 19:47:46 +0000
3163@@ -0,0 +1,2 @@
3164+foo,bar,baz
3165+f,,b
3166
3167=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-null-04.xml.res'
3168--- test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-null-04.xml.res 1970-01-01 00:00:00 +0000
3169+++ test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-null-04.xml.res 2013-09-16 19:47:46 +0000
3170@@ -0,0 +1,2 @@
3171+bar
3172
3173+
3174
3175
3176=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-quote-char-01.xml.res'
3177--- test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-quote-char-01.xml.res 1970-01-01 00:00:00 +0000
3178+++ test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-quote-char-01.xml.res 2013-09-16 19:47:46 +0000
3179@@ -0,0 +1,2 @@
3180+field
3181+'embedded , comma'
3182
3183=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-quote-char-02.xml.res'
3184--- test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-quote-char-02.xml.res 1970-01-01 00:00:00 +0000
3185+++ test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-quote-char-02.xml.res 2013-09-16 19:47:46 +0000
3186@@ -0,0 +1,2 @@
3187+field
3188+'embedded '' quote'
3189
3190=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-quote-escape-01.xml.res'
3191--- test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-quote-escape-01.xml.res 1970-01-01 00:00:00 +0000
3192+++ test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-quote-escape-01.xml.res 2013-09-16 19:47:46 +0000
3193@@ -0,0 +1,2 @@
3194+field
3195+'embedded \' quote'
3196
3197=== added file 'test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-separator-01.xml.res'
3198--- test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-separator-01.xml.res 1970-01-01 00:00:00 +0000
3199+++ test/rbkt/ExpQueryResults/zorba/csv/csv-serialize-separator-01.xml.res 2013-09-16 19:47:46 +0000
3200@@ -0,0 +1,4 @@
3201+first|second|third
3202+one|two|three
3203+four|"embedded "" quote"|"embedded
3204+newline"
3205
3206=== added directory 'test/rbkt/Queries/zorba/csv'
3207=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-01.jq'
3208--- test/rbkt/Queries/zorba/csv/csv-parse-01.jq 1970-01-01 00:00:00 +0000
3209+++ test/rbkt/Queries/zorba/csv/csv-parse-01.jq 2013-09-16 19:47:46 +0000
3210@@ -0,0 +1,10 @@
3211+import module namespace csv = "http://zorba.io/modules/json-csv";
3212+import module namespace file = "http://expath.org/ns/file";
3213+
3214+declare variable $rbktPath as xs:string external;
3215+
3216+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-01.csv" )
3217+let $values := file:read-text( $file )
3218+return csv:parse( $values )
3219+
3220+(: vim:set syntax=xquery et sw=2 ts=2: :)
3221
3222=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-01.spec'
3223--- test/rbkt/Queries/zorba/csv/csv-parse-01.spec 1970-01-01 00:00:00 +0000
3224+++ test/rbkt/Queries/zorba/csv/csv-parse-01.spec 2013-09-16 19:47:46 +0000
3225@@ -0,0 +1,4 @@
3226+Serialization: indent=yes
3227+Args:
3228+-x
3229+rbktPath:=xs:string($RBKT_SRC_DIR)
3230
3231=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-cast-01.jq'
3232--- test/rbkt/Queries/zorba/csv/csv-parse-cast-01.jq 1970-01-01 00:00:00 +0000
3233+++ test/rbkt/Queries/zorba/csv/csv-parse-cast-01.jq 2013-09-16 19:47:46 +0000
3234@@ -0,0 +1,10 @@
3235+import module namespace csv = "http://zorba.io/modules/json-csv";
3236+import module namespace file = "http://expath.org/ns/file";
3237+
3238+declare variable $rbktPath as xs:string external;
3239+
3240+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-cast-01.csv" )
3241+let $values := file:read-text( $file )
3242+return csv:parse( $values )
3243+
3244+(: vim:set syntax=xquery et sw=2 ts=2: :)
3245
3246=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-cast-01.spec'
3247--- test/rbkt/Queries/zorba/csv/csv-parse-cast-01.spec 1970-01-01 00:00:00 +0000
3248+++ test/rbkt/Queries/zorba/csv/csv-parse-cast-01.spec 2013-09-16 19:47:46 +0000
3249@@ -0,0 +1,4 @@
3250+Serialization: indent=yes
3251+Args:
3252+-x
3253+rbktPath:=xs:string($RBKT_SRC_DIR)
3254
3255=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-cast-unquoted-01.jq'
3256--- test/rbkt/Queries/zorba/csv/csv-parse-cast-unquoted-01.jq 1970-01-01 00:00:00 +0000
3257+++ test/rbkt/Queries/zorba/csv/csv-parse-cast-unquoted-01.jq 2013-09-16 19:47:46 +0000
3258@@ -0,0 +1,11 @@
3259+import module namespace csv = "http://zorba.io/modules/json-csv";
3260+import module namespace file = "http://expath.org/ns/file";
3261+
3262+declare variable $rbktPath as xs:string external;
3263+
3264+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-cast-01.csv" )
3265+let $values := file:read-text( $file )
3266+let $options := { "cast-unquoted-values" : false }
3267+return csv:parse( $values, $options )
3268+
3269+(: vim:set syntax=xquery et sw=2 ts=2: :)
3270
3271=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-cast-unquoted-01.spec'
3272--- test/rbkt/Queries/zorba/csv/csv-parse-cast-unquoted-01.spec 1970-01-01 00:00:00 +0000
3273+++ test/rbkt/Queries/zorba/csv/csv-parse-cast-unquoted-01.spec 2013-09-16 19:47:46 +0000
3274@@ -0,0 +1,4 @@
3275+Serialization: indent=yes
3276+Args:
3277+-x
3278+rbktPath:=xs:string($RBKT_SRC_DIR)
3279
3280=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-count-01.jq'
3281--- test/rbkt/Queries/zorba/csv/csv-parse-count-01.jq 1970-01-01 00:00:00 +0000
3282+++ test/rbkt/Queries/zorba/csv/csv-parse-count-01.jq 2013-09-16 19:47:46 +0000
3283@@ -0,0 +1,10 @@
3284+import module namespace csv = "http://zorba.io/modules/json-csv";
3285+import module namespace file = "http://expath.org/ns/file";
3286+
3287+declare variable $rbktPath as xs:string external;
3288+
3289+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-01.csv" )
3290+let $values := file:read-text( $file )
3291+return count( csv:parse( $values ) )
3292+
3293+(: vim:set syntax=xquery et sw=2 ts=2: :)
3294
3295=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-count-01.spec'
3296--- test/rbkt/Queries/zorba/csv/csv-parse-count-01.spec 1970-01-01 00:00:00 +0000
3297+++ test/rbkt/Queries/zorba/csv/csv-parse-count-01.spec 2013-09-16 19:47:46 +0000
3298@@ -0,0 +1,3 @@
3299+Args:
3300+-x
3301+rbktPath:=xs:string($RBKT_SRC_DIR)
3302
3303=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-count-02.jq'
3304--- test/rbkt/Queries/zorba/csv/csv-parse-count-02.jq 1970-01-01 00:00:00 +0000
3305+++ test/rbkt/Queries/zorba/csv/csv-parse-count-02.jq 2013-09-16 19:47:46 +0000
3306@@ -0,0 +1,11 @@
3307+import module namespace csv = "http://zorba.io/modules/json-csv";
3308+import module namespace file = "http://expath.org/ns/file";
3309+
3310+declare variable $rbktPath as xs:string external;
3311+
3312+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-no-field-names-01.csv" )
3313+let $values := file:read-text( $file )
3314+let $options := { "field-names" : [ "first", "second", "third" ] }
3315+return count( csv:parse( $values, $options ) )
3316+
3317+(: vim:set syntax=xquery et sw=2 ts=2: :)
3318
3319=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-count-02.spec'
3320--- test/rbkt/Queries/zorba/csv/csv-parse-count-02.spec 1970-01-01 00:00:00 +0000
3321+++ test/rbkt/Queries/zorba/csv/csv-parse-count-02.spec 2013-09-16 19:47:46 +0000
3322@@ -0,0 +1,3 @@
3323+Args:
3324+-x
3325+rbktPath:=xs:string($RBKT_SRC_DIR)
3326
3327=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-extra-name-01.jq'
3328--- test/rbkt/Queries/zorba/csv/csv-parse-extra-name-01.jq 1970-01-01 00:00:00 +0000
3329+++ test/rbkt/Queries/zorba/csv/csv-parse-extra-name-01.jq 2013-09-16 19:47:46 +0000
3330@@ -0,0 +1,11 @@
3331+import module namespace csv = "http://zorba.io/modules/json-csv";
3332+import module namespace file = "http://expath.org/ns/file";
3333+
3334+declare variable $rbktPath as xs:string external;
3335+
3336+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-extra-01.csv" )
3337+let $values := file:read-text( $file )
3338+let $options := { "extra-name" : "field" }
3339+return csv:parse( $values, $options )
3340+
3341+(: vim:set syntax=xquery et sw=2 ts=2: :)
3342
3343=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-extra-name-01.spec'
3344--- test/rbkt/Queries/zorba/csv/csv-parse-extra-name-01.spec 1970-01-01 00:00:00 +0000
3345+++ test/rbkt/Queries/zorba/csv/csv-parse-extra-name-01.spec 2013-09-16 19:47:46 +0000
3346@@ -0,0 +1,4 @@
3347+Serialization: indent=yes
3348+Args:
3349+-x
3350+rbktPath:=xs:string($RBKT_SRC_DIR)
3351
3352=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-extra-name-02.jq'
3353--- test/rbkt/Queries/zorba/csv/csv-parse-extra-name-02.jq 1970-01-01 00:00:00 +0000
3354+++ test/rbkt/Queries/zorba/csv/csv-parse-extra-name-02.jq 2013-09-16 19:47:46 +0000
3355@@ -0,0 +1,11 @@
3356+import module namespace csv = "http://zorba.io/modules/json-csv";
3357+import module namespace file = "http://expath.org/ns/file";
3358+
3359+declare variable $rbktPath as xs:string external;
3360+
3361+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-extra-01.csv" )
3362+let $values := file:read-text( $file )
3363+let $options := { "extra-name" : "field-#" }
3364+return csv:parse( $values, $options )
3365+
3366+(: vim:set syntax=xquery et sw=2 ts=2: :)
3367
3368=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-extra-name-02.spec'
3369--- test/rbkt/Queries/zorba/csv/csv-parse-extra-name-02.spec 1970-01-01 00:00:00 +0000
3370+++ test/rbkt/Queries/zorba/csv/csv-parse-extra-name-02.spec 2013-09-16 19:47:46 +0000
3371@@ -0,0 +1,4 @@
3372+Serialization: indent=yes
3373+Args:
3374+-x
3375+rbktPath:=xs:string($RBKT_SRC_DIR)
3376
3377=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-extra-name-03.jq'
3378--- test/rbkt/Queries/zorba/csv/csv-parse-extra-name-03.jq 1970-01-01 00:00:00 +0000
3379+++ test/rbkt/Queries/zorba/csv/csv-parse-extra-name-03.jq 2013-09-16 19:47:46 +0000
3380@@ -0,0 +1,10 @@
3381+import module namespace csv = "http://zorba.io/modules/json-csv";
3382+import module namespace file = "http://expath.org/ns/file";
3383+
3384+declare variable $rbktPath as xs:string external;
3385+
3386+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-extra-01.csv" )
3387+let $values := file:read-text( $file )
3388+return csv:parse( $values )
3389+
3390+(: vim:set syntax=xquery et sw=2 ts=2: :)
3391
3392=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-extra-name-03.spec'
3393--- test/rbkt/Queries/zorba/csv/csv-parse-extra-name-03.spec 1970-01-01 00:00:00 +0000
3394+++ test/rbkt/Queries/zorba/csv/csv-parse-extra-name-03.spec 2013-09-16 19:47:46 +0000
3395@@ -0,0 +1,5 @@
3396+Error: http://zorba.io/modules/json-csv:EXTRA_VALUE
3397+Serialization: indent=yes
3398+Args:
3399+-x
3400+rbktPath:=xs:string($RBKT_SRC_DIR)
3401
3402=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-field-names-01.jq'
3403--- test/rbkt/Queries/zorba/csv/csv-parse-field-names-01.jq 1970-01-01 00:00:00 +0000
3404+++ test/rbkt/Queries/zorba/csv/csv-parse-field-names-01.jq 2013-09-16 19:47:46 +0000
3405@@ -0,0 +1,11 @@
3406+import module namespace csv = "http://zorba.io/modules/json-csv";
3407+import module namespace file = "http://expath.org/ns/file";
3408+
3409+declare variable $rbktPath as xs:string external;
3410+
3411+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-no-field-names-01.csv" )
3412+let $values := file:read-text( $file )
3413+let $options := { "field-names" : [ "first", "second", "third" ] }
3414+return csv:parse( $values, $options )
3415+
3416+(: vim:set syntax=xquery et sw=2 ts=2: :)
3417
3418=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-field-names-01.spec'
3419--- test/rbkt/Queries/zorba/csv/csv-parse-field-names-01.spec 1970-01-01 00:00:00 +0000
3420+++ test/rbkt/Queries/zorba/csv/csv-parse-field-names-01.spec 2013-09-16 19:47:46 +0000
3421@@ -0,0 +1,4 @@
3422+Serialization: indent=yes
3423+Args:
3424+-x
3425+rbktPath:=xs:string($RBKT_SRC_DIR)
3426
3427=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-invalid-option-01.jq'
3428--- test/rbkt/Queries/zorba/csv/csv-parse-invalid-option-01.jq 1970-01-01 00:00:00 +0000
3429+++ test/rbkt/Queries/zorba/csv/csv-parse-invalid-option-01.jq 2013-09-16 19:47:46 +0000
3430@@ -0,0 +1,13 @@
3431+(: Test "quote-char" with a string > 1 character in length. :)
3432+
3433+import module namespace csv = "http://zorba.io/modules/json-csv";
3434+import module namespace file = "http://expath.org/ns/file";
3435+
3436+declare variable $rbktPath as xs:string external;
3437+
3438+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-quote-char-01.csv" )
3439+let $values := file:read-text( $file )
3440+let $options := { "quote-char" : "''" }
3441+return csv:parse( $values, $options )
3442+
3443+(: vim:set syntax=xquery et sw=2 ts=2: :)
3444
3445=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-invalid-option-01.spec'
3446--- test/rbkt/Queries/zorba/csv/csv-parse-invalid-option-01.spec 1970-01-01 00:00:00 +0000
3447+++ test/rbkt/Queries/zorba/csv/csv-parse-invalid-option-01.spec 2013-09-16 19:47:46 +0000
3448@@ -0,0 +1,5 @@
3449+Error: http://zorba.io/modules/json-csv:INVALID_OPTION
3450+Serialization: indent=yes
3451+Args:
3452+-x
3453+rbktPath:=xs:string($RBKT_SRC_DIR)
3454
3455=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-invalid-option-02.jq'
3456--- test/rbkt/Queries/zorba/csv/csv-parse-invalid-option-02.jq 1970-01-01 00:00:00 +0000
3457+++ test/rbkt/Queries/zorba/csv/csv-parse-invalid-option-02.jq 2013-09-16 19:47:46 +0000
3458@@ -0,0 +1,13 @@
3459+(: Test "quote-char" with an ISO 8859-1 character. :)
3460+
3461+import module namespace csv = "http://zorba.io/modules/json-csv";
3462+import module namespace file = "http://expath.org/ns/file";
3463+
3464+declare variable $rbktPath as xs:string external;
3465+
3466+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-quote-char-01.csv" )
3467+let $values := file:read-text( $file )
3468+let $options := { "quote-char" : "¦" }
3469+return csv:parse( $values, $options )
3470+
3471+(: vim:set syntax=xquery et sw=2 ts=2: :)
3472
3473=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-invalid-option-02.spec'
3474--- test/rbkt/Queries/zorba/csv/csv-parse-invalid-option-02.spec 1970-01-01 00:00:00 +0000
3475+++ test/rbkt/Queries/zorba/csv/csv-parse-invalid-option-02.spec 2013-09-16 19:47:46 +0000
3476@@ -0,0 +1,5 @@
3477+Error: http://zorba.io/modules/json-csv:INVALID_OPTION
3478+Serialization: indent=yes
3479+Args:
3480+-x
3481+rbktPath:=xs:string($RBKT_SRC_DIR)
3482
3483=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-invalid-option-03.jq'
3484--- test/rbkt/Queries/zorba/csv/csv-parse-invalid-option-03.jq 1970-01-01 00:00:00 +0000
3485+++ test/rbkt/Queries/zorba/csv/csv-parse-invalid-option-03.jq 2013-09-16 19:47:46 +0000
3486@@ -0,0 +1,13 @@
3487+(: Test "quote-char" with a UTF-8 character. :)
3488+
3489+import module namespace csv = "http://zorba.io/modules/json-csv";
3490+import module namespace file = "http://expath.org/ns/file";
3491+
3492+declare variable $rbktPath as xs:string external;
3493+
3494+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-quote-char-01.csv" )
3495+let $values := file:read-text( $file )
3496+let $options := { "quote-char" : "¦" }
3497+return csv:parse( $values, $options )
3498+
3499+(: vim:set syntax=xquery et sw=2 ts=2: :)
3500
3501=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-invalid-option-03.spec'
3502--- test/rbkt/Queries/zorba/csv/csv-parse-invalid-option-03.spec 1970-01-01 00:00:00 +0000
3503+++ test/rbkt/Queries/zorba/csv/csv-parse-invalid-option-03.spec 2013-09-16 19:47:46 +0000
3504@@ -0,0 +1,5 @@
3505+Error: http://zorba.io/modules/json-csv:INVALID_OPTION
3506+Serialization: indent=yes
3507+Args:
3508+-x
3509+rbktPath:=xs:string($RBKT_SRC_DIR)
3510
3511=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-invalid-option-04.jq'
3512--- test/rbkt/Queries/zorba/csv/csv-parse-invalid-option-04.jq 1970-01-01 00:00:00 +0000
3513+++ test/rbkt/Queries/zorba/csv/csv-parse-invalid-option-04.jq 2013-09-16 19:47:46 +0000
3514@@ -0,0 +1,13 @@
3515+(: Test a boolean option with a non-boolean value. :)
3516+
3517+import module namespace csv = "http://zorba.io/modules/json-csv";
3518+import module namespace file = "http://expath.org/ns/file";
3519+
3520+declare variable $rbktPath as xs:string external;
3521+
3522+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-quote-char-01.csv" )
3523+let $values := file:read-text( $file )
3524+let $options := { "cast-unquoted-values" : 1 }
3525+return csv:parse( $values, $options )
3526+
3527+(: vim:set syntax=xquery et sw=2 ts=2: :)
3528
3529=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-invalid-option-04.spec'
3530--- test/rbkt/Queries/zorba/csv/csv-parse-invalid-option-04.spec 1970-01-01 00:00:00 +0000
3531+++ test/rbkt/Queries/zorba/csv/csv-parse-invalid-option-04.spec 2013-09-16 19:47:46 +0000
3532@@ -0,0 +1,5 @@
3533+Error: http://zorba.io/modules/json-csv:INVALID_OPTION
3534+Serialization: indent=yes
3535+Args:
3536+-x
3537+rbktPath:=xs:string($RBKT_SRC_DIR)
3538
3539=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-missing-error-01.jq'
3540--- test/rbkt/Queries/zorba/csv/csv-parse-missing-error-01.jq 1970-01-01 00:00:00 +0000
3541+++ test/rbkt/Queries/zorba/csv/csv-parse-missing-error-01.jq 2013-09-16 19:47:46 +0000
3542@@ -0,0 +1,11 @@
3543+import module namespace csv = "http://zorba.io/modules/json-csv";
3544+import module namespace file = "http://expath.org/ns/file";
3545+
3546+declare variable $rbktPath as xs:string external;
3547+
3548+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-missing-01.csv" )
3549+let $values := file:read-text( $file )
3550+let $options := { "missing-value" : "error" }
3551+return csv:parse( $values, $options )
3552+
3553+(: vim:set syntax=xquery et sw=2 ts=2: :)
3554
3555=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-missing-error-01.spec'
3556--- test/rbkt/Queries/zorba/csv/csv-parse-missing-error-01.spec 1970-01-01 00:00:00 +0000
3557+++ test/rbkt/Queries/zorba/csv/csv-parse-missing-error-01.spec 2013-09-16 19:47:46 +0000
3558@@ -0,0 +1,5 @@
3559+Error: http://zorba.io/modules/json-csv:MISSING_VALUE
3560+Serialization: indent=yes
3561+Args:
3562+-x
3563+rbktPath:=xs:string($RBKT_SRC_DIR)
3564
3565=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-missing-error-02.jq'
3566--- test/rbkt/Queries/zorba/csv/csv-parse-missing-error-02.jq 1970-01-01 00:00:00 +0000
3567+++ test/rbkt/Queries/zorba/csv/csv-parse-missing-error-02.jq 2013-09-16 19:47:46 +0000
3568@@ -0,0 +1,11 @@
3569+import module namespace csv = "http://zorba.io/modules/json-csv";
3570+import module namespace file = "http://expath.org/ns/file";
3571+
3572+declare variable $rbktPath as xs:string external;
3573+
3574+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-missing-02.csv" )
3575+let $values := file:read-text( $file )
3576+let $options := { "missing-value" : "error" }
3577+return csv:parse( $values, $options )
3578+
3579+(: vim:set syntax=xquery et sw=2 ts=2: :)
3580
3581=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-missing-error-02.spec'
3582--- test/rbkt/Queries/zorba/csv/csv-parse-missing-error-02.spec 1970-01-01 00:00:00 +0000
3583+++ test/rbkt/Queries/zorba/csv/csv-parse-missing-error-02.spec 2013-09-16 19:47:46 +0000
3584@@ -0,0 +1,5 @@
3585+Error: http://zorba.io/modules/json-csv:MISSING_VALUE
3586+Serialization: indent=yes
3587+Args:
3588+-x
3589+rbktPath:=xs:string($RBKT_SRC_DIR)
3590
3591=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-missing-error-03.jq'
3592--- test/rbkt/Queries/zorba/csv/csv-parse-missing-error-03.jq 1970-01-01 00:00:00 +0000
3593+++ test/rbkt/Queries/zorba/csv/csv-parse-missing-error-03.jq 2013-09-16 19:47:46 +0000
3594@@ -0,0 +1,11 @@
3595+import module namespace csv = "http://zorba.io/modules/json-csv";
3596+import module namespace file = "http://expath.org/ns/file";
3597+
3598+declare variable $rbktPath as xs:string external;
3599+
3600+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-missing-03.csv" )
3601+let $values := file:read-text( $file )
3602+let $options := { "missing-value" : "error" }
3603+return csv:parse( $values, $options )
3604+
3605+(: vim:set syntax=xquery et sw=2 ts=2: :)
3606
3607=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-missing-error-03.spec'
3608--- test/rbkt/Queries/zorba/csv/csv-parse-missing-error-03.spec 1970-01-01 00:00:00 +0000
3609+++ test/rbkt/Queries/zorba/csv/csv-parse-missing-error-03.spec 2013-09-16 19:47:46 +0000
3610@@ -0,0 +1,5 @@
3611+Error: http://zorba.io/modules/json-csv:MISSING_VALUE
3612+Serialization: indent=yes
3613+Args:
3614+-x
3615+rbktPath:=xs:string($RBKT_SRC_DIR)
3616
3617=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-missing-error-04.jq'
3618--- test/rbkt/Queries/zorba/csv/csv-parse-missing-error-04.jq 1970-01-01 00:00:00 +0000
3619+++ test/rbkt/Queries/zorba/csv/csv-parse-missing-error-04.jq 2013-09-16 19:47:46 +0000
3620@@ -0,0 +1,11 @@
3621+import module namespace csv = "http://zorba.io/modules/json-csv";
3622+import module namespace file = "http://expath.org/ns/file";
3623+
3624+declare variable $rbktPath as xs:string external;
3625+
3626+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-missing-04.csv" )
3627+let $values := file:read-text( $file )
3628+let $options := { "missing-value" : "error" }
3629+return csv:parse( $values, $options )
3630+
3631+(: vim:set syntax=xquery et sw=2 ts=2: :)
3632
3633=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-missing-error-04.spec'
3634--- test/rbkt/Queries/zorba/csv/csv-parse-missing-error-04.spec 1970-01-01 00:00:00 +0000
3635+++ test/rbkt/Queries/zorba/csv/csv-parse-missing-error-04.spec 2013-09-16 19:47:46 +0000
3636@@ -0,0 +1,5 @@
3637+Error: http://zorba.io/modules/json-csv:MISSING_VALUE
3638+Serialization: indent=yes
3639+Args:
3640+-x
3641+rbktPath:=xs:string($RBKT_SRC_DIR)
3642
3643=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-missing-omit-01.jq'
3644--- test/rbkt/Queries/zorba/csv/csv-parse-missing-omit-01.jq 1970-01-01 00:00:00 +0000
3645+++ test/rbkt/Queries/zorba/csv/csv-parse-missing-omit-01.jq 2013-09-16 19:47:46 +0000
3646@@ -0,0 +1,11 @@
3647+import module namespace csv = "http://zorba.io/modules/json-csv";
3648+import module namespace file = "http://expath.org/ns/file";
3649+
3650+declare variable $rbktPath as xs:string external;
3651+
3652+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-missing-01.csv" )
3653+let $values := file:read-text( $file )
3654+let $options := { "missing-value" : "omit" }
3655+return csv:parse( $values, $options )
3656+
3657+(: vim:set syntax=xquery et sw=2 ts=2: :)
3658
3659=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-missing-omit-01.spec'
3660--- test/rbkt/Queries/zorba/csv/csv-parse-missing-omit-01.spec 1970-01-01 00:00:00 +0000
3661+++ test/rbkt/Queries/zorba/csv/csv-parse-missing-omit-01.spec 2013-09-16 19:47:46 +0000
3662@@ -0,0 +1,4 @@
3663+Serialization: indent=yes
3664+Args:
3665+-x
3666+rbktPath:=xs:string($RBKT_SRC_DIR)
3667
3668=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-missing-omit-02.jq'
3669--- test/rbkt/Queries/zorba/csv/csv-parse-missing-omit-02.jq 1970-01-01 00:00:00 +0000
3670+++ test/rbkt/Queries/zorba/csv/csv-parse-missing-omit-02.jq 2013-09-16 19:47:46 +0000
3671@@ -0,0 +1,11 @@
3672+import module namespace csv = "http://zorba.io/modules/json-csv";
3673+import module namespace file = "http://expath.org/ns/file";
3674+
3675+declare variable $rbktPath as xs:string external;
3676+
3677+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-missing-02.csv" )
3678+let $values := file:read-text( $file )
3679+let $options := { "missing-value" : "omit" }
3680+return csv:parse( $values, $options )
3681+
3682+(: vim:set syntax=xquery et sw=2 ts=2: :)
3683
3684=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-missing-omit-02.spec'
3685--- test/rbkt/Queries/zorba/csv/csv-parse-missing-omit-02.spec 1970-01-01 00:00:00 +0000
3686+++ test/rbkt/Queries/zorba/csv/csv-parse-missing-omit-02.spec 2013-09-16 19:47:46 +0000
3687@@ -0,0 +1,4 @@
3688+Serialization: indent=yes
3689+Args:
3690+-x
3691+rbktPath:=xs:string($RBKT_SRC_DIR)
3692
3693=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-missing-omit-03.jq'
3694--- test/rbkt/Queries/zorba/csv/csv-parse-missing-omit-03.jq 1970-01-01 00:00:00 +0000
3695+++ test/rbkt/Queries/zorba/csv/csv-parse-missing-omit-03.jq 2013-09-16 19:47:46 +0000
3696@@ -0,0 +1,11 @@
3697+import module namespace csv = "http://zorba.io/modules/json-csv";
3698+import module namespace file = "http://expath.org/ns/file";
3699+
3700+declare variable $rbktPath as xs:string external;
3701+
3702+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-missing-03.csv" )
3703+let $values := file:read-text( $file )
3704+let $options := { "missing-value" : "omit" }
3705+return csv:parse( $values, $options )
3706+
3707+(: vim:set syntax=xquery et sw=2 ts=2: :)
3708
3709=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-missing-omit-03.spec'
3710--- test/rbkt/Queries/zorba/csv/csv-parse-missing-omit-03.spec 1970-01-01 00:00:00 +0000
3711+++ test/rbkt/Queries/zorba/csv/csv-parse-missing-omit-03.spec 2013-09-16 19:47:46 +0000
3712@@ -0,0 +1,4 @@
3713+Serialization: indent=yes
3714+Args:
3715+-x
3716+rbktPath:=xs:string($RBKT_SRC_DIR)
3717
3718=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-missing-omit-04.jq'
3719--- test/rbkt/Queries/zorba/csv/csv-parse-missing-omit-04.jq 1970-01-01 00:00:00 +0000
3720+++ test/rbkt/Queries/zorba/csv/csv-parse-missing-omit-04.jq 2013-09-16 19:47:46 +0000
3721@@ -0,0 +1,11 @@
3722+import module namespace csv = "http://zorba.io/modules/json-csv";
3723+import module namespace file = "http://expath.org/ns/file";
3724+
3725+declare variable $rbktPath as xs:string external;
3726+
3727+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-missing-04.csv" )
3728+let $values := file:read-text( $file )
3729+let $options := { "missing-value" : "omit" }
3730+return csv:parse( $values, $options )
3731+
3732+(: vim:set syntax=xquery et sw=2 ts=2: :)
3733
3734=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-missing-omit-04.spec'
3735--- test/rbkt/Queries/zorba/csv/csv-parse-missing-omit-04.spec 1970-01-01 00:00:00 +0000
3736+++ test/rbkt/Queries/zorba/csv/csv-parse-missing-omit-04.spec 2013-09-16 19:47:46 +0000
3737@@ -0,0 +1,4 @@
3738+Serialization: indent=yes
3739+Args:
3740+-x
3741+rbktPath:=xs:string($RBKT_SRC_DIR)
3742
3743=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-quote-char-01.jq'
3744--- test/rbkt/Queries/zorba/csv/csv-parse-quote-char-01.jq 1970-01-01 00:00:00 +0000
3745+++ test/rbkt/Queries/zorba/csv/csv-parse-quote-char-01.jq 2013-09-16 19:47:46 +0000
3746@@ -0,0 +1,11 @@
3747+import module namespace csv = "http://zorba.io/modules/json-csv";
3748+import module namespace file = "http://expath.org/ns/file";
3749+
3750+declare variable $rbktPath as xs:string external;
3751+
3752+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-quote-char-01.csv" )
3753+let $values := file:read-text( $file )
3754+let $options := { "quote-char" : "'" }
3755+return csv:parse( $values, $options )
3756+
3757+(: vim:set syntax=xquery et sw=2 ts=2: :)
3758
3759=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-quote-char-01.spec'
3760--- test/rbkt/Queries/zorba/csv/csv-parse-quote-char-01.spec 1970-01-01 00:00:00 +0000
3761+++ test/rbkt/Queries/zorba/csv/csv-parse-quote-char-01.spec 2013-09-16 19:47:46 +0000
3762@@ -0,0 +1,4 @@
3763+Serialization: indent=yes
3764+Args:
3765+-x
3766+rbktPath:=xs:string($RBKT_SRC_DIR)
3767
3768=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-quote-escape-01.jq'
3769--- test/rbkt/Queries/zorba/csv/csv-parse-quote-escape-01.jq 1970-01-01 00:00:00 +0000
3770+++ test/rbkt/Queries/zorba/csv/csv-parse-quote-escape-01.jq 2013-09-16 19:47:46 +0000
3771@@ -0,0 +1,11 @@
3772+import module namespace csv = "http://zorba.io/modules/json-csv";
3773+import module namespace file = "http://expath.org/ns/file";
3774+
3775+declare variable $rbktPath as xs:string external;
3776+
3777+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-quote-escape-01.csv" )
3778+let $values := file:read-text( $file )
3779+let $options := { "quote-escape" : "\\" }
3780+return csv:parse( $values, $options )
3781+
3782+(: vim:set syntax=xquery et sw=2 ts=2: :)
3783
3784=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-quote-escape-01.spec'
3785--- test/rbkt/Queries/zorba/csv/csv-parse-quote-escape-01.spec 1970-01-01 00:00:00 +0000
3786+++ test/rbkt/Queries/zorba/csv/csv-parse-quote-escape-01.spec 2013-09-16 19:47:46 +0000
3787@@ -0,0 +1,4 @@
3788+Serialization: indent=yes
3789+Args:
3790+-x
3791+rbktPath:=xs:string($RBKT_SRC_DIR)
3792
3793=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-separator-01.jq'
3794--- test/rbkt/Queries/zorba/csv/csv-parse-separator-01.jq 1970-01-01 00:00:00 +0000
3795+++ test/rbkt/Queries/zorba/csv/csv-parse-separator-01.jq 2013-09-16 19:47:46 +0000
3796@@ -0,0 +1,11 @@
3797+import module namespace csv = "http://zorba.io/modules/json-csv";
3798+import module namespace file = "http://expath.org/ns/file";
3799+
3800+declare variable $rbktPath as xs:string external;
3801+
3802+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-separator-01.csv" )
3803+let $values := file:read-text( $file )
3804+let $options := { "separator" : "|" }
3805+return csv:parse( $values, $options )
3806+
3807+(: vim:set syntax=xquery et sw=2 ts=2: :)
3808
3809=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-separator-01.spec'
3810--- test/rbkt/Queries/zorba/csv/csv-parse-separator-01.spec 1970-01-01 00:00:00 +0000
3811+++ test/rbkt/Queries/zorba/csv/csv-parse-separator-01.spec 2013-09-16 19:47:46 +0000
3812@@ -0,0 +1,4 @@
3813+Serialization: indent=yes
3814+Args:
3815+-x
3816+rbktPath:=xs:string($RBKT_SRC_DIR)
3817
3818=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-skip-01.jq'
3819--- test/rbkt/Queries/zorba/csv/csv-parse-skip-01.jq 1970-01-01 00:00:00 +0000
3820+++ test/rbkt/Queries/zorba/csv/csv-parse-skip-01.jq 2013-09-16 19:47:46 +0000
3821@@ -0,0 +1,10 @@
3822+import module namespace csv = "http://zorba.io/modules/json-csv";
3823+import module namespace file = "http://expath.org/ns/file";
3824+
3825+declare variable $rbktPath as xs:string external;
3826+
3827+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-01.csv" )
3828+let $values := file:read-text( $file )
3829+return subsequence( csv:parse( $values ), 2 )
3830+
3831+(: vim:set syntax=xquery et sw=2 ts=2: :)
3832
3833=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-skip-01.spec'
3834--- test/rbkt/Queries/zorba/csv/csv-parse-skip-01.spec 1970-01-01 00:00:00 +0000
3835+++ test/rbkt/Queries/zorba/csv/csv-parse-skip-01.spec 2013-09-16 19:47:46 +0000
3836@@ -0,0 +1,4 @@
3837+Serialization: indent=yes
3838+Args:
3839+-x
3840+rbktPath:=xs:string($RBKT_SRC_DIR)
3841
3842=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-skip-02.jq'
3843--- test/rbkt/Queries/zorba/csv/csv-parse-skip-02.jq 1970-01-01 00:00:00 +0000
3844+++ test/rbkt/Queries/zorba/csv/csv-parse-skip-02.jq 2013-09-16 19:47:46 +0000
3845@@ -0,0 +1,10 @@
3846+import module namespace csv = "http://zorba.io/modules/json-csv";
3847+import module namespace file = "http://expath.org/ns/file";
3848+
3849+declare variable $rbktPath as xs:string external;
3850+
3851+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-01.csv" )
3852+let $values := file:read-text( $file )
3853+return subsequence( csv:parse( $values ), 3 )
3854+
3855+(: vim:set syntax=xquery et sw=2 ts=2: :)
3856
3857=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-skip-02.spec'
3858--- test/rbkt/Queries/zorba/csv/csv-parse-skip-02.spec 1970-01-01 00:00:00 +0000
3859+++ test/rbkt/Queries/zorba/csv/csv-parse-skip-02.spec 2013-09-16 19:47:46 +0000
3860@@ -0,0 +1,4 @@
3861+Serialization: indent=yes
3862+Args:
3863+-x
3864+rbktPath:=xs:string($RBKT_SRC_DIR)
3865
3866=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-skip-03.jq'
3867--- test/rbkt/Queries/zorba/csv/csv-parse-skip-03.jq 1970-01-01 00:00:00 +0000
3868+++ test/rbkt/Queries/zorba/csv/csv-parse-skip-03.jq 2013-09-16 19:47:46 +0000
3869@@ -0,0 +1,10 @@
3870+import module namespace csv = "http://zorba.io/modules/json-csv";
3871+import module namespace file = "http://expath.org/ns/file";
3872+
3873+declare variable $rbktPath as xs:string external;
3874+
3875+let $file := concat( $rbktPath, "/Queries/zorba/csv/sample_files/csv-01.csv" )
3876+let $values := file:read-text( $file )
3877+return subsequence( csv:parse( $values ), 3, 1 )
3878+
3879+(: vim:set syntax=xquery et sw=2 ts=2: :)
3880
3881=== added file 'test/rbkt/Queries/zorba/csv/csv-parse-skip-03.spec'
3882--- test/rbkt/Queries/zorba/csv/csv-parse-skip-03.spec 1970-01-01 00:00:00 +0000
3883+++ test/rbkt/Queries/zorba/csv/csv-parse-skip-03.spec 2013-09-16 19:47:46 +0000
3884@@ -0,0 +1,4 @@
3885+Serialization: indent=yes
3886+Args:
3887+-x
3888+rbktPath:=xs:string($RBKT_SRC_DIR)
3889
3890=== added file 'test/rbkt/Queries/zorba/csv/csv-serialize-01.jq'
3891--- test/rbkt/Queries/zorba/csv/csv-serialize-01.jq 1970-01-01 00:00:00 +0000
3892+++ test/rbkt/Queries/zorba/csv/csv-serialize-01.jq 2013-09-16 19:47:46 +0000
3893@@ -0,0 +1,18 @@
3894+import module namespace csv = "http://zorba.io/modules/json-csv";
3895+
3896+let $values := (
3897+ {
3898+ "first" : "one",
3899+ "second" : "two",
3900+ "third" : "three"
3901+ },
3902+ {
3903+ "first" : "four",
3904+ "second" : "embedded \" quote",
3905+ "third" : "embedded\r\nnewline"
3906+ }
3907+)
3908+let $options := { "field-names" : [ "first", "second", "third" ] }
3909+return string-join( csv:serialize( $values, $options ), "" )
3910+
3911+(: vim:set syntax=xquery et sw=2 ts=2: :)
3912
3913=== added file 'test/rbkt/Queries/zorba/csv/csv-serialize-01.spec'
3914--- test/rbkt/Queries/zorba/csv/csv-serialize-01.spec 1970-01-01 00:00:00 +0000
3915+++ test/rbkt/Queries/zorba/csv/csv-serialize-01.spec 2013-09-16 19:47:46 +0000
3916@@ -0,0 +1,1 @@
3917+Serialization: method=text
3918
3919=== added file 'test/rbkt/Queries/zorba/csv/csv-serialize-boolean-01.jq'
3920--- test/rbkt/Queries/zorba/csv/csv-serialize-boolean-01.jq 1970-01-01 00:00:00 +0000
3921+++ test/rbkt/Queries/zorba/csv/csv-serialize-boolean-01.jq 2013-09-16 19:47:46 +0000
3922@@ -0,0 +1,15 @@
3923+import module namespace csv = "http://zorba.io/modules/json-csv";
3924+
3925+let $values := (
3926+ {
3927+ "b1" : true,
3928+ "b2" : false
3929+ }
3930+)
3931+let $options := {
3932+ "field-names" : [ "b1", "b2" ],
3933+ "serialize-boolean-as" : { "true" : "T", "false" : "F" }
3934+}
3935+return string-join( csv:serialize( $values, $options ), "" )
3936+
3937+(: vim:set syntax=xquery et sw=2 ts=2: :)
3938
3939=== added file 'test/rbkt/Queries/zorba/csv/csv-serialize-boolean-01.spec'
3940--- test/rbkt/Queries/zorba/csv/csv-serialize-boolean-01.spec 1970-01-01 00:00:00 +0000
3941+++ test/rbkt/Queries/zorba/csv/csv-serialize-boolean-01.spec 2013-09-16 19:47:46 +0000
3942@@ -0,0 +1,1 @@
3943+Serialization: method=text
3944
3945=== added file 'test/rbkt/Queries/zorba/csv/csv-serialize-header-01.jq'
3946--- test/rbkt/Queries/zorba/csv/csv-serialize-header-01.jq 1970-01-01 00:00:00 +0000
3947+++ test/rbkt/Queries/zorba/csv/csv-serialize-header-01.jq 2013-09-16 19:47:46 +0000
3948@@ -0,0 +1,10 @@
3949+import module namespace csv = "http://zorba.io/modules/json-csv";
3950+
3951+let $values := (
3952+ { "field" : "one" },
3953+ { "field" : "two" }
3954+)
3955+let $options := { "serialize-header" : false }
3956+return string-join( csv:serialize( $values, $options ), "" )
3957+
3958+(: vim:set syntax=xquery et sw=2 ts=2: :)
3959
3960=== added file 'test/rbkt/Queries/zorba/csv/csv-serialize-header-01.spec'
3961--- test/rbkt/Queries/zorba/csv/csv-serialize-header-01.spec 1970-01-01 00:00:00 +0000
3962+++ test/rbkt/Queries/zorba/csv/csv-serialize-header-01.spec 2013-09-16 19:47:46 +0000
3963@@ -0,0 +1,1 @@
3964+Serialization: method=text
3965
3966=== added file 'test/rbkt/Queries/zorba/csv/csv-serialize-null-01.jq'
3967--- test/rbkt/Queries/zorba/csv/csv-serialize-null-01.jq 1970-01-01 00:00:00 +0000
3968+++ test/rbkt/Queries/zorba/csv/csv-serialize-null-01.jq 2013-09-16 19:47:46 +0000
3969@@ -0,0 +1,16 @@
3970+import module namespace csv = "http://zorba.io/modules/json-csv";
3971+
3972+let $values := (
3973+ {
3974+ "foo" : "f",
3975+ "bar" : null,
3976+ "baz" : "b"
3977+ }
3978+)
3979+let $options := {
3980+ "field-names" : [ "foo", "bar", "baz" ],
3981+ "serialize-null-as" : "null"
3982+}
3983+return string-join( csv:serialize( $values, $options ), "" )
3984+
3985+(: vim:set syntax=xquery et sw=2 ts=2: :)
3986
3987=== added file 'test/rbkt/Queries/zorba/csv/csv-serialize-null-01.spec'
3988--- test/rbkt/Queries/zorba/csv/csv-serialize-null-01.spec 1970-01-01 00:00:00 +0000
3989+++ test/rbkt/Queries/zorba/csv/csv-serialize-null-01.spec 2013-09-16 19:47:46 +0000
3990@@ -0,0 +1,1 @@
3991+Serialization: method=text
3992
3993=== added file 'test/rbkt/Queries/zorba/csv/csv-serialize-null-02.jq'
3994--- test/rbkt/Queries/zorba/csv/csv-serialize-null-02.jq 1970-01-01 00:00:00 +0000
3995+++ test/rbkt/Queries/zorba/csv/csv-serialize-null-02.jq 2013-09-16 19:47:46 +0000
3996@@ -0,0 +1,13 @@
3997+import module namespace csv = "http://zorba.io/modules/json-csv";
3998+
3999+let $values := (
4000+ {
4001+ "bar" : null
4002+ }
4003+)
4004+let $options := {
4005+ "serialize-null-as" : "null"
4006+}
4007+return string-join( csv:serialize( $values, $options ), "" )
4008+
4009+(: vim:set syntax=xquery et sw=2 ts=2: :)
4010
4011=== added file 'test/rbkt/Queries/zorba/csv/csv-serialize-null-02.spec'
4012--- test/rbkt/Queries/zorba/csv/csv-serialize-null-02.spec 1970-01-01 00:00:00 +0000
4013+++ test/rbkt/Queries/zorba/csv/csv-serialize-null-02.spec 2013-09-16 19:47:46 +0000
4014@@ -0,0 +1,1 @@
4015+Serialization: method=text
4016
4017=== added file 'test/rbkt/Queries/zorba/csv/csv-serialize-null-03.jq'
4018--- test/rbkt/Queries/zorba/csv/csv-serialize-null-03.jq 1970-01-01 00:00:00 +0000
4019+++ test/rbkt/Queries/zorba/csv/csv-serialize-null-03.jq 2013-09-16 19:47:46 +0000
4020@@ -0,0 +1,16 @@
4021+import module namespace csv = "http://zorba.io/modules/json-csv";
4022+
4023+let $values := (
4024+ {
4025+ "foo" : "f",
4026+ "bar" : null,
4027+ "baz" : "b"
4028+ }
4029+)
4030+let $options := {
4031+ "field-names" : [ "foo", "bar", "baz" ],
4032+ "serialize-null-as" : ""
4033+}
4034+return string-join( csv:serialize( $values, $options ), "" )
4035+
4036+(: vim:set syntax=xquery et sw=2 ts=2: :)
4037
4038=== added file 'test/rbkt/Queries/zorba/csv/csv-serialize-null-03.spec'
4039--- test/rbkt/Queries/zorba/csv/csv-serialize-null-03.spec 1970-01-01 00:00:00 +0000
4040+++ test/rbkt/Queries/zorba/csv/csv-serialize-null-03.spec 2013-09-16 19:47:46 +0000
4041@@ -0,0 +1,1 @@
4042+Serialization: method=text
4043
4044=== added file 'test/rbkt/Queries/zorba/csv/csv-serialize-null-04.jq'
4045--- test/rbkt/Queries/zorba/csv/csv-serialize-null-04.jq 1970-01-01 00:00:00 +0000
4046+++ test/rbkt/Queries/zorba/csv/csv-serialize-null-04.jq 2013-09-16 19:47:46 +0000
4047@@ -0,0 +1,13 @@
4048+import module namespace csv = "http://zorba.io/modules/json-csv";
4049+
4050+let $values := (
4051+ {
4052+ "bar" : null
4053+ }
4054+)
4055+let $options := {
4056+ "serialize-null-as" : ""
4057+}
4058+return string-join( csv:serialize( $values, $options ), "" )
4059+
4060+(: vim:set syntax=xquery et sw=2 ts=2: :)
4061
4062=== added file 'test/rbkt/Queries/zorba/csv/csv-serialize-null-04.spec'
4063--- test/rbkt/Queries/zorba/csv/csv-serialize-null-04.spec 1970-01-01 00:00:00 +0000
4064+++ test/rbkt/Queries/zorba/csv/csv-serialize-null-04.spec 2013-09-16 19:47:46 +0000
4065@@ -0,0 +1,1 @@
4066+Serialization: method=text
4067
4068=== added file 'test/rbkt/Queries/zorba/csv/csv-serialize-quote-char-01.jq'
4069--- test/rbkt/Queries/zorba/csv/csv-serialize-quote-char-01.jq 1970-01-01 00:00:00 +0000
4070+++ test/rbkt/Queries/zorba/csv/csv-serialize-quote-char-01.jq 2013-09-16 19:47:46 +0000
4071@@ -0,0 +1,9 @@
4072+import module namespace csv = "http://zorba.io/modules/json-csv";
4073+
4074+let $values := (
4075+ { "field" : "embedded , comma" }
4076+)
4077+let $options := { "quote-char" : "'" }
4078+return string-join( csv:serialize( $values, $options ), "" )
4079+
4080+(: vim:set syntax=xquery et sw=2 ts=2: :)
4081
4082=== added file 'test/rbkt/Queries/zorba/csv/csv-serialize-quote-char-01.spec'
4083--- test/rbkt/Queries/zorba/csv/csv-serialize-quote-char-01.spec 1970-01-01 00:00:00 +0000
4084+++ test/rbkt/Queries/zorba/csv/csv-serialize-quote-char-01.spec 2013-09-16 19:47:46 +0000
4085@@ -0,0 +1,1 @@
4086+Serialization: method=text
4087
4088=== added file 'test/rbkt/Queries/zorba/csv/csv-serialize-quote-char-02.jq'
4089--- test/rbkt/Queries/zorba/csv/csv-serialize-quote-char-02.jq 1970-01-01 00:00:00 +0000
4090+++ test/rbkt/Queries/zorba/csv/csv-serialize-quote-char-02.jq 2013-09-16 19:47:46 +0000
4091@@ -0,0 +1,9 @@
4092+import module namespace csv = "http://zorba.io/modules/json-csv";
4093+
4094+let $values := (
4095+ { "field" : "embedded ' quote" }
4096+)
4097+let $options := { "quote-char" : "'" }
4098+return string-join( csv:serialize( $values, $options ), "" )
4099+
4100+(: vim:set syntax=xquery et sw=2 ts=2: :)
4101
4102=== added file 'test/rbkt/Queries/zorba/csv/csv-serialize-quote-char-02.spec'
4103--- test/rbkt/Queries/zorba/csv/csv-serialize-quote-char-02.spec 1970-01-01 00:00:00 +0000
4104+++ test/rbkt/Queries/zorba/csv/csv-serialize-quote-char-02.spec 2013-09-16 19:47:46 +0000
4105@@ -0,0 +1,1 @@
4106+Serialization: method=text
4107
4108=== added file 'test/rbkt/Queries/zorba/csv/csv-serialize-quote-escape-01.jq'
4109--- test/rbkt/Queries/zorba/csv/csv-serialize-quote-escape-01.jq 1970-01-01 00:00:00 +0000
4110+++ test/rbkt/Queries/zorba/csv/csv-serialize-quote-escape-01.jq 2013-09-16 19:47:46 +0000
4111@@ -0,0 +1,9 @@
4112+import module namespace csv = "http://zorba.io/modules/json-csv";
4113+
4114+let $values := (
4115+ { "field" : "embedded ' quote" }
4116+)
4117+let $options := { "quote-char" : "'", "quote-escape" : "\\" }
4118+return string-join( csv:serialize( $values, $options ), "" )
4119+
4120+(: vim:set syntax=xquery et sw=2 ts=2: :)
4121
4122=== added file 'test/rbkt/Queries/zorba/csv/csv-serialize-quote-escape-01.spec'
4123--- test/rbkt/Queries/zorba/csv/csv-serialize-quote-escape-01.spec 1970-01-01 00:00:00 +0000
4124+++ test/rbkt/Queries/zorba/csv/csv-serialize-quote-escape-01.spec 2013-09-16 19:47:46 +0000
4125@@ -0,0 +1,1 @@
4126+Serialization: method=text
4127
4128=== added file 'test/rbkt/Queries/zorba/csv/csv-serialize-separator-01.jq'
4129--- test/rbkt/Queries/zorba/csv/csv-serialize-separator-01.jq 1970-01-01 00:00:00 +0000
4130+++ test/rbkt/Queries/zorba/csv/csv-serialize-separator-01.jq 2013-09-16 19:47:46 +0000
4131@@ -0,0 +1,21 @@
4132+import module namespace csv = "http://zorba.io/modules/json-csv";
4133+
4134+let $values := (
4135+ {
4136+ "first" : "one",
4137+ "second" : "two",
4138+ "third" : "three"
4139+ },
4140+ {
4141+ "first" : "four",
4142+ "second" : "embedded \" quote",
4143+ "third" : "embedded\r\nnewline"
4144+ }
4145+)
4146+let $options := {
4147+ "field-names" : [ "first", "second", "third" ],
4148+ "separator" : "|"
4149+}
4150+return string-join( csv:serialize( $values, $options ), "" )
4151+
4152+(: vim:set syntax=xquery et sw=2 ts=2: :)
4153
4154=== added file 'test/rbkt/Queries/zorba/csv/csv-serialize-separator-01.spec'
4155--- test/rbkt/Queries/zorba/csv/csv-serialize-separator-01.spec 1970-01-01 00:00:00 +0000
4156+++ test/rbkt/Queries/zorba/csv/csv-serialize-separator-01.spec 2013-09-16 19:47:46 +0000
4157@@ -0,0 +1,1 @@
4158+Serialization: method=text
4159
4160=== added directory 'test/rbkt/Queries/zorba/csv/sample_files'
4161=== added file 'test/rbkt/Queries/zorba/csv/sample_files/csv-01.csv'
4162--- test/rbkt/Queries/zorba/csv/sample_files/csv-01.csv 1970-01-01 00:00:00 +0000
4163+++ test/rbkt/Queries/zorba/csv/sample_files/csv-01.csv 2013-09-16 19:47:46 +0000
4164@@ -0,0 +1,6 @@
4165+first,second,third
4166+one,two,three
4167+"quoted","embedded "" quote","embedded
4168+newline"
4169+""" leading quote","","trailing quote """
4170+last,three,fields
4171
4172=== added file 'test/rbkt/Queries/zorba/csv/sample_files/csv-cast-01.csv'
4173--- test/rbkt/Queries/zorba/csv/sample_files/csv-cast-01.csv 1970-01-01 00:00:00 +0000
4174+++ test/rbkt/Queries/zorba/csv/sample_files/csv-cast-01.csv 2013-09-16 19:47:46 +0000
4175@@ -0,0 +1,2 @@
4176+string,integer,decimal,double,boolean,null
4177+foo,42,98.6,1E4,false,null
4178
4179=== added file 'test/rbkt/Queries/zorba/csv/sample_files/csv-extra-01.csv'
4180--- test/rbkt/Queries/zorba/csv/sample_files/csv-extra-01.csv 1970-01-01 00:00:00 +0000
4181+++ test/rbkt/Queries/zorba/csv/sample_files/csv-extra-01.csv 2013-09-16 19:47:46 +0000
4182@@ -0,0 +1,3 @@
4183+first,second,third
4184+one,two,three,four
4185+last,three,fields
4186
4187=== added file 'test/rbkt/Queries/zorba/csv/sample_files/csv-missing-01.csv'
4188--- test/rbkt/Queries/zorba/csv/sample_files/csv-missing-01.csv 1970-01-01 00:00:00 +0000
4189+++ test/rbkt/Queries/zorba/csv/sample_files/csv-missing-01.csv 2013-09-16 19:47:46 +0000
4190@@ -0,0 +1,3 @@
4191+first,second,third
4192+,two,three
4193+last,three,fields
4194
4195=== added file 'test/rbkt/Queries/zorba/csv/sample_files/csv-missing-02.csv'
4196--- test/rbkt/Queries/zorba/csv/sample_files/csv-missing-02.csv 1970-01-01 00:00:00 +0000
4197+++ test/rbkt/Queries/zorba/csv/sample_files/csv-missing-02.csv 2013-09-16 19:47:46 +0000
4198@@ -0,0 +1,3 @@
4199+first,second,third
4200+one,,three
4201+last,three,fields
4202
4203=== added file 'test/rbkt/Queries/zorba/csv/sample_files/csv-missing-03.csv'
4204--- test/rbkt/Queries/zorba/csv/sample_files/csv-missing-03.csv 1970-01-01 00:00:00 +0000
4205+++ test/rbkt/Queries/zorba/csv/sample_files/csv-missing-03.csv 2013-09-16 19:47:46 +0000
4206@@ -0,0 +1,3 @@
4207+first,second,third
4208+one,two,
4209+last,three,fields
4210
4211=== added file 'test/rbkt/Queries/zorba/csv/sample_files/csv-missing-04.csv'
4212--- test/rbkt/Queries/zorba/csv/sample_files/csv-missing-04.csv 1970-01-01 00:00:00 +0000
4213+++ test/rbkt/Queries/zorba/csv/sample_files/csv-missing-04.csv 2013-09-16 19:47:46 +0000
4214@@ -0,0 +1,3 @@
4215+first,second,third
4216+one,two
4217+last,three,fields
4218
4219=== added file 'test/rbkt/Queries/zorba/csv/sample_files/csv-no-field-names-01.csv'
4220--- test/rbkt/Queries/zorba/csv/sample_files/csv-no-field-names-01.csv 1970-01-01 00:00:00 +0000
4221+++ test/rbkt/Queries/zorba/csv/sample_files/csv-no-field-names-01.csv 2013-09-16 19:47:46 +0000
4222@@ -0,0 +1,5 @@
4223+one,two,three
4224+"quoted","embedded "" quote","embedded
4225+newline"
4226+""" leading quote","","trailing quote """
4227+last,three,fields
4228
4229=== added file 'test/rbkt/Queries/zorba/csv/sample_files/csv-quote-char-01.csv'
4230--- test/rbkt/Queries/zorba/csv/sample_files/csv-quote-char-01.csv 1970-01-01 00:00:00 +0000
4231+++ test/rbkt/Queries/zorba/csv/sample_files/csv-quote-char-01.csv 2013-09-16 19:47:46 +0000
4232@@ -0,0 +1,6 @@
4233+first,second,third
4234+one,two,three
4235+'quoted','embedded '' quote','embedded
4236+newline'
4237+''' leading quote','','trailing quote '''
4238+last,three,fields
4239
4240=== added file 'test/rbkt/Queries/zorba/csv/sample_files/csv-quote-escape-01.csv'
4241--- test/rbkt/Queries/zorba/csv/sample_files/csv-quote-escape-01.csv 1970-01-01 00:00:00 +0000
4242+++ test/rbkt/Queries/zorba/csv/sample_files/csv-quote-escape-01.csv 2013-09-16 19:47:46 +0000
4243@@ -0,0 +1,6 @@
4244+first,second,third
4245+one,two,three
4246+"quoted","embedded \" quote","embedded
4247+newline"
4248+"\" leading quote","","trailing quote \""
4249+last,three,fields
4250
4251=== added file 'test/rbkt/Queries/zorba/csv/sample_files/csv-separator-01.csv'
4252--- test/rbkt/Queries/zorba/csv/sample_files/csv-separator-01.csv 1970-01-01 00:00:00 +0000
4253+++ test/rbkt/Queries/zorba/csv/sample_files/csv-separator-01.csv 2013-09-16 19:47:46 +0000
4254@@ -0,0 +1,6 @@
4255+first|second|third
4256+one|two|three
4257+"quoted"|"embedded "" quote"|"embedded
4258+newline"
4259+""" leading quote"|""|"trailing quote """
4260+last|three|fields

Subscribers

People subscribed via source and target branches