Merge lp:~zorba-coders/zorba/feature-fetch_binary into lp:zorba
- feature-fetch_binary
- Merge into trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~zorba-coders/zorba/feature-fetch_binary |
Merge into: | lp:zorba |
Diff against target: |
978 lines (+437/-101) 34 files modified
include/zorba/uri_resolvers.h (+5/-1) modules/com/zorba-xquery/www/modules/CMakeLists.txt (+1/-1) modules/com/zorba-xquery/www/modules/fetch.xq (+93/-46) src/api/uri_resolver_wrappers.cpp (+3/-1) src/api/uriresolverimpl.cpp (+7/-4) src/api/uriresolverimpl.h (+9/-2) src/context/default_url_resolvers.cpp (+2/-1) src/context/uri_resolver.cpp (+4/-2) src/context/uri_resolver.h (+11/-1) src/functions/pregenerated/func_fetch.cpp (+25/-1) src/functions/pregenerated/func_fetch.h (+17/-0) src/functions/pregenerated/function_enum.h (+2/-1) src/runtime/fetch/fetch_impl.cpp (+115/-29) src/runtime/fetch/pregenerated/fetch.cpp (+22/-0) src/runtime/fetch/pregenerated/fetch.h (+36/-0) src/runtime/nodes/nodes_impl.cpp (+4/-2) src/runtime/spec/fetch/fetch.xml (+29/-3) src/runtime/visitors/pregenerated/planiter_visitor.h (+5/-0) src/runtime/visitors/pregenerated/printer_visitor.cpp (+14/-0) src/runtime/visitors/pregenerated/printer_visitor.h (+3/-0) test/rbkt/ExpQueryResults/zorba/fetch/fetch_seekable.xml.res (+1/-0) test/rbkt/ExpQueryResults/zorba/fetch/fetch_seekable_binary.xml.res (+1/-0) test/rbkt/ExpQueryResults/zorba/fetch/fetch_some_transcode.xml.res (+1/-0) test/rbkt/Queries/zorba/fetch/fetch_bogus1.xq (+1/-1) test/rbkt/Queries/zorba/fetch/fetch_bogus2.xq (+1/-1) test/rbkt/Queries/zorba/fetch/fetch_module1.xq (+1/-1) test/rbkt/Queries/zorba/fetch/fetch_module2.xq (+1/-1) test/rbkt/Queries/zorba/fetch/fetch_random_file.xq (+1/-1) test/rbkt/Queries/zorba/fetch/fetch_schema1.xq (+1/-1) test/rbkt/Queries/zorba/fetch/fetch_seekable.xml.res (+1/-0) test/rbkt/Queries/zorba/fetch/fetch_seekable.xq (+8/-0) test/rbkt/Queries/zorba/fetch/fetch_seekable_binary.xq (+8/-0) test/rbkt/Queries/zorba/fetch/fetch_some_transcode.xq (+3/-0) test/rbkt/Queries/zorba/fetch/iso-8859-1.txt (+1/-0) |
To merge this branch: | bzr merge lp:~zorba-coders/zorba/feature-fetch_binary |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Matthias Brantner | Pending | ||
Review via email: mp+105274@code.launchpad.net |
This proposal supersedes a proposal from 2012-05-09.
This proposal has been superseded by a proposal from 2012-05-09.
Commit message
- fetch:content-
- fetch:content#3 (with encoding parameter)
- StreamResource:
Description of the change
- fetch:content-
- fetch:content#3 (with encoding parameter)
- StreamResource:
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal | # |
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal | # |
The attempt to merge lp:~zorba-coders/zorba/feature-fetch_binary into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job feature-
finished. The final status was:
13 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
- 10835. By Matthias Brantner
-
fixed unintended indentation change
- 10836. By Matthias Brantner
-
improved error messages + warning fixes
- 10837. By Matthias Brantner
-
increase major version number of fetch module
- 10838. By Matthias Brantner
-
fetch became non-pure
- 10839. By Matthias Brantner
-
expose the SOME_CONTENT entity in the api
- 10840. By Matthias Brantner
-
merge + changelog
- 10841. By Matthias Brantner
-
change version of the fetch module (3.0 => 2.1)
- 10842. By Matthias Brantner
-
improved documentation
- 10843. By Matthias Brantner
-
code improvements as suggested by review
- 10844. By Matthias Brantner
-
added StaticContext:
:fetchBinary + StaticContext: :fetch with encoding to C++ api - 10845. By Matthias Brantner
-
documentation improvements
- 10846. By Matthias Brantner
-
merge
Unmerged revisions
Preview Diff
1 | === modified file 'ChangeLog' |
2 | === modified file 'include/zorba/uri_resolvers.h' |
3 | --- include/zorba/uri_resolvers.h 2012-05-03 12:31:51 +0000 |
4 | +++ include/zorba/uri_resolvers.h 2012-05-09 22:19:21 +0000 |
5 | @@ -84,9 +84,11 @@ |
6 | * @param aStreamReleaser A function pointer which is invoked once |
7 | * the StreamResource is destroyed. Normally this function will delete |
8 | * the std::istream object passed to it. |
9 | + * @param aIsStreamSeekable Determines whether the given stream is seekable. |
10 | */ |
11 | static StreamResource* create(std::istream* aStream, |
12 | - StreamReleaser aStreamReleaser); |
13 | + StreamReleaser aStreamReleaser, |
14 | + bool aIsStreamSeekable = false); |
15 | |
16 | /** |
17 | * @brief Retrieve the istream associated with this Resource. |
18 | @@ -99,6 +101,8 @@ |
19 | virtual StreamReleaser getStreamReleaser() = 0; |
20 | |
21 | virtual ~StreamResource() = 0; |
22 | + |
23 | + virtual bool isStreamSeekable() const = 0; |
24 | }; |
25 | |
26 | /** |
27 | |
28 | === modified file 'modules/com/zorba-xquery/www/modules/CMakeLists.txt' |
29 | --- modules/com/zorba-xquery/www/modules/CMakeLists.txt 2012-05-03 12:31:51 +0000 |
30 | +++ modules/com/zorba-xquery/www/modules/CMakeLists.txt 2012-05-09 22:19:21 +0000 |
31 | @@ -43,7 +43,7 @@ |
32 | DECLARE_ZORBA_SCHEMA(FILE xqdoc.xsd URI "http://www.xqdoc.org/1.0") |
33 | DECLARE_ZORBA_MODULE(FILE datetime.xq VERSION 2.0 |
34 | URI "http://www.zorba-xquery.com/modules/datetime") |
35 | -DECLARE_ZORBA_MODULE(FILE fetch.xq VERSION 2.0 |
36 | +DECLARE_ZORBA_MODULE(FILE fetch.xq VERSION 2.1 |
37 | URI "http://www.zorba-xquery.com/modules/fetch") |
38 | DECLARE_ZORBA_MODULE(FILE math.xq VERSION 2.0 |
39 | URI "http://www.zorba-xquery.com/modules/math") |
40 | |
41 | === modified file 'modules/com/zorba-xquery/www/modules/fetch.xq' |
42 | --- modules/com/zorba-xquery/www/modules/fetch.xq 2012-05-03 12:31:51 +0000 |
43 | +++ modules/com/zorba-xquery/www/modules/fetch.xq 2012-05-09 22:19:21 +0000 |
44 | @@ -17,15 +17,13 @@ |
45 | :) |
46 | |
47 | (:~ |
48 | - : This module provides functions to fetch the contents or the type |
49 | - : of the content for a resource identified by a URI. |
50 | - : For example, it fetches content for file or http resources if Zorba |
51 | - : allows file or http access, respectively. |
52 | - : |
53 | - : <p>The errors raised by functions of this module have the namespace |
54 | - : <tt>http://www.zorba-xquery.com/errors</tt> (associated with prefix zerr).</p> |
55 | - : |
56 | - : @see <a href="www.zorba-xquery.com_errors.html">http://www.zorba-xquery.com/errors</a> |
57 | + : <p>This module provides functions to fetch the content of a resource identified |
58 | + : by a URI. For example, it fetches the content of file or http resources.</p> |
59 | + : |
60 | + : <p>In order to retrieve such content, the functions use the |
61 | + : URI resolution and URL resolver process as documented at |
62 | + : <a href="../../html/uriresolvers.html"> |
63 | + : URI Resolvers</a>.</p> |
64 | : |
65 | : @author Matthias Brantner |
66 | : |
67 | @@ -38,23 +36,15 @@ |
68 | declare namespace zerr = "http://www.zorba-xquery.com/errors"; |
69 | |
70 | declare namespace ver = "http://www.zorba-xquery.com/options/versioning"; |
71 | -declare option ver:module-version "2.0"; |
72 | +declare option ver:module-version "2.1"; |
73 | |
74 | (:~ |
75 | : <p>Tries to fetch the resource referred to by the given URI.</p> |
76 | : |
77 | - : <p>In order to retrieve the content, the functions uses the |
78 | - : URI resolution and URL resolver process as documented at |
79 | - : <a href="../../html/uriresolvers.html"> |
80 | - : URI Resolvers</a>. Therefore, it queries all URI mappers |
81 | - : and resolvers with kind <tt>EntityData::SOME_CONTENT</tt>.</p> |
82 | + : <p>It queries all URI mappers and resolvers with kind |
83 | + : <tt>EntityData::SOME_CONTENT</tt>.</p> |
84 | : |
85 | - : <p>The function is annotated with the <tt>an:streamable</tt> |
86 | - : annotation, that is it returns a streamable string. A streamable |
87 | - : string can only be consumed once. Please see section "Streamable Strings" |
88 | - : in the <a href="../../html/options_and_annotations.html"> |
89 | - : documentation of Zorba's annotations</a>. |
90 | - : </p> |
91 | + : <p>The content is assumed to be UTF-8 encoded.</p> |
92 | : |
93 | : @param $uri the resource to fetch. |
94 | : @return the resource referred to by the given URI as streamble string. |
95 | @@ -73,28 +63,85 @@ |
96 | (:~ |
97 | : <p>Tries to fetch the resource referred to by the given URI.</p> |
98 | : |
99 | - : <p>In order to retrieve the content, the functions uses the |
100 | - : URI resolution and URL resolver process as documented at |
101 | - : <a href="../../html/uriresolvers.html"> |
102 | - : URI Resolvers</a>. Therefore, it queries all URI mappers |
103 | - : and resolvers with the specified entity kind.</p> |
104 | - : |
105 | - : <p>The function is annotated with the <tt>an:streamable</tt> |
106 | - : annotation, that is it returns a streamable string. A streamable |
107 | - : string can only be consumed once. Please see section "Streamable Strings" |
108 | - : in the <a href="../../html/options_and_annotations.html"> |
109 | - : documentation of Zorba's annotations</a>. |
110 | - : </p> |
111 | - : |
112 | - : @param $uri the resource to fetch. |
113 | - : @param $entityKind the kind of resource to fetch. |
114 | - : @return the resource referred to by the given URI as streamble string. |
115 | - : |
116 | - : @error zerr:ZXQP0025 if the URI could not be resolved |
117 | - : or did not resolve to a <tt>StreamResource</tt>. |
118 | - : |
119 | - : @see <a href="../../html/uriresolvers.html">URI Resolvers</a>. |
120 | - : @see <a href="../../html/options_and_annotations.html">Documentation of Zorba's annotations</a>. |
121 | - :) |
122 | - |
123 | -declare %an:streamable function fetch:content($uri as xs:string, $entityKind as xs:string) as xs:string external; |
124 | + : <p>It queries all URI mappers and resolvers with kind the specified |
125 | + : entity kind.</p> |
126 | + : |
127 | + : <p>The content is assumed to be UTF-8 encoded.</p> |
128 | + : |
129 | + : @param $uri the resource to fetch. |
130 | + : @param $entity-kind the kind of resource to fetch. |
131 | + : @return the resource referred to by the given URI as streamble string. |
132 | + : |
133 | + : @error zerr:ZXQP0025 if the URI could not be resolved |
134 | + : or did not resolve to a <tt>StreamResource</tt>. |
135 | + : |
136 | + : @see <a href="../../html/uriresolvers.html">URI Resolvers</a>. |
137 | + : @see <a href="../../html/options_and_annotations.html">Documentation of Zorba's annotations</a>. |
138 | + :) |
139 | +declare %an:streamable function fetch:content($uri as xs:string, $entity-kind as xs:string) |
140 | +as xs:string |
141 | +{ |
142 | + fetch:content($uri, $entity-kind, "UTF-8") |
143 | +}; |
144 | + |
145 | +(:~ |
146 | + : <p>Tries to fetch the resource referred to by the given URI.</p> |
147 | + : |
148 | + : <p>It queries all URI mappers and resolvers with kind the specified |
149 | + : entity kind.</p> |
150 | + : |
151 | + : @param $uri the resource to fetch. |
152 | + : @param $entity-kind the kind of resource to fetch. |
153 | + : @param $encoding the encoding of the content |
154 | + : @return the resource referred to by the given URI as streamble string. |
155 | + : |
156 | + : @error zerr:ZXQP0025 if the URI could not be resolved |
157 | + : or did not resolve to a <tt>StreamResource</tt>. |
158 | + : @error zerr:ZXQP0006 if the given encoding is invalid or not supported. |
159 | + : |
160 | + : @see <a href="../../html/uriresolvers.html">URI Resolvers</a>. |
161 | + : @see <a href="../../html/options_and_annotations.html">Documentation of Zorba's annotations</a>. |
162 | + :) |
163 | +declare %an:streamable function fetch:content( |
164 | + $uri as xs:string, |
165 | + $entity-kind as xs:string, |
166 | + $encoding as xs:string) |
167 | +as xs:string external; |
168 | + |
169 | +(:~ |
170 | + : <p>Tries to fetch the resource referred to by the given URI and |
171 | + : returning it as base64Binary.</p> |
172 | + : |
173 | + : <p>It queries all URI mappers and resolvers with kind |
174 | + : <tt>EntityData::SOME_CONTENT</tt>.</p> |
175 | + |
176 | + : @param $uri the resource to fetch. |
177 | + : @return the resource referred to by the given URI as streamble base64Binary. |
178 | + : |
179 | + : @error zerr:ZXQP0025 if the URI could not be resolved |
180 | + : or did not resolve to a <tt>StreamResource</tt>. |
181 | + :) |
182 | +declare %an:streamable function fetch:content-binary($uri as xs:string) |
183 | +as xs:base64Binary |
184 | +{ |
185 | + fetch:content-binary($uri, "SOME_CONTENT") |
186 | +}; |
187 | + |
188 | +(:~ |
189 | + : <p>Tries to fetch the resource referred to by the given URI and |
190 | + : returning it as base64Binary.</p> |
191 | + : |
192 | + : <p>It queries all URI mappers and resolvers with kind the specified |
193 | + : entity kind.</p> |
194 | + : |
195 | + : @param $uri the resource to fetch. |
196 | + : @param $entity-kind the kind of resource to fetch. |
197 | + : @return the resource referred to by the given URI as streamble base64Binary. |
198 | + : |
199 | + : @error zerr:ZXQP0025 if the URI could not be resolved |
200 | + : or did not resolve to a <tt>StreamResource</tt>. |
201 | + :) |
202 | +declare %an:streamable function fetch:content-binary( |
203 | + $uri as xs:string, |
204 | + $entity-kind as xs:string) |
205 | +as xs:base64Binary external; |
206 | |
207 | === modified file 'src/api/uri_resolver_wrappers.cpp' |
208 | --- src/api/uri_resolver_wrappers.cpp 2012-05-03 12:31:51 +0000 |
209 | +++ src/api/uri_resolver_wrappers.cpp 2012-05-09 22:19:21 +0000 |
210 | @@ -146,7 +146,9 @@ |
211 | // StreamResource, by passing the StreamReleaser to it and setting the |
212 | // user's StreamResource's StreamReleaser to nullptr. |
213 | lRetval = new internal::StreamResource(lUserStream->getStream(), |
214 | - lUserStream->getStreamReleaser()); |
215 | + lUserStream->getStreamReleaser(), |
216 | + "", |
217 | + lUserStream->isStreamSeekable()); |
218 | lUserStream->setStreamReleaser(nullptr); |
219 | } |
220 | #ifndef ZORBA_NO_FULL_TEXT |
221 | |
222 | === modified file 'src/api/uriresolverimpl.cpp' |
223 | --- src/api/uriresolverimpl.cpp 2012-05-03 12:31:51 +0000 |
224 | +++ src/api/uriresolverimpl.cpp 2012-05-09 22:19:21 +0000 |
225 | @@ -43,15 +43,18 @@ |
226 | } |
227 | |
228 | StreamResource* StreamResource::create(std::istream* aStream, |
229 | - StreamReleaser aStreamReleaser) |
230 | + StreamReleaser aStreamReleaser, |
231 | + bool aIsStreamSeekable) |
232 | { |
233 | - return new StreamResourceImpl(aStream, aStreamReleaser); |
234 | + return new StreamResourceImpl(aStream, aStreamReleaser, aIsStreamSeekable); |
235 | } |
236 | |
237 | StreamResourceImpl::StreamResourceImpl(std::istream* aStream, |
238 | - StreamReleaser aStreamReleaser) |
239 | + StreamReleaser aStreamReleaser, |
240 | + bool aIsStreamSeekable) |
241 | : theStream(aStream), |
242 | - theStreamReleaser(aStreamReleaser) |
243 | + theStreamReleaser(aStreamReleaser), |
244 | + theIsStreamSeekable(aIsStreamSeekable) |
245 | { |
246 | } |
247 | |
248 | |
249 | === modified file 'src/api/uriresolverimpl.h' |
250 | --- src/api/uriresolverimpl.h 2012-05-03 12:31:51 +0000 |
251 | +++ src/api/uriresolverimpl.h 2012-05-09 22:19:21 +0000 |
252 | @@ -39,14 +39,21 @@ |
253 | |
254 | virtual void destroy() const; |
255 | |
256 | + virtual bool isStreamSeekable() const { return theIsStreamSeekable; } |
257 | + |
258 | private: |
259 | |
260 | - StreamResourceImpl(std::istream* aStream, StreamReleaser aStreamReleaser); |
261 | + StreamResourceImpl( |
262 | + std::istream* aStream, |
263 | + StreamReleaser aStreamReleaser, |
264 | + bool aIsStreamSeekable); |
265 | |
266 | friend StreamResource* StreamResource::create(std::istream *aStream, |
267 | - StreamReleaser aStreamReleaser); |
268 | + StreamReleaser aStreamReleaser, |
269 | + bool aIsStreamSeekable); |
270 | std::istream* theStream; |
271 | StreamReleaser theStreamReleaser; |
272 | + bool theIsStreamSeekable; |
273 | |
274 | }; |
275 | |
276 | |
277 | === modified file 'src/context/default_url_resolvers.cpp' |
278 | --- src/context/default_url_resolvers.cpp 2012-05-03 12:31:51 +0000 |
279 | +++ src/context/default_url_resolvers.cpp 2012-05-09 22:19:21 +0000 |
280 | @@ -107,7 +107,8 @@ |
281 | zstring lPath = fs::get_normalized_path(aUrl); |
282 | if (fs::get_type(lPath) == fs::file) { |
283 | std::ifstream* lStream = new std::ifstream(lPath.c_str()); |
284 | - return new StreamResource(lStream, &fileStreamReleaser); |
285 | + return new StreamResource( |
286 | + lStream, &fileStreamReleaser, "", true /* seekable */); |
287 | } |
288 | return NULL; |
289 | } |
290 | |
291 | === modified file 'src/context/uri_resolver.cpp' |
292 | --- src/context/uri_resolver.cpp 2012-05-03 12:31:51 +0000 |
293 | +++ src/context/uri_resolver.cpp 2012-05-09 22:19:21 +0000 |
294 | @@ -46,11 +46,13 @@ |
295 | |
296 | StreamResource::StreamResource |
297 | (std::istream* aStream, StreamReleaser aStreamReleaser, |
298 | - zstring aStreamUrl /* = "" */) |
299 | + zstring aStreamUrl /* = "" */, |
300 | + bool aIsStreamSeekable) |
301 | : Resource(), |
302 | theStream(aStream), |
303 | theStreamReleaser(aStreamReleaser), |
304 | - theStreamUrl(aStreamUrl) |
305 | + theStreamUrl(aStreamUrl), |
306 | + theIsStreamSeekable(aIsStreamSeekable) |
307 | {} |
308 | |
309 | StreamResource::~StreamResource() |
310 | |
311 | === modified file 'src/context/uri_resolver.h' |
312 | --- src/context/uri_resolver.h 2012-05-03 12:31:51 +0000 |
313 | +++ src/context/uri_resolver.h 2012-05-09 22:19:21 +0000 |
314 | @@ -97,10 +97,13 @@ |
315 | * are certain unusual circumstances where a URLResolver may wish to |
316 | * return a stream over some other URL than the one passed to it. In |
317 | * that case, the URLResolver may pass the true URL here. |
318 | + * @param aIsStreamSeekable determines whether the stream passed as first |
319 | + * argument is seekable. |
320 | */ |
321 | StreamResource(std::istream* aStream, |
322 | StreamReleaser aStreamReleaser, |
323 | - zstring aStreamUrl = ""); |
324 | + zstring aStreamUrl = "", |
325 | + bool aIsStreamSeekable = false); |
326 | |
327 | virtual ~StreamResource(); |
328 | |
329 | @@ -127,11 +130,18 @@ |
330 | */ |
331 | zstring getStreamUrl(); |
332 | |
333 | + /** |
334 | + * @brief Returns true if the stream returned by getStream is seekable, |
335 | + * false otherwise. |
336 | + */ |
337 | + bool isStreamSeekable() const { return theIsStreamSeekable; } |
338 | + |
339 | private: |
340 | |
341 | std::istream* theStream; |
342 | StreamReleaser theStreamReleaser; |
343 | zstring theStreamUrl; |
344 | + bool theIsStreamSeekable; |
345 | }; |
346 | |
347 | /** |
348 | |
349 | === modified file 'src/functions/pregenerated/func_fetch.cpp' |
350 | --- src/functions/pregenerated/func_fetch.cpp 2012-05-03 12:31:51 +0000 |
351 | +++ src/functions/pregenerated/func_fetch.cpp 2012-05-09 22:19:21 +0000 |
352 | @@ -41,6 +41,16 @@ |
353 | return new FetchContentIterator(sctx, loc, argv); |
354 | } |
355 | |
356 | +PlanIter_t fn_zorba_fetch_content_binary::codegen( |
357 | + CompilerCB*, |
358 | + static_context* sctx, |
359 | + const QueryLoc& loc, |
360 | + std::vector<PlanIter_t>& argv, |
361 | + expr& ann) const |
362 | +{ |
363 | + return new FetchContentBinaryIterator(sctx, loc, argv); |
364 | +} |
365 | + |
366 | PlanIter_t fn_zorba_fetch_content_type::codegen( |
367 | CompilerCB*, |
368 | static_context* sctx, |
369 | @@ -60,8 +70,22 @@ |
370 | (createQName("http://www.zorba-xquery.com/modules/fetch","","content"), |
371 | GENV_TYPESYSTEM.STRING_TYPE_ONE, |
372 | GENV_TYPESYSTEM.STRING_TYPE_ONE, |
373 | + GENV_TYPESYSTEM.STRING_TYPE_ONE, |
374 | GENV_TYPESYSTEM.STRING_TYPE_ONE), |
375 | - FunctionConsts::FN_ZORBA_FETCH_CONTENT_2); |
376 | + FunctionConsts::FN_ZORBA_FETCH_CONTENT_3); |
377 | + |
378 | + } |
379 | + |
380 | + |
381 | + { |
382 | + |
383 | + |
384 | + DECL_WITH_KIND(sctx, fn_zorba_fetch_content_binary, |
385 | + (createQName("http://www.zorba-xquery.com/modules/fetch","","content-binary"), |
386 | + GENV_TYPESYSTEM.STRING_TYPE_ONE, |
387 | + GENV_TYPESYSTEM.STRING_TYPE_ONE, |
388 | + GENV_TYPESYSTEM.BASE64BINARY_TYPE_ONE), |
389 | + FunctionConsts::FN_ZORBA_FETCH_CONTENT_BINARY_2); |
390 | |
391 | } |
392 | |
393 | |
394 | === modified file 'src/functions/pregenerated/func_fetch.h' |
395 | --- src/functions/pregenerated/func_fetch.h 2012-05-03 12:31:51 +0000 |
396 | +++ src/functions/pregenerated/func_fetch.h 2012-05-09 22:19:21 +0000 |
397 | @@ -55,6 +55,23 @@ |
398 | }; |
399 | |
400 | |
401 | +//fn-zorba-fetch:content-binary |
402 | +class fn_zorba_fetch_content_binary : public function |
403 | +{ |
404 | +public: |
405 | + fn_zorba_fetch_content_binary(const signature& sig, FunctionConsts::FunctionKind kind) |
406 | + : |
407 | + function(sig, kind) |
408 | + { |
409 | + |
410 | + } |
411 | + |
412 | + bool accessesDynCtx() const { return true; } |
413 | + |
414 | + CODEGEN_DECL(); |
415 | +}; |
416 | + |
417 | + |
418 | //fn-zorba-fetch:content-type |
419 | class fn_zorba_fetch_content_type : public function |
420 | { |
421 | |
422 | === modified file 'src/functions/pregenerated/function_enum.h' |
423 | --- src/functions/pregenerated/function_enum.h 2012-05-08 03:09:12 +0000 |
424 | +++ src/functions/pregenerated/function_enum.h 2012-05-09 22:19:21 +0000 |
425 | @@ -137,7 +137,8 @@ |
426 | FN_TRACE_2, |
427 | OP_ZORBA_READ_LINE_0, |
428 | FN_ZORBA_UTIL_PRINT_1, |
429 | - FN_ZORBA_FETCH_CONTENT_2, |
430 | + FN_ZORBA_FETCH_CONTENT_3, |
431 | + FN_ZORBA_FETCH_CONTENT_BINARY_2, |
432 | FN_ZORBA_FETCH_CONTENT_TYPE_1, |
433 | FN_PUT_2, |
434 | FULL_TEXT_CURRENT_LANG_0, |
435 | |
436 | === modified file 'src/runtime/fetch/fetch_impl.cpp' |
437 | --- src/runtime/fetch/fetch_impl.cpp 2012-05-03 12:31:51 +0000 |
438 | +++ src/runtime/fetch/fetch_impl.cpp 2012-05-09 22:19:21 +0000 |
439 | @@ -15,6 +15,8 @@ |
440 | */ |
441 | #include "stdafx.h" |
442 | |
443 | +#include <zorba/transcode_stream.h> |
444 | + |
445 | #include "diagnostics/assert.h" |
446 | #include "diagnostics/xquery_diagnostics.h" |
447 | |
448 | @@ -30,33 +32,17 @@ |
449 | |
450 | /******************************************************************************* |
451 | ********************************************************************************/ |
452 | -void |
453 | -FetchContentIterator::destroyStream(std::istream& aStream) |
454 | -{ |
455 | - delete &aStream; |
456 | -} |
457 | - |
458 | -bool |
459 | -FetchContentIterator::nextImpl( |
460 | - store::Item_t& result, |
461 | - PlanState& aPlanState) const |
462 | -{ |
463 | - store::Item_t lUri; |
464 | - store::Item_t lEntityKind; |
465 | +std::auto_ptr<internal::Resource> |
466 | +getFetchResource( |
467 | + const store::Item_t& aUri, |
468 | + const store::Item_t& aKind, |
469 | + const static_context* aSctx, |
470 | + const QueryLoc& aLoc) |
471 | +{ |
472 | internal::EntityData::Kind lKind; |
473 | - zstring lKindStr; |
474 | - zstring lErrorMessage; |
475 | - std::auto_ptr<internal::Resource> lRes; |
476 | - internal::StreamResource* lStreamRes; |
477 | - |
478 | - PlanIteratorState* state; |
479 | - DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState); |
480 | - |
481 | - consumeNext(lUri, theChildren[0].getp(), aPlanState); |
482 | - consumeNext(lEntityKind, theChildren[1].getp(), aPlanState); |
483 | + zstring lKindStr = aKind->getStringValue(); |
484 | |
485 | // Figure out the EntityKind (any better way to do this?) |
486 | - lKindStr = lEntityKind->getStringValue(); |
487 | if ( ! lKindStr.compare("SOME_CONTENT")) { |
488 | lKind = internal::EntityData::SOME_CONTENT; |
489 | } |
490 | @@ -78,14 +64,15 @@ |
491 | throw XQUERY_EXCEPTION( |
492 | zerr::ZXQP0026_INVALID_ENUM_VALUE, |
493 | ERROR_PARAMS(lKindStr, "entityKind"), |
494 | - ERROR_LOC(loc)); |
495 | + ERROR_LOC(aLoc)); |
496 | } |
497 | |
498 | try { |
499 | // ask the uri mappers and resolvers to give |
500 | // me a resource of specified kind |
501 | - lRes = theSctx->resolve_uri( |
502 | - lUri->getStringValue(), |
503 | + zstring lErrorMessage; |
504 | + return aSctx->resolve_uri( |
505 | + aUri->getStringValue(), |
506 | lKind, |
507 | lErrorMessage); |
508 | |
509 | @@ -93,9 +80,41 @@ |
510 | throw XQUERY_EXCEPTION( |
511 | zerr::ZXQP0025_ITEM_CREATION_FAILED, |
512 | ERROR_PARAMS( e.what() ), |
513 | - ERROR_LOC( loc ) |
514 | + ERROR_LOC( aLoc ) |
515 | ); |
516 | } |
517 | +} |
518 | + |
519 | +/******************************************************************************* |
520 | +********************************************************************************/ |
521 | +void |
522 | +FetchContentIterator::destroyStream(std::istream& aStream) |
523 | +{ |
524 | + delete &aStream; |
525 | +} |
526 | + |
527 | +bool |
528 | +FetchContentIterator::nextImpl( |
529 | + store::Item_t& result, |
530 | + PlanState& aPlanState) const |
531 | +{ |
532 | + store::Item_t lUri; |
533 | + store::Item_t lEntityKind; |
534 | + store::Item_t lEncoding; |
535 | + zstring lEncodingStr("UTF-8"); |
536 | + std::auto_ptr<internal::Resource> lRes; |
537 | + internal::StreamResource* lStreamRes; |
538 | + |
539 | + PlanIteratorState* state; |
540 | + DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState); |
541 | + |
542 | + consumeNext(lUri, theChildren[0].getp(), aPlanState); |
543 | + consumeNext(lEntityKind, theChildren[1].getp(), aPlanState); |
544 | + consumeNext(lEncoding, theChildren[2].getp(), aPlanState); |
545 | + |
546 | + lEncodingStr = lEncoding->getStringValue(); |
547 | + |
548 | + lRes = getFetchResource(lUri, lEntityKind, theSctx, loc); |
549 | |
550 | lStreamRes = dynamic_cast<internal::StreamResource*>(lRes.get()); |
551 | if ( !lStreamRes ) { |
552 | @@ -106,13 +125,80 @@ |
553 | ); |
554 | } |
555 | |
556 | + if (transcode::is_necessary(lEncodingStr.c_str())) |
557 | + { |
558 | + if (!transcode::is_supported(lEncodingStr.c_str())) |
559 | + { |
560 | + throw XQUERY_EXCEPTION( |
561 | + zerr::ZXQP0006_UNKNOWN_ENCODING, |
562 | + ERROR_PARAMS( lEncodingStr.c_str() ), |
563 | + ERROR_LOC( loc ) |
564 | + ); |
565 | + } |
566 | + transcode::attach(*lStreamRes->getStream(), lEncodingStr.c_str()); |
567 | + } |
568 | + |
569 | // return the resource in a streamable string. This transfers memory |
570 | // ownership of the istream (via its StreamReleaser) to the StreamableString |
571 | // object, so we then remove the StreamReleaser from the StreamResource. |
572 | GENV_ITEMFACTORY->createStreamableString( |
573 | result, |
574 | *lStreamRes->getStream(), |
575 | - lStreamRes->getStreamReleaser() |
576 | + lStreamRes->getStreamReleaser(), |
577 | + lStreamRes->isStreamSeekable() |
578 | + ); |
579 | + lStreamRes->setStreamReleaser(nullptr); |
580 | + |
581 | + STACK_PUSH(result != NULL, state); |
582 | + |
583 | + STACK_END(state); |
584 | +} |
585 | + |
586 | + |
587 | +/******************************************************************************* |
588 | +********************************************************************************/ |
589 | +void |
590 | +FetchContentBinaryIterator::destroyStream(std::istream& aStream) |
591 | +{ |
592 | + delete &aStream; |
593 | +} |
594 | + |
595 | +bool |
596 | +FetchContentBinaryIterator::nextImpl( |
597 | + store::Item_t& result, |
598 | + PlanState& aPlanState) const |
599 | +{ |
600 | + store::Item_t lUri; |
601 | + store::Item_t lEntityKind; |
602 | + std::auto_ptr<internal::Resource> lRes; |
603 | + internal::StreamResource* lStreamRes; |
604 | + |
605 | + PlanIteratorState* state; |
606 | + DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState); |
607 | + |
608 | + consumeNext(lUri, theChildren[0].getp(), aPlanState); |
609 | + consumeNext(lEntityKind, theChildren[1].getp(), aPlanState); |
610 | + |
611 | + lRes = getFetchResource(lUri, lEntityKind, theSctx, loc); |
612 | + |
613 | + lStreamRes = dynamic_cast<internal::StreamResource*>(lRes.get()); |
614 | + if ( !lStreamRes ) { |
615 | + throw XQUERY_EXCEPTION( |
616 | + zerr::ZXQP0025_ITEM_CREATION_FAILED, |
617 | + ERROR_PARAMS( "Resource not available." ), |
618 | + ERROR_LOC( loc ) |
619 | + ); |
620 | + } |
621 | + |
622 | + // return the resource in a streamable base64. This transfers memory |
623 | + // ownership of the istream (via its StreamReleaser) to the StreamableBase64BinaryItem |
624 | + // object, so we then remove the StreamReleaser from the StreamResource. |
625 | + GENV_ITEMFACTORY->createStreamableBase64Binary( |
626 | + result, |
627 | + *lStreamRes->getStream(), |
628 | + lStreamRes->getStreamReleaser(), |
629 | + lStreamRes->isStreamSeekable(), |
630 | + false |
631 | ); |
632 | lStreamRes->setStreamReleaser(nullptr); |
633 | |
634 | |
635 | === modified file 'src/runtime/fetch/pregenerated/fetch.cpp' |
636 | --- src/runtime/fetch/pregenerated/fetch.cpp 2012-05-03 12:31:51 +0000 |
637 | +++ src/runtime/fetch/pregenerated/fetch.cpp 2012-05-09 22:19:21 +0000 |
638 | @@ -54,6 +54,28 @@ |
639 | // </FetchContentIterator> |
640 | |
641 | |
642 | +// <FetchContentBinaryIterator> |
643 | +FetchContentBinaryIterator::class_factory<FetchContentBinaryIterator> |
644 | +FetchContentBinaryIterator::g_class_factory; |
645 | + |
646 | + |
647 | +void FetchContentBinaryIterator::accept(PlanIterVisitor& v) const { |
648 | + v.beginVisit(*this); |
649 | + |
650 | + std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin(); |
651 | + std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end(); |
652 | + for ( ; lIter != lEnd; ++lIter ){ |
653 | + (*lIter)->accept(v); |
654 | + } |
655 | + |
656 | + v.endVisit(*this); |
657 | +} |
658 | + |
659 | +FetchContentBinaryIterator::~FetchContentBinaryIterator() {} |
660 | + |
661 | +// </FetchContentBinaryIterator> |
662 | + |
663 | + |
664 | // <FetchContentTypeIterator> |
665 | FetchContentTypeIterator::class_factory<FetchContentTypeIterator> |
666 | FetchContentTypeIterator::g_class_factory; |
667 | |
668 | === modified file 'src/runtime/fetch/pregenerated/fetch.h' |
669 | --- src/runtime/fetch/pregenerated/fetch.h 2012-05-03 12:31:51 +0000 |
670 | +++ src/runtime/fetch/pregenerated/fetch.h 2012-05-09 22:19:21 +0000 |
671 | @@ -73,6 +73,42 @@ |
672 | * |
673 | * Author: Matthias Brantner |
674 | */ |
675 | +class FetchContentBinaryIterator : public NaryBaseIterator<FetchContentBinaryIterator, PlanIteratorState> |
676 | +{ |
677 | +public: |
678 | + SERIALIZABLE_CLASS(FetchContentBinaryIterator); |
679 | + |
680 | + SERIALIZABLE_CLASS_CONSTRUCTOR2T(FetchContentBinaryIterator, |
681 | + NaryBaseIterator<FetchContentBinaryIterator, PlanIteratorState>); |
682 | + |
683 | + void serialize( ::zorba::serialization::Archiver& ar) |
684 | + { |
685 | + serialize_baseclass(ar, |
686 | + (NaryBaseIterator<FetchContentBinaryIterator, PlanIteratorState>*)this); |
687 | + } |
688 | + |
689 | + FetchContentBinaryIterator( |
690 | + static_context* sctx, |
691 | + const QueryLoc& loc, |
692 | + std::vector<PlanIter_t>& children) |
693 | + : |
694 | + NaryBaseIterator<FetchContentBinaryIterator, PlanIteratorState>(sctx, loc, children) |
695 | + {} |
696 | + |
697 | + virtual ~FetchContentBinaryIterator(); |
698 | + |
699 | +public: |
700 | + static void destroyStream(std::istream& aStream); |
701 | + void accept(PlanIterVisitor& v) const; |
702 | + |
703 | + bool nextImpl(store::Item_t& result, PlanState& aPlanState) const; |
704 | +}; |
705 | + |
706 | + |
707 | +/** |
708 | + * |
709 | + * Author: Matthias Brantner |
710 | + */ |
711 | class FetchContentTypeIterator : public NaryBaseIterator<FetchContentTypeIterator, PlanIteratorState> |
712 | { |
713 | public: |
714 | |
715 | === modified file 'src/runtime/nodes/nodes_impl.cpp' |
716 | --- src/runtime/nodes/nodes_impl.cpp 2012-05-03 12:31:51 +0000 |
717 | +++ src/runtime/nodes/nodes_impl.cpp 2012-05-09 22:19:21 +0000 |
718 | @@ -638,11 +638,13 @@ |
719 | lIterator->open(); |
720 | while(lIterator->next(lItem)) |
721 | { |
722 | - if(lItem->getNodeKind() == aNode->getNodeKind()) |
723 | + if (lItem->getNodeKind() == aNode->getNodeKind()) |
724 | + { |
725 | if(lItem->equals(aNode)) |
726 | break; |
727 | else |
728 | count++; |
729 | + } |
730 | } |
731 | lIterator->close(); |
732 | return count; |
733 | @@ -663,7 +665,7 @@ |
734 | PlanIteratorState* state; |
735 | DEFAULT_STACK_INIT(PlanIteratorState, state, planState); |
736 | |
737 | - if (consumeNext(inNode, theChildren[0], planState)); |
738 | + if (consumeNext(inNode, theChildren[0], planState)) |
739 | { |
740 | do |
741 | { |
742 | |
743 | === modified file 'src/runtime/spec/fetch/fetch.xml' |
744 | --- src/runtime/spec/fetch/fetch.xml 2012-05-03 12:31:51 +0000 |
745 | +++ src/runtime/spec/fetch/fetch.xml 2012-05-09 22:19:21 +0000 |
746 | @@ -16,7 +16,8 @@ |
747 | <zorba:function> |
748 | <zorba:signature localname="content" prefix="fn-zorba-fetch"> |
749 | <zorba:param>xs:string</zorba:param> |
750 | - <zorba:param>xs:string</zorba:param> |
751 | + <zorba:param>xs:string</zorba:param> <!-- entityKind --> |
752 | + <zorba:param>xs:string</zorba:param> <!-- encoding --> |
753 | <zorba:output>xs:string</zorba:output> |
754 | </zorba:signature> |
755 | |
756 | @@ -25,8 +26,33 @@ |
757 | </zorba:methods> |
758 | </zorba:function> |
759 | |
760 | - <zorba:method static="true" name="destroyStream" |
761 | - return="void"> |
762 | + <zorba:method static="true" name="destroyStream" return="void"> |
763 | + <zorba:param type="std::istream&" name="aStream"/> |
764 | + </zorba:method> |
765 | + |
766 | +</zorba:iterator> |
767 | + |
768 | +<!-- |
769 | +/********************************************************************* |
770 | +*********************************************************************/ |
771 | +--> |
772 | +<zorba:iterator name="FetchContentBinaryIterator"> |
773 | + |
774 | + <zorba:description author="Matthias Brantner"></zorba:description> |
775 | + |
776 | + <zorba:function> |
777 | + <zorba:signature localname="content-binary" prefix="fn-zorba-fetch"> |
778 | + <zorba:param>xs:string</zorba:param> |
779 | + <zorba:param>xs:string</zorba:param> |
780 | + <zorba:output>xs:base64Binary</zorba:output> |
781 | + </zorba:signature> |
782 | + |
783 | + <zorba:methods> |
784 | + <zorba:accessesDynCtx returnValue="true"/> |
785 | + </zorba:methods> |
786 | + </zorba:function> |
787 | + |
788 | + <zorba:method static="true" name="destroyStream" return="void"> |
789 | <zorba:param type="std::istream&" name="aStream"/> |
790 | </zorba:method> |
791 | |
792 | |
793 | === modified file 'src/runtime/visitors/pregenerated/planiter_visitor.h' |
794 | --- src/runtime/visitors/pregenerated/planiter_visitor.h 2012-05-03 12:31:51 +0000 |
795 | +++ src/runtime/visitors/pregenerated/planiter_visitor.h 2012-05-09 22:19:21 +0000 |
796 | @@ -189,6 +189,8 @@ |
797 | |
798 | class FetchContentIterator; |
799 | |
800 | + class FetchContentBinaryIterator; |
801 | + |
802 | class FetchContentTypeIterator; |
803 | |
804 | class FnPutIterator; |
805 | @@ -897,6 +899,9 @@ |
806 | virtual void beginVisit ( const FetchContentIterator& ) = 0; |
807 | virtual void endVisit ( const FetchContentIterator& ) = 0; |
808 | |
809 | + virtual void beginVisit ( const FetchContentBinaryIterator& ) = 0; |
810 | + virtual void endVisit ( const FetchContentBinaryIterator& ) = 0; |
811 | + |
812 | virtual void beginVisit ( const FetchContentTypeIterator& ) = 0; |
813 | virtual void endVisit ( const FetchContentTypeIterator& ) = 0; |
814 | |
815 | |
816 | === modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp' |
817 | --- src/runtime/visitors/pregenerated/printer_visitor.cpp 2012-05-03 12:31:51 +0000 |
818 | +++ src/runtime/visitors/pregenerated/printer_visitor.cpp 2012-05-09 22:19:21 +0000 |
819 | @@ -1219,6 +1219,20 @@ |
820 | // </FetchContentIterator> |
821 | |
822 | |
823 | +// <FetchContentBinaryIterator> |
824 | +void PrinterVisitor::beginVisit ( const FetchContentBinaryIterator& a) { |
825 | + thePrinter.startBeginVisit("FetchContentBinaryIterator", ++theId); |
826 | + printCommons( &a, theId ); |
827 | + thePrinter.endBeginVisit( theId ); |
828 | +} |
829 | + |
830 | +void PrinterVisitor::endVisit ( const FetchContentBinaryIterator& ) { |
831 | + thePrinter.startEndVisit(); |
832 | + thePrinter.endEndVisit(); |
833 | +} |
834 | +// </FetchContentBinaryIterator> |
835 | + |
836 | + |
837 | // <FetchContentTypeIterator> |
838 | void PrinterVisitor::beginVisit ( const FetchContentTypeIterator& a) { |
839 | thePrinter.startBeginVisit("FetchContentTypeIterator", ++theId); |
840 | |
841 | === modified file 'src/runtime/visitors/pregenerated/printer_visitor.h' |
842 | --- src/runtime/visitors/pregenerated/printer_visitor.h 2012-05-03 12:31:51 +0000 |
843 | +++ src/runtime/visitors/pregenerated/printer_visitor.h 2012-05-09 22:19:21 +0000 |
844 | @@ -286,6 +286,9 @@ |
845 | void beginVisit( const FetchContentIterator& ); |
846 | void endVisit ( const FetchContentIterator& ); |
847 | |
848 | + void beginVisit( const FetchContentBinaryIterator& ); |
849 | + void endVisit ( const FetchContentBinaryIterator& ); |
850 | + |
851 | void beginVisit( const FetchContentTypeIterator& ); |
852 | void endVisit ( const FetchContentTypeIterator& ); |
853 | |
854 | |
855 | === added file 'test/rbkt/ExpQueryResults/zorba/fetch/fetch_seekable.xml.res' |
856 | --- test/rbkt/ExpQueryResults/zorba/fetch/fetch_seekable.xml.res 1970-01-01 00:00:00 +0000 |
857 | +++ test/rbkt/ExpQueryResults/zorba/fetch/fetch_seekable.xml.res 2012-05-09 22:19:21 +0000 |
858 | @@ -0,0 +1,1 @@ |
859 | +true true true |
860 | |
861 | === added file 'test/rbkt/ExpQueryResults/zorba/fetch/fetch_seekable_binary.xml.res' |
862 | --- test/rbkt/ExpQueryResults/zorba/fetch/fetch_seekable_binary.xml.res 1970-01-01 00:00:00 +0000 |
863 | +++ test/rbkt/ExpQueryResults/zorba/fetch/fetch_seekable_binary.xml.res 2012-05-09 22:19:21 +0000 |
864 | @@ -0,0 +1,1 @@ |
865 | +8 5Pb8Cg== |
866 | |
867 | === added file 'test/rbkt/ExpQueryResults/zorba/fetch/fetch_some_transcode.xml.res' |
868 | --- test/rbkt/ExpQueryResults/zorba/fetch/fetch_some_transcode.xml.res 1970-01-01 00:00:00 +0000 |
869 | +++ test/rbkt/ExpQueryResults/zorba/fetch/fetch_some_transcode.xml.res 2012-05-09 22:19:21 +0000 |
870 | @@ -0,0 +1,1 @@ |
871 | +äöü |
872 | |
873 | === modified file 'test/rbkt/Queries/zorba/fetch/fetch_bogus1.xq' |
874 | --- test/rbkt/Queries/zorba/fetch/fetch_bogus1.xq 2012-05-03 12:31:51 +0000 |
875 | +++ test/rbkt/Queries/zorba/fetch/fetch_bogus1.xq 2012-05-09 22:19:21 +0000 |
876 | @@ -1,4 +1,4 @@ |
877 | (: Fetch with unknown entity kind :) |
878 | -import module namespace fetch = "http://www.zorba-xquery.com/modules/fetch#2.0"; |
879 | +import module namespace fetch = "http://www.zorba-xquery.com/modules/fetch"; |
880 | |
881 | fetch:content("http://www.zorba-xquery.com/modules/ext", "NOTHING") |
882 | |
883 | === modified file 'test/rbkt/Queries/zorba/fetch/fetch_bogus2.xq' |
884 | --- test/rbkt/Queries/zorba/fetch/fetch_bogus2.xq 2012-05-03 12:31:51 +0000 |
885 | +++ test/rbkt/Queries/zorba/fetch/fetch_bogus2.xq 2012-05-09 22:19:21 +0000 |
886 | @@ -1,4 +1,4 @@ |
887 | (: Fetch a valid module URI but as SOME_CONTENT :) |
888 | -import module namespace fetch = "http://www.zorba-xquery.com/modules/fetch#2.0"; |
889 | +import module namespace fetch = "http://www.zorba-xquery.com/modules/fetch"; |
890 | |
891 | fetch:content("http://www.flworfound.org/modules/ext", "SOME_CONTENT") |
892 | |
893 | === modified file 'test/rbkt/Queries/zorba/fetch/fetch_module1.xq' |
894 | --- test/rbkt/Queries/zorba/fetch/fetch_module1.xq 2012-05-03 12:31:51 +0000 |
895 | +++ test/rbkt/Queries/zorba/fetch/fetch_module1.xq 2012-05-09 22:19:21 +0000 |
896 | @@ -1,4 +1,4 @@ |
897 | (: Fetch a module's content :) |
898 | -import module namespace fetch = "http://www.zorba-xquery.com/modules/fetch#2.0"; |
899 | +import module namespace fetch = "http://www.zorba-xquery.com/modules/fetch"; |
900 | |
901 | fetch:content("http://www.zorba-xquery.com/modules/ext", "MODULE") |
902 | |
903 | === modified file 'test/rbkt/Queries/zorba/fetch/fetch_module2.xq' |
904 | --- test/rbkt/Queries/zorba/fetch/fetch_module2.xq 2012-05-03 12:31:51 +0000 |
905 | +++ test/rbkt/Queries/zorba/fetch/fetch_module2.xq 2012-05-09 22:19:21 +0000 |
906 | @@ -1,4 +1,4 @@ |
907 | (: Fetch a module's content with versioning :) |
908 | -import module namespace fetch = "http://www.zorba-xquery.com/modules/fetch#2.0"; |
909 | +import module namespace fetch = "http://www.zorba-xquery.com/modules/fetch"; |
910 | |
911 | fetch:content("http://www.zorba-xquery.com/modules/ext#1.0", "MODULE") |
912 | |
913 | === modified file 'test/rbkt/Queries/zorba/fetch/fetch_random_file.xq' |
914 | --- test/rbkt/Queries/zorba/fetch/fetch_random_file.xq 2012-02-01 17:13:01 +0000 |
915 | +++ test/rbkt/Queries/zorba/fetch/fetch_random_file.xq 2012-05-09 22:19:21 +0000 |
916 | @@ -1,4 +1,4 @@ |
917 | (: Fetch a random file from the filesystem :) |
918 | -import module namespace fetch = "http://www.zorba-xquery.com/modules/fetch#2.0"; |
919 | +import module namespace fetch = "http://www.zorba-xquery.com/modules/fetch"; |
920 | |
921 | fetch:content("http://www.zorba-xquery.com/random-file", "SOME_CONTENT") |
922 | |
923 | === modified file 'test/rbkt/Queries/zorba/fetch/fetch_schema1.xq' |
924 | --- test/rbkt/Queries/zorba/fetch/fetch_schema1.xq 2012-05-03 12:31:51 +0000 |
925 | +++ test/rbkt/Queries/zorba/fetch/fetch_schema1.xq 2012-05-09 22:19:21 +0000 |
926 | @@ -1,5 +1,5 @@ |
927 | (: Fetch a schemas's content :) |
928 | -import module namespace fetch = "http://www.zorba-xquery.com/modules/fetch#2.0"; |
929 | +import module namespace fetch = "http://www.zorba-xquery.com/modules/fetch"; |
930 | |
931 | fn:parse-xml( |
932 | fetch:content("http://www.zorba-xquery.com/modules/theschema", "SCHEMA") |
933 | |
934 | === added file 'test/rbkt/Queries/zorba/fetch/fetch_seekable.xml.res' |
935 | --- test/rbkt/Queries/zorba/fetch/fetch_seekable.xml.res 1970-01-01 00:00:00 +0000 |
936 | +++ test/rbkt/Queries/zorba/fetch/fetch_seekable.xml.res 2012-05-09 22:19:21 +0000 |
937 | @@ -0,0 +1,1 @@ |
938 | +true true true |
939 | |
940 | === added file 'test/rbkt/Queries/zorba/fetch/fetch_seekable.xq' |
941 | --- test/rbkt/Queries/zorba/fetch/fetch_seekable.xq 1970-01-01 00:00:00 +0000 |
942 | +++ test/rbkt/Queries/zorba/fetch/fetch_seekable.xq 2012-05-09 22:19:21 +0000 |
943 | @@ -0,0 +1,8 @@ |
944 | +import module namespace fetch = "http://www.zorba-xquery.com/modules/fetch"; |
945 | + |
946 | +import module namespace s = "http://www.zorba-xquery.com/modules/string"; |
947 | + |
948 | +(: make sure the returned string is streamable and can be consumed twice, i.e. is seekable :) |
949 | +let $x := fetch:content(fn:resolve-uri("iso-8859-1.txt")) |
950 | +return (s:is-streamable($x), string-length($x) gt 0, string-length($x) gt 0) |
951 | + |
952 | |
953 | === added file 'test/rbkt/Queries/zorba/fetch/fetch_seekable_binary.xq' |
954 | --- test/rbkt/Queries/zorba/fetch/fetch_seekable_binary.xq 1970-01-01 00:00:00 +0000 |
955 | +++ test/rbkt/Queries/zorba/fetch/fetch_seekable_binary.xq 2012-05-09 22:19:21 +0000 |
956 | @@ -0,0 +1,8 @@ |
957 | +import module namespace fetch = "http://www.zorba-xquery.com/modules/fetch"; |
958 | + |
959 | +import module namespace b = "http://www.zorba-xquery.com/modules/converters/base64"; |
960 | + |
961 | +(: make sure the returned string is streamable and can be consumed twice, i.e. is seekable :) |
962 | +let $x := fetch:content-binary(fn:resolve-uri("iso-8859-1.txt")) |
963 | +return (string-length(xs:string($x)), $x) |
964 | + |
965 | |
966 | === added file 'test/rbkt/Queries/zorba/fetch/fetch_some_transcode.xq' |
967 | --- test/rbkt/Queries/zorba/fetch/fetch_some_transcode.xq 1970-01-01 00:00:00 +0000 |
968 | +++ test/rbkt/Queries/zorba/fetch/fetch_some_transcode.xq 2012-05-09 22:19:21 +0000 |
969 | @@ -0,0 +1,3 @@ |
970 | +import module namespace fetch = "http://www.zorba-xquery.com/modules/fetch"; |
971 | + |
972 | +fetch:content(resolve-uri("iso-8859-1.txt"), "SOME_CONTENT", "ISO-8859-1") |
973 | |
974 | === added file 'test/rbkt/Queries/zorba/fetch/iso-8859-1.txt' |
975 | --- test/rbkt/Queries/zorba/fetch/iso-8859-1.txt 1970-01-01 00:00:00 +0000 |
976 | +++ test/rbkt/Queries/zorba/fetch/iso-8859-1.txt 2012-05-09 22:19:21 +0000 |
977 | @@ -0,0 +1,1 @@ |
978 | +äöü |
Validation queue starting for merge proposal. zorbatest. lambda. nu:8080/ remotequeue/ feature- fetch_binary- 2012-05- 09T01-28- 08.563Z/ log.html
Log at: http://