Merge lp:~zorba-coders/zorba/feature-EntityDataNS into lp:zorba

Proposed by Matthias Brantner
Status: Needs review
Proposed branch: lp:~zorba-coders/zorba/feature-EntityDataNS
Merge into: lp:zorba
Diff against target: 304 lines (+95/-14)
10 files modified
ChangeLog (+1/-0)
include/zorba/uri_resolvers.h (+2/-0)
src/api/uri_resolver_wrappers.cpp (+17/-2)
src/compiler/rewriter/rules/fold_rules.cpp (+1/-2)
src/compiler/translator/translator.cpp (+8/-10)
src/context/static_context.cpp (+25/-0)
src/context/static_context.h (+20/-0)
src/context/uri_resolver.cpp (+13/-0)
src/context/uri_resolver.h (+5/-0)
test/api/userdefined_uri_resolution.cpp (+3/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/feature-EntityDataNS
Reviewer Review Type Date Requested Status
Chris Hillery Needs Fixing
Matthias Brantner Approve
Review via email: mp+148618@code.launchpad.net

Commit message

Added getTargetNamespace to the URLResolver EntityData. This allows the URIMapper/URLResolver
to distinguish between target namespaces and location hints.

To post a comment you must log in.
Revision history for this message
Matthias Brantner (matthias-brantner) :
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/feature-EntityDataNS into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:275 (message):
  Validation queue job feature-EntityDataNS-2013-02-15T06-19-46.112Z is
  finished. The final status was:

  66 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/feature-EntityDataNS into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:275 (message):
  Validation queue job feature-EntityDataNS-2013-02-20T09-43-49.711Z is
  finished. The final status was:

  67 tests did not succeed - changes not commited.

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

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

I reviewed the code and it looks OK (I fixed one small typo). Obviously the test failures need to be fixed though; I'll re-review when that's done.

review: Needs Fixing
Revision history for this message
William Candillon (wcandillon) wrote :

Unmerged revisions

11242. By Chris Hillery

Fix typo.

11241. By Matthias Brantner

added getTargetNamespace to the URLResolver EntityData. This allows the URIMapper/URLResolver
to distinguish between target namespaces and location hints.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2013-02-15 21:39:41 +0000
3+++ ChangeLog 2013-02-20 09:58:22 +0000
4@@ -3,6 +3,7 @@
5 version 2.9
6
7 New Features:
8+ * Added getTargetNamespace to the URLResolver EntityData information.
9 * Typeswitch expression extended to allow union of types in each case clause,
10 as specified by XQuery v3.0
11 * In C++ API, added optional XML formatting of exceptions.
12
13=== modified file 'include/zorba/uri_resolvers.h'
14--- include/zorba/uri_resolvers.h 2012-09-19 21:16:15 +0000
15+++ include/zorba/uri_resolvers.h 2013-02-20 09:58:22 +0000
16@@ -137,6 +137,8 @@
17 */
18 virtual Kind getKind() const = 0;
19
20+ virtual zorba::String getTargetNamespace() const = 0;
21+
22 virtual ~EntityData() = 0;
23 };
24
25
26=== modified file 'src/api/uri_resolver_wrappers.cpp'
27--- src/api/uri_resolver_wrappers.cpp 2012-09-19 21:16:15 +0000
28+++ src/api/uri_resolver_wrappers.cpp 2013-02-20 09:58:22 +0000
29@@ -32,13 +32,16 @@
30 {
31 public:
32 static EntityDataWrapper const* create(internal::EntityData const* aData) {
33+
34+ const zorba::zstring& lTargetNS = aData->getTargetNamespace();
35+
36 // More ugly: Create a public-API EntityData with the same Entity Kind,
37 // but only if it's one of the publicly-supported kinds
38 switch (aData->getKind()) {
39 case internal::EntityData::MODULE:
40- return new EntityDataWrapper(EntityData::MODULE);
41+ return new EntityDataWrapper(EntityData::MODULE, lTargetNS);
42 case internal::EntityData::SCHEMA:
43- return new EntityDataWrapper(EntityData::SCHEMA);
44+ return new EntityDataWrapper(EntityData::SCHEMA, lTargetNS);
45 #ifndef ZORBA_NO_FULL_TEXT
46 case internal::EntityData::THESAURUS:
47 return new EntityDataWrapper(EntityData::THESAURUS);
48@@ -60,12 +63,24 @@
49 return theKind;
50 }
51
52+ virtual zorba::String getTargetNamespace() const {
53+ return theTargetNamespace;
54+ }
55+
56 private:
57 EntityDataWrapper(EntityData::Kind aKind)
58 : theKind(aKind)
59 {}
60
61+ EntityDataWrapper(
62+ EntityData::Kind aKind,
63+ const zorba::zstring& aTargetNS)
64+ : theKind(aKind),
65+ theTargetNamespace(zorba::Unmarshaller::newString(aTargetNS))
66+ {}
67+
68 EntityData::Kind const theKind;
69+ zorba::String const theTargetNamespace;
70 };
71
72 URIMapperWrapper::URIMapperWrapper(zorba::URIMapper& aUserMapper)
73
74=== modified file 'src/compiler/rewriter/rules/fold_rules.cpp'
75--- src/compiler/rewriter/rules/fold_rules.cpp 2013-01-08 11:07:41 +0000
76+++ src/compiler/rewriter/rules/fold_rules.cpp 2013-02-20 09:58:22 +0000
77@@ -161,8 +161,7 @@
78
79 if (!f->isUdf())
80 {
81- if (FunctionConsts::FN_ERROR_0 <= f->getKind() &&
82- f->getKind() <= FunctionConsts::FN_TRACE_2)
83+ if (FunctionConsts::FN_ERROR_0 <= f->getKind())
84 {
85 curNonDiscardable = ANNOTATION_TRUE_FIXED;
86 curUnfoldable = ANNOTATION_TRUE_FIXED;
87
88=== modified file 'src/compiler/translator/translator.cpp'
89--- src/compiler/translator/translator.cpp 2013-02-09 00:26:52 +0000
90+++ src/compiler/translator/translator.cpp 2013-02-20 09:58:22 +0000
91@@ -2183,12 +2183,12 @@
92 std::auto_ptr<internal::Resource> lSchema;
93 internal::StreamResource* lStream = NULL;
94 zstring lErrorMessage;
95+ internal::EntityData lData(internal::EntityData::SCHEMA, targetNS);
96 for (std::vector<zstring>::iterator lIter = lCandidates.begin();
97 lIter != lCandidates.end();
98 ++lIter)
99 {
100- lSchema = theSctx->resolve_uri(*lIter, internal::EntityData::SCHEMA,
101- lErrorMessage);
102+ lSchema = theSctx->resolve_uri(*lIter, lData, lErrorMessage);
103 lStream = dynamic_cast<internal::StreamResource*>(lSchema.get());
104 if (lStream != NULL)
105 {
106@@ -3000,9 +3000,8 @@
107 {
108 // just a test, this will throw, if the access is denied
109 std::vector<zstring> candidateURIs;
110- theRootSctx->get_candidate_uris(targetNS,
111- internal::EntityData::MODULE,
112- candidateURIs);
113+ internal::EntityData lData(internal::EntityData::MODULE, targetNS);
114+ theRootSctx->get_candidate_uris(targetNS, lData, candidateURIs);
115 theRootSctx->add_imported_builtin_module(targetNS);
116 #ifdef NDEBUG
117 // We cannot skip the math or the sctx introspection modules because they
118@@ -3034,8 +3033,8 @@
119 {
120 // Note the use of versioned_uri() here, so that the namespace with any
121 // version fragment will be passed through to the mappers.
122- theSctx->get_component_uris(modVer.versioned_uri(),
123- internal::EntityData::MODULE, compURIs);
124+ internal::EntityData lData(internal::EntityData::MODULE, targetNS);
125+ theSctx->get_component_uris(modVer.versioned_uri(), lData, compURIs);
126 }
127 else
128 {
129@@ -3121,10 +3120,9 @@
130
131 try
132 {
133+ internal::EntityData const lData(internal::EntityData::MODULE, targetNS);
134 lResource =
135- theSctx->resolve_uri(compModVer.versioned_uri(),
136- internal::EntityData::MODULE,
137- lErrorMessage);
138+ theSctx->resolve_uri(compModVer.versioned_uri(), lData, lErrorMessage);
139
140 lStreamResource =
141 dynamic_cast<internal::StreamResource*> (lResource.get());
142
143=== modified file 'src/context/static_context.cpp'
144--- src/context/static_context.cpp 2013-01-29 19:52:28 +0000
145+++ src/context/static_context.cpp 2013-02-20 09:58:22 +0000
146@@ -1611,6 +1611,19 @@
147
148 void static_context::get_component_uris(
149 zstring const& aUri,
150+ internal::EntityData& aEntityData,
151+ std::vector<zstring>& oComponents) const
152+{
153+ apply_uri_mappers(aUri, &aEntityData,
154+ internal::URIMapper::COMPONENT, oComponents);
155+ if (oComponents.size() == 0)
156+ {
157+ oComponents.push_back(aUri);
158+ }
159+}
160+
161+void static_context::get_component_uris(
162+ zstring const& aUri,
163 internal::EntityData::Kind aEntityKind,
164 std::vector<zstring>& oComponents) const
165 {
166@@ -1639,6 +1652,18 @@
167 }
168 }
169
170+void static_context::get_candidate_uris(
171+ zstring const& aUri,
172+ internal::EntityData& aEntityData,
173+ std::vector<zstring>& oComponents) const
174+{
175+ apply_uri_mappers(aUri, &aEntityData,
176+ internal::URIMapper::CANDIDATE, oComponents);
177+ if (oComponents.size() == 0)
178+ {
179+ oComponents.push_back(aUri);
180+ }
181+}
182
183 /***************************************************************************//**
184
185
186=== modified file 'src/context/static_context.h'
187--- src/context/static_context.h 2013-01-29 19:52:28 +0000
188+++ src/context/static_context.h 2013-02-20 09:58:22 +0000
189@@ -785,6 +785,16 @@
190 std::vector<zstring>& oComponents) const;
191
192 /**
193+ * Given a URI, populate a vector with a list of component URIs. If
194+ * no component URIs are available, the vector will be populated
195+ * with (only) the input URI.
196+ */
197+ void get_component_uris(
198+ const zstring& aUri,
199+ internal::EntityData& aEntityData,
200+ std::vector<zstring>& oComponents) const;
201+
202+ /**
203 * Given a URI, populate a vector with a list of candidate URIs. If
204 * no candidate URIs are available, the vector will be populated
205 * with (only) the input URI.
206@@ -794,6 +804,16 @@
207 internal::EntityData::Kind aEntityKind,
208 std::vector<zstring>& oComponents) const;
209
210+ /**
211+ * Given a URI, populate a vector with a list of candidate URIs. If
212+ * no candidate URIs are available, the vector will be populated
213+ * with (only) the input URI.
214+ */
215+ void get_candidate_uris(
216+ const zstring& aUri,
217+ internal::EntityData& aEntityData,
218+ std::vector<zstring>& oComponents) const;
219+
220 void set_uri_path(const std::vector<zstring>& aURIPath);
221
222 void get_uri_path(std::vector<zstring>& oURIPath) const;
223
224=== modified file 'src/context/uri_resolver.cpp'
225--- src/context/uri_resolver.cpp 2012-09-19 21:16:15 +0000
226+++ src/context/uri_resolver.cpp 2013-02-20 09:58:22 +0000
227@@ -110,11 +110,24 @@
228 {
229 }
230
231+ EntityData::EntityData(
232+ EntityData::Kind aKind,
233+ const zstring& aTargetNS)
234+ : theKind(aKind),
235+ theTargetNamespace(aTargetNS)
236+ {
237+ }
238+
239 EntityData::Kind EntityData::getKind() const
240 {
241 return theKind;
242 }
243
244+ const zstring& EntityData::getTargetNamespace() const
245+ {
246+ return theTargetNamespace;
247+ }
248+
249 EntityData::~EntityData()
250 {
251 }
252
253=== modified file 'src/context/uri_resolver.h'
254--- src/context/uri_resolver.h 2012-09-19 21:16:15 +0000
255+++ src/context/uri_resolver.h 2013-02-20 09:58:22 +0000
256@@ -192,15 +192,20 @@
257
258 EntityData(Kind aKind);
259
260+ EntityData(Kind aKind, const zstring& aTargetNS);
261+
262 /**
263 * @brief Return the Kind of Entity for which this URI is being resolved.
264 */
265 virtual Kind getKind() const;
266
267+ virtual const zstring& getTargetNamespace() const;
268+
269 virtual ~EntityData();
270
271 private:
272 Kind const theKind;
273+ zstring const theTargetNamespace;
274 };
275
276 /**
277
278=== modified file 'test/api/userdefined_uri_resolution.cpp'
279--- test/api/userdefined_uri_resolution.cpp 2012-10-08 12:09:36 +0000
280+++ test/api/userdefined_uri_resolution.cpp 2013-02-20 09:58:22 +0000
281@@ -18,6 +18,7 @@
282 #include <sstream>
283 #include <vector>
284 #include <memory>
285+#include <cassert>
286 #include <zorba/zorba.h>
287 #include <zorba/store_manager.h>
288 #include <zorba/zorba_exception.h>
289@@ -45,6 +46,7 @@
290 if (aEntityData->getKind() != EntityData::SCHEMA) {
291 return;
292 }
293+ assert(aUri == aEntityData->getTargetNamespace());
294 if(aUri == "http://www.zorba-xquery.com/helloworld") {
295 oUris.push_back("http://www.zorba-xquery.com/tutorials/helloworld.xsd");
296 }
297@@ -66,6 +68,7 @@
298 if (aEntityData->getKind() != EntityData::MODULE) {
299 return;
300 }
301+ assert(aUri == aEntityData->getTargetNamespace());
302 if(aUri == "http://www.zorba-xquery.com/mymodule") {
303 oUris.push_back("http://www.zorba-xquery.com/mymodule/mod1");
304 oUris.push_back("http://www.zorba-xquery.com/mymodule/mod2");

Subscribers

People subscribed via source and target branches