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

Proposed by Matthias Brantner
Status: Merged
Approved by: Till Westmann
Approved revision: 11030
Merged at revision: 11036
Proposed branch: lp:~zorba-coders/zorba/bug-1034990
Merge into: lp:zorba
Diff against target: 235 lines (+114/-1)
10 files modified
ChangeLog (+1/-0)
include/zorba/pregenerated/diagnostic_list.h (+2/-0)
modules/org/jsoniq/www/pregenerated/errors.xq (+7/-0)
src/api/serialization/serializer.cpp (+45/-1)
src/api/serialization/serializer.h (+7/-0)
src/diagnostics/diagnostic_en.xml (+7/-0)
src/diagnostics/pregenerated/diagnostic_list.cpp (+3/-0)
src/diagnostics/pregenerated/dict_en.cpp (+3/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/serializer-JNSE0022.xml.res (+1/-0)
test/rbkt/Queries/zorba/jsoniq/serializer-JNSE0022.xq (+38/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug-1034990
Reviewer Review Type Date Requested Status
Till Westmann Approve
Matthias Brantner Approve
Review via email: mp+123610@code.launchpad.net

Commit message

fix for bug #1034990 (text serialization with jsoniq fails)

To post a comment you must log in.
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-1034990-2012-09-10T17-58-56.235Z is finished. The final status was:

All tests succeeded!

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

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 1 Approve, 1 Pending.

Revision history for this message
Till Westmann (tillw) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-1034990-2012-09-12T07-36-56.794Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2012-09-10 16:34:17 +0000
3+++ ChangeLog 2012-09-10 17:57:19 +0000
4@@ -16,6 +16,7 @@
5 * Fixed bug #867227 (Improved error message for missing commas)
6 * Fixed bug #1024033 and #1023170 (segfaults in parse-xml:parse())
7 * Fixed bug #898792 (Dynamically computed strings can now be cast to xs:QName)
8+ * Fixed bug #1034990 (text serialization with jsoniq fails)
9 * Fixed bugs #899364 and 899363 (throw XQST0103 in case of non-distinct window
10 variables)
11 * Fixed bug #899366 (enforce the type declaration of a window variable)
12
13=== modified file 'include/zorba/pregenerated/diagnostic_list.h'
14--- include/zorba/pregenerated/diagnostic_list.h 2012-09-10 16:34:17 +0000
15+++ include/zorba/pregenerated/diagnostic_list.h 2012-09-10 17:57:19 +0000
16@@ -839,6 +839,8 @@
17
18 extern ZORBA_DLL_PUBLIC JSONiqErrorCode JNSE0014;
19
20+extern ZORBA_DLL_PUBLIC JSONiqErrorCode JNSE0022;
21+
22 extern ZORBA_DLL_PUBLIC JSONiqErrorCode JNUP0016;
23
24 extern ZORBA_DLL_PUBLIC JSONiqErrorCode JNUP0017;
25
26=== modified file 'modules/org/jsoniq/www/pregenerated/errors.xq'
27--- modules/org/jsoniq/www/pregenerated/errors.xq 2012-09-10 16:34:17 +0000
28+++ modules/org/jsoniq/www/pregenerated/errors.xq 2012-09-10 17:57:19 +0000
29@@ -119,6 +119,13 @@
30 declare variable $jerr:JNSE0014 as xs:QName := fn:QName($jerr:NS, "jerr:JNSE0014");
31
32 (:~
33+ :It is a dynamic error to serialize a sequence that does
34+ : not exist of exactly one document node with XML, HTML, XHTML, Text.
35+ :
36+:)
37+declare variable $jerr:JNSE0022 as xs:QName := fn:QName($jerr:NS, "jerr:JNSE0022");
38+
39+(:~
40 :It is a dynamic error if it is attempted to create a replace, delete or rename update primitive with a selector that cannot be resolved against the target array or object.
41 :)
42 declare variable $jerr:JNUP0016 as xs:QName := fn:QName($jerr:NS, "jerr:JNUP0016");
43
44=== modified file 'src/api/serialization/serializer.cpp'
45--- src/api/serialization/serializer.cpp 2012-09-10 16:34:17 +0000
46+++ src/api/serialization/serializer.cpp 2012-09-10 17:57:19 +0000
47@@ -434,9 +434,15 @@
48 #ifdef ZORBA_WITH_JSON
49 if (item->isJSONItem())
50 {
51- throw XQUERY_EXCEPTION(zerr::ZAPI0043_CANNOT_SERIALIZE_JSON_ITEM);
52+ zstring lMethod;
53+ ser->getSerializationMethod(lMethod);
54+ throw ZORBA_EXCEPTION(
55+ jerr::JNSE0022,
56+ ERROR_PARAMS(lMethod, item->getType()->getStringValue())
57+ );
58 }
59 #endif
60+
61 if (item->isAtomic())
62 {
63 if (previous_item == PREVIOUS_ITEM_WAS_TEXT)
64@@ -2119,6 +2125,16 @@
65 ********************************************************************************/
66 void serializer::text_emitter::emit_item(store::Item* item)
67 {
68+#ifdef ZORBA_WITH_JSON
69+ if (item->isJSONItem())
70+ {
71+ throw ZORBA_EXCEPTION(
72+ jerr::JNSE0022,
73+ ERROR_PARAMS("text", item->getType()->getStringValue())
74+ );
75+ }
76+#endif
77+
78 if (item->isAtomic())
79 {
80 if (previous_item == PREVIOUS_ITEM_WAS_TEXT)
81@@ -2238,6 +2254,15 @@
82 ********************************************************************************/
83 void serializer::binary_emitter::emit_item(store::Item* item)
84 {
85+#ifdef ZORBA_WITH_JSON
86+ if (item->isJSONItem())
87+ {
88+ throw ZORBA_EXCEPTION(
89+ jerr::JNSE0022,
90+ ERROR_PARAMS("binary", item->getType()->getStringValue())
91+ );
92+ }
93+#endif
94 if (item->isStreamable())
95 {
96 std::istream& stream = item->getStream();
97@@ -2553,6 +2578,25 @@
98 /*******************************************************************************
99
100 ********************************************************************************/
101+void serializer::getSerializationMethod(zstring& m) const
102+{
103+ switch (getSerializationMethod())
104+ {
105+ case PARAMETER_VALUE_XML: m = "xml"; break;
106+ case PARAMETER_VALUE_HTML: m = "html"; break;
107+ case PARAMETER_VALUE_XHTML: m = "xhtml"; break;
108+ case PARAMETER_VALUE_TEXT: m = "text"; break;
109+ case PARAMETER_VALUE_BINARY: m = "binary"; break;
110+ case PARAMETER_VALUE_JSON: m = "json"; break;
111+ case PARAMETER_VALUE_JSONIQ: m = "jsoniq"; break;
112+ default: ZORBA_ASSERT(false);
113+ }
114+}
115+
116+
117+/*******************************************************************************
118+
119+********************************************************************************/
120 short int serializer::getSerializationMethod() const
121 {
122 return method;
123
124=== modified file 'src/api/serialization/serializer.h'
125--- src/api/serialization/serializer.h 2012-09-10 16:34:17 +0000
126+++ src/api/serialization/serializer.h 2012-09-10 17:57:19 +0000
127@@ -185,6 +185,13 @@
128 */
129 short getSerializationMethod() const;
130
131+ /**
132+ * Get the serialization method as a string
133+ *
134+ * @return the value of the serialization method as string
135+ */
136+ void getSerializationMethod(zstring&) const;
137+
138 protected:
139 void reset();
140
141
142=== modified file 'src/diagnostics/diagnostic_en.xml'
143--- src/diagnostics/diagnostic_en.xml 2012-09-10 16:34:17 +0000
144+++ src/diagnostics/diagnostic_en.xml 2012-09-10 17:57:19 +0000
145@@ -2662,6 +2662,13 @@
146 <value>Cannot serialize a function item as JSON</value>
147 </diagnostic>
148
149+ <diagnostic code="JNSE0022" if="defined(ZORBA_WITH_JSON)">
150+ <comment>It is a dynamic error to serialize a sequence that does
151+ not exist of exactly one document node with XML, HTML, XHTML, Text.
152+ </comment>
153+ <value>$1: invalid serialization method for item type ($2)</value>
154+ </diagnostic>
155+
156 <diagnostic code="JNUP0016" if="defined(ZORBA_WITH_JSON)">
157 <comment>It is a dynamic error if it is attempted to create a replace, delete or rename update primitive with a selector that cannot be resolved against the target array or object.</comment>
158
159
160=== modified file 'src/diagnostics/pregenerated/diagnostic_list.cpp'
161--- src/diagnostics/pregenerated/diagnostic_list.cpp 2012-09-10 16:34:17 +0000
162+++ src/diagnostics/pregenerated/diagnostic_list.cpp 2012-09-10 17:57:19 +0000
163@@ -1234,6 +1234,9 @@
164 JSONiqErrorCode JNSE0014( "JNSE0014" );
165
166
167+JSONiqErrorCode JNSE0022( "JNSE0022" );
168+
169+
170 JSONiqErrorCode JNUP0016( "JNUP0016" );
171
172
173
174=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
175--- src/diagnostics/pregenerated/dict_en.cpp 2012-09-10 16:34:17 +0000
176+++ src/diagnostics/pregenerated/dict_en.cpp 2012-09-10 17:57:19 +0000
177@@ -110,6 +110,9 @@
178 { "JNSE0014", "Cannot serialize a function item as JSON" },
179 #endif
180 #if defined(ZORBA_WITH_JSON)
181+ { "JNSE0022", "$1: invalid serialization method for item type ($2)" },
182+#endif
183+#if defined(ZORBA_WITH_JSON)
184 { "JNTY0001", "Cannot atomize and/or cast value of type $1 to a string." },
185 #endif
186 #if defined(ZORBA_WITH_JSON)
187
188=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/serializer-JNSE0022.xml.res'
189--- test/rbkt/ExpQueryResults/zorba/jsoniq/serializer-JNSE0022.xml.res 1970-01-01 00:00:00 +0000
190+++ test/rbkt/ExpQueryResults/zorba/jsoniq/serializer-JNSE0022.xml.res 2012-09-10 17:57:19 +0000
191@@ -0,0 +1,1 @@
192+html: invalid serialization method for item type (jdm:object) text: invalid serialization method for item type (jdm:object) xml: invalid serialization method for item type (jdm:object) xhtml: invalid serialization method for item type (jdm:object)
193
194=== added file 'test/rbkt/Queries/zorba/jsoniq/serializer-JNSE0022.xq'
195--- test/rbkt/Queries/zorba/jsoniq/serializer-JNSE0022.xq 1970-01-01 00:00:00 +0000
196+++ test/rbkt/Queries/zorba/jsoniq/serializer-JNSE0022.xq 2012-09-10 17:57:19 +0000
197@@ -0,0 +1,38 @@
198+(: make sure jerr:JNSE0022 is raised if trying to serialize a non-document node with methods html, text, xml, or xhtml :)
199+declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
200+
201+declare namespace err = "http://www.w3.org/2005/xqt-errors";
202+declare namespace jerr = "http://www.jsoniq.org/errors";
203+
204+let $obj := { "message": "test" }
205+return
206+ (
207+ try
208+ {
209+ serialize($obj, <output:serialization-parameters><output:method value="html"/></output:serialization-parameters>)
210+ } catch jerr:JNSE0022
211+ {
212+ $err:description
213+ },
214+ try
215+ {
216+ serialize($obj, <output:serialization-parameters><output:method value="text"/></output:serialization-parameters>)
217+ } catch jerr:JNSE0022
218+ {
219+ $err:description
220+ },
221+ try
222+ {
223+ serialize($obj, <output:serialization-parameters><output:method value="xml"/></output:serialization-parameters>)
224+ } catch jerr:JNSE0022
225+ {
226+ $err:description
227+ },
228+ try
229+ {
230+ serialize($obj, <output:serialization-parameters><output:method value="xhtml"/></output:serialization-parameters>)
231+ } catch jerr:JNSE0022
232+ {
233+ $err:description
234+ }
235+ )

Subscribers

People subscribed via source and target branches