Merge lp:~zorba-coders/zorba/feature-EntityDataNS into lp:zorba
- feature-EntityDataNS
- Merge into trunk
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 |
Related bugs: |
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/
to distinguish between target namespaces and location hints.
Description of the change
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/
Validation queue job feature-
finished. The final status was:
66 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
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/
Validation queue job feature-
finished. The final status was:
67 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
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.
William Candillon (wcandillon) wrote : | # |
superseeded at https:/
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
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 | 3 | version 2.9 | 3 | version 2.9 |
6 | 4 | 4 | ||
7 | 5 | New Features: | 5 | New Features: |
8 | 6 | * Added getTargetNamespace to the URLResolver EntityData information. | ||
9 | 6 | * Typeswitch expression extended to allow union of types in each case clause, | 7 | * Typeswitch expression extended to allow union of types in each case clause, |
10 | 7 | as specified by XQuery v3.0 | 8 | as specified by XQuery v3.0 |
11 | 8 | * In C++ API, added optional XML formatting of exceptions. | 9 | * In C++ API, added optional XML formatting of exceptions. |
12 | 9 | 10 | ||
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 | 137 | */ | 137 | */ |
18 | 138 | virtual Kind getKind() const = 0; | 138 | virtual Kind getKind() const = 0; |
19 | 139 | 139 | ||
20 | 140 | virtual zorba::String getTargetNamespace() const = 0; | ||
21 | 141 | |||
22 | 140 | virtual ~EntityData() = 0; | 142 | virtual ~EntityData() = 0; |
23 | 141 | }; | 143 | }; |
24 | 142 | 144 | ||
25 | 143 | 145 | ||
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 | 32 | { | 32 | { |
31 | 33 | public: | 33 | public: |
32 | 34 | static EntityDataWrapper const* create(internal::EntityData const* aData) { | 34 | static EntityDataWrapper const* create(internal::EntityData const* aData) { |
33 | 35 | |||
34 | 36 | const zorba::zstring& lTargetNS = aData->getTargetNamespace(); | ||
35 | 37 | |||
36 | 35 | // More ugly: Create a public-API EntityData with the same Entity Kind, | 38 | // More ugly: Create a public-API EntityData with the same Entity Kind, |
37 | 36 | // but only if it's one of the publicly-supported kinds | 39 | // but only if it's one of the publicly-supported kinds |
38 | 37 | switch (aData->getKind()) { | 40 | switch (aData->getKind()) { |
39 | 38 | case internal::EntityData::MODULE: | 41 | case internal::EntityData::MODULE: |
41 | 39 | return new EntityDataWrapper(EntityData::MODULE); | 42 | return new EntityDataWrapper(EntityData::MODULE, lTargetNS); |
42 | 40 | case internal::EntityData::SCHEMA: | 43 | case internal::EntityData::SCHEMA: |
44 | 41 | return new EntityDataWrapper(EntityData::SCHEMA); | 44 | return new EntityDataWrapper(EntityData::SCHEMA, lTargetNS); |
45 | 42 | #ifndef ZORBA_NO_FULL_TEXT | 45 | #ifndef ZORBA_NO_FULL_TEXT |
46 | 43 | case internal::EntityData::THESAURUS: | 46 | case internal::EntityData::THESAURUS: |
47 | 44 | return new EntityDataWrapper(EntityData::THESAURUS); | 47 | return new EntityDataWrapper(EntityData::THESAURUS); |
48 | @@ -60,12 +63,24 @@ | |||
49 | 60 | return theKind; | 63 | return theKind; |
50 | 61 | } | 64 | } |
51 | 62 | 65 | ||
52 | 66 | virtual zorba::String getTargetNamespace() const { | ||
53 | 67 | return theTargetNamespace; | ||
54 | 68 | } | ||
55 | 69 | |||
56 | 63 | private: | 70 | private: |
57 | 64 | EntityDataWrapper(EntityData::Kind aKind) | 71 | EntityDataWrapper(EntityData::Kind aKind) |
58 | 65 | : theKind(aKind) | 72 | : theKind(aKind) |
59 | 66 | {} | 73 | {} |
60 | 67 | 74 | ||
61 | 75 | EntityDataWrapper( | ||
62 | 76 | EntityData::Kind aKind, | ||
63 | 77 | const zorba::zstring& aTargetNS) | ||
64 | 78 | : theKind(aKind), | ||
65 | 79 | theTargetNamespace(zorba::Unmarshaller::newString(aTargetNS)) | ||
66 | 80 | {} | ||
67 | 81 | |||
68 | 68 | EntityData::Kind const theKind; | 82 | EntityData::Kind const theKind; |
69 | 83 | zorba::String const theTargetNamespace; | ||
70 | 69 | }; | 84 | }; |
71 | 70 | 85 | ||
72 | 71 | URIMapperWrapper::URIMapperWrapper(zorba::URIMapper& aUserMapper) | 86 | URIMapperWrapper::URIMapperWrapper(zorba::URIMapper& aUserMapper) |
73 | 72 | 87 | ||
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 | 161 | 161 | ||
79 | 162 | if (!f->isUdf()) | 162 | if (!f->isUdf()) |
80 | 163 | { | 163 | { |
83 | 164 | if (FunctionConsts::FN_ERROR_0 <= f->getKind() && | 164 | if (FunctionConsts::FN_ERROR_0 <= f->getKind()) |
82 | 165 | f->getKind() <= FunctionConsts::FN_TRACE_2) | ||
84 | 166 | { | 165 | { |
85 | 167 | curNonDiscardable = ANNOTATION_TRUE_FIXED; | 166 | curNonDiscardable = ANNOTATION_TRUE_FIXED; |
86 | 168 | curUnfoldable = ANNOTATION_TRUE_FIXED; | 167 | curUnfoldable = ANNOTATION_TRUE_FIXED; |
87 | 169 | 168 | ||
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 | 2183 | std::auto_ptr<internal::Resource> lSchema; | 2183 | std::auto_ptr<internal::Resource> lSchema; |
93 | 2184 | internal::StreamResource* lStream = NULL; | 2184 | internal::StreamResource* lStream = NULL; |
94 | 2185 | zstring lErrorMessage; | 2185 | zstring lErrorMessage; |
95 | 2186 | internal::EntityData lData(internal::EntityData::SCHEMA, targetNS); | ||
96 | 2186 | for (std::vector<zstring>::iterator lIter = lCandidates.begin(); | 2187 | for (std::vector<zstring>::iterator lIter = lCandidates.begin(); |
97 | 2187 | lIter != lCandidates.end(); | 2188 | lIter != lCandidates.end(); |
98 | 2188 | ++lIter) | 2189 | ++lIter) |
99 | 2189 | { | 2190 | { |
102 | 2190 | lSchema = theSctx->resolve_uri(*lIter, internal::EntityData::SCHEMA, | 2191 | lSchema = theSctx->resolve_uri(*lIter, lData, lErrorMessage); |
101 | 2191 | lErrorMessage); | ||
103 | 2192 | lStream = dynamic_cast<internal::StreamResource*>(lSchema.get()); | 2192 | lStream = dynamic_cast<internal::StreamResource*>(lSchema.get()); |
104 | 2193 | if (lStream != NULL) | 2193 | if (lStream != NULL) |
105 | 2194 | { | 2194 | { |
106 | @@ -3000,9 +3000,8 @@ | |||
107 | 3000 | { | 3000 | { |
108 | 3001 | // just a test, this will throw, if the access is denied | 3001 | // just a test, this will throw, if the access is denied |
109 | 3002 | std::vector<zstring> candidateURIs; | 3002 | std::vector<zstring> candidateURIs; |
113 | 3003 | theRootSctx->get_candidate_uris(targetNS, | 3003 | internal::EntityData lData(internal::EntityData::MODULE, targetNS); |
114 | 3004 | internal::EntityData::MODULE, | 3004 | theRootSctx->get_candidate_uris(targetNS, lData, candidateURIs); |
112 | 3005 | candidateURIs); | ||
115 | 3006 | theRootSctx->add_imported_builtin_module(targetNS); | 3005 | theRootSctx->add_imported_builtin_module(targetNS); |
116 | 3007 | #ifdef NDEBUG | 3006 | #ifdef NDEBUG |
117 | 3008 | // We cannot skip the math or the sctx introspection modules because they | 3007 | // We cannot skip the math or the sctx introspection modules because they |
118 | @@ -3034,8 +3033,8 @@ | |||
119 | 3034 | { | 3033 | { |
120 | 3035 | // Note the use of versioned_uri() here, so that the namespace with any | 3034 | // Note the use of versioned_uri() here, so that the namespace with any |
121 | 3036 | // version fragment will be passed through to the mappers. | 3035 | // version fragment will be passed through to the mappers. |
124 | 3037 | theSctx->get_component_uris(modVer.versioned_uri(), | 3036 | internal::EntityData lData(internal::EntityData::MODULE, targetNS); |
125 | 3038 | internal::EntityData::MODULE, compURIs); | 3037 | theSctx->get_component_uris(modVer.versioned_uri(), lData, compURIs); |
126 | 3039 | } | 3038 | } |
127 | 3040 | else | 3039 | else |
128 | 3041 | { | 3040 | { |
129 | @@ -3121,10 +3120,9 @@ | |||
130 | 3121 | 3120 | ||
131 | 3122 | try | 3121 | try |
132 | 3123 | { | 3122 | { |
133 | 3123 | internal::EntityData const lData(internal::EntityData::MODULE, targetNS); | ||
134 | 3124 | lResource = | 3124 | lResource = |
138 | 3125 | theSctx->resolve_uri(compModVer.versioned_uri(), | 3125 | theSctx->resolve_uri(compModVer.versioned_uri(), lData, lErrorMessage); |
136 | 3126 | internal::EntityData::MODULE, | ||
137 | 3127 | lErrorMessage); | ||
139 | 3128 | 3126 | ||
140 | 3129 | lStreamResource = | 3127 | lStreamResource = |
141 | 3130 | dynamic_cast<internal::StreamResource*> (lResource.get()); | 3128 | dynamic_cast<internal::StreamResource*> (lResource.get()); |
142 | 3131 | 3129 | ||
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 | 1611 | 1611 | ||
148 | 1612 | void static_context::get_component_uris( | 1612 | void static_context::get_component_uris( |
149 | 1613 | zstring const& aUri, | 1613 | zstring const& aUri, |
150 | 1614 | internal::EntityData& aEntityData, | ||
151 | 1615 | std::vector<zstring>& oComponents) const | ||
152 | 1616 | { | ||
153 | 1617 | apply_uri_mappers(aUri, &aEntityData, | ||
154 | 1618 | internal::URIMapper::COMPONENT, oComponents); | ||
155 | 1619 | if (oComponents.size() == 0) | ||
156 | 1620 | { | ||
157 | 1621 | oComponents.push_back(aUri); | ||
158 | 1622 | } | ||
159 | 1623 | } | ||
160 | 1624 | |||
161 | 1625 | void static_context::get_component_uris( | ||
162 | 1626 | zstring const& aUri, | ||
163 | 1614 | internal::EntityData::Kind aEntityKind, | 1627 | internal::EntityData::Kind aEntityKind, |
164 | 1615 | std::vector<zstring>& oComponents) const | 1628 | std::vector<zstring>& oComponents) const |
165 | 1616 | { | 1629 | { |
166 | @@ -1639,6 +1652,18 @@ | |||
167 | 1639 | } | 1652 | } |
168 | 1640 | } | 1653 | } |
169 | 1641 | 1654 | ||
170 | 1655 | void static_context::get_candidate_uris( | ||
171 | 1656 | zstring const& aUri, | ||
172 | 1657 | internal::EntityData& aEntityData, | ||
173 | 1658 | std::vector<zstring>& oComponents) const | ||
174 | 1659 | { | ||
175 | 1660 | apply_uri_mappers(aUri, &aEntityData, | ||
176 | 1661 | internal::URIMapper::CANDIDATE, oComponents); | ||
177 | 1662 | if (oComponents.size() == 0) | ||
178 | 1663 | { | ||
179 | 1664 | oComponents.push_back(aUri); | ||
180 | 1665 | } | ||
181 | 1666 | } | ||
182 | 1642 | 1667 | ||
183 | 1643 | /***************************************************************************//** | 1668 | /***************************************************************************//** |
184 | 1644 | 1669 | ||
185 | 1645 | 1670 | ||
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 | 785 | std::vector<zstring>& oComponents) const; | 785 | std::vector<zstring>& oComponents) const; |
191 | 786 | 786 | ||
192 | 787 | /** | 787 | /** |
193 | 788 | * Given a URI, populate a vector with a list of component URIs. If | ||
194 | 789 | * no component URIs are available, the vector will be populated | ||
195 | 790 | * with (only) the input URI. | ||
196 | 791 | */ | ||
197 | 792 | void get_component_uris( | ||
198 | 793 | const zstring& aUri, | ||
199 | 794 | internal::EntityData& aEntityData, | ||
200 | 795 | std::vector<zstring>& oComponents) const; | ||
201 | 796 | |||
202 | 797 | /** | ||
203 | 788 | * Given a URI, populate a vector with a list of candidate URIs. If | 798 | * Given a URI, populate a vector with a list of candidate URIs. If |
204 | 789 | * no candidate URIs are available, the vector will be populated | 799 | * no candidate URIs are available, the vector will be populated |
205 | 790 | * with (only) the input URI. | 800 | * with (only) the input URI. |
206 | @@ -794,6 +804,16 @@ | |||
207 | 794 | internal::EntityData::Kind aEntityKind, | 804 | internal::EntityData::Kind aEntityKind, |
208 | 795 | std::vector<zstring>& oComponents) const; | 805 | std::vector<zstring>& oComponents) const; |
209 | 796 | 806 | ||
210 | 807 | /** | ||
211 | 808 | * Given a URI, populate a vector with a list of candidate URIs. If | ||
212 | 809 | * no candidate URIs are available, the vector will be populated | ||
213 | 810 | * with (only) the input URI. | ||
214 | 811 | */ | ||
215 | 812 | void get_candidate_uris( | ||
216 | 813 | const zstring& aUri, | ||
217 | 814 | internal::EntityData& aEntityData, | ||
218 | 815 | std::vector<zstring>& oComponents) const; | ||
219 | 816 | |||
220 | 797 | void set_uri_path(const std::vector<zstring>& aURIPath); | 817 | void set_uri_path(const std::vector<zstring>& aURIPath); |
221 | 798 | 818 | ||
222 | 799 | void get_uri_path(std::vector<zstring>& oURIPath) const; | 819 | void get_uri_path(std::vector<zstring>& oURIPath) const; |
223 | 800 | 820 | ||
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 | 110 | { | 110 | { |
229 | 111 | } | 111 | } |
230 | 112 | 112 | ||
231 | 113 | EntityData::EntityData( | ||
232 | 114 | EntityData::Kind aKind, | ||
233 | 115 | const zstring& aTargetNS) | ||
234 | 116 | : theKind(aKind), | ||
235 | 117 | theTargetNamespace(aTargetNS) | ||
236 | 118 | { | ||
237 | 119 | } | ||
238 | 120 | |||
239 | 113 | EntityData::Kind EntityData::getKind() const | 121 | EntityData::Kind EntityData::getKind() const |
240 | 114 | { | 122 | { |
241 | 115 | return theKind; | 123 | return theKind; |
242 | 116 | } | 124 | } |
243 | 117 | 125 | ||
244 | 126 | const zstring& EntityData::getTargetNamespace() const | ||
245 | 127 | { | ||
246 | 128 | return theTargetNamespace; | ||
247 | 129 | } | ||
248 | 130 | |||
249 | 118 | EntityData::~EntityData() | 131 | EntityData::~EntityData() |
250 | 119 | { | 132 | { |
251 | 120 | } | 133 | } |
252 | 121 | 134 | ||
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 | 192 | 192 | ||
258 | 193 | EntityData(Kind aKind); | 193 | EntityData(Kind aKind); |
259 | 194 | 194 | ||
260 | 195 | EntityData(Kind aKind, const zstring& aTargetNS); | ||
261 | 196 | |||
262 | 195 | /** | 197 | /** |
263 | 196 | * @brief Return the Kind of Entity for which this URI is being resolved. | 198 | * @brief Return the Kind of Entity for which this URI is being resolved. |
264 | 197 | */ | 199 | */ |
265 | 198 | virtual Kind getKind() const; | 200 | virtual Kind getKind() const; |
266 | 199 | 201 | ||
267 | 202 | virtual const zstring& getTargetNamespace() const; | ||
268 | 203 | |||
269 | 200 | virtual ~EntityData(); | 204 | virtual ~EntityData(); |
270 | 201 | 205 | ||
271 | 202 | private: | 206 | private: |
272 | 203 | Kind const theKind; | 207 | Kind const theKind; |
273 | 208 | zstring const theTargetNamespace; | ||
274 | 204 | }; | 209 | }; |
275 | 205 | 210 | ||
276 | 206 | /** | 211 | /** |
277 | 207 | 212 | ||
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 | 18 | #include <sstream> | 18 | #include <sstream> |
283 | 19 | #include <vector> | 19 | #include <vector> |
284 | 20 | #include <memory> | 20 | #include <memory> |
285 | 21 | #include <cassert> | ||
286 | 21 | #include <zorba/zorba.h> | 22 | #include <zorba/zorba.h> |
287 | 22 | #include <zorba/store_manager.h> | 23 | #include <zorba/store_manager.h> |
288 | 23 | #include <zorba/zorba_exception.h> | 24 | #include <zorba/zorba_exception.h> |
289 | @@ -45,6 +46,7 @@ | |||
290 | 45 | if (aEntityData->getKind() != EntityData::SCHEMA) { | 46 | if (aEntityData->getKind() != EntityData::SCHEMA) { |
291 | 46 | return; | 47 | return; |
292 | 47 | } | 48 | } |
293 | 49 | assert(aUri == aEntityData->getTargetNamespace()); | ||
294 | 48 | if(aUri == "http://www.zorba-xquery.com/helloworld") { | 50 | if(aUri == "http://www.zorba-xquery.com/helloworld") { |
295 | 49 | oUris.push_back("http://www.zorba-xquery.com/tutorials/helloworld.xsd"); | 51 | oUris.push_back("http://www.zorba-xquery.com/tutorials/helloworld.xsd"); |
296 | 50 | } | 52 | } |
297 | @@ -66,6 +68,7 @@ | |||
298 | 66 | if (aEntityData->getKind() != EntityData::MODULE) { | 68 | if (aEntityData->getKind() != EntityData::MODULE) { |
299 | 67 | return; | 69 | return; |
300 | 68 | } | 70 | } |
301 | 71 | assert(aUri == aEntityData->getTargetNamespace()); | ||
302 | 69 | if(aUri == "http://www.zorba-xquery.com/mymodule") { | 72 | if(aUri == "http://www.zorba-xquery.com/mymodule") { |
303 | 70 | oUris.push_back("http://www.zorba-xquery.com/mymodule/mod1"); | 73 | oUris.push_back("http://www.zorba-xquery.com/mymodule/mod1"); |
304 | 71 | oUris.push_back("http://www.zorba-xquery.com/mymodule/mod2"); | 74 | oUris.push_back("http://www.zorba-xquery.com/mymodule/mod2"); |
Validation queue starting for merge proposal. zorbatest. lambda. nu:8080/ remotequeue/ feature- EntityDataNS- 2013-02- 15T06-19- 46.112Z/ log.html
Log at: http://