Merge lp:~zorba-coders/zorba/bug-996084-reuse-stream into lp:zorba

Proposed by Matthias Brantner on 2012-05-08
Status: Merged
Approved by: Chris Hillery on 2012-05-09
Approved revision: 10826
Merged at revision: 10831
Proposed branch: lp:~zorba-coders/zorba/bug-996084-reuse-stream
Merge into: lp:zorba
Diff against target: 435 lines (+198/-22)
18 files modified
ChangeLog (+2/-0)
modules/com/zorba-xquery/www/modules/converters/base64.xq (+21/-1)
src/functions/pregenerated/func_base64.cpp (+13/-0)
src/functions/pregenerated/function_enum.h (+1/-0)
src/runtime/base64/base64_impl.cpp (+66/-11)
src/runtime/spec/base64/base64.xml (+6/-1)
src/store/api/item_factory.h (+13/-0)
src/store/naive/atomic_items.cpp (+30/-0)
src/store/naive/atomic_items.h (+6/-9)
src/store/naive/simple_item_factory.cpp (+8/-0)
src/store/naive/simple_item_factory.h (+4/-0)
test/rbkt/ExpQueryResults/zorba/base64/decode_iso-8859-1.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/base64/decode_iso-8859-1_file.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/base64/reuse-stream.xml.res (+1/-0)
test/rbkt/Queries/zorba/base64/decode_iso-8859-1.xq (+3/-0)
test/rbkt/Queries/zorba/base64/decode_iso-8859-1_file.xq (+5/-0)
test/rbkt/Queries/zorba/base64/iso-8859-1.txt (+1/-0)
test/rbkt/Queries/zorba/base64/reuse-stream.xq (+16/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug-996084-reuse-stream
Reviewer Review Type Date Requested Status
Chris Hillery 2012-05-08 Approve on 2012-05-09
Dennis Knochenwefel 2012-05-08 Approve on 2012-05-08
William Candillon 2012-05-08 Approve on 2012-05-08
Matthias Brantner Approve on 2012-05-08
Review via email: mp+105025@code.launchpad.net

This proposal supersedes a proposal from 2012-05-08.

Commit message

- Add the ability to create a StreamableStringItem that re-uses the stream from another Streamable*Item (in a memory-ownership-safe way). Fixed bug #996084 (crash in Streamable*Item with file module)

- Add a base64:decode#2 function that also does transcoding to utf-8

Description of the change

Add the ability to create a StreamableStringItem that re-uses the stream from another Streamable*Item (in a memory-ownership-safe way).

Added a base64:decode#2 function that also does transcoding to utf-8

To post a comment you must log in.
Chris Hillery (ceejatec) : Posted in a previous version of this proposal
review: Approve
Chris Hillery (ceejatec) wrote : Posted in a previous version of this proposal

Two things I'm not totally sure/happy about:

1. The name createSharedStreamableString(). Probably createSharingStreamableString() would be more apt, but it doesn't seem clear to me. Maybe I should have just stuck with overloading createStreamableString(). Thoughts?

2. I had to initialize theIstream in the initializer block of the new StreamableStringItem constructor, because theIstream is a reference. Therefore, the ZORBA_ASSERT() in that constructor will probably never go off - if the streamable_dependent isn't streamable, we'll have already thrown an exception in the call to getStream() in the initializer block. I can't see a way around this.

review: Approve
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-996084-reuse-stream-2012-05-08T03-38-00.431Z is finished. The final status was:

All tests succeeded!

Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 1 Approve, 3 Pending.

William Candillon (wcandillon) wrote :

Should the implementation of base64:decode#1 be:

declare function base64:decode($base64 as xs:base64Binary) as xs:string { base64:decode($base64, "UTF-8")};

?

review: Needs Information
Chris Hillery (ceejatec) wrote :

I don't believe it can be done that way, because the base64 module is an internally-implemented module. In release mode, the .xq file for the module won't even be parsed, so it cannot contain user-defined functions. Matthias, correct me if I'm wrong.

William Candillon (wcandillon) wrote :

yes correct, sorry I missed that.

On Tue, May 8, 2012 at 12:23 PM, Chris Hillery
<email address hidden> wrote:
> I don't believe it can be done that way, because the base64 module is an internally-implemented module. In release mode, the .xq file for the module won't even be parsed, so it cannot contain user-defined functions. Matthias, correct me if I'm wrong.
> --
> https://code.launchpad.net/~zorba-coders/zorba/bug-996084-reuse-stream/+merge/105025
> You are reviewing the proposed merge of lp:~zorba-coders/zorba/bug-996084-reuse-stream into lp:zorba.

review: Approve
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-996084-reuse-stream-2012-05-08T10-33-54.117Z is finished. The final status was:

All tests succeeded!

Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 2 Approve, 2 Pending.

> I don't believe it can be done that way, because the base64 module is an
> internally-implemented module. In release mode, the .xq file for the module
> won't even be parsed, so it cannot contain user-defined functions. Matthias,
> correct me if I'm wrong.
It could but it would require us to process the .xq file at runtime which I wanted to avoid given the fact that it doesn't make the C++ implementation too complex.

I tested it and it works.

review: Approve
Chris Hillery (ceejatec) :
review: Approve
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-996084-reuse-stream-2012-05-09T00-51-58.501Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2012-05-07 23:43:04 +0000
3+++ ChangeLog 2012-05-08 03:24:31 +0000
4@@ -18,6 +18,7 @@
5 - fn:has-children#0
6 - fn:nilled#0
7 - fn:path
8+ * Added base64:decode#2 function which also does transcoding
9 * Extended API for Python, Java, PHP and Ruby.
10 * Add jvm classpath to zorbacmd and to Zorba API. Tracked by #931816
11 * Added full-text module.
12@@ -49,6 +50,7 @@
13 * Fixed bug #912586, #912593 and #912722 (assertion failures with lax validation)
14 * Fixed bug #921458 (file:read-text-lines() blocking)
15 * Fixed bug #981405 (do not hoist expr containing try-catch variables out of the associated try-catch expression)
16+ * Fixed bug #996084 (crash in Streamable*Item with file module)
17 * Fixed bug #947627 (throw XQST0099 if more than one declarations of context item type in same module)
18 * Fixed bug #980526 (no-copy rule bug due to global var being set in "distant" udf)
19 * Fixed bug #949910 (has-children may be invoked on all nodes). Internally, zorba::store::Item::getChildren() now returns NULL on node classes without offspring (instead of raising an error).
20
21=== modified file 'modules/com/zorba-xquery/www/modules/converters/base64.xq'
22--- modules/com/zorba-xquery/www/modules/converters/base64.xq 2012-05-03 12:31:51 +0000
23+++ modules/com/zorba-xquery/www/modules/converters/base64.xq 2012-05-08 03:24:31 +0000
24@@ -25,6 +25,8 @@
25 :)
26 module namespace base64 = "http://www.zorba-xquery.com/modules/converters/base64";
27
28+declare namespace zerr = "http://www.zorba-xquery.com/errors";
29+
30 declare namespace ver = "http://www.zorba-xquery.com/options/versioning";
31 declare option ver:module-version "2.0";
32
33@@ -32,7 +34,7 @@
34 : Decode a xs:base64Binary.
35 :
36 : The function assumes that the content after decoding is valid
37- : UTF-8.
38+ : UTF-8.
39 :
40 : @param $base64 The xs:base64Binary item to decode
41 : @return the base64 decoded value as string
42@@ -41,6 +43,24 @@
43 as xs:string external;
44
45 (:~
46+ : Decode a xs:base64Binary.
47+ :
48+ : The function assumes that the content after decoding has
49+ : the given encoding.
50+ :
51+ : @param $base64 The xs:base64Binary item to decode
52+ : @param $encoding The encoding of the string after base64 decoding it.
53+ :
54+ : @return the base64 decoded value as string
55+ :
56+ : @error zerr:ZXQP0006 if the given encoding is invalid or not supported.
57+ :)
58+declare function base64:decode(
59+ $base64 as xs:base64Binary,
60+ $encoding as xs:string)
61+as xs:string external;
62+
63+(:~
64 : Encode a xs:string as xs:base64Binary.
65 :
66 : @param $string The item whose string-value should be encoded
67
68=== modified file 'src/functions/pregenerated/func_base64.cpp'
69--- src/functions/pregenerated/func_base64.cpp 2012-05-03 12:31:51 +0000
70+++ src/functions/pregenerated/func_base64.cpp 2012-05-08 03:24:31 +0000
71@@ -68,6 +68,19 @@
72 {
73
74
75+ DECL_WITH_KIND(sctx, fn_zorba_base64_decode,
76+ (createQName("http://www.zorba-xquery.com/modules/converters/base64","","decode"),
77+ GENV_TYPESYSTEM.BASE64BINARY_TYPE_ONE,
78+ GENV_TYPESYSTEM.STRING_TYPE_ONE,
79+ GENV_TYPESYSTEM.STRING_TYPE_ONE),
80+ FunctionConsts::FN_ZORBA_BASE64_DECODE_2);
81+
82+ }
83+
84+
85+ {
86+
87+
88 DECL_WITH_KIND(sctx, fn_zorba_base64_encode,
89 (createQName("http://www.zorba-xquery.com/modules/converters/base64","","encode"),
90 GENV_TYPESYSTEM.STRING_TYPE_ONE,
91
92=== modified file 'src/functions/pregenerated/function_enum.h'
93--- src/functions/pregenerated/function_enum.h 2012-05-03 12:31:51 +0000
94+++ src/functions/pregenerated/function_enum.h 2012-05-08 03:24:31 +0000
95@@ -36,6 +36,7 @@
96 FN_RESOLVE_URI_1,
97 FN_RESOLVE_URI_2,
98 FN_ZORBA_BASE64_DECODE_1,
99+ FN_ZORBA_BASE64_DECODE_2,
100 FN_ZORBA_BASE64_ENCODE_1,
101 OP_IS_SAME_NODE_2,
102 OP_NODE_BEFORE_2,
103
104=== modified file 'src/runtime/base64/base64_impl.cpp'
105--- src/runtime/base64/base64_impl.cpp 2012-05-03 12:31:51 +0000
106+++ src/runtime/base64/base64_impl.cpp 2012-05-08 03:24:31 +0000
107@@ -15,6 +15,9 @@
108 */
109 #include "stdafx.h"
110
111+#include <sstream>
112+#include <zorba/transcode_stream.h>
113+
114 #include "system/globalenv.h"
115
116 #include "diagnostics/xquery_diagnostics.h"
117@@ -33,6 +36,7 @@
118 {
119 store::Item_t lItem;
120 zstring lResultString;
121+ zstring lEncoding("UTF-8");
122 const char* lContent;
123 size_t lSize;
124 result = NULL;
125@@ -42,21 +46,45 @@
126
127 consumeNext(lItem, theChildren[0].getp(), planState);
128
129+ if (theChildren.size() == 2)
130+ {
131+ store::Item_t lEncodingItem;
132+ consumeNext(lEncodingItem, theChildren[1].getp(), planState);
133+ lEncoding = lEncodingItem->getStringValue();
134+
135+ if (!transcode::is_supported(lEncoding.c_str()))
136+ {
137+ throw XQUERY_EXCEPTION(
138+ zerr::ZXQP0006_UNKNOWN_ENCODING,
139+ ERROR_PARAMS( lEncoding ),
140+ ERROR_LOC( loc )
141+ );
142+ }
143+ }
144+
145 if (lItem->isStreamable())
146 {
147 if (lItem->isEncoded())
148 {
149- // decode and eventually transcode
150 lResultString = Base64::decode(lItem->getStream());
151 }
152 else
153 {
154- // streamable string eventually transcoding
155- GENV_ITEMFACTORY->createStreamableString(
156- result,
157- lItem->getStream(),
158- lItem->getStreamReleaser(),
159- lItem->isSeekable());
160+ if (transcode::is_necessary(lEncoding.c_str()))
161+ {
162+ transcode::attach(lItem->getStream(), lEncoding.c_str());
163+ GENV_ITEMFACTORY->createStreamableString(
164+ result,
165+ lItem->getStream(),
166+ lItem->getStreamReleaser(),
167+ lItem->isSeekable());
168+ }
169+ else
170+ {
171+ GENV_ITEMFACTORY->createSharedStreamableString(
172+ result,
173+ lItem);
174+ }
175 }
176 }
177 else
178@@ -74,10 +102,37 @@
179 {
180 lResultString.insert(0, lContent, lSize);
181 }
182- }
183- if (!result) // otherwise it's a streamable string already
184- {
185- GENV_ITEMFACTORY->createString(result, lResultString);
186+
187+ if (transcode::is_necessary(lEncoding.c_str()))
188+ {
189+ try
190+ {
191+ zstring lTranscodedString;
192+ transcode::stream<std::istringstream> lTranscoder(
193+ lEncoding.c_str(),
194+ lResultString.c_str()
195+ );
196+ char buf[1024];
197+ while (lTranscoder.good())
198+ {
199+ lTranscoder.read(buf, 1024);
200+ lTranscodedString.append(buf, lTranscoder.gcount());
201+ }
202+ GENV_ITEMFACTORY->createString(result, lTranscodedString);
203+ }
204+ catch (ZorbaException& e)
205+ {
206+ throw XQUERY_EXCEPTION(
207+ zerr::ZOSE0006_TRANSCODING_ERROR,
208+ ERROR_PARAMS( e.what() ),
209+ ERROR_LOC( loc )
210+ );
211+ }
212+ }
213+ else
214+ {
215+ GENV_ITEMFACTORY->createString(result, lResultString);
216+ }
217 }
218 STACK_PUSH (true, state);
219
220
221=== modified file 'src/runtime/spec/base64/base64.xml'
222--- src/runtime/spec/base64/base64.xml 2012-05-03 12:31:51 +0000
223+++ src/runtime/spec/base64/base64.xml 2012-05-08 03:24:31 +0000
224@@ -25,8 +25,13 @@
225 <zorba:param>xs:base64Binary</zorba:param>
226 <zorba:output>xs:string</zorba:output>
227 </zorba:signature>
228+ <zorba:signature localname="decode" prefix="fn-zorba-base64">
229+ <zorba:param>xs:base64Binary</zorba:param>
230+ <zorba:param>xs:string</zorba:param> <!-- encoding -->
231+ <zorba:output>xs:string</zorba:output>
232+ </zorba:signature>
233 </zorba:function>
234-
235+
236 </zorba:iterator>
237
238 <!--
239
240=== modified file 'src/store/api/item_factory.h'
241--- src/store/api/item_factory.h 2012-05-03 12:31:51 +0000
242+++ src/store/api/item_factory.h 2012-05-08 03:24:31 +0000
243@@ -97,6 +97,19 @@
244 bool seekable = false) = 0;
245
246 /**
247+ * Create a StreamableStringItem which re-uses the stream from another
248+ * Streamable*Item. This will maintain a reference to the original
249+ * item to ensure the stream is not cleaned up before we are done with it.
250+ *
251+ * It only makes sense to use this method if either (a) the dependent item's
252+ * stream is seekable and hence re-usable, or (b) you are sure that the
253+ * dependent item will not be utilized after this new item is created.
254+ */
255+ virtual bool createSharedStreamableString(
256+ Item_t& result,
257+ Item_t& streamble_dependent) = 0;
258+
259+ /**
260 * Specification: [http://www.w3.org/TR/xmlschema-2/#normalizedString]
261 * @param value string representation of the value
262 */
263
264=== modified file 'src/store/naive/atomic_items.cpp'
265--- src/store/naive/atomic_items.cpp 2012-05-04 14:32:28 +0000
266+++ src/store/naive/atomic_items.cpp 2012-05-08 03:24:31 +0000
267@@ -1673,6 +1673,36 @@
268 /*******************************************************************************
269 class StreamableStringItem
270 ********************************************************************************/
271+StreamableStringItem::StreamableStringItem(
272+ std::istream& aStream,
273+ StreamReleaser streamReleaser,
274+ bool seekable) :
275+ theIstream(aStream),
276+ theIsMaterialized(false),
277+ theIsConsumed(false),
278+ theIsSeekable(seekable),
279+ theStreamReleaser(streamReleaser),
280+ theStreamableDependent(nullptr)
281+{
282+}
283+
284+StreamableStringItem::StreamableStringItem(
285+ store::Item_t& aStreamableDependent) :
286+ theIstream(aStreamableDependent->getStream()),
287+ theIsMaterialized(false),
288+ theIsConsumed(false),
289+ theIsSeekable(aStreamableDependent->isSeekable()),
290+ theStreamReleaser(nullptr),
291+ theStreamableDependent(aStreamableDependent)
292+{
293+ ZORBA_ASSERT(theStreamableDependent->isStreamable());
294+
295+ // We copied the dependent item's stream and seekable flag in the initializer
296+ // above, but did NOT copy the StreamReleaser. The dependent item maintains
297+ // memory ownership of the stream in this way.
298+}
299+
300+
301 void StreamableStringItem::appendStringValue(zstring& aBuf) const
302 {
303 if (!theIsMaterialized)
304
305=== modified file 'src/store/naive/atomic_items.h'
306--- src/store/naive/atomic_items.h 2012-05-03 12:31:51 +0000
307+++ src/store/naive/atomic_items.h 2012-05-08 03:24:31 +0000
308@@ -875,6 +875,8 @@
309
310 StreamReleaser theStreamReleaser;
311
312+ store::Item_t theStreamableDependent;
313+
314 public:
315 bool equals(
316 store::Item const*,
317@@ -922,15 +924,10 @@
318 StreamableStringItem(
319 std::istream& aStream,
320 StreamReleaser streamReleaser,
321- bool seekable = false)
322- :
323- theIstream(aStream),
324- theIsMaterialized(false),
325- theIsConsumed(false),
326- theIsSeekable(seekable),
327- theStreamReleaser(streamReleaser)
328- {
329- }
330+ bool seekable = false);
331+
332+ StreamableStringItem(
333+ store::Item_t& aStreamableDependent);
334
335 void materialize() const;
336 };
337
338=== modified file 'src/store/naive/simple_item_factory.cpp'
339--- src/store/naive/simple_item_factory.cpp 2012-05-03 12:31:51 +0000
340+++ src/store/naive/simple_item_factory.cpp 2012-05-08 03:24:31 +0000
341@@ -157,6 +157,14 @@
342 return true;
343 }
344
345+bool BasicItemFactory::createSharedStreamableString(
346+ store::Item_t &result,
347+ store::Item_t &streamable_dependent)
348+{
349+ result = new StreamableStringItem( streamable_dependent );
350+ return true;
351+}
352+
353
354 bool BasicItemFactory::createNormalizedString(store::Item_t& result, zstring& value)
355 {
356
357=== modified file 'src/store/naive/simple_item_factory.h'
358--- src/store/naive/simple_item_factory.h 2012-05-03 12:31:51 +0000
359+++ src/store/naive/simple_item_factory.h 2012-05-08 03:24:31 +0000
360@@ -106,6 +106,10 @@
361 StreamReleaser,
362 bool seekable = false);
363
364+ bool createSharedStreamableString(
365+ store::Item_t& result,
366+ store::Item_t& streamable_dependent);
367+
368 bool createBase64Binary(store::Item_t& result, xs_base64Binary value);
369
370 bool createBase64Binary(
371
372=== added file 'test/rbkt/ExpQueryResults/zorba/base64/decode_iso-8859-1.xml.res'
373--- test/rbkt/ExpQueryResults/zorba/base64/decode_iso-8859-1.xml.res 1970-01-01 00:00:00 +0000
374+++ test/rbkt/ExpQueryResults/zorba/base64/decode_iso-8859-1.xml.res 2012-05-08 03:24:31 +0000
375@@ -0,0 +1,1 @@
376+äöü
377
378=== added file 'test/rbkt/ExpQueryResults/zorba/base64/decode_iso-8859-1_file.xml.res'
379--- test/rbkt/ExpQueryResults/zorba/base64/decode_iso-8859-1_file.xml.res 1970-01-01 00:00:00 +0000
380+++ test/rbkt/ExpQueryResults/zorba/base64/decode_iso-8859-1_file.xml.res 2012-05-08 03:24:31 +0000
381@@ -0,0 +1,1 @@
382+äöü
383
384=== added file 'test/rbkt/ExpQueryResults/zorba/base64/reuse-stream.xml.res'
385--- test/rbkt/ExpQueryResults/zorba/base64/reuse-stream.xml.res 1970-01-01 00:00:00 +0000
386+++ test/rbkt/ExpQueryResults/zorba/base64/reuse-stream.xml.res 2012-05-08 03:24:31 +0000
387@@ -0,0 +1,1 @@
388+<file><content>f0VMRgEBAQAAAAAAAAAAAAMAAwABAAAAIPxDADQAAAD0JTMHAAAAADQAIAAHACgAKAAlAAEAAAAAAAAAAAAAAAAAAAAv22gBL9toAQUAAAAAEAAAAQAAAJTbaAGU62gBlOtoAehnBwAwpgcABgAAAAAQAAACAAAAvKBuAbywbgG8sG4BGAEAABgBAAAGAAAABAAAAAQAAAAUAQAAFAEAABQBAAAkAAAAJAAAAAQAAAAEAAAAUOV0ZKyHJwGshycBrIcnAfyBCAD8gQgABAAAAAQAAABR5XRkAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAAABAAAAFLldGSU22gBlOtoAZTraAFs5AUAbOQFAAQAAAABAAAABAAAABQAAAADAAAAR05VANMOFlHRDhyfmkw9H3+lYuAncwGhG0AAAAYDAAAAIAAAEgAAABBkRVIkEIgUIwhRukiBHLCOBAAEAgggoSCCg0CkED5YAAAGFAIgABkACJAAiQAwAFCQEwAQIABBAIIFYAIACAASAAZARACAABkTpAQB5EQIYEF0IBIAIgAhciYEoEICZGgAAQAABCAAkBACZAJAAQQUEhGAIIAAKBULIJYAAABRAKFV4AIWgQAEIYgAAIAAQECAMgBGiCIGiRAEkAABAMAIgEQAAAQAACgIJYAAAEAAAAGAAgtCpFwEAAZRQACAABAICAASiBBFgRhIAkEBMAApJchACQZDAIAAgABIAKQEgKEACGE05FgCAAAgACEAgEAAQoxkUAEAiBAGAAkCFiBoISRFFCBEBMV3gARBgBAosUJBQQAEEDIAUUCBAABAEAhgAEAAAAAAACApACIBBgHKkAWBQAAEAAAAAACDURggAkEEEIlEgIEADQZwAAATC5AQNYxCABABAAAAAAEAlQD0WGD3gAAAIEDKCCAQQMGNIAAQAAAACECCAADAbMAWABABaRAAUFQCgAAAgxJmDAEIAiIZCmIAIAIEgAESCSAjETEQIws2A8AIgAEAAAAAkGkAiEAKDEYEBRGJhFEAIACICAIBKMAGAAAHIAQBqIgAUAECgAAAAhoEER4BASMBBhEIIQGCAFbg8IiBYAgCAQgAgEBwCAAAIAEAQATGAj+QQaAIIQAIAAShAgg2AKQAAAQBkCoASAAAFAAgAYFqAQDCcoOEg0sAIhKAABQAAgpAAghAAIQgIBAkAAQBDA4gRAACAAIgAPBAUgBDARCAggB0GQBaEAg1Mk8CABEAAAQgBBgAECIAvEIhFCRAIBgAAEALyBEQAhACQoIKwAABkBiAVM4QAQlFgBAS4AASAIIkAZEkEgAsBMCABSCAKACAIBMAD4JSLEyAAGQBBqATAUECQUgACQGBGA==</content><md5>f027633a677f42caf1544f6913bc2dab</md5></file>
389\ No newline at end of file
390
391=== added file 'test/rbkt/Queries/zorba/base64/decode_iso-8859-1.xq'
392--- test/rbkt/Queries/zorba/base64/decode_iso-8859-1.xq 1970-01-01 00:00:00 +0000
393+++ test/rbkt/Queries/zorba/base64/decode_iso-8859-1.xq 2012-05-08 03:24:31 +0000
394@@ -0,0 +1,3 @@
395+import module namespace b = "http://www.zorba-xquery.com/modules/converters/base64";
396+
397+b:decode(xs:base64Binary("5Pb8Cg=="), "ISO-8859-1")
398
399=== added file 'test/rbkt/Queries/zorba/base64/decode_iso-8859-1_file.xq'
400--- test/rbkt/Queries/zorba/base64/decode_iso-8859-1_file.xq 1970-01-01 00:00:00 +0000
401+++ test/rbkt/Queries/zorba/base64/decode_iso-8859-1_file.xq 2012-05-08 03:24:31 +0000
402@@ -0,0 +1,5 @@
403+import module namespace f = "http://expath.org/ns/file";
404+import module namespace b = "http://www.zorba-xquery.com/modules/converters/base64";
405+
406+b:decode(xs:base64Binary(f:read-text(resolve-uri("iso-8859-1.txt"))), "ISO-8859-1")
407+
408
409=== added file 'test/rbkt/Queries/zorba/base64/iso-8859-1.txt'
410--- test/rbkt/Queries/zorba/base64/iso-8859-1.txt 1970-01-01 00:00:00 +0000
411+++ test/rbkt/Queries/zorba/base64/iso-8859-1.txt 2012-05-08 03:24:31 +0000
412@@ -0,0 +1,1 @@
413+5Pb8Cg==
414\ No newline at end of file
415
416=== added file 'test/rbkt/Queries/zorba/base64/reuse-stream.xq'
417--- test/rbkt/Queries/zorba/base64/reuse-stream.xq 1970-01-01 00:00:00 +0000
418+++ test/rbkt/Queries/zorba/base64/reuse-stream.xq 2012-05-08 03:24:31 +0000
419@@ -0,0 +1,16 @@
420+(: From bug 996084. We need to ensure that a streamable base64 item can be re-used. :)
421+
422+import module namespace base64="http://www.zorba-xquery.com/modules/converters/base64";
423+import module namespace hash = "http://www.zorba-xquery.com/modules/cryptography/hash";
424+import module namespace file = "http://expath.org/ns/file";
425+
426+declare variable $filename as xs:anyURI := resolve-uri("decoded");
427+
428+let $data as xs:base64Binary := file:read-binary ($filename)
429+let $md5 as xs:string := hash:md5(base64:decode($data))
430+
431+return
432+ <file>
433+ <content>{$data}</content>
434+ <md5>{$md5}</md5>
435+ </file>

Subscribers

People subscribed via source and target branches