Merge lp:~ceejatec/zorba/feature-module-installation into lp:zorba
- feature-module-installation
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Matthias Brantner |
Approved revision: | 10527 |
Merged at revision: | 10536 |
Proposed branch: | lp:~ceejatec/zorba/feature-module-installation |
Merge into: | lp:zorba |
Diff against target: |
1712 lines (+730/-284) 32 files modified
CMakeLists.txt (+28/-6) ChangeLog (+2/-0) NOTICE.txt (+1/-1) bin/CMakeLists.txt (+32/-2) bin/path_util.cpp (+60/-45) bin/path_util.h (+9/-24) bin/zorbacmd.cpp (+3/-5) bin/zorbacmdproperties.cpp (+14/-5) bin/zorbacmdproperties.h (+7/-1) bin/zorbacmdproperties.txt (+3/-1) bin/zorbacmdproperties_base.h (+19/-3) cmake_modules/ZorbaModule.cmake (+15/-12) config/CMakeLists.txt (+5/-5) config/ZorbaConfig.cmake.in (+7/-4) doc/zorba/commandline.dox (+7/-1) doc/zorba/external_functions.dox (+2/-2) doc/zorba/modules_authoring.dox (+2/-3) doc/zorba/modules_authoring_2.dox (+4/-3) doc/zorba/modules_building_in.dox (+1/-1) doc/zorba/uriresolvers.dox (+120/-38) include/zorba/config.h.cmake (+4/-1) include/zorba/static_context.h (+81/-0) src/api/staticcontextimpl.cpp (+140/-42) src/api/staticcontextimpl.h (+18/-0) src/context/default_uri_mappers.cpp (+1/-1) src/context/dynamic_loader.cpp (+6/-7) src/context/root_static_context.cpp (+36/-20) src/context/root_static_context.h (+5/-3) src/context/root_static_context_init.cpp.in (+9/-2) src/context/static_context.cpp (+72/-38) src/context/static_context.h (+14/-7) test/rbkt/testdriver_common.cpp (+3/-1) |
To merge this branch: | bzr merge lp:~ceejatec/zorba/feature-module-installation |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Matthias Brantner | Approve | ||
Chris Hillery | Approve | ||
Review via email: mp+80040@code.launchpad.net |
Commit message
Replace ZORBA_MODULES_
Description of the change
Chris Hillery (ceejatec) : | # |
Chris Hillery (ceejatec) wrote : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job feature-
All tests succeeded!
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1. Got: 1 Approve, 1 Pending.
Matthias Brantner (matthias-brantner) wrote : | # |
Looks good in general. Only tried compiling so far but didn't install. I would suggest that at least somebody with Windows also tries it.
Minor comments:
- theURIPath (good name?); theXQPath?
- setLibPath or setLibPaths in the public api?
- should we really remove -module-path from zorbacmd but keep it in the public sctx (backwards incompatible?)
- same for ZORBA_MODULES_
Will you add documentation & change log before merging?
Chris Hillery (ceejatec) wrote : | # |
>Looks good in general. Only tried compiling so far but didn't install. I would suggest that at
> least somebody with Windows also tries it.
I built and tested (and even debugged) it on Windows, and at least my own test cases worked fine.
> Minor comments:
> - theURIPath (good name?); theXQPath?
It's used for all URIs, not just .xq files, so I think --uri-path / theURIPath is more accurate.
> - setLibPath or setLibPaths in the public api?
IMHO, a "path" is "a list of directories." See $PATH in shell, $CLASSPATH in Java, etc. So I consistently used "path" for the URI path and Library path. I couldn't change setModulePaths(), but actually that's kind of accurate because what that function now does is set both the URI and Library paths simultaneously.
I spelled out that "path" == "list of directories" in comments and the --help output, so hopefully it's not confusing.
> - should we really remove -module-path from zorbacmd but keep it in the public sctx (backwards
> incompatible?)
I don't think so. I left --module-path there because I assumed people were using it. It is sometimes convenient as well. I originally considered marking it as "deprecated" and I'm still not sure that it shouldn't be...
> - same for ZORBA_MODULES_
Hm. The variable is only for CMake. I didn't think that "backwards compatibility" extended all the way to build configuration variables. I don't think it's possible to maintain that variable even as a "convenience wrapper", because it would break the core/non-core split.
> Will you add documentation & change log before merging?
That is now done.
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job feature-
All tests succeeded!
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1. Got: 1 Approve, 1 Needs Information.
Matthias Brantner (matthias-brantner) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job feature-
All tests succeeded!
Preview Diff
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2011-10-09 13:56:39 +0000 |
3 | +++ CMakeLists.txt 2011-11-04 11:47:43 +0000 |
4 | @@ -417,13 +417,35 @@ |
5 | |
6 | # zorba versioning |
7 | SET(ZORBA_MAJOR_NUMBER "2") |
8 | -SET(ZORBA_MINOR_NUMBER "0") |
9 | -SET(ZORBA_PATCH_NUMBER "1") |
10 | +SET(ZORBA_MINOR_NUMBER "1") |
11 | +SET(ZORBA_PATCH_NUMBER "0") |
12 | SET(ZORBA_VERSION ${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER}) |
13 | MESSAGE(STATUS "Zorba version number: ${ZORBA_VERSION}") |
14 | -SET(ZORBA_MODULES_INSTALL_DIR "share/zorba-${ZORBA_VERSION}/modules" |
15 | - CACHE STRING "Path (relative to installdir) to modules" FORCE) |
16 | -MARK_AS_ADVANCED(ZORBA_MODULES_INSTALL_DIR) |
17 | + |
18 | +SET(ZORBA_LIB_DIRNAME "lib" CACHE STRING |
19 | + "directory name for libs (may want to set to 'lib64' on 64-bit Linux platforms)") |
20 | + |
21 | +# Directories for modules and schemas. "Core" are those which are |
22 | +# shipped with Zorba and must be present for correct Zorba |
23 | +# functionality. "Non-core" are developed independently of Zorba and |
24 | +# have different version lifecycles. |
25 | +# |
26 | +# URI dir is for things resolved by URI - specifically modules (.xq |
27 | +# files) and schemas (.xsd files) - which are platform- |
28 | +# independent. Lib dir is for platform-specific files, specifically |
29 | +# shared libraries for module external functions. |
30 | +SET(ZORBA_NONCORE_URI_DIR "share/zorba/uris" |
31 | + CACHE STRING "Path (relative to installdir) to non-core modules/schemas") |
32 | +MARK_AS_ADVANCED(ZORBA_NONCORE_URI_DIR) |
33 | +SET(ZORBA_CORE_URI_DIR "${ZORBA_NONCORE_URI_DIR}/core/${ZORBA_VERSION}" |
34 | + CACHE STRING "Path (relative to installdir) to core modules/schemas") |
35 | +MARK_AS_ADVANCED(ZORBA_CORE_URI_DIR) |
36 | +SET(ZORBA_NONCORE_LIB_DIR "${ZORBA_LIB_DIRNAME}/zorba" |
37 | + CACHE STRING "Path (relative to installdir) to non-core libraries") |
38 | +MARK_AS_ADVANCED(ZORBA_NONCORE_LIB_DIR) |
39 | +SET(ZORBA_CORE_LIB_DIR "${ZORBA_NONCORE_LIB_DIR}/core/${ZORBA_VERSION}" |
40 | + CACHE STRING "Path (relative to installdir) to core libraries") |
41 | +MARK_AS_ADVANCED(ZORBA_CORE_LIB_DIR) |
42 | |
43 | # add compiler variables |
44 | ADD_DEFINITIONS(${DEFINITIONS}) |
45 | @@ -460,7 +482,7 @@ |
46 | SET(ZORBA_CMAKE_DIR "cmake" CACHE STRING |
47 | "Relative path to CMake files in Zorba installation") |
48 | ELSE (WIN32) |
49 | - SET(ZORBA_CMAKE_DIR "share/zorba-${ZORBA_VERSION}/cmake" CACHE STRING |
50 | + SET(ZORBA_CMAKE_DIR "share/cmake/zorba-${ZORBA_VERSION}" CACHE STRING |
51 | "Relative path to CMake files in Zorba installation") |
52 | ENDIF (WIN32) |
53 | |
54 | |
55 | === modified file 'ChangeLog' |
56 | --- ChangeLog 2011-11-02 17:19:09 +0000 |
57 | +++ ChangeLog 2011-11-04 11:47:43 +0000 |
58 | @@ -57,6 +57,8 @@ |
59 | * Fixed bug #872796 (validate-in-place can interfere with other update primitives) |
60 | * Fixed bug #872799 (validate-in-place can set incorrect types) |
61 | * Fixed bug #855715 (Invalid escaped characters in regex not caught) |
62 | + * Fixed bug #862089 (Split binary/xq install directories for modules) by |
63 | + splitting "module path" into separate URI and Library paths |
64 | * New node-position module. This module allows to obtain a representation of a node position, which |
65 | can be used to assess structural relationships with other nodes. |
66 | * Fixed bug #872502 (validation of the JSON module xqdoc fails) |
67 | |
68 | === modified file 'NOTICE.txt' |
69 | --- NOTICE.txt 2011-10-19 15:28:51 +0000 |
70 | +++ NOTICE.txt 2011-11-04 11:47:43 +0000 |
71 | @@ -1,5 +1,5 @@ |
72 | ----------- |
73 | -Zorba 2.0.1 |
74 | +Zorba 2.1.0 |
75 | ----------- |
76 | |
77 | (Note: This file is generated automatically from NOTICE.xml. |
78 | |
79 | === modified file 'bin/CMakeLists.txt' |
80 | --- bin/CMakeLists.txt 2011-10-14 16:37:29 +0000 |
81 | +++ bin/CMakeLists.txt 2011-11-04 11:47:43 +0000 |
82 | @@ -41,7 +41,7 @@ |
83 | zorbacmdproperties.cpp |
84 | error_printer.cpp |
85 | util.cpp |
86 | - module_path.cpp |
87 | + path_util.cpp |
88 | ) |
89 | |
90 | INCLUDE("${CMAKE_SOURCE_DIR}/cmake_modules/ZorbaGenerateExe.cmake") |
91 | @@ -85,6 +85,36 @@ |
92 | ZORBA_ADD_TEST(bin/zorba_option zorbacmd -q "${CMAKE_CURRENT_SOURCE_DIR}/test/option.xq" -f --option "{http://www.zorba-xquery.com}option=value") |
93 | ZORBA_SET_TEST_PROPERTY(bin/zorba_option PASS_REGULAR_EXPRESSION "value") |
94 | |
95 | +# test the --uri-path, --lib-path, and --module-path args. |
96 | +# Use the versioning tests as they utilize test modules already. |
97 | +SET (_testdir |
98 | + "${CMAKE_CURRENT_SOURCE_DIR}/../test/rbkt/Queries/zorba/versioning") |
99 | +SET (_uridir "${CMAKE_BINARY_DIR}/TEST_URI_PATH") |
100 | +SET (_libdir "${CMAKE_BINARY_DIR}/TEST_LIB_PATH") |
101 | +ZORBA_ADD_TEST(bin/zorba_uri_path_1 zorbacmd -f -q "${_testdir}/import1.xq" |
102 | + --uri-path "${_uridir}") |
103 | +ZORBA_SET_TEST_PROPERTY(bin/zorba_uri_path_1 |
104 | + PASS_REGULAR_EXPRESSION "hello, v2") |
105 | + |
106 | +ZORBA_ADD_TEST(bin/zorba_uri_path_2 zorbacmd -f -q "${_testdir}/external1.xq" |
107 | + --uri-path "${_uridir}") |
108 | +ZORBA_SET_TEST_PROPERTY(bin/zorba_uri_path_2 |
109 | + PASS_REGULAR_EXPRESSION "ZXQP0008") |
110 | + |
111 | +ZORBA_ADD_TEST(bin/zorba_uri_path_3 zorbacmd -f -q "${_testdir}/external1.xq" |
112 | + --uri-path "${_uridir}" --lib-path "${_libdir}") |
113 | +ZORBA_SET_TEST_PROPERTY(bin/zorba_uri_path_3 |
114 | + PASS_REGULAR_EXPRESSION "hello, v2") |
115 | + |
116 | +IF(WIN32) |
117 | + SET(PATH_SEP ";") |
118 | +ELSE(WIN32) |
119 | + SET(PATH_SEP ":") |
120 | +ENDIF(WIN32) |
121 | +ZORBA_ADD_TEST(bin/zorba_module_path_1 zorbacmd -f -q "${_testdir}/external1.xq" |
122 | + --module-path "${_libdir}${PATH_SEP}${_uridir}") |
123 | +ZORBA_SET_TEST_PROPERTY(bin/zorba_module_path_1 |
124 | + PASS_REGULAR_EXPRESSION "hello, v2") |
125 | + |
126 | # test compilation of the perf script |
127 | ZORBA_ADD_TEST(bin/zorba_compilechk4 zorbacmd -q "${CMAKE_CURRENT_SOURCE_DIR}/../test/zperf/src/start.xq" -f --compile-only) |
128 | - |
129 | |
130 | === renamed file 'bin/module_path.cpp' => 'bin/path_util.cpp' |
131 | --- bin/module_path.cpp 2011-05-25 16:40:26 +0000 |
132 | +++ bin/path_util.cpp 2011-11-04 11:47:43 +0000 |
133 | @@ -14,85 +14,100 @@ |
134 | * limitations under the License. |
135 | */ |
136 | |
137 | -#include "module_path.h" |
138 | +#include "path_util.h" |
139 | |
140 | #include <stdlib.h> |
141 | -#include "zorba/zorba_string.h" |
142 | +//#include "zorba/zorba_string.h" |
143 | #include "zorba/util/path.h" |
144 | |
145 | #include "util.h" |
146 | #include "zorbacmdproperties.h" |
147 | +#include <zorba/static_context.h> |
148 | |
149 | namespace zorba { |
150 | |
151 | -std::string |
152 | -ModulePath::getEnvironmentModulePath() |
153 | +namespace PathUtil { |
154 | + |
155 | +static std::string |
156 | +getPathFromEnvironment(std::string const& aEnvVar) |
157 | { |
158 | - std::string lEnvName("ZORBA_MODULE_PATH"); |
159 | #ifdef WIN32 |
160 | char* lBuffer; |
161 | size_t lLen=0; |
162 | - errno_t lErr = getenv_s(&lLen, NULL, 0, lEnvName.c_str()); |
163 | + errno_t lErr = getenv_s(&lLen, NULL, 0, aEnvVar.c_str()); |
164 | if (lErr || !lLen) return ""; |
165 | lBuffer = (char*)malloc(lLen * sizeof(char)); |
166 | if (!lBuffer) return ""; |
167 | - getenv_s(&lLen, lBuffer, lLen, lEnvName.c_str()); |
168 | + getenv_s(&lLen, lBuffer, lLen, aEnvVar.c_str()); |
169 | std::string lRes(lBuffer); |
170 | free(lBuffer); |
171 | return lRes; |
172 | #else |
173 | - const char* lEnvValue = getenv(lEnvName.c_str()); |
174 | - return lEnvValue!=0?lEnvValue:""; |
175 | + const char* lEnvValue = getenv(aEnvVar.c_str()); |
176 | + return lEnvValue != 0 ? lEnvValue : ""; |
177 | #endif |
178 | } |
179 | |
180 | -void |
181 | -ModulePath::convertVector( |
182 | - const std::vector<std::string>& aSource, |
183 | - std::vector<String>& aDest) |
184 | -{ |
185 | - for (std::vector<std::string>::const_iterator lIter = aSource.begin(); |
186 | - lIter != aSource.end(); ++lIter) { |
187 | - aDest.push_back(*lIter); |
188 | - } |
189 | -} |
190 | |
191 | -void |
192 | -ModulePath::tokenizeModulePath( |
193 | - const std::string& aModulePath, |
194 | - std::vector<std::string>& aResult) |
195 | +static void |
196 | +tokenizePath( |
197 | + const std::string& aPathStr, |
198 | + std::vector<String>& aResult) |
199 | { |
200 | + std::vector<std::string> lPath; |
201 | #ifdef WIN32 |
202 | - Util::tokenize(aModulePath, ";", aResult); |
203 | + Util::tokenize(aPathStr, ";", lPath); |
204 | #else |
205 | - Util::tokenize(aModulePath, ":", aResult); |
206 | + Util::tokenize(aPathStr, ":", lPath); |
207 | #endif |
208 | + for (std::vector<std::string>::iterator lIter = lPath.begin(); |
209 | + lIter != lPath.end(); ++lIter) { |
210 | + aResult.push_back(*lIter); |
211 | + } |
212 | } |
213 | |
214 | void |
215 | -ModulePath::getModulePaths( |
216 | +setPathsOnContext( |
217 | const ZorbaCMDProperties& aProperties, |
218 | - std::vector<String>& aModulePaths) |
219 | + StaticContext_t& aStaticCtx) |
220 | { |
221 | - std::vector<std::string> lModulePaths; // result vector |
222 | - std::string lModulePath; // temporary variable for collections paths |
223 | - |
224 | - // 1. add the module paths from the command line properties |
225 | - aProperties.getModulePaths(lModulePath); |
226 | - |
227 | - tokenizeModulePath(lModulePath, lModulePaths); |
228 | - |
229 | - // 2. add the module paths from the environment |
230 | - lModulePath = ModulePath::getEnvironmentModulePath(); |
231 | - |
232 | - tokenizeModulePath(lModulePath, lModulePaths); |
233 | - |
234 | - // 3. add the current working directory as module path |
235 | + std::vector<String> lPath; |
236 | + std::string lPathStr, lEnvStr; |
237 | + |
238 | + // Compute the current working directory to append to all paths. |
239 | filesystem_path lCWD; |
240 | - lModulePaths.push_back(lCWD.get_path()); |
241 | - |
242 | - // convert std::string to zorba::String |
243 | - convertVector(lModulePaths, aModulePaths); |
244 | + |
245 | + // setModulePaths() *overwrites* the URI path and lib path, so there's no |
246 | + // sense in calling both. So if either --module-path or ZORBA_MODULE_PATH |
247 | + // exists, just use those. |
248 | + aProperties.getModulePath(lPathStr); |
249 | + lEnvStr = getPathFromEnvironment("ZORBA_MODULE_PATH"); |
250 | + if (lPathStr.length() > 0 || lEnvStr.length() > 0) { |
251 | + tokenizePath(lPathStr, lPath); |
252 | + tokenizePath(lEnvStr, lPath); |
253 | + lPath.push_back(lCWD.get_path()); |
254 | + aStaticCtx->setModulePaths(lPath); |
255 | + } |
256 | + else { |
257 | + // Compute and set URI path |
258 | + aProperties.getURIPath(lPathStr); |
259 | + tokenizePath(lPathStr, lPath); |
260 | + lEnvStr = getPathFromEnvironment("ZORBA_URI_PATH"); |
261 | + tokenizePath(lEnvStr, lPath); |
262 | + lPath.push_back(lCWD.get_path()); |
263 | + aStaticCtx->setURIPath(lPath); |
264 | + lPath.clear(); |
265 | + |
266 | + // Compute and set lib path |
267 | + aProperties.getLibPath(lPathStr); |
268 | + tokenizePath(lPathStr, lPath); |
269 | + lEnvStr = getPathFromEnvironment("ZORBA_LIB_PATH"); |
270 | + lPath.push_back(lCWD.get_path()); |
271 | + tokenizePath(lEnvStr, lPath); |
272 | + aStaticCtx->setLibPath(lPath); |
273 | + } |
274 | } |
275 | |
276 | +} /* namespace ModulePath */ |
277 | + |
278 | } /* namespace zorba */ |
279 | |
280 | === renamed file 'bin/module_path.h' => 'bin/path_util.h' |
281 | --- bin/module_path.h 2010-02-12 08:57:04 +0000 |
282 | +++ bin/path_util.h 2011-11-04 11:47:43 +0000 |
283 | @@ -18,6 +18,7 @@ |
284 | |
285 | #include <vector> |
286 | #include <string> |
287 | +#include <zorba/api_shared_types.h> |
288 | |
289 | class ZorbaCMDProperties; |
290 | |
291 | @@ -25,30 +26,14 @@ |
292 | |
293 | class String; |
294 | |
295 | - class ModulePath { |
296 | - protected: |
297 | - static std::string |
298 | - getEnvironmentModulePath(); |
299 | - |
300 | - static void |
301 | - convertVector(const std::vector<std::string>& aSource, |
302 | - std::vector<String>& aDest); |
303 | - |
304 | - static void |
305 | - tokenizeModulePath(const std::string& aModulePath, |
306 | - std::vector<std::string>& aResult); |
307 | - |
308 | - static void |
309 | - getInstalledModulePath(const std::string& aModulePath, |
310 | - std::vector<std::string>& aResult); |
311 | - |
312 | - public: |
313 | - static void |
314 | - getModulePaths(const ZorbaCMDProperties& aProperties, |
315 | - std::vector<String>& aModulePaths); |
316 | - |
317 | - |
318 | - }; |
319 | + namespace PathUtil { |
320 | + |
321 | + void |
322 | + setPathsOnContext(const ZorbaCMDProperties& aProperties, |
323 | + zorba::StaticContext_t& aStaticCtx); |
324 | + |
325 | + |
326 | + } |
327 | } /* namespace zorba */ |
328 | |
329 | #endif |
330 | |
331 | === modified file 'bin/zorbacmd.cpp' |
332 | --- bin/zorbacmd.cpp 2011-07-11 11:12:23 +0000 |
333 | +++ bin/zorbacmd.cpp 2011-11-04 11:47:43 +0000 |
334 | @@ -43,7 +43,7 @@ |
335 | |
336 | #include "error_printer.h" |
337 | #include "util.h" |
338 | -#include "module_path.h" |
339 | +#include "path_util.h" |
340 | |
341 | // For setting the base URI from the current directory |
342 | #include <zorba/util/path.h> |
343 | @@ -85,10 +85,8 @@ |
344 | // 2. environment ZORBA_MODULE_PATH |
345 | // 3. current working directory |
346 | { |
347 | - std::vector<String> lModulePaths; |
348 | - ModulePath::getModulePaths(aProperties, lModulePaths); |
349 | - |
350 | - aStaticContext->setModulePaths(lModulePaths); |
351 | + std::vector<String> lModulePath; |
352 | + PathUtil::setPathsOnContext(aProperties, aStaticContext); |
353 | } |
354 | |
355 | if (aProperties.boundarySpace().size() != 0 ) |
356 | |
357 | === modified file 'bin/zorbacmdproperties.cpp' |
358 | --- bin/zorbacmdproperties.cpp 2011-07-21 19:21:25 +0000 |
359 | +++ bin/zorbacmdproperties.cpp 2011-11-04 11:47:43 +0000 |
360 | @@ -166,11 +166,20 @@ |
361 | } |
362 | |
363 | |
364 | -void ZorbaCMDProperties::getModulePaths(std::string& aPaths) const |
365 | -{ |
366 | - aPaths = theModulePath; |
367 | -} |
368 | - |
369 | +void ZorbaCMDProperties::getModulePath(std::string& aPath) const |
370 | +{ |
371 | + aPath = theModulePath; |
372 | +} |
373 | + |
374 | +void ZorbaCMDProperties::getURIPath(std::string& aPath) const |
375 | +{ |
376 | + aPath = theUriPath; |
377 | +} |
378 | + |
379 | +void ZorbaCMDProperties::getLibPath(std::string& aPath) const |
380 | +{ |
381 | + aPath = theLibPath; |
382 | +} |
383 | |
384 | std::vector<std::pair<std::string,std::string> > ZorbaCMDProperties::getSerializerParameters() const |
385 | { |
386 | |
387 | === modified file 'bin/zorbacmdproperties.h' |
388 | --- bin/zorbacmdproperties.h 2011-06-29 17:25:50 +0000 |
389 | +++ bin/zorbacmdproperties.h 2011-11-04 11:47:43 +0000 |
390 | @@ -84,8 +84,14 @@ |
391 | getSerializerParameters() const; |
392 | |
393 | void |
394 | - getModulePaths(std::string&) const; |
395 | + getModulePath(std::string&) const; |
396 | |
397 | + void |
398 | + getURIPath(std::string&) const; |
399 | + |
400 | + void |
401 | + getLibPath(std::string&) const; |
402 | + |
403 | bool isDebug(){ return theDebug; } |
404 | |
405 | bool hasNoLogo(){ return theNoLogo; } |
406 | |
407 | === modified file 'bin/zorbacmdproperties.txt' |
408 | --- bin/zorbacmdproperties.txt 2011-07-04 08:31:01 +0000 |
409 | +++ bin/zorbacmdproperties.txt 2011-11-04 11:47:43 +0000 |
410 | @@ -28,7 +28,9 @@ |
411 | ("debug-port,p", po::value<unsigned int>()->default_value (28028), "The port on which the DBGP-enabled debugger client listens for connections. Defaults to: 28028") |
412 | ("no-logo", "Print no logo when starting.") |
413 | ("timeout", po::value<long>()->default_value(-1), "Specify a timeout in seconds. After the specified time, the execution of the query will be aborted.") |
414 | -("module-path", po::value<std::string>(), "Module paths added to the built-in resolver, i.e. where module imports are looking for modules.") |
415 | +("uri-path", po::value<std::string>(), "URI path (list of directories) added to the built-in URI resolver, i.e. where to find modules/schemas to import.") |
416 | +("lib-path", po::value<std::string>(), "Library path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.") |
417 | +("module-path", po::value<std::string>(), "Path (list of directories) to add to both the URI and Library paths.") |
418 | ("option", po::value<std::vector<std::string> >(), "Set an XQuery option in the static context. The QName of the option is passed as a string in the notation by James Clark (i.e. {namespace}localname). For example, --option {http://www.zorba-xquery.com}option=value"). |
419 | ("trailing-nl", "Output a trailing newline after the result of the query.") |
420 | ("stop-words", po::value<std::vector<std::string> >(), "Mapping specifying a stop-words URI to another.") |
421 | |
422 | === modified file 'bin/zorbacmdproperties_base.h' |
423 | --- bin/zorbacmdproperties_base.h 2011-07-04 08:31:01 +0000 |
424 | +++ bin/zorbacmdproperties_base.h 2011-11-04 11:47:43 +0000 |
425 | @@ -34,7 +34,7 @@ |
426 | class ZorbaCMDPropertiesBase : public ::zorba::PropertiesBase { |
427 | protected: |
428 | const char **get_all_options () const { |
429 | - static const char *result [] = { "--timing", "--output-file", "--serialization-parameter", "--serialize-html", "--serialize-text", "--indent", "--print-query", "--print-errors-as-xml", "--byte-order-mark", "--omit-xml-declaration", "--base-uri", "--boundary-space", "--default-collation", "--construction-mode", "--ordering-mode", "--multiple", "--query", "--as-files", "--external-variable", "--context-item", "--optimization-level", "--lib-module", "--parse-only", "--compile-only", "--no-serializer", "--debug", "--debug-host", "--debug-port", "--no-logo", "--timeout", "--module-path", "--option", "--trailing-nl", "--stop-words", "--thesaurus", NULL }; |
430 | + static const char *result [] = { "--timing", "--output-file", "--serialization-parameter", "--serialize-html", "--serialize-text", "--indent", "--print-query", "--print-errors-as-xml", "--byte-order-mark", "--omit-xml-declaration", "--base-uri", "--boundary-space", "--default-collation", "--construction-mode", "--ordering-mode", "--multiple", "--query", "--as-files", "--external-variable", "--context-item", "--optimization-level", "--lib-module", "--parse-only", "--compile-only", "--no-serializer", "--debug", "--debug-host", "--debug-port", "--no-logo", "--timeout", "--uri-path", "--lib-path", "--module-path", "--option", "--trailing-nl", "--stop-words", "--thesaurus", NULL }; |
431 | return result; |
432 | } |
433 | bool theTiming; |
434 | @@ -67,6 +67,8 @@ |
435 | unsigned int theDebugPort; |
436 | bool theNoLogo; |
437 | long theTimeout; |
438 | + std::string theUriPath; |
439 | + std::string theLibPath; |
440 | std::string theModulePath; |
441 | std::vector<std::string> theOption; |
442 | bool theTrailingNl; |
443 | @@ -127,6 +129,8 @@ |
444 | const unsigned int &debugPort () const { return theDebugPort; } |
445 | const bool &noLogo () const { return theNoLogo; } |
446 | const long &timeout () const { return theTimeout; } |
447 | + const std::string &uriPath () const { return theUriPath; } |
448 | + const std::string &libPath () const { return theLibPath; } |
449 | const std::string &modulePath () const { return theModulePath; } |
450 | const std::vector<std::string> &option () const { return theOption; } |
451 | const bool &trailingNl () const { return theTrailingNl; } |
452 | @@ -262,6 +266,16 @@ |
453 | if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; } |
454 | if (*argv == NULL) { result = "No value given for --timeout option"; break; } init_val (*argv, theTimeout, d); |
455 | } |
456 | + else if (strcmp (*argv, "--uri-path") == 0) { |
457 | + int d = 2; |
458 | + if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; } |
459 | + if (*argv == NULL) { result = "No value given for --uri-path option"; break; } init_val (*argv, theUriPath, d); |
460 | + } |
461 | + else if (strcmp (*argv, "--lib-path") == 0) { |
462 | + int d = 2; |
463 | + if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; } |
464 | + if (*argv == NULL) { result = "No value given for --lib-path option"; break; } init_val (*argv, theLibPath, d); |
465 | + } |
466 | else if (strcmp (*argv, "--module-path") == 0) { |
467 | int d = 2; |
468 | if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; } |
469 | @@ -327,11 +341,13 @@ |
470 | "--compile-only\nOnly compile (don't execute)\n\n" |
471 | "--no-serializer\nDo not serialize (discard) result.\n\n" |
472 | "--debug, -d\nLaunch the Zorba debugger server and connect to a DBGP-enabled debugger client.\n\n" |
473 | -"--debug-host, -p\nThe host where the DBGP-enabled debugger client listens for connections. Defaults to: 127.0.0.1\n\n" |
474 | +"--debug-host, -h\nThe host where the DBGP-enabled debugger client listens for connections. Defaults to: 127.0.0.1\n\n" |
475 | "--debug-port, -p\nThe port on which the DBGP-enabled debugger client listens for connections. Defaults to: 28028\n\n" |
476 | "--no-logo\nPrint no logo when starting.\n\n" |
477 | "--timeout\nSpecify a timeout in seconds. After the specified time, the execution of the query will be aborted.\n\n" |
478 | -"--module-path\nModule paths added to the built-in resolver, i.e. where module imports are looking for modules.\n\n" |
479 | +"--uri-path\nURI path (list of directories) added to the built-in URI resolver, i.e. where to find modules/schemas to import.\n\n" |
480 | +"--lib-path\nLibrary path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.\n\n" |
481 | +"--module-path\nPath (list of directories) to add to both the URI and Library paths.\n\n" |
482 | "--option\nSet an XQuery option in the static context. The QName of the option is passed as a string in the notation by James Clark (i.e. {namespace}localname). For example, --option {http://www.zorba-xquery.com}option=value\n\n" |
483 | "--trailing-nl\nOutput a trailing newline after the result of the query.\n\n" |
484 | "--stop-words\nMapping specifying a stop-words URI to another.\n\n" |
485 | |
486 | === modified file 'cmake_modules/ZorbaModule.cmake' |
487 | --- cmake_modules/ZorbaModule.cmake 2011-10-10 10:31:20 +0000 |
488 | +++ cmake_modules/ZorbaModule.cmake 2011-11-04 11:47:43 +0000 |
489 | @@ -272,12 +272,12 @@ |
490 | IF(NOT ${PROJECT_NAME} STREQUAL "zorba") |
491 | STRING(REPLACE "-" "_" component_name ${PROJECT_NAME}) |
492 | INSTALL(TARGETS ${module_lib_target} |
493 | - ${target_type} DESTINATION ${ZORBA_MODULES_INSTALL_DIR}/${module_path} |
494 | + ${target_type} DESTINATION ${ZORBA_CORE_LIB_DIR}/${module_path} |
495 | COMPONENT ${component_name}) |
496 | |
497 | ELSE(NOT ${PROJECT_NAME} STREQUAL "zorba") |
498 | INSTALL(TARGETS ${module_lib_target} |
499 | - ${target_type} DESTINATION ${ZORBA_MODULES_INSTALL_DIR}/${module_path}) |
500 | + ${target_type} DESTINATION ${ZORBA_NONCORE_LIB_DIR}/${module_path}) |
501 | ENDIF(NOT ${PROJECT_NAME} STREQUAL "zorba") |
502 | ENDIF (NOT MODULE_TEST_ONLY) |
503 | |
504 | @@ -296,7 +296,7 @@ |
505 | ENDIF (patch_ver) |
506 | ENDIF (MODULE_VERSION) |
507 | FOREACH (version_infix "" ${version_infixes}) |
508 | - ADD_COPY_RULE ("${SOURCE_FILE}" "${module_path}/${module_filename}" |
509 | + ADD_COPY_RULE ("URI" "${SOURCE_FILE}" "${module_path}/${module_filename}" |
510 | "${version_infix}" "" "${MODULE_TEST_ONLY}") |
511 | ENDFOREACH (version_infix) |
512 | |
513 | @@ -304,7 +304,7 @@ |
514 | IF (module_lib_target) |
515 | GET_TARGET_PROPERTY (lib_location "${module_lib_target}" LOCATION) |
516 | GET_FILENAME_COMPONENT (lib_filename "${lib_location}" NAME) |
517 | - ADD_COPY_RULE ("${lib_location}" "${module_path}/${lib_filename}" |
518 | + ADD_COPY_RULE ("LIB" "${lib_location}" "${module_path}/${lib_filename}" |
519 | "" "${module_lib_target}" "${MODULE_TEST_ONLY}") |
520 | ENDIF (module_lib_target) |
521 | |
522 | @@ -357,27 +357,30 @@ |
523 | ADD_ZORBA_MANIFEST_ENTRY("schema" ${SCHEMA_URI} "") |
524 | ENDIF (NOT SCHEMA_TEST_ONLY) |
525 | |
526 | - ADD_COPY_RULE ("${SOURCE_FILE}" "${schema_path}/${schema_filename}" |
527 | + ADD_COPY_RULE ("URI" "${SOURCE_FILE}" "${schema_path}/${schema_filename}" |
528 | "" "" "${SCHEMA_TEST_ONLY}") |
529 | |
530 | ENDMACRO (DECLARE_ZORBA_SCHEMA) |
531 | |
532 | # Utility macro for setting up a build rule to copy a file to a |
533 | -# particular (possible versioned) file in URI_PATH if such a file has |
534 | +# particular (possibly versioned) file in a shared directory if such a file has |
535 | # not already been output. |
536 | +# FILE_TYPE: Either "URI" or "LIB"; will be used to determine which shared |
537 | +# directory to place output in (URI_PATH or LIB_PATH). |
538 | # INPUT_FILE: Absolute path to file to copy. |
539 | # OUTPUT_FILE: Relative path to output file (relative to URI_PATH). |
540 | # VERSION_ARG: Version; may be "" for non-versioned files. |
541 | # DEPEND_TARGET: A CMake target name upon which the copy rule should depend; |
542 | # may be "". |
543 | # TEST_ONLY: If 1, file is for testcases only; will be copied into |
544 | -# TEST_URI_PATH and will not be installed |
545 | -MACRO (ADD_COPY_RULE INPUT_FILE OUTPUT_FILE VERSION_ARG DEPEND_TARGET TEST_ONLY) |
546 | +# TEST_URI_PATH/TEST_LIB_PATH and will not be installed |
547 | +MACRO (ADD_COPY_RULE FILE_TYPE INPUT_FILE OUTPUT_FILE VERSION_ARG |
548 | + DEPEND_TARGET TEST_ONLY) |
549 | # Choose output base directory |
550 | IF (${TEST_ONLY} EQUAL 1) |
551 | - SET (_output_basedir "${CMAKE_BINARY_DIR}/TEST_URI_PATH") |
552 | + SET (_output_basedir "${CMAKE_BINARY_DIR}/TEST_${FILE_TYPE}_PATH") |
553 | ELSE (${TEST_ONLY} EQUAL 1) |
554 | - SET (_output_basedir "${CMAKE_BINARY_DIR}/URI_PATH") |
555 | + SET (_output_basedir "${CMAKE_BINARY_DIR}/${FILE_TYPE}_PATH") |
556 | ENDIF (${TEST_ONLY} EQUAL 1) |
557 | |
558 | # Compute the modified output filename by inserting VERSION_ARG (if |
559 | @@ -416,7 +419,7 @@ |
560 | IF(NOT PROJECT_NAME STREQUAL "zorba") |
561 | STRING(REPLACE "-" "_" component_name ${PROJECT_NAME}) |
562 | INSTALL (FILES "${INPUT_FILE}" |
563 | - DESTINATION "${ZORBA_MODULES_INSTALL_DIR}/${_output_path}" |
564 | + DESTINATION "${ZORBA_CORE_URI_DIR}/${_output_path}" |
565 | RENAME "${_output_filename}" |
566 | COMPONENT "${component_name}") |
567 | |
568 | @@ -436,7 +439,7 @@ |
569 | |
570 | ELSE(NOT PROJECT_NAME STREQUAL "zorba") |
571 | INSTALL (FILES "${INPUT_FILE}" |
572 | - DESTINATION "${ZORBA_MODULES_INSTALL_DIR}/${_output_path}" |
573 | + DESTINATION "${ZORBA_NONCORE_URI_DIR}/${_output_path}" |
574 | RENAME "${_output_filename}") |
575 | ENDIF(NOT PROJECT_NAME STREQUAL "zorba") |
576 | |
577 | |
578 | === modified file 'config/CMakeLists.txt' |
579 | --- config/CMakeLists.txt 2011-09-08 19:19:54 +0000 |
580 | +++ config/CMakeLists.txt 2011-11-04 11:47:43 +0000 |
581 | @@ -34,7 +34,8 @@ |
582 | SET(Zorba_EXE_PATH "${ZORBA_ROOT}/bin/zorba") |
583 | SET(Zorba_EXTERNALMODULECONFIG_FILE |
584 | "${ZORBA_ROOT}/${ZORBA_CMAKE_DIR}/ExternalModuleConfig.cmake.in") |
585 | -SET(Zorba_MODULES_INSTALL_DIR "${ZORBA_ROOT}/${ZORBA_MODULES_INSTALL_DIR}") |
586 | +SET(Zorba_NONCORE_URI_DIR "${ZORBA_ROOT}/${ZORBA_NONCORE_URI_DIR}") |
587 | +SET(Zorba_NONCORE_LIB_DIR "${ZORBA_ROOT}/${ZORBA_NONCORE_LIB_DIR}") |
588 | |
589 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ZorbaConfig.cmake.in" |
590 | "${CMAKE_CURRENT_BINARY_DIR}/ZorbaConfig.cmake" @ONLY) |
591 | @@ -58,7 +59,7 @@ |
592 | STRING (REPLACE ".exe" ".bat" Zorba_TESTDRIVER ${Zorba_TESTDRIVER}) |
593 | ENDIF (WIN32) |
594 | |
595 | -SET(Zorba_EXE_PATH "${ZORBA_EXE}") |
596 | +SET(Zorba_EXE_PATH "${ZORBA_EXE}") |
597 | SET(Zorba_EXTERNALMODULECONFIG_FILE |
598 | "${CMAKE_CURRENT_SOURCE_DIR}/ExternalModuleConfig.cmake.in") |
599 | # Note: We also set these two into the parent's scope, so that it is |
600 | @@ -67,10 +68,9 @@ |
601 | "${CMAKE_CURRENT_SOURCE_DIR}/ExternalModuleConfig.cmake.in" |
602 | PARENT_SCOPE) |
603 | SET(Zorba_EXE "${ZORBA_EXE}" PARENT_SCOPE) |
604 | +SET(Zorba_NONCORE_URI_DIR "${ZORBA_NONCORE_URI_DIR}") |
605 | +SET(Zorba_NONCORE_LIB_DIR "${ZORBA_NONCORE_LIB_DIR}") |
606 | |
607 | -# Note: This value doesn't really make much sense, but neither does any |
608 | -# other value |
609 | -SET(Zorba_MODULES_INSTALL_DIR "${ZORBA_MODULES_INSTALL_DIR}") |
610 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ZorbaConfig.cmake.in" |
611 | "${CMAKE_BINARY_DIR}/ZorbaConfig.cmake" @ONLY) |
612 | |
613 | |
614 | === modified file 'config/ZorbaConfig.cmake.in' |
615 | --- config/ZorbaConfig.cmake.in 2011-08-24 09:09:02 +0000 |
616 | +++ config/ZorbaConfig.cmake.in 2011-11-04 11:47:43 +0000 |
617 | @@ -47,10 +47,13 @@ |
618 | "Path to Zorba's testdriver" FORCE) |
619 | SET_NORMALIZED (Zorba_EXE "@Zorba_EXE_PATH@" CACHE PATH "Path to Zorba executable" FORCE) |
620 | |
621 | -# Tell the user project where modules are installed. Note: This variable |
622 | -# is all-uppercase because it is also used internally by Zorba's build. |
623 | -SET (ZORBA_MODULES_INSTALL_DIR "@Zorba_MODULES_INSTALL_DIR@" |
624 | - CACHE STRING "Path to Zorba modules in this Zorba installation" FORCE) |
625 | +# Tell the user project where (non-core) modules are installed. Note: |
626 | +# These variables are all-uppercase because they are also used |
627 | +# internally by Zorba's build. |
628 | +SET (ZORBA_NONCORE_URI_DIR "@Zorba_NONCORE_URI_DIR@" |
629 | + CACHE STRING "Path to Zorba to non-core modules/schemas in this Zorba installation" FORCE) |
630 | +SET (ZORBA_NONCORE_LIB_DIR "@Zorba_NONCORE_LIB_DIR@" |
631 | + CACHE STRING "Path to Zorba to non-core libraries in this Zorba installation" FORCE) |
632 | |
633 | # Tell the user project where to find the "USE" file. |
634 | # This file uses the above settings to configure the user project. |
635 | |
636 | === modified file 'doc/zorba/commandline.dox' |
637 | --- doc/zorba/commandline.dox 2011-07-24 22:28:31 +0000 |
638 | +++ doc/zorba/commandline.dox 2011-11-04 11:47:43 +0000 |
639 | @@ -112,8 +112,14 @@ |
640 | --timeout |
641 | Specify a timeout in seconds. After the specified time, the execution of the query will be aborted. |
642 | |
643 | +--uri-path |
644 | +URI path (list of directories) added to the built-in URI resolver, i.e. where to find modules/schemas to import. |
645 | + |
646 | +--lib-path |
647 | +Library path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations. |
648 | + |
649 | --module-path |
650 | -Module paths added to the built-in resolver, i.e. where module imports are looking for modules. |
651 | +Path (list of directories) to add to both the URI and Library paths. |
652 | |
653 | --option |
654 | Set an XQuery option in the static context. The QName of the option is passed as a string in the notation by James Clark (i.e. {namespace}localname). For example, --option {http://www.zorba-xquery.com}option=value |
655 | |
656 | === modified file 'doc/zorba/external_functions.dox' |
657 | --- doc/zorba/external_functions.dox 2011-08-19 17:04:48 +0000 |
658 | +++ doc/zorba/external_functions.dox 2011-11-04 11:47:43 +0000 |
659 | @@ -112,8 +112,8 @@ |
660 | load it at runtime. |
661 | |
662 | To locate a dynamic libary, Zorba first transforms its target |
663 | -namespace URI to a relative file path and then uses the "modules path" |
664 | -mechanism (described in \ref uriresolvers) to turn this relative path |
665 | +namespace URI to a relative file path and then uses the "Library Path" |
666 | +mechanism (described in \ref libpath) to turn this relative path |
667 | to the absolute path name of the dynamic library file. The |
668 | transformation of the URI to a relative path is done using the |
669 | following steps. In describing the steps, we will use the URI |
670 | |
671 | === modified file 'doc/zorba/modules_authoring.dox' |
672 | --- doc/zorba/modules_authoring.dox 2011-08-17 09:25:23 +0000 |
673 | +++ doc/zorba/modules_authoring.dox 2011-11-04 11:47:43 +0000 |
674 | @@ -268,12 +268,12 @@ |
675 | and then execute Zorba as follows: |
676 | |
677 | \code |
678 | -% zorba --module-path /tmp/myproject/build/URI_PATH -f -q query.xq |
679 | +% zorba --uri-path /tmp/myproject/build/URI_PATH -f -q query.xq |
680 | <?xml version="1.0" encoding="UTF-8"?> |
681 | hello |
682 | \endcode |
683 | |
684 | -By providing this one <tt>--module-path</tt> argument, Zorba will |
685 | +By providing this one <tt>--uri-path</tt> argument, Zorba will |
686 | automatically be able to load any of our modules or schemas by URI, |
687 | rather than requiring explicit filesystem paths to them. This makes it |
688 | much easier to develop larger XQuery applications, because the entire |
689 | @@ -281,7 +281,6 @@ |
690 | of your queries to change the paths to load your modules as you move |
691 | from development to production. |
692 | |
693 | - |
694 | \ref modules_authoring_2 |
695 | |
696 | \ref modules_building_in |
697 | |
698 | === modified file 'doc/zorba/modules_authoring_2.dox' |
699 | --- doc/zorba/modules_authoring_2.dox 2011-08-19 17:04:48 +0000 |
700 | +++ doc/zorba/modules_authoring_2.dox 2011-11-04 11:47:43 +0000 |
701 | @@ -280,11 +280,12 @@ |
702 | 2. Link them together into an appropriately-named shared library for |
703 | your operating system |
704 | |
705 | -3. Copy the resulting shared library into <tt>URI_PATH</tt> with the |
706 | -correct name and location, and |
707 | +3. Copy the resulting shared library into |
708 | +<tt><build_dir>/LIB_PATH</tt> with the correct name and location, and |
709 | |
710 | 4. Create an <tt>INSTALL</tt> rule so that the shared library will be |
711 | -installed correctly along with your project. |
712 | +installed correctly along with your project. It will be automatically |
713 | +installed into Zorba's default non-core library path (see \libpath). |
714 | |
715 | If your code depends on other dynamic libraries, you can pass the full |
716 | paths to those libraries to <tt>DECLARE_ZORBA_MODULE()</tt> using the |
717 | |
718 | === modified file 'doc/zorba/modules_building_in.dox' |
719 | --- doc/zorba/modules_building_in.dox 2011-08-17 09:25:23 +0000 |
720 | +++ doc/zorba/modules_building_in.dox 2011-11-04 11:47:43 +0000 |
721 | @@ -3,7 +3,7 @@ |
722 | Once you have created a module project (see \ref modules_authoring) |
723 | containing modules and schemas, there are two different ways that you |
724 | can build those modules directly into Zorba, such that they are on |
725 | -Zorba's default module path and will be found automatically. |
726 | +Zorba's default URI and Library paths and will be found automatically. |
727 | |
728 | These same techniques can be used with non-core modules developed by |
729 | the Zorba team. |
730 | |
731 | === modified file 'doc/zorba/uriresolvers.dox' |
732 | --- doc/zorba/uriresolvers.dox 2011-08-17 09:25:23 +0000 |
733 | +++ doc/zorba/uriresolvers.dox 2011-11-04 11:47:43 +0000 |
734 | @@ -56,9 +56,9 @@ |
735 | the algorithm listed below. |
736 | |
737 | <li>Second, Zorba attempts to load the relative path within every |
738 | -directory listed on its <i>module path</i>. (Note: the terminology |
739 | -here is a misnomer; the same mechanism is used for all URIs, not just |
740 | -modules.) |
741 | +directory listed on its <i>URI path</i>. (Through this documentation, |
742 | +a "path" is defines as "an ordered list of directories in the |
743 | +filesystem.) |
744 | |
745 | </ol> |
746 | |
747 | @@ -71,7 +71,7 @@ |
748 | <ol> |
749 | |
750 | <li>The domain (authority) component of the URI is reversed, and then |
751 | -transformed into a path notation separated by forward slashes: |
752 | +transformed into a relative filename separated by forward slashes: |
753 | <code>www.example.com</code> => <code>com/example/www</code> |
754 | |
755 | <li>The path component of the URI is appended: |
756 | @@ -100,35 +100,35 @@ |
757 | |
758 | </ul> |
759 | |
760 | -\subsection modulepath The "Module Path" |
761 | +\subsection uripath Zorba's URI Path |
762 | |
763 | Zorba will now attempt to find the named file relative to each |
764 | -directory in the "module path". By default, the only entry on the |
765 | -module path is the directory |
766 | -<code>/usr/share/zorba-2.0.0/modules/</code> (on Unix and MacOS X) or |
767 | +directory in the <i>URI Path</i>. By default, the only entry on the |
768 | +URI path is the directory |
769 | +<code>/usr/share/zorba/uris/</code> (on Unix and MacOS X) or |
770 | <code>C:\\Program Files\\Zorba |
771 | -2.0.0\\share\\zorba-2.0.0\\modules</code> (on Windows). So, to |
772 | +2.1.0\\share\\zorba\\uris</code> (on Windows). So, to |
773 | complete this example, assuming Zorba is installed on a Unix system in |
774 | the default location, Zorba will attempt to resolve the module |
775 | namespace URI <code>http://www.example.com/modules/utils</code> to the |
776 | file |
777 | |
778 | \code |
779 | - /usr/share/zorba-2.0.0/modules/com/example/www/modules/utils.xq |
780 | + /usr/share/zorba/modules/com/example/www/modules/utils.xq |
781 | \endcode |
782 | |
783 | -If you have modules installed in other locations on your system, you |
784 | -may provide additional search paths either by passing the |
785 | -<code>--module-path</code> command-line argument to Zorba, or by |
786 | -setting the <code>ZORBA_MODULE_PATH</code> environment variable. In |
787 | -both cases, the value is an ordered list of filesystem paths separated |
788 | -by ":" (on Unix/MacOS X) or ";" (on Windows). Zorba will search each |
789 | -path on the module path in the order specified, and the first match |
790 | -found will be used. So, for example, if you invoke Zorba as follows |
791 | -(example is for a Unix system): |
792 | +If you have modules or schemas installed in other locations on your |
793 | +system, you may provide additional search directories either by |
794 | +passing the <code>--uri-path</code> command-line argument to Zorba, or |
795 | +by setting the <code>ZORBA_URI_PATH</code> environment variable. In |
796 | +both cases, the value is an ordered list of filesystem directories |
797 | +separated by ":" (on Unix/MacOS X) or ";" (on Windows). Zorba will |
798 | +search each directory on the URI path in the order specified, and the |
799 | +first match found will be used. So, for example, if you invoke Zorba |
800 | +as follows (example is for a Unix system): |
801 | |
802 | \code |
803 | - zorba --module-path '/home/foo/xquery/modules:/opt/share/xquery/modules' |
804 | + zorba --uri-path '/home/foo/xquery/uris:/opt/share/xquery/uris' |
805 | -q 'import module namespace utils="http://www.example.com/modules/utils"; 1' |
806 | \endcode |
807 | |
808 | @@ -136,31 +136,108 @@ |
809 | order: |
810 | |
811 | \code |
812 | - /home/foo/xquery/modules/com/example/www/modules/utils.xq |
813 | - /opt/share/xquery/modules/com/example/www/modules/utils.xq |
814 | - /usr/share/zorba-2.0.0/modules/com/example/www/modules/utils.xq |
815 | + /home/foo/xquery/uris/com/example/www/modules/utils.xq |
816 | + /opt/share/xquery/uris/com/example/www/modules/utils.xq |
817 | + /usr/share/zorba/uris/com/example/www/modules/utils.xq |
818 | \endcode |
819 | |
820 | -If, after searching all module path directories, no match is found for |
821 | +If, after searching all URI path directories, no match is found for |
822 | a given URI, Zorba will by default fall back to interpretting the URI |
823 | -as a URL and loading the resource via HTTP (at least, assuming the URI |
824 | +as a URL and loading the resource via HTTP (assuming the URI |
825 | has the http: scheme). |
826 | |
827 | +\section libpath Zorba's Library Path |
828 | + |
829 | +The above URI path mechanism is used for all URIs that are resolved by |
830 | +Zorba - most especially module and schema imports, but also full-text |
831 | +thesaurus and stop-word lists, documents, and so on. |
832 | + |
833 | +When considering modules in particular, however, there is another |
834 | +important path: the Library Path. Zorba will look on this path when it |
835 | +needs to load dynamic libraries containing the implementation of |
836 | +external functions for a module (ie, those functions implemented in |
837 | +C++; see \ref mod_author_cpp). This path is separate from the URI |
838 | +path because on certain systems - most notably Fedora, but also other |
839 | +Linux distributions - it is important that platform-dependent binary |
840 | +files (such as dynamic libraries) be installed in a separate directory |
841 | +structure from platform-independent files (such as <code>.xq</code> |
842 | +module files and <code>.xsd</code> schema files). |
843 | + |
844 | +The Library Path mechanism is exactly parallel to the URI Path |
845 | +mechanism. The default, built-in entry on this path is |
846 | +<code>/usr/lib/zorba</code> (on Unix and MacOS X) and |
847 | +<code>C:\\Program Files\\Zorba 2.1.0\\lib\\zorba</code> (on |
848 | +Windows). You can add directories to this path using the |
849 | +<code>--lib-path</code> command-line argument, or by setting the |
850 | +<code>ZORBA_LIB_PATH</code> environment variable. |
851 | + |
852 | +\section internalpaths Internal (Core) Paths |
853 | + |
854 | +There is actually one additional built-in directory on Zorba's URI |
855 | +Path, and one additional built-in directory on Zorba's Library Path, |
856 | +in addition to the default values mentioned above. These directories |
857 | +hold Zorba's built-in "core" modules (see \ref core_modules). The |
858 | +directories are subdirectories of the default directory named |
859 | +"core/ZORBA_VERSION". So for example, for Zorba 2.1.0 on Unix, the |
860 | +default internal URI directory is |
861 | +<code>/usr/share/zorba/uris/core/2.1.0</code> and the default internal |
862 | +library directory is <code>/usr/lib/zorba/core/2.1.0</code>. |
863 | + |
864 | +These directories are separate to make it easier to upgrade Zorba, or |
865 | +support multiple installed versions of Zorba, while allowing non-core |
866 | +modules to be installed and versioned indepedently of the Zorba |
867 | +version. Normally you should not modify the contents of these |
868 | +directories. |
869 | + |
870 | +\section configurepaths Changing the Default Paths |
871 | + |
872 | +All four paths mentioned above - the core and non-core URI Path, and |
873 | +the core and non-core Library Path - have compiled-in default values |
874 | +as discussed. All four of these default values can be modified at |
875 | +Zorba build time to meet your environment's requirements. You can do |
876 | +this by specifying alternate values for the following CMake variables: |
877 | + |
878 | +\code |
879 | +ZORBA_NONCORE_URI_DIR |
880 | +ZORBA_CORE_URI_DIR |
881 | +ZORBA_NONCORE_LIB_DIR |
882 | +ZORBA_CORE_LIB_DIR |
883 | +\endcode |
884 | + |
885 | +Note that these are <i>relative</i> directories, and will be resolved |
886 | +relative to <code>CMAKE_INSTALL_PREFIX</code>. |
887 | + |
888 | +\section modulepath Zorba's "Module Path" |
889 | + |
890 | +Earlier versions of Zorba had a single path for specifying where both |
891 | +platform-dependent library files and platform-independent module and |
892 | +schema files were located. This was somewhat inaccurately named the |
893 | +"module path". For backwards compatibility, Zorba still supports a |
894 | +<code>--module-path</code> command-line argument and a |
895 | +<code>ZORBA_MODULE_PATH</code> environment variable (and the C++ API |
896 | +has a <code>StaticContext::setModulePaths()</code> method). |
897 | +Specifying a set of directories as the "module path" using any of |
898 | +these mechanisms is exactly the same as specifying that set of |
899 | +directories as both the URI path and library path. |
900 | + |
901 | +The Module Path is deprecated, and these mechanisms may be removed in |
902 | +a future major version of Zorba. There is no "default module path". |
903 | + |
904 | \section cplusplus C++ API for URI Resolving |
905 | |
906 | -\subsection extmodulepath Modifying the Module Path programmatically |
907 | +\subsection cppuripath Modifying the URI Path programmatically |
908 | |
909 | The simplest modification to Zorba's default behavior is setting the |
910 | -module-path programmatically. This allows you to have different module |
911 | +URI path programmatically. This allows you to have different URI |
912 | paths per static context, if you wish. |
913 | |
914 | The <code>StaticContext</code> C++ API class provides the |
915 | -<code>setModulePaths()</code> method for this purpose. It is passed a |
916 | +<code>setURIPath()</code> method for this purpose. It is passed a |
917 | vector of <code>zorba::String</code> values, each being an absolute |
918 | -path to add to the module path. |
919 | +directory to add to the URI path. |
920 | |
921 | For example, the following code snippet creates a |
922 | -<code>StaticContext</code> object; adds two module paths to the module |
923 | +<code>StaticContext</code> object; adds two directories to the URI |
924 | path component of this static context; and compiles and executes a |
925 | query given the information that is present in this static context |
926 | (passed as the second parameter to the <code>compileQuery()</code> |
927 | @@ -170,12 +247,12 @@ |
928 | // Create a new static context |
929 | zorba::StaticContext_t staticCtx = zorba->createStaticContext(); |
930 | |
931 | - // Set the module paths |
932 | - std::vector<zorba::String> modulePaths(2); |
933 | - modulePaths[0] = "/home/foo/xquery/modules"; |
934 | - modulePaths[1] = "/opt/share/xquery/modules"; |
935 | + // Set the URI Path |
936 | + std::vector<zorba::String> uriPath(2); |
937 | + uriPath[0] = "/home/foo/xquery/uris"; |
938 | + uriPath[1] = "/opt/share/xquery/uris"; |
939 | |
940 | - staticCtx->setModulePaths(modulePaths); |
941 | + staticCtx->setURIPath(uriPath); |
942 | |
943 | // Compile a query using the static context created above |
944 | zorba::XQuery_t query = zorba->compileQuery( |
945 | @@ -186,6 +263,12 @@ |
946 | std::cout << query << std::endl; |
947 | \endcode |
948 | |
949 | +\subsection cpplibpath Modifying the Library Path programmatically |
950 | + |
951 | +Similarly, <code>StaticContext</code> has a method named |
952 | +<code>setLibPath()</code> for specifying the Library Path to use. In |
953 | +operation it behaves exactly like <code>setURIPath()</code>. |
954 | + |
955 | \subsection mapresolve URI Mappers and URL Resolvers |
956 | |
957 | Now we will discuss more advanced techniques for manipulating Zorba's |
958 | @@ -228,9 +311,8 @@ |
959 | \subsubsection urimappers URI Mappers |
960 | |
961 | Zorba includes a few built-in URI Mappers. For instance, the mechanism |
962 | -which iterates through the module path and produces a set of |
963 | -filesystem paths where the URI might be located is implemented as a |
964 | -URI Mapper. |
965 | +which iterates through the URI path and produces a set of filesystem |
966 | +files where the URI might be located is implemented as a URI Mapper. |
967 | |
968 | To implement your own URI Mapper, subclass the C++ API class |
969 | <code>URIMapper</code> and implement the <code>mapURI()</code> method: |
970 | |
971 | === modified file 'include/zorba/config.h.cmake' |
972 | --- include/zorba/config.h.cmake 2011-08-22 15:14:14 +0000 |
973 | +++ include/zorba/config.h.cmake 2011-11-04 11:47:43 +0000 |
974 | @@ -138,7 +138,10 @@ |
975 | #define ZORBA_MAJOR_NUMBER ${ZORBA_MAJOR_NUMBER} |
976 | #define ZORBA_MINOR_NUMBER ${ZORBA_MINOR_NUMBER} |
977 | #define ZORBA_PATCH_NUMBER ${ZORBA_PATCH_NUMBER} |
978 | -#define ZORBA_MODULES_INSTALL_DIR "${ZORBA_MODULES_INSTALL_DIR}" |
979 | +#define ZORBA_CORE_URI_DIR "${ZORBA_CORE_URI_DIR}" |
980 | +#define ZORBA_CORE_LIB_DIR "${ZORBA_CORE_LIB_DIR}" |
981 | +#define ZORBA_NONCORE_URI_DIR "${ZORBA_NONCORE_URI_DIR}" |
982 | +#define ZORBA_NONCORE_LIB_DIR "${ZORBA_NONCORE_LIB_DIR}" |
983 | |
984 | // Zorba features |
985 | #cmakedefine ZORBA_NO_FULL_TEXT |
986 | |
987 | === modified file 'include/zorba/static_context.h' |
988 | --- include/zorba/static_context.h 2011-08-31 13:17:59 +0000 |
989 | +++ include/zorba/static_context.h 2011-11-04 11:47:43 +0000 |
990 | @@ -450,12 +450,36 @@ |
991 | virtual void |
992 | declareOption( const Item& aQName, const String& aOptionValue) = 0; |
993 | |
994 | + /** |
995 | + * @brief Set the URI and library lookup paths (lists of filesystem |
996 | + * directories) for this static context. Note that calling this method |
997 | + * will override any values previously passed to \link setURIPath() |
998 | + * and \link setLibPath(). |
999 | + * @deprecated Use \link setURIPath() and \link setLibPath(). |
1000 | + * |
1001 | + * Convenience method which adds the listed directories to both the |
1002 | + * URI path and Library path for this static context. |
1003 | + */ |
1004 | virtual void |
1005 | setModulePaths( const std::vector<String>& aModulePaths ) = 0; |
1006 | |
1007 | + /** |
1008 | + * @brief Return the union of the URI and library lookup paths (lists of |
1009 | + * filesystem directories) for this static context. @deprecated Use \link |
1010 | + * getURIPath() and \link getLibPath(). |
1011 | + * @deprecated Use \link getURIPath() and \link getLibPath(). |
1012 | + * |
1013 | + * Returns any values set by \link setLibPath() and/or \link setURIPath() |
1014 | + * on this static context. |
1015 | + */ |
1016 | virtual void |
1017 | getModulePaths( std::vector<String>& aModulePaths ) const = 0; |
1018 | |
1019 | + /** |
1020 | + * @brief Return the union of the URI and library lookup paths (lists of |
1021 | + * filesystem directories) for this static context and all its parents. |
1022 | + * @deprecated Use \link getFullURIPath() and \link getFullLibPath(). |
1023 | + */ |
1024 | virtual void |
1025 | getFullModulePaths( std::vector<String>& aFullModulePaths ) const = 0; |
1026 | |
1027 | @@ -576,6 +600,63 @@ |
1028 | virtual audit::Event* |
1029 | getAuditEvent() = 0; |
1030 | |
1031 | + /** |
1032 | + * @brief Set the URI lookup path (list of filesystem directories) for this |
1033 | + * static context. |
1034 | + * |
1035 | + * Queries which resolve URIs (for instance, importing modules or schemas) |
1036 | + * will look in these directories. |
1037 | + */ |
1038 | + virtual void |
1039 | + setURIPath(const std::vector<String>& aURIPath) = 0; |
1040 | + |
1041 | + /** |
1042 | + * @brief Return the URI lookup path (list of filesystem directories) for |
1043 | + * this static context. |
1044 | + * |
1045 | + * Returns any values set by \link setURIPath() on this static context. |
1046 | + * To return the full URI lookup path for this static context and |
1047 | + * all its parents (usually most useful), call \link getFullURIPath(). |
1048 | + */ |
1049 | + virtual void |
1050 | + getURIPath(std::vector<String>& aURIPath) const = 0; |
1051 | + |
1052 | + /** |
1053 | + * @brief Return the URI lookup path (list of filesystem directories) for |
1054 | + * this static context and all its parents. |
1055 | + */ |
1056 | + virtual void |
1057 | + getFullURIPath(std::vector<String>& aURIPath) const = 0; |
1058 | + |
1059 | + /** |
1060 | + * @brief Set the library lookup path (list of filesystem directories) for |
1061 | + * this static context. |
1062 | + * |
1063 | + * Queries which import modules that have external function |
1064 | + * implementations will look for the implementation of those functions |
1065 | + * (shared libraries) in these directories. |
1066 | + */ |
1067 | + virtual void |
1068 | + setLibPath(const std::vector<String>& aLibPath) = 0; |
1069 | + |
1070 | + /** |
1071 | + * @brief Return the URI lookup path (list of filesystem directories) for |
1072 | + * this static context. |
1073 | + * |
1074 | + * Returns any values set by \link setLibPath() on this static context. |
1075 | + * To return the full library lookup path for this static context and |
1076 | + * all its parents (usually most useful), call \link getFullLibPath(). |
1077 | + */ |
1078 | + virtual void |
1079 | + getLibPath(std::vector<String>& aLibPath) const = 0; |
1080 | + |
1081 | + /** |
1082 | + * @brief Return the URI lookup path (list of filesystem directories) for |
1083 | + * this static context and all its parents. |
1084 | + */ |
1085 | + virtual void |
1086 | + getFullLibPath(std::vector<String>& aLibPath) const = 0; |
1087 | + |
1088 | }; |
1089 | } /* namespace zorba */ |
1090 | #endif |
1091 | |
1092 | === modified file 'src/api/staticcontextimpl.cpp' |
1093 | --- src/api/staticcontextimpl.cpp 2011-09-14 11:08:52 +0000 |
1094 | +++ src/api/staticcontextimpl.cpp 2011-11-04 11:47:43 +0000 |
1095 | @@ -963,50 +963,151 @@ |
1096 | theSctxMap = impl.theCompilerCB->theSctxMap; |
1097 | } |
1098 | |
1099 | - |
1100 | -void StaticContextImpl::setModulePaths(const std::vector<String>& aModulePaths) |
1101 | +static void |
1102 | +toInternalPath(const std::vector<String>& aPublicStrings, |
1103 | + std::vector<zstring>& aInternalStrings) |
1104 | { |
1105 | - try |
1106 | + for (std::vector<String>::const_iterator lIter = aPublicStrings.begin(); |
1107 | + lIter != aPublicStrings.end(); ++lIter) |
1108 | { |
1109 | - std::vector<zstring> lModulePaths; |
1110 | - |
1111 | - for (std::vector<String>::const_iterator lIter = aModulePaths.begin(); |
1112 | - lIter != aModulePaths.end(); ++lIter) |
1113 | + if (lIter->length() != 0) |
1114 | { |
1115 | - if (lIter->length() != 0) |
1116 | + aInternalStrings.push_back(Unmarshaller::getInternalString(*lIter).c_str()); |
1117 | + zstring& lPath = aInternalStrings.back(); |
1118 | + if (lPath[lPath.length() - 1] != *filesystem_path::get_directory_separator()) |
1119 | { |
1120 | - lModulePaths.push_back(Unmarshaller::getInternalString(*lIter).c_str()); |
1121 | - zstring& lPath = lModulePaths.back(); |
1122 | - if (lPath.rfind(filesystem_path::get_directory_separator()) != std::string::npos) |
1123 | - { |
1124 | - lPath.append(filesystem_path::get_directory_separator()); |
1125 | - } |
1126 | + lPath.append(filesystem_path::get_directory_separator()); |
1127 | } |
1128 | - |
1129 | } |
1130 | - |
1131 | - theCtx->set_module_paths(lModulePaths); |
1132 | - } |
1133 | - catch (ZorbaException const& e) |
1134 | - { |
1135 | - ZorbaImpl::notifyError(theDiagnosticHandler, e); |
1136 | - } |
1137 | -} |
1138 | - |
1139 | + } |
1140 | +} |
1141 | + |
1142 | +static void |
1143 | +toPublicPath(const std::vector<zstring>& aInternalStrings, |
1144 | + std::vector<String>& aPublicStrings) |
1145 | +{ |
1146 | + for (std::vector<zstring>::const_iterator lIter = aInternalStrings.begin(); |
1147 | + lIter != aInternalStrings.end(); ++lIter) |
1148 | + { |
1149 | + aPublicStrings.push_back(lIter->c_str()); |
1150 | + } |
1151 | +} |
1152 | + |
1153 | +void |
1154 | +StaticContextImpl::setURIPath(const std::vector<String> &aURIPath) |
1155 | +{ |
1156 | + try |
1157 | + { |
1158 | + std::vector<zstring> lInternalURIPath; |
1159 | + toInternalPath(aURIPath, lInternalURIPath); |
1160 | + theCtx->set_uri_path(lInternalURIPath); |
1161 | + } |
1162 | + catch (ZorbaException const& e) |
1163 | + { |
1164 | + ZorbaImpl::notifyError(theDiagnosticHandler, e); |
1165 | + } |
1166 | +} |
1167 | + |
1168 | +void |
1169 | +StaticContextImpl::getURIPath(std::vector<String> &aURIPath) const |
1170 | +{ |
1171 | + try |
1172 | + { |
1173 | + std::vector<zstring> lInternalURIPath; |
1174 | + theCtx->get_uri_path(lInternalURIPath); |
1175 | + toPublicPath(lInternalURIPath, aURIPath); |
1176 | + } |
1177 | + catch (ZorbaException const& e) |
1178 | + { |
1179 | + ZorbaImpl::notifyError(theDiagnosticHandler, e); |
1180 | + } |
1181 | +} |
1182 | + |
1183 | +void |
1184 | +StaticContextImpl::getFullURIPath(std::vector<String> &aURIPath) const |
1185 | +{ |
1186 | + try |
1187 | + { |
1188 | + std::vector<zstring> lInternalURIPath; |
1189 | + theCtx->get_full_uri_path(lInternalURIPath); |
1190 | + toPublicPath(lInternalURIPath, aURIPath); |
1191 | + } |
1192 | + catch (ZorbaException const& e) |
1193 | + { |
1194 | + ZorbaImpl::notifyError(theDiagnosticHandler, e); |
1195 | + } |
1196 | +} |
1197 | + |
1198 | +void |
1199 | +StaticContextImpl::setLibPath(const std::vector<String> &aLibPath) |
1200 | +{ |
1201 | + try |
1202 | + { |
1203 | + std::vector<zstring> lInternalLibPath; |
1204 | + toInternalPath(aLibPath, lInternalLibPath); |
1205 | + theCtx->set_lib_path(lInternalLibPath); |
1206 | + } |
1207 | + catch (ZorbaException const& e) |
1208 | + { |
1209 | + ZorbaImpl::notifyError(theDiagnosticHandler, e); |
1210 | + } |
1211 | +} |
1212 | + |
1213 | +void |
1214 | +StaticContextImpl::getLibPath(std::vector<String> &aLibPath) const |
1215 | +{ |
1216 | + try |
1217 | + { |
1218 | + std::vector<zstring> lInternalLibPath; |
1219 | + theCtx->get_lib_path(lInternalLibPath); |
1220 | + toPublicPath(lInternalLibPath, aLibPath); |
1221 | + } |
1222 | + catch (ZorbaException const& e) |
1223 | + { |
1224 | + ZorbaImpl::notifyError(theDiagnosticHandler, e); |
1225 | + } |
1226 | +} |
1227 | + |
1228 | +void |
1229 | +StaticContextImpl::getFullLibPath(std::vector<String> &aLibPath) const |
1230 | +{ |
1231 | + try |
1232 | + { |
1233 | + std::vector<zstring> lInternalLibPath; |
1234 | + theCtx->get_full_lib_path(lInternalLibPath); |
1235 | + toPublicPath(lInternalLibPath, aLibPath); |
1236 | + } |
1237 | + catch (ZorbaException const& e) |
1238 | + { |
1239 | + ZorbaImpl::notifyError(theDiagnosticHandler, e); |
1240 | + } |
1241 | +} |
1242 | + |
1243 | +void StaticContextImpl::setModulePaths(const std::vector<String>& aModulePaths) |
1244 | +{ |
1245 | + try |
1246 | + { |
1247 | + std::vector<zstring> lInternalModulePath; |
1248 | + toInternalPath(aModulePaths, lInternalModulePath); |
1249 | + theCtx->set_lib_path(lInternalModulePath); |
1250 | + theCtx->set_uri_path(lInternalModulePath); |
1251 | + } |
1252 | + catch (ZorbaException const& e) |
1253 | + { |
1254 | + ZorbaImpl::notifyError(theDiagnosticHandler, e); |
1255 | + } |
1256 | +} |
1257 | |
1258 | void StaticContextImpl::getModulePaths(std::vector<String>& aModulePaths) const |
1259 | { |
1260 | try |
1261 | { |
1262 | - std::vector<zstring> lModulePaths; |
1263 | - |
1264 | - theCtx->get_module_paths(lModulePaths); |
1265 | - |
1266 | - for (std::vector<zstring>::const_iterator lIter = lModulePaths.begin(); |
1267 | - lIter != lModulePaths.end(); ++lIter) |
1268 | - { |
1269 | - aModulePaths.push_back(lIter->c_str()); |
1270 | - } |
1271 | + std::vector<zstring> lInternalModulePath; |
1272 | + theCtx->get_lib_path(lInternalModulePath); |
1273 | + toPublicPath(lInternalModulePath, aModulePaths); |
1274 | + lInternalModulePath.clear(); |
1275 | + theCtx->get_uri_path(lInternalModulePath); |
1276 | + toPublicPath(lInternalModulePath, aModulePaths); |
1277 | } |
1278 | catch (ZorbaException const& e) |
1279 | { |
1280 | @@ -1020,15 +1121,12 @@ |
1281 | { |
1282 | try |
1283 | { |
1284 | - std::vector<zstring> lFullModulePaths; |
1285 | - |
1286 | - theCtx->get_full_module_paths(lFullModulePaths); |
1287 | - |
1288 | - for (std::vector<zstring>::const_iterator lIter = lFullModulePaths.begin(); |
1289 | - lIter != lFullModulePaths.end(); ++lIter) |
1290 | - { |
1291 | - aFullModulePaths.push_back(lIter->c_str()); |
1292 | - } |
1293 | + std::vector<zstring> lInternalModulePath; |
1294 | + theCtx->get_full_lib_path(lInternalModulePath); |
1295 | + toPublicPath(lInternalModulePath, aFullModulePaths); |
1296 | + lInternalModulePath.clear(); |
1297 | + theCtx->get_full_uri_path(lInternalModulePath); |
1298 | + toPublicPath(lInternalModulePath, aFullModulePaths); |
1299 | } |
1300 | catch (ZorbaException const& e) |
1301 | { |
1302 | |
1303 | === modified file 'src/api/staticcontextimpl.h' |
1304 | --- src/api/staticcontextimpl.h 2011-08-31 13:17:59 +0000 |
1305 | +++ src/api/staticcontextimpl.h 2011-11-04 11:47:43 +0000 |
1306 | @@ -269,6 +269,24 @@ |
1307 | virtual audit::Event* |
1308 | getAuditEvent(); |
1309 | |
1310 | + virtual void |
1311 | + setURIPath(const std::vector<String>& aURIPath); |
1312 | + |
1313 | + virtual void |
1314 | + getURIPath(std::vector<String>& aURIPath) const; |
1315 | + |
1316 | + virtual void |
1317 | + getFullURIPath(std::vector<String>& aURIPath) const; |
1318 | + |
1319 | + virtual void |
1320 | + setLibPath(const std::vector<String>& aLibPath); |
1321 | + |
1322 | + virtual void |
1323 | + getLibPath(std::vector<String>& aLibPath) const; |
1324 | + |
1325 | + virtual void |
1326 | + getFullLibPath(std::vector<String>& aLibPath) const; |
1327 | + |
1328 | protected: |
1329 | String |
1330 | createInvokeQuery(const Function_t&, size_t aArity) const; |
1331 | |
1332 | === modified file 'src/context/default_uri_mappers.cpp' |
1333 | --- src/context/default_uri_mappers.cpp 2011-08-10 09:40:29 +0000 |
1334 | +++ src/context/default_uri_mappers.cpp 2011-11-04 11:47:43 +0000 |
1335 | @@ -147,7 +147,7 @@ |
1336 | // file: URI based on every member of the static context's module |
1337 | // paths, and return that URI to the caller. |
1338 | std::vector<zstring> lModulePaths; |
1339 | - aSctx.get_full_module_paths(lModulePaths); |
1340 | + aSctx.get_full_uri_path(lModulePaths); |
1341 | for (std::vector<zstring>::const_iterator lIter = lModulePaths.begin(); |
1342 | lIter != lModulePaths.end(); lIter++) |
1343 | { |
1344 | |
1345 | === modified file 'src/context/dynamic_loader.cpp' |
1346 | --- src/context/dynamic_loader.cpp 2011-08-08 13:51:27 +0000 |
1347 | +++ src/context/dynamic_loader.cpp 2011-11-04 11:47:43 +0000 |
1348 | @@ -216,12 +216,12 @@ |
1349 | ExternalModule* |
1350 | DynamicLoader::getExternalModule(zstring const& aNsURI, static_context& aSctx) |
1351 | { |
1352 | - std::vector<zstring> lModulePaths; |
1353 | - aSctx.get_full_module_paths(lModulePaths); |
1354 | + std::vector<zstring> lLibPath; |
1355 | + aSctx.get_full_lib_path(lLibPath); |
1356 | |
1357 | std::auto_ptr<std::istream> modfile(0); // result file |
1358 | |
1359 | - if (lModulePaths.size() != 0) |
1360 | + if (lLibPath.size() != 0) |
1361 | { |
1362 | URI lURI(aNsURI); |
1363 | |
1364 | @@ -243,10 +243,9 @@ |
1365 | |
1366 | zstring lLibraryNameDebug = computeLibraryName(lURI, lImportedVersion, true); |
1367 | |
1368 | - // Check all module path in the according order. The higher in the hirarchy |
1369 | - // the static context is the higher the priority of its module paths. |
1370 | - for (std::vector<zstring>::const_iterator ite = lModulePaths.begin(); |
1371 | - ite != lModulePaths.end(); |
1372 | + // Check all module path in the according order. |
1373 | + for (std::vector<zstring>::const_iterator ite = lLibPath.begin(); |
1374 | + ite != lLibPath.end(); |
1375 | ++ite) |
1376 | { |
1377 | zstring potentialModuleFile = (*ite); |
1378 | |
1379 | === modified file 'src/context/root_static_context.cpp' |
1380 | --- src/context/root_static_context.cpp 2011-08-19 00:03:31 +0000 |
1381 | +++ src/context/root_static_context.cpp 2011-11-04 11:47:43 +0000 |
1382 | @@ -40,6 +40,17 @@ |
1383 | theTypemgr = new RootTypeManager(); |
1384 | } |
1385 | |
1386 | +#ifdef WIN32 |
1387 | +static void append_to_path(std::vector<zstring>& aPath, zstring& zorba_root, |
1388 | + zstring& relpath) |
1389 | +{ |
1390 | + ascii::replace_all(relpath, '/', '\\'); |
1391 | + zstring full_path(zorba_root); |
1392 | + full_path.append(relpath); |
1393 | + full_path.append("\\"); |
1394 | + aPath.push_back(full_path); |
1395 | +} |
1396 | +#endif |
1397 | |
1398 | void root_static_context::init() |
1399 | { |
1400 | @@ -105,9 +116,10 @@ |
1401 | |
1402 | set_validation_mode(StaticContextConsts::lax_validation); |
1403 | |
1404 | - std::vector<zstring> lRootModulePaths; |
1405 | + std::vector<zstring> lRootURIPath; |
1406 | + std::vector<zstring> lRootLibPath; |
1407 | #ifdef WIN32 |
1408 | - //add first the relative path to zorba_simplestore.dll (this dll) |
1409 | + // compute the relative path to zorba_simplestore.dll (this dll) |
1410 | WCHAR wdll_path[1024]; |
1411 | DWORD dll_path_size; |
1412 | dll_path_size = GetModuleFileNameW(NULL, wdll_path, sizeof(wdll_path)/sizeof(wdll_path[0])); |
1413 | @@ -116,30 +128,34 @@ |
1414 | wdll_path[dll_path_size] = 0; |
1415 | char dll_path[1024]; |
1416 | WideCharToMultiByte(CP_UTF8, 0, wdll_path, -1, dll_path, sizeof(dll_path), NULL, NULL); |
1417 | - char *last_slash; |
1418 | - last_slash = strrchr(dll_path, '\\'); |
1419 | + char *last_slash = strrchr(dll_path, '\\'); |
1420 | if(last_slash) |
1421 | { |
1422 | last_slash[1] = 0; |
1423 | - zstring moddir(ZORBA_MODULES_INSTALL_DIR); |
1424 | - ascii::replace_all(moddir, '/', '\\'); |
1425 | - zstring fileURL; |
1426 | - fileURL = dll_path; |
1427 | - fileURL = fileURL.append("..\\"); |
1428 | - fileURL = fileURL.append(moddir); |
1429 | - fileURL = fileURL.append("\\"); |
1430 | - lRootModulePaths.push_back(fileURL); |
1431 | + zstring zorba_root_dir(dll_path); |
1432 | + |
1433 | + append_to_path(lRootURIPath, zorba_root_dir, zstring(ZORBA_CORE_URI_DIR)); |
1434 | + append_to_path(lRootURIPath, zorba_root_dir, zstring(ZORBA_NONCORE_URI_DIR)); |
1435 | + append_to_path(lRootLibPath, zorba_root_dir, zstring(ZORBA_CORE_LIB_DIR)); |
1436 | + append_to_path(lRootLibPath, zorba_root_dir, zstring(ZORBA_NONCORE_LIB_DIR)); |
1437 | } |
1438 | } |
1439 | #endif |
1440 | - const char ** lPathsIter = get_builtin_module_paths(); |
1441 | - for (; *lPathsIter != 0; ++lPathsIter) |
1442 | - { |
1443 | - lRootModulePaths.push_back(*lPathsIter); |
1444 | - } |
1445 | - set_module_paths(lRootModulePaths); |
1446 | - |
1447 | - // by default enabled features |
1448 | + const char ** lURIPathIter = get_builtin_uri_path(); |
1449 | + for (; *lURIPathIter != 0; ++lURIPathIter) |
1450 | + { |
1451 | + lRootURIPath.push_back(*lURIPathIter); |
1452 | + } |
1453 | + set_uri_path(lRootURIPath); |
1454 | + |
1455 | + const char ** lLibPathIter = get_builtin_lib_path(); |
1456 | + for (; *lLibPathIter != 0; ++lLibPathIter) |
1457 | + { |
1458 | + lRootLibPath.push_back(*lLibPathIter); |
1459 | + } |
1460 | + set_lib_path(lRootLibPath); |
1461 | + |
1462 | + // by default enabled features |
1463 | set_feature( feature::ddl ); |
1464 | set_feature( feature::scripting ); |
1465 | set_feature( feature::trace ); |
1466 | |
1467 | === modified file 'src/context/root_static_context.h' |
1468 | --- src/context/root_static_context.h 2011-07-12 23:32:16 +0000 |
1469 | +++ src/context/root_static_context.h 2011-11-04 11:47:43 +0000 |
1470 | @@ -26,8 +26,9 @@ |
1471 | friend class GlobalEnvironment; |
1472 | friend class static_context; |
1473 | |
1474 | -protected: |
1475 | - static const char* theBuiltInModulePaths[]; |
1476 | +private: |
1477 | + static const char* theBuiltinURIPath[]; |
1478 | + static const char* theBuiltinLibPath[]; |
1479 | |
1480 | protected: |
1481 | zstring theImplementationBaseUri; |
1482 | @@ -39,7 +40,8 @@ |
1483 | |
1484 | void init(); |
1485 | |
1486 | - const char** get_builtin_module_paths() const { return theBuiltInModulePaths; } |
1487 | + const char** get_builtin_uri_path() const { return theBuiltinURIPath; } |
1488 | + const char** get_builtin_lib_path() const { return theBuiltinLibPath; } |
1489 | }; |
1490 | |
1491 | } |
1492 | |
1493 | === modified file 'src/context/root_static_context_init.cpp.in' |
1494 | --- src/context/root_static_context_init.cpp.in 2011-07-22 08:36:51 +0000 |
1495 | +++ src/context/root_static_context_init.cpp.in 2011-11-04 11:47:43 +0000 |
1496 | @@ -20,9 +20,16 @@ |
1497 | |
1498 | namespace zorba { |
1499 | |
1500 | - const char* root_static_context::theBuiltInModulePaths[] = { |
1501 | - "@CMAKE_INSTALL_PREFIX@/@ZORBA_MODULES_INSTALL_DIR@/", |
1502 | + const char* root_static_context::theBuiltinURIPath[] = { |
1503 | + "@CMAKE_INSTALL_PREFIX@/@ZORBA_CORE_URI_DIR@/", |
1504 | + "@CMAKE_INSTALL_PREFIX@/@ZORBA_NONCORE_URI_DIR@/", |
1505 | "@CMAKE_BINARY_DIR@/URI_PATH/", |
1506 | 0 }; |
1507 | |
1508 | + const char* root_static_context::theBuiltinLibPath[] = { |
1509 | + "@CMAKE_INSTALL_PREFIX@/@ZORBA_CORE_LIB_DIR@/", |
1510 | + "@CMAKE_INSTALL_PREFIX@/@ZORBA_NONCORE_LIB_DIR@/", |
1511 | + "@CMAKE_BINARY_DIR@/LIB_PATH/", |
1512 | + 0 }; |
1513 | + |
1514 | } /* namespace zorba */ |
1515 | |
1516 | === modified file 'src/context/static_context.cpp' |
1517 | --- src/context/static_context.cpp 2011-11-02 17:19:09 +0000 |
1518 | +++ src/context/static_context.cpp 2011-11-04 11:47:43 +0000 |
1519 | @@ -864,7 +864,8 @@ |
1520 | serialize_resolvers(ar); |
1521 | serialize_tracestream(ar); |
1522 | |
1523 | - ar & theModulePaths; |
1524 | + ar & theURIPath; |
1525 | + ar & theLibPath; |
1526 | |
1527 | // Options must be serialized BEFORE external modules |
1528 | ar & theOptionMap; |
1529 | @@ -1515,6 +1516,13 @@ |
1530 | for (std::vector<zstring>::iterator url = aUrls.begin(); |
1531 | url != aUrls.end(); url++) |
1532 | { |
1533 | + // if the http-client module is not available, we must not search |
1534 | + // for it by calling the http-client... |
1535 | + if (*url == "http://www.zorba-xquery.com/modules/http-client") |
1536 | + { |
1537 | + continue; |
1538 | + } |
1539 | + |
1540 | // Iterate upwards through the static_context tree... |
1541 | for (static_context const* sctx = this; |
1542 | sctx != NULL; sctx = sctx->theParent) |
1543 | @@ -1526,18 +1534,13 @@ |
1544 | { |
1545 | try |
1546 | { |
1547 | - // if the http-client module is not available, we must not search |
1548 | - // for it by calling the http-client... |
1549 | - if (*url != "http://www.zorba-xquery.com/modules/http-client") |
1550 | + // Take ownership of returned Resource (if any) |
1551 | + oResource.reset((*resolver)->resolveURL(*url, aEntityData)); |
1552 | + if (oResource.get() != NULL) |
1553 | { |
1554 | - // Take ownership of returned Resource (if any) |
1555 | - oResource.reset((*resolver)->resolveURL(*url, aEntityData)); |
1556 | - if (oResource.get() != NULL) |
1557 | - { |
1558 | - // Populate the URL used to load this Resource |
1559 | - oResource->setUrl(*url); |
1560 | - return; |
1561 | - } |
1562 | + // Populate the URL used to load this Resource |
1563 | + oResource->setUrl(*url); |
1564 | + return; |
1565 | } |
1566 | } |
1567 | catch (const std::exception& e) |
1568 | @@ -1562,32 +1565,63 @@ |
1569 | /******************************************************************************* |
1570 | |
1571 | ********************************************************************************/ |
1572 | -void static_context::set_module_paths(const std::vector<zstring>& paths) |
1573 | -{ |
1574 | - theModulePaths = paths; |
1575 | -} |
1576 | - |
1577 | - |
1578 | -/******************************************************************************* |
1579 | - |
1580 | -********************************************************************************/ |
1581 | -void static_context::get_module_paths(std::vector<zstring>& paths) const |
1582 | -{ |
1583 | - paths.insert(paths.end(), theModulePaths.begin(), theModulePaths.end()); |
1584 | -} |
1585 | - |
1586 | - |
1587 | -/******************************************************************************* |
1588 | - |
1589 | -********************************************************************************/ |
1590 | -void static_context::get_full_module_paths(std::vector<zstring>& paths) const |
1591 | -{ |
1592 | - if (theParent != NULL) |
1593 | - { |
1594 | - theParent->get_full_module_paths(paths); |
1595 | - } |
1596 | - |
1597 | - get_module_paths(paths); |
1598 | +void static_context::set_uri_path(const std::vector<zstring>& path) |
1599 | +{ |
1600 | + theURIPath = path; |
1601 | +} |
1602 | + |
1603 | + |
1604 | +/******************************************************************************* |
1605 | + |
1606 | +********************************************************************************/ |
1607 | +void static_context::get_uri_path(std::vector<zstring>& path) const |
1608 | +{ |
1609 | + path.insert(path.end(), theURIPath.begin(), theURIPath.end()); |
1610 | +} |
1611 | + |
1612 | + |
1613 | +/******************************************************************************* |
1614 | + |
1615 | +********************************************************************************/ |
1616 | +void static_context::get_full_uri_path(std::vector<zstring>& path) const |
1617 | +{ |
1618 | + if (theParent != NULL) |
1619 | + { |
1620 | + theParent->get_full_uri_path(path); |
1621 | + } |
1622 | + |
1623 | + get_uri_path(path); |
1624 | +} |
1625 | + |
1626 | +/******************************************************************************* |
1627 | + |
1628 | +********************************************************************************/ |
1629 | +void static_context::set_lib_path(const std::vector<zstring>& path) |
1630 | +{ |
1631 | + theLibPath = path; |
1632 | +} |
1633 | + |
1634 | + |
1635 | +/******************************************************************************* |
1636 | + |
1637 | +********************************************************************************/ |
1638 | +void static_context::get_lib_path(std::vector<zstring>& path) const |
1639 | +{ |
1640 | + path.insert(path.end(), theLibPath.begin(), theLibPath.end()); |
1641 | +} |
1642 | + |
1643 | + |
1644 | +/******************************************************************************* |
1645 | + |
1646 | +********************************************************************************/ |
1647 | +void static_context::get_full_lib_path(std::vector<zstring>& path) const |
1648 | +{ |
1649 | + if (theParent != NULL) |
1650 | + { |
1651 | + theParent->get_full_lib_path(path); |
1652 | + } |
1653 | + |
1654 | + get_lib_path(path); |
1655 | } |
1656 | |
1657 | |
1658 | |
1659 | === modified file 'src/context/static_context.h' |
1660 | --- src/context/static_context.h 2011-11-02 17:19:09 +0000 |
1661 | +++ src/context/static_context.h 2011-11-04 11:47:43 +0000 |
1662 | @@ -507,7 +507,9 @@ |
1663 | thesaurus_providers_t theThesaurusProviders; |
1664 | #endif /* ZORBA_NO_FULL_TEXT */ |
1665 | |
1666 | - checked_vector<zstring> theModulePaths; |
1667 | + checked_vector<zstring> theURIPath; |
1668 | + |
1669 | + checked_vector<zstring> theLibPath; |
1670 | |
1671 | ExternalModuleMap * theExternalModulesMap; |
1672 | |
1673 | @@ -701,12 +703,17 @@ |
1674 | void remove_thesaurus_provider( internal::ThesaurusProvider const *p ); |
1675 | #endif /* ZORBA_NO_FULL_TEXT */ |
1676 | |
1677 | - void set_module_paths(const std::vector<zstring>& aModulePaths); |
1678 | - |
1679 | - void get_module_paths(std::vector<zstring>& aModulePaths) const; |
1680 | - |
1681 | - void get_full_module_paths(std::vector<zstring>& aFullModulePaths) const; |
1682 | - |
1683 | + void set_uri_path(const std::vector<zstring>& aURIPath); |
1684 | + |
1685 | + void get_uri_path(std::vector<zstring>& oURIPath) const; |
1686 | + |
1687 | + void get_full_uri_path(std::vector<zstring>& oURIPath) const; |
1688 | + |
1689 | + void set_lib_path(const std::vector<zstring>& aLibPath); |
1690 | + |
1691 | + void get_lib_path(std::vector<zstring>& oLibPath) const; |
1692 | + |
1693 | + void get_full_lib_path(std::vector<zstring>& oLibPath) const; |
1694 | |
1695 | // |
1696 | // Validating Items |
1697 | |
1698 | === modified file 'test/rbkt/testdriver_common.cpp' |
1699 | --- test/rbkt/testdriver_common.cpp 2011-09-06 14:04:01 +0000 |
1700 | +++ test/rbkt/testdriver_common.cpp 2011-11-04 11:47:43 +0000 |
1701 | @@ -527,8 +527,10 @@ |
1702 | } |
1703 | lModulePaths.push_back(paths); |
1704 | |
1705 | - // Add the default path for test modules. |
1706 | + // Add the default paths for test modules. |
1707 | zorba::String lDefPath = zorba::CMAKE_BINARY_DIR + "/TEST_URI_PATH"; |
1708 | lModulePaths.push_back(lDefPath); |
1709 | + lDefPath = zorba::CMAKE_BINARY_DIR + "/TEST_LIB_PATH"; |
1710 | + lModulePaths.push_back(lDefPath); |
1711 | sctx->setModulePaths(lModulePaths); |
1712 | } |
I realize this needs Changelog and doc updates.