zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #18115
[Merge] lp:~zorba-coders/zorba/feature-EntityDataNS into lp:zorba
Matthias Brantner has proposed merging lp:~zorba-coders/zorba/feature-EntityDataNS into lp:zorba.
Commit message:
Added getTargetNamespace to the URLResolver EntityData. This allows the URIMapper/URLResolver
to distinguish between target namespaces and location hints.
Requested reviews:
Matthias Brantner (matthias-brantner)
Chris Hillery (ceejatec)
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/feature-EntityDataNS/+merge/148618
--
https://code.launchpad.net/~zorba-coders/zorba/feature-EntityDataNS/+merge/148618
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog 2013-02-13 16:25:55 +0000
+++ ChangeLog 2013-02-15 06:15:07 +0000
@@ -3,6 +3,7 @@
version 2.9
New Features:
+ * Added getTargetNamespace to the URLResolver EntityData information.
* Typeswitch expression extended to allow union of types in each case clause,
as specified by XQuery v3.0
* In C++ API, added optional XML formatting of exceptions.
=== 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-15 06:15:07 +0000
@@ -137,6 +137,8 @@
*/
virtual Kind getKind() const = 0;
+ virtual zorba::String getTargetNamespace() const = 0;
+
virtual ~EntityData() = 0;
};
=== 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-15 06:15:07 +0000
@@ -32,13 +32,16 @@
{
public:
static EntityDataWrapper const* create(internal::EntityData const* aData) {
+
+ const zorba::zstring& lTargeNS = aData->getTargetNamespace();
+
// More ugly: Create a public-API EntityData with the same Entity Kind,
// but only if it's one of the publicly-supported kinds
switch (aData->getKind()) {
case internal::EntityData::MODULE:
- return new EntityDataWrapper(EntityData::MODULE);
+ return new EntityDataWrapper(EntityData::MODULE, lTargeNS);
case internal::EntityData::SCHEMA:
- return new EntityDataWrapper(EntityData::SCHEMA);
+ return new EntityDataWrapper(EntityData::SCHEMA, lTargeNS);
#ifndef ZORBA_NO_FULL_TEXT
case internal::EntityData::THESAURUS:
return new EntityDataWrapper(EntityData::THESAURUS);
@@ -60,12 +63,24 @@
return theKind;
}
+ virtual zorba::String getTargetNamespace() const {
+ return theTargetNamespace;
+ }
+
private:
EntityDataWrapper(EntityData::Kind aKind)
: theKind(aKind)
{}
+ EntityDataWrapper(
+ EntityData::Kind aKind,
+ const zorba::zstring& aTargetNS)
+ : theKind(aKind),
+ theTargetNamespace(zorba::Unmarshaller::newString(aTargetNS))
+ {}
+
EntityData::Kind const theKind;
+ zorba::String const theTargetNamespace;
};
URIMapperWrapper::URIMapperWrapper(zorba::URIMapper& aUserMapper)
=== 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-15 06:15:07 +0000
@@ -161,8 +161,7 @@
if (!f->isUdf())
{
- if (FunctionConsts::FN_ERROR_0 <= f->getKind() &&
- f->getKind() <= FunctionConsts::FN_TRACE_2)
+ if (FunctionConsts::FN_ERROR_0 <= f->getKind())
{
curNonDiscardable = ANNOTATION_TRUE_FIXED;
curUnfoldable = ANNOTATION_TRUE_FIXED;
=== 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-15 06:15:07 +0000
@@ -2183,12 +2183,12 @@
std::auto_ptr<internal::Resource> lSchema;
internal::StreamResource* lStream = NULL;
zstring lErrorMessage;
+ internal::EntityData lData(internal::EntityData::SCHEMA, targetNS);
for (std::vector<zstring>::iterator lIter = lCandidates.begin();
lIter != lCandidates.end();
++lIter)
{
- lSchema = theSctx->resolve_uri(*lIter, internal::EntityData::SCHEMA,
- lErrorMessage);
+ lSchema = theSctx->resolve_uri(*lIter, lData, lErrorMessage);
lStream = dynamic_cast<internal::StreamResource*>(lSchema.get());
if (lStream != NULL)
{
@@ -3000,9 +3000,8 @@
{
// just a test, this will throw, if the access is denied
std::vector<zstring> candidateURIs;
- theRootSctx->get_candidate_uris(targetNS,
- internal::EntityData::MODULE,
- candidateURIs);
+ internal::EntityData lData(internal::EntityData::MODULE, targetNS);
+ theRootSctx->get_candidate_uris(targetNS, lData, candidateURIs);
theRootSctx->add_imported_builtin_module(targetNS);
#ifdef NDEBUG
// We cannot skip the math or the sctx introspection modules because they
@@ -3034,8 +3033,8 @@
{
// Note the use of versioned_uri() here, so that the namespace with any
// version fragment will be passed through to the mappers.
- theSctx->get_component_uris(modVer.versioned_uri(),
- internal::EntityData::MODULE, compURIs);
+ internal::EntityData lData(internal::EntityData::MODULE, targetNS);
+ theSctx->get_component_uris(modVer.versioned_uri(), lData, compURIs);
}
else
{
@@ -3121,10 +3120,9 @@
try
{
+ internal::EntityData const lData(internal::EntityData::MODULE, targetNS);
lResource =
- theSctx->resolve_uri(compModVer.versioned_uri(),
- internal::EntityData::MODULE,
- lErrorMessage);
+ theSctx->resolve_uri(compModVer.versioned_uri(), lData, lErrorMessage);
lStreamResource =
dynamic_cast<internal::StreamResource*> (lResource.get());
=== 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-15 06:15:07 +0000
@@ -1611,6 +1611,19 @@
void static_context::get_component_uris(
zstring const& aUri,
+ internal::EntityData& aEntityData,
+ std::vector<zstring>& oComponents) const
+{
+ apply_uri_mappers(aUri, &aEntityData,
+ internal::URIMapper::COMPONENT, oComponents);
+ if (oComponents.size() == 0)
+ {
+ oComponents.push_back(aUri);
+ }
+}
+
+void static_context::get_component_uris(
+ zstring const& aUri,
internal::EntityData::Kind aEntityKind,
std::vector<zstring>& oComponents) const
{
@@ -1639,6 +1652,18 @@
}
}
+void static_context::get_candidate_uris(
+ zstring const& aUri,
+ internal::EntityData& aEntityData,
+ std::vector<zstring>& oComponents) const
+{
+ apply_uri_mappers(aUri, &aEntityData,
+ internal::URIMapper::CANDIDATE, oComponents);
+ if (oComponents.size() == 0)
+ {
+ oComponents.push_back(aUri);
+ }
+}
/***************************************************************************//**
=== 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-15 06:15:07 +0000
@@ -785,6 +785,16 @@
std::vector<zstring>& oComponents) const;
/**
+ * Given a URI, populate a vector with a list of component URIs. If
+ * no component URIs are available, the vector will be populated
+ * with (only) the input URI.
+ */
+ void get_component_uris(
+ const zstring& aUri,
+ internal::EntityData& aEntityData,
+ std::vector<zstring>& oComponents) const;
+
+ /**
* Given a URI, populate a vector with a list of candidate URIs. If
* no candidate URIs are available, the vector will be populated
* with (only) the input URI.
@@ -794,6 +804,16 @@
internal::EntityData::Kind aEntityKind,
std::vector<zstring>& oComponents) const;
+ /**
+ * Given a URI, populate a vector with a list of candidate URIs. If
+ * no candidate URIs are available, the vector will be populated
+ * with (only) the input URI.
+ */
+ void get_candidate_uris(
+ const zstring& aUri,
+ internal::EntityData& aEntityData,
+ std::vector<zstring>& oComponents) const;
+
void set_uri_path(const std::vector<zstring>& aURIPath);
void get_uri_path(std::vector<zstring>& oURIPath) const;
=== 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-15 06:15:07 +0000
@@ -110,11 +110,24 @@
{
}
+ EntityData::EntityData(
+ EntityData::Kind aKind,
+ const zstring& aTargetNS)
+ : theKind(aKind),
+ theTargetNamespace(aTargetNS)
+ {
+ }
+
EntityData::Kind EntityData::getKind() const
{
return theKind;
}
+ const zstring& EntityData::getTargetNamespace() const
+ {
+ return theTargetNamespace;
+ }
+
EntityData::~EntityData()
{
}
=== 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-15 06:15:07 +0000
@@ -192,15 +192,20 @@
EntityData(Kind aKind);
+ EntityData(Kind aKind, const zstring& aTargetNS);
+
/**
* @brief Return the Kind of Entity for which this URI is being resolved.
*/
virtual Kind getKind() const;
+ virtual const zstring& getTargetNamespace() const;
+
virtual ~EntityData();
private:
Kind const theKind;
+ zstring const theTargetNamespace;
};
/**
=== 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-15 06:15:07 +0000
@@ -18,6 +18,7 @@
#include <sstream>
#include <vector>
#include <memory>
+#include <cassert>
#include <zorba/zorba.h>
#include <zorba/store_manager.h>
#include <zorba/zorba_exception.h>
@@ -45,6 +46,7 @@
if (aEntityData->getKind() != EntityData::SCHEMA) {
return;
}
+ assert(aUri == aEntityData->getTargetNamespace());
if(aUri == "http://www.zorba-xquery.com/helloworld") {
oUris.push_back("http://www.zorba-xquery.com/tutorials/helloworld.xsd");
}
@@ -66,6 +68,7 @@
if (aEntityData->getKind() != EntityData::MODULE) {
return;
}
+ assert(aUri == aEntityData->getTargetNamespace());
if(aUri == "http://www.zorba-xquery.com/mymodule") {
oUris.push_back("http://www.zorba-xquery.com/mymodule/mod1");
oUris.push_back("http://www.zorba-xquery.com/mymodule/mod2");
Follow ups
-
Re: [Merge] lp:~zorba-coders/zorba/feature-EntityDataNS into lp:zorba
From: William Candillon, 2014-05-11
-
Re: [Merge] lp:~zorba-coders/zorba/feature-EntityDataNS into lp:zorba
From: Chris Hillery, 2013-02-20
-
[Merge] lp:~zorba-coders/zorba/feature-EntityDataNS into lp:zorba
From: Zorba Build Bot, 2013-02-20
-
Re: [Merge] lp:~zorba-coders/zorba/feature-EntityDataNS into lp:zorba
From: Zorba Build Bot, 2013-02-20
-
[Merge] lp:~zorba-coders/zorba/feature-EntityDataNS into lp:zorba
From: Zorba Build Bot, 2013-02-20
-
[Merge] lp:~zorba-coders/zorba/feature-EntityDataNS into lp:zorba
From: Chris Hillery, 2013-02-20
-
[Merge] lp:~zorba-coders/zorba/feature-EntityDataNS into lp:zorba
From: Chris Hillery, 2013-02-20
-
[Merge] lp:~zorba-coders/zorba/feature-EntityDataNS into lp:zorba
From: Chris Hillery, 2013-02-20
-
[Merge] lp:~zorba-coders/zorba/feature-EntityDataNS into lp:zorba
From: Chris Hillery, 2013-02-20
-
[Merge] lp:~zorba-coders/zorba/feature-EntityDataNS into lp:zorba
From: Zorba Build Bot, 2013-02-15
-
Re: [Merge] lp:~zorba-coders/zorba/feature-EntityDataNS into lp:zorba
From: Zorba Build Bot, 2013-02-15
-
[Merge] lp:~zorba-coders/zorba/feature-EntityDataNS into lp:zorba
From: Zorba Build Bot, 2013-02-15
-
[Merge] lp:~zorba-coders/zorba/feature-EntityDataNS into lp:zorba
From: Matthias Brantner, 2013-02-15
-
Re: [Merge] lp:~zorba-coders/zorba/feature-EntityDataNS into lp:zorba
From: Matthias Brantner, 2013-02-15