zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #07655
[Merge] lp:~zorba-coders/zorba/bug-948879 into lp:zorba
Matthias Brantner has proposed merging lp:~zorba-coders/zorba/bug-948879 into lp:zorba.
Requested reviews:
Matthias Brantner (matthias-brantner)
Chris Hillery (ceejatec)
Related bugs:
Bug #948879 in Zorba: "--uri-path doesn't work with fetch:content()"
https://bugs.launchpad.net/zorba/+bug/948879
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-948879/+merge/101874
fix for bug #948879 (--uri-path doesn't work with fetch:content())
Deprecated the C++ API's XmlDataManager::fetch function and replaced it with two StaticContext::fetch functions.
--
https://code.launchpad.net/~zorba-coders/zorba/bug-948879/+merge/101874
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog 2012-04-12 09:32:55 +0000
+++ ChangeLog 2012-04-13 09:13:22 +0000
@@ -11,6 +11,7 @@
* Fixed bug 955170 (Catch clause with URILiteral-based wilcard NameTest)
* Fixed bug 955135 (err:XQDY0044 not caught by try-catch expressions)
* Fixed bug #967864 (var substitution did not update theFreeVars property)
+ * Fixed bug #948879 (--uri-path doesn't work with fetch:content())
* Fixed bug in window iterator (binding the end vars in the output tuple stream)
* Fixed bug #866547 (protect index-join rule from general flwor)
* Fixed bug #967428 (do not hoist index creation outside a try-catch)
=== modified file 'include/zorba/static_context.h'
--- include/zorba/static_context.h 2012-03-28 05:19:57 +0000
+++ include/zorba/static_context.h 2012-04-13 09:13:22 +0000
@@ -685,6 +685,38 @@
*/
virtual void
getFullLibPath(std::vector<String>& aLibPath) const = 0;
+
+ /** \brief Fetches an resource refered to by the given URI.
+ *
+ * Resolution is done using the URI mappers and resolvers registered
+ * in this static context. If no such mappers or resolvers have been
+ * registered, the built-in ones are used.
+ *
+ * The default EntityKind for resources fetched by this function
+ * is "SOME_CONTENT".
+ *
+ * @param aURI the name of the resource to fetch
+ *
+ * @return the fetched resource
+ */
+ virtual Item
+ fetch(const String& aURI) const = 0;
+
+ /** \brief Fetches an resource refered to by the given URI.
+ *
+ * Resolution is done using the URI mappers and resolvers registered
+ * in this static context. If no such mappers or resolvers have been
+ * registered, the built-in ones are used.
+ *
+ * @param aURI the name of the resource to fetch
+ *
+ * @param aEntityKind the kind of the entity to fetch (i.e.
+ * SOME_CONTENT, SCHEMA, MODULE, THESAURUS, or STOP_WORDS)
+ *
+ * @return the fetched resource
+ */
+ virtual Item
+ fetch(const String& aURI, const String& aEntityKind) const = 0;
};
} /* namespace zorba */
=== modified file 'include/zorba/xmldatamanager.h'
--- include/zorba/xmldatamanager.h 2012-03-28 05:19:57 +0000
+++ include/zorba/xmldatamanager.h 2012-04-13 09:13:22 +0000
@@ -187,6 +187,8 @@
ParseOptions& aOptions) const = 0;
/** \brief Fetches an resource refered to by the given URI.
+ *
+ * @deprecated this function has been replaced by StaticContext::fetch.
*/
virtual Item
fetch(const String& aURI) const = 0;
=== modified file 'src/api/staticcontextimpl.cpp'
--- src/api/staticcontextimpl.cpp 2012-03-28 05:19:57 +0000
+++ src/api/staticcontextimpl.cpp 2012-04-13 09:13:22 +0000
@@ -25,6 +25,7 @@
#include <zorba/typeident.h>
#include <zorba/util/path.h>
#include <zorba/empty_sequence.h>
+#include <zorba/singleton_item_sequence.h>
#include "store/api/item_factory.h"
#include "store/api/temp_seq.h"
@@ -1539,5 +1540,50 @@
ZORBA_CATCH
}
+Item
+StaticContextImpl::fetch(const String& aURI) const
+{
+ return fetch(aURI, "SOME_CONTENT");
+}
+
+Item
+StaticContextImpl::fetch(
+ const String& aURI,
+ const String& aEntityKind) const
+{
+ ZORBA_TRY
+ {
+ Zorba* lZorba = Zorba::getInstance(0);
+ ItemFactory* lFactory = lZorba->getItemFactory();
+
+ Item lQName = lFactory->createQName(static_context::ZORBA_FETCH_FN_NS,
+ "content");
+
+ // create a streamable string item
+ std::vector<ItemSequence_t> lArgs;
+ lArgs.push_back(new SingletonItemSequence(lFactory->createString(aURI)));
+ lArgs.push_back(
+ new SingletonItemSequence(lFactory->createString(aEntityKind)));
+
+ StaticContext_t lCtx = createChildContext();
+
+ Zorba_CompilerHints_t lHints;
+ std::ostringstream lProlog;
+ lProlog
+ << "import module namespace d = '" << static_context::ZORBA_FETCH_FN_NS << "';";
+
+ lCtx->loadProlog(lProlog.str(), lHints);
+
+ ItemSequence_t lSeq = lCtx->invoke(lQName, lArgs);
+ Iterator_t lIter = lSeq->getIterator();
+ lIter->open();
+ Item lRes;
+ lIter->next(lRes);
+ return lRes;
+ }
+ ZORBA_CATCH
+ return 0;
+}
+
} /* namespace zorba */
/* vim:set et sw=2 ts=2: */
=== modified file 'src/api/staticcontextimpl.h'
--- src/api/staticcontextimpl.h 2012-03-28 05:19:57 +0000
+++ src/api/staticcontextimpl.h 2012-04-13 09:13:22 +0000
@@ -281,6 +281,12 @@
virtual void
getFullLibPath(std::vector<String>& aLibPath) const;
+ virtual Item
+ fetch(const String& aURI) const;
+
+ virtual Item
+ fetch(const String& aURI, const String& aEntityKind) const;
+
protected:
String
createInvokeQuery(const Function_t&, size_t aArity) const;
=== modified file 'test/unit/static_context.cpp'
--- test/unit/static_context.cpp 2012-01-17 19:07:24 +0000
+++ test/unit/static_context.cpp 2012-04-13 09:13:22 +0000
@@ -60,6 +60,26 @@
return lFooFound && lBindings.size() == 6;
}
+bool
+sctx_test_2(Zorba* const zorba)
+{
+ StaticContext_t lSctx = zorba->createStaticContext();
+
+ Zorba_CompilerHints_t lHints;
+
+ try
+ {
+ Item lFetched = lSctx->fetch("http://www.zorba-xquery.com/modules/fetch", "MODULE");
+
+ return !lFetched.isNull();
+ }
+ catch (ZorbaException& e)
+ {
+ std::cerr << e << std::endl;
+ }
+ return false;
+}
+
int static_context( int argc, char *argv[] ) {
void *const zstore = StoreManager::getStore();
Zorba *const zorba = Zorba::getInstance( zstore );
@@ -67,6 +87,9 @@
if (!sctx_test_1(zorba))
return 1;
+ if (!sctx_test_2(zorba))
+ return 2;
+
zorba->shutdown();
StoreManager::shutdownStore( zstore );
return 0;
Follow ups
-
[Merge] lp:~zorba-coders/zorba/bug-948879 into lp:zorba
From: noreply, 2012-04-13
-
[Merge] lp:~zorba-coders/zorba/bug-948879 into lp:zorba
From: Zorba Build Bot, 2012-04-13
-
[Merge] lp:~zorba-coders/zorba/bug-948879 into lp:zorba
From: Zorba Build Bot, 2012-04-13
-
[Merge] lp:~zorba-coders/zorba/bug-948879 into lp:zorba
From: Chris Hillery, 2012-04-13
-
Re: [Merge] lp:~zorba-coders/zorba/bug-948879 into lp:zorba
From: Chris Hillery, 2012-04-13
-
[Merge] lp:~zorba-coders/zorba/bug-948879 into lp:zorba
From: Zorba Build Bot, 2012-04-13
-
Re: [Merge] lp:~zorba-coders/zorba/bug-948879 into lp:zorba
From: Zorba Build Bot, 2012-04-13
-
[Merge] lp:~zorba-coders/zorba/bug-948879 into lp:zorba
From: Zorba Build Bot, 2012-04-13
-
[Merge] lp:~zorba-coders/zorba/bug-948879 into lp:zorba
From: Zorba Build Bot, 2012-04-13
-
[Merge] lp:~zorba-coders/zorba/bug-948879 into lp:zorba
From: Matthias Brantner, 2012-04-13
-
Re: [Merge] lp:~zorba-coders/zorba/bug-948879 into lp:zorba
From: Matthias Brantner, 2012-04-13
-
[Merge] lp:~zorba-coders/zorba/bug-948879 into lp:zorba
From: Matthias Brantner, 2012-04-13