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
=== modified file 'ChangeLog'
--- ChangeLog 2013-02-15 21:39:41 +0000
+++ ChangeLog 2013-02-20 09:58:22 +0000
@@ -3,6 +3,7 @@
3version 2.93version 2.9
44
5New Features:5New Features:
6 * Added getTargetNamespace to the URLResolver EntityData information.
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,
7 as specified by XQuery v3.08 as specified by XQuery v3.0
8 * In C++ API, added optional XML formatting of exceptions.9 * In C++ API, added optional XML formatting of exceptions.
910
=== modified file 'include/zorba/uri_resolvers.h'
--- include/zorba/uri_resolvers.h 2012-09-19 21:16:15 +0000
+++ include/zorba/uri_resolvers.h 2013-02-20 09:58:22 +0000
@@ -137,6 +137,8 @@
137 */137 */
138 virtual Kind getKind() const = 0;138 virtual Kind getKind() const = 0;
139139
140 virtual zorba::String getTargetNamespace() const = 0;
141
140 virtual ~EntityData() = 0;142 virtual ~EntityData() = 0;
141};143};
142144
143145
=== modified file 'src/api/uri_resolver_wrappers.cpp'
--- src/api/uri_resolver_wrappers.cpp 2012-09-19 21:16:15 +0000
+++ src/api/uri_resolver_wrappers.cpp 2013-02-20 09:58:22 +0000
@@ -32,13 +32,16 @@
32 {32 {
33 public:33 public:
34 static EntityDataWrapper const* create(internal::EntityData const* aData) {34 static EntityDataWrapper const* create(internal::EntityData const* aData) {
35
36 const zorba::zstring& lTargetNS = aData->getTargetNamespace();
37
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,
36 // but only if it's one of the publicly-supported kinds39 // but only if it's one of the publicly-supported kinds
37 switch (aData->getKind()) {40 switch (aData->getKind()) {
38 case internal::EntityData::MODULE:41 case internal::EntityData::MODULE:
39 return new EntityDataWrapper(EntityData::MODULE);42 return new EntityDataWrapper(EntityData::MODULE, lTargetNS);
40 case internal::EntityData::SCHEMA:43 case internal::EntityData::SCHEMA:
41 return new EntityDataWrapper(EntityData::SCHEMA);44 return new EntityDataWrapper(EntityData::SCHEMA, lTargetNS);
42#ifndef ZORBA_NO_FULL_TEXT45#ifndef ZORBA_NO_FULL_TEXT
43 case internal::EntityData::THESAURUS:46 case internal::EntityData::THESAURUS:
44 return new EntityDataWrapper(EntityData::THESAURUS);47 return new EntityDataWrapper(EntityData::THESAURUS);
@@ -60,12 +63,24 @@
60 return theKind;63 return theKind;
61 }64 }
6265
66 virtual zorba::String getTargetNamespace() const {
67 return theTargetNamespace;
68 }
69
63 private:70 private:
64 EntityDataWrapper(EntityData::Kind aKind)71 EntityDataWrapper(EntityData::Kind aKind)
65 : theKind(aKind)72 : theKind(aKind)
66 {}73 {}
6774
75 EntityDataWrapper(
76 EntityData::Kind aKind,
77 const zorba::zstring& aTargetNS)
78 : theKind(aKind),
79 theTargetNamespace(zorba::Unmarshaller::newString(aTargetNS))
80 {}
81
68 EntityData::Kind const theKind;82 EntityData::Kind const theKind;
83 zorba::String const theTargetNamespace;
69 };84 };
7085
71 URIMapperWrapper::URIMapperWrapper(zorba::URIMapper& aUserMapper)86 URIMapperWrapper::URIMapperWrapper(zorba::URIMapper& aUserMapper)
7287
=== modified file 'src/compiler/rewriter/rules/fold_rules.cpp'
--- src/compiler/rewriter/rules/fold_rules.cpp 2013-01-08 11:07:41 +0000
+++ src/compiler/rewriter/rules/fold_rules.cpp 2013-02-20 09:58:22 +0000
@@ -161,8 +161,7 @@
161 161
162 if (!f->isUdf())162 if (!f->isUdf())
163 {163 {
164 if (FunctionConsts::FN_ERROR_0 <= f->getKind() &&164 if (FunctionConsts::FN_ERROR_0 <= f->getKind())
165 f->getKind() <= FunctionConsts::FN_TRACE_2)
166 {165 {
167 curNonDiscardable = ANNOTATION_TRUE_FIXED;166 curNonDiscardable = ANNOTATION_TRUE_FIXED;
168 curUnfoldable = ANNOTATION_TRUE_FIXED;167 curUnfoldable = ANNOTATION_TRUE_FIXED;
169168
=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp 2013-02-09 00:26:52 +0000
+++ src/compiler/translator/translator.cpp 2013-02-20 09:58:22 +0000
@@ -2183,12 +2183,12 @@
2183 std::auto_ptr<internal::Resource> lSchema;2183 std::auto_ptr<internal::Resource> lSchema;
2184 internal::StreamResource* lStream = NULL;2184 internal::StreamResource* lStream = NULL;
2185 zstring lErrorMessage;2185 zstring lErrorMessage;
2186 internal::EntityData lData(internal::EntityData::SCHEMA, targetNS);
2186 for (std::vector<zstring>::iterator lIter = lCandidates.begin();2187 for (std::vector<zstring>::iterator lIter = lCandidates.begin();
2187 lIter != lCandidates.end();2188 lIter != lCandidates.end();
2188 ++lIter)2189 ++lIter)
2189 {2190 {
2190 lSchema = theSctx->resolve_uri(*lIter, internal::EntityData::SCHEMA,2191 lSchema = theSctx->resolve_uri(*lIter, lData, lErrorMessage);
2191 lErrorMessage);
2192 lStream = dynamic_cast<internal::StreamResource*>(lSchema.get());2192 lStream = dynamic_cast<internal::StreamResource*>(lSchema.get());
2193 if (lStream != NULL)2193 if (lStream != NULL)
2194 {2194 {
@@ -3000,9 +3000,8 @@
3000 {3000 {
3001 // just a test, this will throw, if the access is denied3001 // just a test, this will throw, if the access is denied
3002 std::vector<zstring> candidateURIs;3002 std::vector<zstring> candidateURIs;
3003 theRootSctx->get_candidate_uris(targetNS,3003 internal::EntityData lData(internal::EntityData::MODULE, targetNS);
3004 internal::EntityData::MODULE,3004 theRootSctx->get_candidate_uris(targetNS, lData, candidateURIs);
3005 candidateURIs);
3006 theRootSctx->add_imported_builtin_module(targetNS);3005 theRootSctx->add_imported_builtin_module(targetNS);
3007#ifdef NDEBUG3006#ifdef NDEBUG
3008 // We cannot skip the math or the sctx introspection modules because they3007 // We cannot skip the math or the sctx introspection modules because they
@@ -3034,8 +3033,8 @@
3034 {3033 {
3035 // Note the use of versioned_uri() here, so that the namespace with any3034 // Note the use of versioned_uri() here, so that the namespace with any
3036 // version fragment will be passed through to the mappers.3035 // version fragment will be passed through to the mappers.
3037 theSctx->get_component_uris(modVer.versioned_uri(),3036 internal::EntityData lData(internal::EntityData::MODULE, targetNS);
3038 internal::EntityData::MODULE, compURIs);3037 theSctx->get_component_uris(modVer.versioned_uri(), lData, compURIs);
3039 }3038 }
3040 else3039 else
3041 {3040 {
@@ -3121,10 +3120,9 @@
31213120
3122 try3121 try
3123 {3122 {
3123 internal::EntityData const lData(internal::EntityData::MODULE, targetNS);
3124 lResource =3124 lResource =
3125 theSctx->resolve_uri(compModVer.versioned_uri(),3125 theSctx->resolve_uri(compModVer.versioned_uri(), lData, lErrorMessage);
3126 internal::EntityData::MODULE,
3127 lErrorMessage);
31283126
3129 lStreamResource =3127 lStreamResource =
3130 dynamic_cast<internal::StreamResource*> (lResource.get());3128 dynamic_cast<internal::StreamResource*> (lResource.get());
31313129
=== modified file 'src/context/static_context.cpp'
--- src/context/static_context.cpp 2013-01-29 19:52:28 +0000
+++ src/context/static_context.cpp 2013-02-20 09:58:22 +0000
@@ -1611,6 +1611,19 @@
16111611
1612void static_context::get_component_uris(1612void static_context::get_component_uris(
1613 zstring const& aUri,1613 zstring const& aUri,
1614 internal::EntityData& aEntityData,
1615 std::vector<zstring>& oComponents) const
1616{
1617 apply_uri_mappers(aUri, &aEntityData,
1618 internal::URIMapper::COMPONENT, oComponents);
1619 if (oComponents.size() == 0)
1620 {
1621 oComponents.push_back(aUri);
1622 }
1623}
1624
1625void static_context::get_component_uris(
1626 zstring const& aUri,
1614 internal::EntityData::Kind aEntityKind,1627 internal::EntityData::Kind aEntityKind,
1615 std::vector<zstring>& oComponents) const1628 std::vector<zstring>& oComponents) const
1616{1629{
@@ -1639,6 +1652,18 @@
1639 }1652 }
1640}1653}
16411654
1655void static_context::get_candidate_uris(
1656 zstring const& aUri,
1657 internal::EntityData& aEntityData,
1658 std::vector<zstring>& oComponents) const
1659{
1660 apply_uri_mappers(aUri, &aEntityData,
1661 internal::URIMapper::CANDIDATE, oComponents);
1662 if (oComponents.size() == 0)
1663 {
1664 oComponents.push_back(aUri);
1665 }
1666}
16421667
1643/***************************************************************************//**1668/***************************************************************************//**
16441669
16451670
=== modified file 'src/context/static_context.h'
--- src/context/static_context.h 2013-01-29 19:52:28 +0000
+++ src/context/static_context.h 2013-02-20 09:58:22 +0000
@@ -785,6 +785,16 @@
785 std::vector<zstring>& oComponents) const;785 std::vector<zstring>& oComponents) const;
786786
787 /**787 /**
788 * Given a URI, populate a vector with a list of component URIs. If
789 * no component URIs are available, the vector will be populated
790 * with (only) the input URI.
791 */
792 void get_component_uris(
793 const zstring& aUri,
794 internal::EntityData& aEntityData,
795 std::vector<zstring>& oComponents) const;
796
797 /**
788 * Given a URI, populate a vector with a list of candidate URIs. If798 * Given a URI, populate a vector with a list of candidate URIs. If
789 * no candidate URIs are available, the vector will be populated799 * no candidate URIs are available, the vector will be populated
790 * with (only) the input URI.800 * with (only) the input URI.
@@ -794,6 +804,16 @@
794 internal::EntityData::Kind aEntityKind,804 internal::EntityData::Kind aEntityKind,
795 std::vector<zstring>& oComponents) const;805 std::vector<zstring>& oComponents) const;
796806
807 /**
808 * Given a URI, populate a vector with a list of candidate URIs. If
809 * no candidate URIs are available, the vector will be populated
810 * with (only) the input URI.
811 */
812 void get_candidate_uris(
813 const zstring& aUri,
814 internal::EntityData& aEntityData,
815 std::vector<zstring>& oComponents) const;
816
797 void set_uri_path(const std::vector<zstring>& aURIPath);817 void set_uri_path(const std::vector<zstring>& aURIPath);
798818
799 void get_uri_path(std::vector<zstring>& oURIPath) const;819 void get_uri_path(std::vector<zstring>& oURIPath) const;
800820
=== modified file 'src/context/uri_resolver.cpp'
--- src/context/uri_resolver.cpp 2012-09-19 21:16:15 +0000
+++ src/context/uri_resolver.cpp 2013-02-20 09:58:22 +0000
@@ -110,11 +110,24 @@
110 {110 {
111 }111 }
112112
113 EntityData::EntityData(
114 EntityData::Kind aKind,
115 const zstring& aTargetNS)
116 : theKind(aKind),
117 theTargetNamespace(aTargetNS)
118 {
119 }
120
113 EntityData::Kind EntityData::getKind() const121 EntityData::Kind EntityData::getKind() const
114 {122 {
115 return theKind;123 return theKind;
116 }124 }
117125
126 const zstring& EntityData::getTargetNamespace() const
127 {
128 return theTargetNamespace;
129 }
130
118 EntityData::~EntityData()131 EntityData::~EntityData()
119 {132 {
120 }133 }
121134
=== modified file 'src/context/uri_resolver.h'
--- src/context/uri_resolver.h 2012-09-19 21:16:15 +0000
+++ src/context/uri_resolver.h 2013-02-20 09:58:22 +0000
@@ -192,15 +192,20 @@
192192
193 EntityData(Kind aKind);193 EntityData(Kind aKind);
194194
195 EntityData(Kind aKind, const zstring& aTargetNS);
196
195 /**197 /**
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.
197 */199 */
198 virtual Kind getKind() const;200 virtual Kind getKind() const;
199201
202 virtual const zstring& getTargetNamespace() const;
203
200 virtual ~EntityData();204 virtual ~EntityData();
201205
202private:206private:
203 Kind const theKind;207 Kind const theKind;
208 zstring const theTargetNamespace;
204};209};
205210
206/**211/**
207212
=== modified file 'test/api/userdefined_uri_resolution.cpp'
--- test/api/userdefined_uri_resolution.cpp 2012-10-08 12:09:36 +0000
+++ test/api/userdefined_uri_resolution.cpp 2013-02-20 09:58:22 +0000
@@ -18,6 +18,7 @@
18#include <sstream>18#include <sstream>
19#include <vector>19#include <vector>
20#include <memory>20#include <memory>
21#include <cassert>
21#include <zorba/zorba.h>22#include <zorba/zorba.h>
22#include <zorba/store_manager.h>23#include <zorba/store_manager.h>
23#include <zorba/zorba_exception.h>24#include <zorba/zorba_exception.h>
@@ -45,6 +46,7 @@
45 if (aEntityData->getKind() != EntityData::SCHEMA) {46 if (aEntityData->getKind() != EntityData::SCHEMA) {
46 return;47 return;
47 }48 }
49 assert(aUri == aEntityData->getTargetNamespace());
48 if(aUri == "http://www.zorba-xquery.com/helloworld") {50 if(aUri == "http://www.zorba-xquery.com/helloworld") {
49 oUris.push_back("http://www.zorba-xquery.com/tutorials/helloworld.xsd");51 oUris.push_back("http://www.zorba-xquery.com/tutorials/helloworld.xsd");
50 }52 }
@@ -66,6 +68,7 @@
66 if (aEntityData->getKind() != EntityData::MODULE) {68 if (aEntityData->getKind() != EntityData::MODULE) {
67 return;69 return;
68 }70 }
71 assert(aUri == aEntityData->getTargetNamespace());
69 if(aUri == "http://www.zorba-xquery.com/mymodule") {72 if(aUri == "http://www.zorba-xquery.com/mymodule") {
70 oUris.push_back("http://www.zorba-xquery.com/mymodule/mod1");73 oUris.push_back("http://www.zorba-xquery.com/mymodule/mod1");
71 oUris.push_back("http://www.zorba-xquery.com/mymodule/mod2");74 oUris.push_back("http://www.zorba-xquery.com/mymodule/mod2");

Subscribers

People subscribed via source and target branches