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

Proposed by Paul J. Lucas
Status: Merged
Approved by: Paul J. Lucas
Approved revision: 11614
Merged at revision: 11617
Proposed branch: lp:~zorba-coders/zorba/bug-1217140
Merge into: lp:zorba
Diff against target: 194 lines (+39/-4)
12 files modified
ChangeLog (+1/-0)
include/zorba/options.h (+1/-0)
src/api/options.cpp (+9/-0)
src/api/serialization/serializer.cpp (+17/-4)
src/api/serialization/serializer.h (+2/-0)
src/api/serializerimpl.cpp (+3/-0)
test/rbkt/ExpQueryResults/zorba/serialization/item-separator-1.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/serialization/item-separator-2.xml.res (+1/-0)
test/rbkt/Queries/zorba/serialization/item-separator-1.spec (+1/-0)
test/rbkt/Queries/zorba/serialization/item-separator-1.xq (+1/-0)
test/rbkt/Queries/zorba/serialization/item-separator-2.spec (+1/-0)
test/rbkt/Queries/zorba/serialization/item-separator-2.xq (+1/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug-1217140
Reviewer Review Type Date Requested Status
Chris Hillery Approve
Paul J. Lucas Approve
Review via email: mp+184906@code.launchpad.net

Commit message

Added item-separator serializer option.

Description of the change

Added item-separator serializer option.

To post a comment you must log in.
Revision history for this message
Paul J. Lucas (paul-lucas) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

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

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

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue result for https://code.launchpad.net/~zorba-coders/zorba/bug-1217140/+merge/184906

Stage "CommitZorba" failed.

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

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting criteria failed for the following merge proposals:

https://code.launchpad.net/~zorba-coders/zorba/bug-1217140/+merge/184906 :
Votes: {'Approve': 1}

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

item-separator isn't a drop-in replacement for the space separator which was introduced previously. If item-separator is specified, it is used to separate *every* *item* in the top-level sequence, not just adjacent strings as the space character was before. So, for example:

zorba -z item-separator="--" -q '(<hello/>,<world/>,1,2,3)'

should output

<hello/>--<world/>--1--2--3

See the discussion in section 2 of the XQuery 3.0 serialization spec:
http://www.w3.org/TR/2013/WD-xslt-xquery-serialization-30-20130108/#serdm

review: Needs Fixing
lp:~zorba-coders/zorba/bug-1217140 updated
11615. By Paul J. Lucas

Can now distinguish unset vs empty item-separator.

Revision history for this message
Paul J. Lucas (paul-lucas) wrote :

OK, it now distinguishes between not set vs empty.

Revision history for this message
Chris Hillery (ceejatec) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

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

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

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue succeeded - proposal merged!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2013-08-21 10:25:42 +0000
3+++ ChangeLog 2013-09-11 21:02:10 +0000
4@@ -44,6 +44,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 #1217140 (Support XQuery 3.0 item-separator serialization parameter)
9 * Fixed bug #942171 (file module to allow for arbitrary encodings)
10 * Fixed bug #1192285 (Have JSON token know number subtype)
11 * Fixed bug #1210628 (file:last-modified returns wrong month)
12
13=== modified file 'include/zorba/options.h'
14--- include/zorba/options.h 2013-08-13 23:32:22 +0000
15+++ include/zorba/options.h 2013-09-11 21:02:10 +0000
16@@ -222,6 +222,7 @@
17 Zorba_opaque_char_ptr_t doctype_system;
18 Zorba_opaque_char_ptr_t doctype_public;
19 Zorba_opaque_char_ptr_t cdata_section_elements;
20+ Zorba_opaque_char_ptr_t item_separator;
21 Zorba_opaque_char_ptr_t version;
22
23 Zorba_jsoniq_multiple_items_t jsoniq_multiple_items;
24
25=== modified file 'src/api/options.cpp'
26--- src/api/options.cpp 2013-08-14 02:10:00 +0000
27+++ src/api/options.cpp 2013-09-11 21:02:10 +0000
28@@ -59,6 +59,8 @@
29 to->doctype_public.ptr = ztd::new_strdup( from->doctype_public.ptr );
30 if ( from->cdata_section_elements.ptr )
31 to->cdata_section_elements.ptr = ztd::new_strdup( from->cdata_section_elements.ptr );
32+ if ( from->item_separator.ptr )
33+ to->item_separator.ptr = ztd::new_strdup( from->item_separator.ptr );
34 if ( from->version.ptr )
35 to->version.ptr = ztd::new_strdup( from->version.ptr );
36 }
37@@ -69,6 +71,7 @@
38 opts->doctype_system.ptr = nullptr;
39 opts->doctype_public.ptr = nullptr;
40 opts->cdata_section_elements.ptr = nullptr;
41+ opts->item_separator.ptr = nullptr;
42 opts->version.ptr = nullptr;
43 }
44
45@@ -122,6 +125,7 @@
46 delete[] opts->doctype_system.ptr;
47 delete[] opts->doctype_public.ptr;
48 delete[] opts->cdata_section_elements.ptr;
49+ delete[] opts->item_separator.ptr;
50 delete[] opts->version.ptr;
51 null_ptrs( opts );
52 }
53@@ -165,6 +169,11 @@
54 if ( strcmp( option, "indent" ) == 0 )
55 return parse_yes_no( value, &opts->indent );
56
57+ if ( strcmp( option, "item-separator" ) == 0 ) {
58+ assign( opts->item_separator, value );
59+ return true;
60+ }
61+
62 if ( strcmp( option, "jsoniq-multiple-items" ) == 0 )
63 return parse_yes_no( value, &opts->jsoniq_multiple_items );
64
65
66=== modified file 'src/api/serialization/serializer.cpp'
67--- src/api/serialization/serializer.cpp 2013-08-16 21:37:19 +0000
68+++ src/api/serialization/serializer.cpp 2013-09-11 21:02:10 +0000
69@@ -412,8 +412,7 @@
70
71 rollover = emit_expanded_string(buffer, static_cast<zstring::size_type>(read_bytes + rollover));
72 memmove(buffer, buffer + 1024 - rollover, rollover);
73- }
74- while (read_bytes > 0);
75+ } while (read_bytes > 0);
76 break;
77 }
78 case store::XS_BASE64BINARY:
79@@ -448,7 +447,9 @@
80 if (item->isAtomic())
81 {
82 if (thePreviousItemKind == PREVIOUS_ITEM_WAS_TEXT)
83- tr << " ";
84+ tr << (ser->item_separator_is_set ? ser->item_separator : " ");
85+ else if (thePreviousItemKind)
86+ tr << ser->item_separator;
87
88 if (item->isStreamable())
89 {
90@@ -494,6 +495,8 @@
91 ********************************************************************************/
92 void serializer::emitter::emit_node(const store::Item* item, int depth)
93 {
94+ if (thePreviousItemKind)
95+ tr << ser->item_separator;
96 switch (item->getNodeKind())
97 {
98 case store::StoreConsts::documentNode:
99@@ -2090,7 +2093,9 @@
100 if (item->isAtomic())
101 {
102 if (thePreviousItemKind == PREVIOUS_ITEM_WAS_TEXT)
103- tr << " ";
104+ tr << (ser->item_separator_is_set ? ser->item_separator : " ");
105+ else if (thePreviousItemKind)
106+ tr << ser->item_separator;
107
108 if (item->isStreamable())
109 emit_streamable_item(item);
110@@ -2304,6 +2309,9 @@
111
112 include_content_type = PARAMETER_VALUE_NO;
113
114+ item_separator.clear();
115+ item_separator_is_set = false;
116+
117 media_type.clear();
118
119 // This default should match the default for ser_method in Zorba_SerializerOptions
120@@ -2469,6 +2477,11 @@
121 {
122 cdata_section_elements = aValue;
123 }
124+ else if (!strcmp(aName, "item-separator"))
125+ {
126+ item_separator = aValue;
127+ item_separator_is_set = true;
128+ }
129 else if (!strcmp(aName, "jsoniq-multiple-items"))
130 {
131 if (!strcmp(aValue, "no"))
132
133=== modified file 'src/api/serialization/serializer.h'
134--- src/api/serialization/serializer.h 2013-08-13 17:43:02 +0000
135+++ src/api/serialization/serializer.h 2013-09-11 21:02:10 +0000
136@@ -95,6 +95,8 @@
137 zstring encoding;
138 short int escape_uri_attributes; // TODO: yes/no requires unicode normalization
139 short int include_content_type; // yes/no, implemented
140+ zstring item_separator;
141+ bool item_separator_is_set;
142 zstring media_type; // string, implemented
143 short int method; // an expanded QName: "xml", "html", "xhtml",
144 // "text" and "binary"
145
146=== modified file 'src/api/serializerimpl.cpp'
147--- src/api/serializerimpl.cpp 2013-08-13 05:43:39 +0000
148+++ src/api/serializerimpl.cpp 2013-09-11 21:02:10 +0000
149@@ -206,6 +206,9 @@
150 if (aSerializerOptions.cdata_section_elements)
151 aInternalSerializer.setParameter("cdata-section-elements", aSerializerOptions.cdata_section_elements);
152
153+ if (aSerializerOptions.item_separator)
154+ aInternalSerializer.setParameter("item-separator", aSerializerOptions.item_separator);
155+
156 if (aSerializerOptions.version)
157 aInternalSerializer.setParameter("version", aSerializerOptions.version);
158
159
160=== added file 'test/rbkt/ExpQueryResults/zorba/serialization/item-separator-1.xml.res'
161--- test/rbkt/ExpQueryResults/zorba/serialization/item-separator-1.xml.res 1970-01-01 00:00:00 +0000
162+++ test/rbkt/ExpQueryResults/zorba/serialization/item-separator-1.xml.res 2013-09-11 21:02:10 +0000
163@@ -0,0 +1,1 @@
164+12<hello/>3
165
166=== added file 'test/rbkt/ExpQueryResults/zorba/serialization/item-separator-2.xml.res'
167--- test/rbkt/ExpQueryResults/zorba/serialization/item-separator-2.xml.res 1970-01-01 00:00:00 +0000
168+++ test/rbkt/ExpQueryResults/zorba/serialization/item-separator-2.xml.res 2013-09-11 21:02:10 +0000
169@@ -0,0 +1,1 @@
170+1|2|<hello/>|3
171
172=== added file 'test/rbkt/Queries/zorba/serialization/item-separator-1.spec'
173--- test/rbkt/Queries/zorba/serialization/item-separator-1.spec 1970-01-01 00:00:00 +0000
174+++ test/rbkt/Queries/zorba/serialization/item-separator-1.spec 2013-09-11 21:02:10 +0000
175@@ -0,0 +1,1 @@
176+Serialization: item-separator=
177
178=== added file 'test/rbkt/Queries/zorba/serialization/item-separator-1.xq'
179--- test/rbkt/Queries/zorba/serialization/item-separator-1.xq 1970-01-01 00:00:00 +0000
180+++ test/rbkt/Queries/zorba/serialization/item-separator-1.xq 2013-09-11 21:02:10 +0000
181@@ -0,0 +1,1 @@
182+(1, 2, <hello/>, 3)
183
184=== added file 'test/rbkt/Queries/zorba/serialization/item-separator-2.spec'
185--- test/rbkt/Queries/zorba/serialization/item-separator-2.spec 1970-01-01 00:00:00 +0000
186+++ test/rbkt/Queries/zorba/serialization/item-separator-2.spec 2013-09-11 21:02:10 +0000
187@@ -0,0 +1,1 @@
188+Serialization: item-separator=|
189
190=== added file 'test/rbkt/Queries/zorba/serialization/item-separator-2.xq'
191--- test/rbkt/Queries/zorba/serialization/item-separator-2.xq 1970-01-01 00:00:00 +0000
192+++ test/rbkt/Queries/zorba/serialization/item-separator-2.xq 2013-09-11 21:02:10 +0000
193@@ -0,0 +1,1 @@
194+(1, 2, <hello/>, 3)

Subscribers

People subscribed via source and target branches