Merge lp:~zorba-coders/zorba/bug-1057792-serialize-nested-xdm-nodes into lp:zorba

Proposed by Till Westmann
Status: Merged
Approved by: Till Westmann
Approved revision: 11071
Merged at revision: 11078
Proposed branch: lp:~zorba-coders/zorba/bug-1057792-serialize-nested-xdm-nodes
Merge into: lp:zorba
Diff against target: 216 lines (+48/-46)
6 files modified
src/api/serialization/serializer.cpp (+23/-27)
src/api/serialization/serializer.h (+20/-19)
test/rbkt/ExpQueryResults/zorba/jsoniq/serializer-nested-xml_01.xml.res (+1/-0)
test/rbkt/Queries/zorba/jsoniq/serializer-nested-xml_01.xq (+1/-0)
test/rbkt/Queries/zorba/jsoniq/serializer-nested-xml_02.spec (+2/-0)
test/rbkt/Queries/zorba/jsoniq/serializer-nested-xml_02.xq (+1/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug-1057792-serialize-nested-xdm-nodes
Reviewer Review Type Date Requested Status
Ghislain Fourny Approve
Till Westmann Approve
Review via email: mp+126833@code.launchpad.net

Commit message

serialize nested XDM nodes as XML for the json-xml-hybrid method

Description of the change

serialize nested XDM nodes as XML for the json-xml-hybrid method

To post a comment you must log in.
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-1057792-serialize-nested-xdm-nodes-2012-09-28T00-16-55.417Z 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
Ghislain Fourny (gislenius) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~zorba-coders/zorba/bug-1057792-serialize-nested-xdm-nodes into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job
  bug-1057792-serialize-nested-xdm-nodes-2012-10-01T16-49-01.266Z is
  finished. The final status was:

  1 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

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

The attempt to merge lp:~zorba-coders/zorba/bug-1057792-serialize-nested-xdm-nodes into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job
  bug-1057792-serialize-nested-xdm-nodes-2012-10-01T21-08-00.13Z is finished.
  The final status was:

  1 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

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-1057792-serialize-nested-xdm-nodes-2012-10-02T10-57-54.564Z 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 'src/api/serialization/serializer.cpp'
2--- src/api/serialization/serializer.cpp 2012-09-21 04:09:29 +0000
3+++ src/api/serialization/serializer.cpp 2012-09-28 00:14:39 +0000
4@@ -956,14 +956,12 @@
5 serializer* the_serializer,
6 std::ostream& the_stream)
7 : emitter(the_serializer, the_stream),
8- theXMLStringStream(nullptr),
9 theMultipleItems(false)
10 {
11 }
12
13 serializer::json_emitter::~json_emitter()
14 {
15- delete theXMLStringStream;
16 }
17
18 void serializer::json_emitter::emit_item(store::Item *item)
19@@ -1117,26 +1115,9 @@
20 /*******************************************************************************
21
22 ********************************************************************************/
23-void serializer::json_emitter::emit_jsoniq_xdm_node(
24- store::Item* item,
25- int)
26+void serializer::json_emitter::emit_jsoniq_xdm_node(store::Item*, int)
27 {
28- if (true) {
29- // It could be useful to have some form of serialization of nested XML nodes
30- // (if only for debugging purposes). However as this is not (yet?) specified
31- // we throw an error here.
32- throw XQUERY_EXCEPTION(jerr::JNSE0014);
33- }
34- if (!theXMLEmitter) {
35- theXMLStringStream = new std::stringstream();
36- ser->attach_transcoder(*theXMLStringStream);
37- theXMLEmitter = new serializer::xml_emitter(ser, *theXMLStringStream);
38- }
39- theXMLEmitter->emit_item(item);
40- zstring xml(theXMLStringStream->str());
41- theXMLStringStream->str("");
42-
43- emit_json_string(xml);
44+ throw XQUERY_EXCEPTION(jerr::JNSE0014);
45 }
46
47
48@@ -1159,18 +1140,17 @@
49 serializer* the_serializer,
50 std::ostream& the_stream,
51 bool aEmitAttributes)
52- :
53- emitter(the_serializer, the_stream),
54+ : json_emitter(the_serializer, the_stream),
55 theEmitterState(JESTATE_UNDETERMINED),
56 theXMLEmitter(new xml_emitter(the_serializer, the_stream, aEmitAttributes)),
57- theJSONEmitter(new json_emitter(the_serializer, the_stream))
58+ theNestedXMLStringStream(nullptr)
59 {
60 }
61
62 serializer::hybrid_emitter::~hybrid_emitter()
63 {
64+ delete theNestedXMLStringStream;
65 delete theXMLEmitter;
66- delete theJSONEmitter;
67 }
68
69 void serializer::hybrid_emitter::emit_declaration()
70@@ -1181,7 +1161,7 @@
71 {
72 if (item->isJSONItem()) {
73 theEmitterState = JESTATE_JDM;
74- theJSONEmitter->emit_item(item);
75+ json_emitter::emit_item(item);
76 }
77 else {
78 if (theEmitterState == JESTATE_UNDETERMINED) {
79@@ -1197,7 +1177,7 @@
80 switch(theEmitterState)
81 {
82 case JESTATE_JDM:
83- theJSONEmitter->emit_end();
84+ json_emitter::emit_end();
85 return;
86 case JESTATE_XDM:
87 default:
88@@ -1205,6 +1185,22 @@
89 }
90 }
91
92+void serializer::hybrid_emitter::emit_jsoniq_xdm_node(
93+ store::Item* item,
94+ int)
95+{
96+ if (! theNestedXMLEmitter) {
97+ theNestedXMLStringStream = new std::stringstream();
98+ ser->attach_transcoder(*theNestedXMLStringStream);
99+ theNestedXMLEmitter
100+ = new serializer::xml_emitter(ser, *theNestedXMLStringStream);
101+ }
102+ theNestedXMLEmitter->emit_item(item);
103+ zstring xml(theNestedXMLStringStream->str());
104+ theNestedXMLStringStream->str("");
105+
106+ emit_json_string(xml);
107+}
108
109 #endif /* ZORBA_WITH_JSON */
110
111
112=== modified file 'src/api/serialization/serializer.h'
113--- src/api/serialization/serializer.h 2012-09-20 04:54:07 +0000
114+++ src/api/serialization/serializer.h 2012-09-28 00:14:39 +0000
115@@ -385,32 +385,28 @@
116
117 virtual void emit_end();
118
119- private:
120+ protected:
121
122 /**
123 * Outputs a JSON item. This method is called both for top-level JSON
124 * items as well as any items within a JSON object or array, so it may
125 * output simple typed values differently than standard XML serialization.
126 */
127- void emit_json_item(store::Item* item, int depth);
128-
129- void emit_json_object(store::Item* object, int depth);
130-
131- void emit_json_array(store::Item* array, int depth);
132-
133- void emit_json_value(store::Item* value, int depth);
134-
135- void emit_jsoniq_xdm_node(store::Item *item, int depth);
136-
137- void emit_json_string(zstring const &string);
138+ virtual void emit_json_item(store::Item* item, int depth);
139+
140+ virtual void emit_json_object(store::Item* object, int depth);
141+
142+ virtual void emit_json_array(store::Item* array, int depth);
143+
144+ virtual void emit_jsoniq_xdm_node(store::Item *item, int depth);
145+
146+ virtual void emit_json_string(zstring const &string);
147
148 store::Item_t theJSONiqValueName;
149 store::Item_t theTypeName;
150 store::Item_t theValueName;
151 store::Item_t theJSONiqXDMNodeName;
152
153- rchandle<emitter> theXMLEmitter;
154- std::stringstream* theXMLStringStream;
155 bool theMultipleItems;
156 };
157
158@@ -421,7 +417,7 @@
159 // //
160 ///////////////////////////////////////////////////////////
161
162- class hybrid_emitter : public emitter
163+ class hybrid_emitter : public json_emitter
164 {
165 public:
166 hybrid_emitter(
167@@ -437,15 +433,20 @@
168
169 virtual void emit_end();
170
171+ protected:
172+ virtual void emit_jsoniq_xdm_node(store::Item* item, int);
173+
174 private:
175 enum JSONiqEmitterState {
176 JESTATE_UNDETERMINED,
177 JESTATE_JDM,
178 JESTATE_XDM
179- } theEmitterState;
180-
181- serializer::xml_emitter* theXMLEmitter;
182- serializer::json_emitter* theJSONEmitter;
183+ } theEmitterState;
184+
185+ serializer::xml_emitter* theXMLEmitter;
186+
187+ rchandle<emitter> theNestedXMLEmitter;
188+ std::stringstream* theNestedXMLStringStream;
189 };
190
191 #endif /* ZORBA_WITH_JSON */
192
193=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/serializer-nested-xml_01.xml.res'
194--- test/rbkt/ExpQueryResults/zorba/jsoniq/serializer-nested-xml_01.xml.res 1970-01-01 00:00:00 +0000
195+++ test/rbkt/ExpQueryResults/zorba/jsoniq/serializer-nested-xml_01.xml.res 2012-09-28 00:14:39 +0000
196@@ -0,0 +1,1 @@
197+{ "a" : "<a b=\"c\"><!--comment--><?target pi?></a>" }
198
199=== added file 'test/rbkt/Queries/zorba/jsoniq/serializer-nested-xml_01.xq'
200--- test/rbkt/Queries/zorba/jsoniq/serializer-nested-xml_01.xq 1970-01-01 00:00:00 +0000
201+++ test/rbkt/Queries/zorba/jsoniq/serializer-nested-xml_01.xq 2012-09-28 00:14:39 +0000
202@@ -0,0 +1,1 @@
203+{ "a" : <a b="c">{ comment { "comment" }, processing-instruction target { "pi" } }</a> }
204
205=== added file 'test/rbkt/Queries/zorba/jsoniq/serializer-nested-xml_02.spec'
206--- test/rbkt/Queries/zorba/jsoniq/serializer-nested-xml_02.spec 1970-01-01 00:00:00 +0000
207+++ test/rbkt/Queries/zorba/jsoniq/serializer-nested-xml_02.spec 2012-09-28 00:14:39 +0000
208@@ -0,0 +1,2 @@
209+Serialization: method=json
210+Error: http://jsoniq.org/errors:JNSE0014
211
212=== added file 'test/rbkt/Queries/zorba/jsoniq/serializer-nested-xml_02.xq'
213--- test/rbkt/Queries/zorba/jsoniq/serializer-nested-xml_02.xq 1970-01-01 00:00:00 +0000
214+++ test/rbkt/Queries/zorba/jsoniq/serializer-nested-xml_02.xq 2012-09-28 00:14:39 +0000
215@@ -0,0 +1,1 @@
216+{ "a" : <a b="c">{ comment { "comment" }, processing-instruction target { "pi" } }</a> }

Subscribers

People subscribed via source and target branches