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

Proposed by Matthias Brantner
Status: Merged
Approved by: Chris Hillery
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 Approve
Dennis Knochenwefel Approve
William Candillon Approve
Matthias Brantner Approve
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.
Revision history for this message
Chris Hillery (ceejatec) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
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.

Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
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!

Revision history for this message
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.

Revision history for this message
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
Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
William Candillon (wcandillon) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
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!

Revision history for this message
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.

Revision history for this message
Matthias Brantner (matthias-brantner) 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.
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.

Revision history for this message
Dennis Knochenwefel (dennis-knochenwefel) wrote :

I tested it and it works.

review: Approve
Revision history for this message
Chris Hillery (ceejatec) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
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
=== modified file 'ChangeLog'
--- ChangeLog 2012-05-07 23:43:04 +0000
+++ ChangeLog 2012-05-08 03:24:31 +0000
@@ -18,6 +18,7 @@
18 - fn:has-children#018 - fn:has-children#0
19 - fn:nilled#019 - fn:nilled#0
20 - fn:path20 - fn:path
21 * Added base64:decode#2 function which also does transcoding
21 * Extended API for Python, Java, PHP and Ruby.22 * Extended API for Python, Java, PHP and Ruby.
22 * Add jvm classpath to zorbacmd and to Zorba API. Tracked by #93181623 * Add jvm classpath to zorbacmd and to Zorba API. Tracked by #931816
23 * Added full-text module.24 * Added full-text module.
@@ -49,6 +50,7 @@
49 * Fixed bug #912586, #912593 and #912722 (assertion failures with lax validation)50 * Fixed bug #912586, #912593 and #912722 (assertion failures with lax validation)
50 * Fixed bug #921458 (file:read-text-lines() blocking)51 * Fixed bug #921458 (file:read-text-lines() blocking)
51 * Fixed bug #981405 (do not hoist expr containing try-catch variables out of the associated try-catch expression)52 * Fixed bug #981405 (do not hoist expr containing try-catch variables out of the associated try-catch expression)
53 * Fixed bug #996084 (crash in Streamable*Item with file module)
52 * Fixed bug #947627 (throw XQST0099 if more than one declarations of context item type in same module)54 * Fixed bug #947627 (throw XQST0099 if more than one declarations of context item type in same module)
53 * Fixed bug #980526 (no-copy rule bug due to global var being set in "distant" udf)55 * Fixed bug #980526 (no-copy rule bug due to global var being set in "distant" udf)
54 * 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).56 * 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).
5557
=== modified file 'modules/com/zorba-xquery/www/modules/converters/base64.xq'
--- modules/com/zorba-xquery/www/modules/converters/base64.xq 2012-05-03 12:31:51 +0000
+++ modules/com/zorba-xquery/www/modules/converters/base64.xq 2012-05-08 03:24:31 +0000
@@ -25,6 +25,8 @@
25 :)25 :)
26module namespace base64 = "http://www.zorba-xquery.com/modules/converters/base64";26module namespace base64 = "http://www.zorba-xquery.com/modules/converters/base64";
2727
28declare namespace zerr = "http://www.zorba-xquery.com/errors";
29
28declare namespace ver = "http://www.zorba-xquery.com/options/versioning";30declare namespace ver = "http://www.zorba-xquery.com/options/versioning";
29declare option ver:module-version "2.0";31declare option ver:module-version "2.0";
3032
@@ -32,7 +34,7 @@
32 : Decode a xs:base64Binary.34 : Decode a xs:base64Binary.
33 :35 :
34 : The function assumes that the content after decoding is valid36 : The function assumes that the content after decoding is valid
35 : UTF-8. 37 : UTF-8.
36 :38 :
37 : @param $base64 The xs:base64Binary item to decode39 : @param $base64 The xs:base64Binary item to decode
38 : @return the base64 decoded value as string40 : @return the base64 decoded value as string
@@ -41,6 +43,24 @@
41as xs:string external;43as xs:string external;
4244
43(:~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 :)
58declare function base64:decode(
59 $base64 as xs:base64Binary,
60 $encoding as xs:string)
61as xs:string external;
62
63(:~
44 : Encode a xs:string as xs:base64Binary.64 : Encode a xs:string as xs:base64Binary.
45 :65 :
46 : @param $string The item whose string-value should be encoded66 : @param $string The item whose string-value should be encoded
4767
=== modified file 'src/functions/pregenerated/func_base64.cpp'
--- src/functions/pregenerated/func_base64.cpp 2012-05-03 12:31:51 +0000
+++ src/functions/pregenerated/func_base64.cpp 2012-05-08 03:24:31 +0000
@@ -68,6 +68,19 @@
68 {68 {
69 69
7070
71 DECL_WITH_KIND(sctx, fn_zorba_base64_decode,
72 (createQName("http://www.zorba-xquery.com/modules/converters/base64","","decode"),
73 GENV_TYPESYSTEM.BASE64BINARY_TYPE_ONE,
74 GENV_TYPESYSTEM.STRING_TYPE_ONE,
75 GENV_TYPESYSTEM.STRING_TYPE_ONE),
76 FunctionConsts::FN_ZORBA_BASE64_DECODE_2);
77
78 }
79
80
81 {
82
83
71 DECL_WITH_KIND(sctx, fn_zorba_base64_encode,84 DECL_WITH_KIND(sctx, fn_zorba_base64_encode,
72 (createQName("http://www.zorba-xquery.com/modules/converters/base64","","encode"), 85 (createQName("http://www.zorba-xquery.com/modules/converters/base64","","encode"),
73 GENV_TYPESYSTEM.STRING_TYPE_ONE, 86 GENV_TYPESYSTEM.STRING_TYPE_ONE,
7487
=== modified file 'src/functions/pregenerated/function_enum.h'
--- src/functions/pregenerated/function_enum.h 2012-05-03 12:31:51 +0000
+++ src/functions/pregenerated/function_enum.h 2012-05-08 03:24:31 +0000
@@ -36,6 +36,7 @@
36 FN_RESOLVE_URI_1,36 FN_RESOLVE_URI_1,
37 FN_RESOLVE_URI_2,37 FN_RESOLVE_URI_2,
38 FN_ZORBA_BASE64_DECODE_1,38 FN_ZORBA_BASE64_DECODE_1,
39 FN_ZORBA_BASE64_DECODE_2,
39 FN_ZORBA_BASE64_ENCODE_1,40 FN_ZORBA_BASE64_ENCODE_1,
40 OP_IS_SAME_NODE_2,41 OP_IS_SAME_NODE_2,
41 OP_NODE_BEFORE_2,42 OP_NODE_BEFORE_2,
4243
=== modified file 'src/runtime/base64/base64_impl.cpp'
--- src/runtime/base64/base64_impl.cpp 2012-05-03 12:31:51 +0000
+++ src/runtime/base64/base64_impl.cpp 2012-05-08 03:24:31 +0000
@@ -15,6 +15,9 @@
15 */15 */
16#include "stdafx.h"16#include "stdafx.h"
1717
18#include <sstream>
19#include <zorba/transcode_stream.h>
20
18#include "system/globalenv.h"21#include "system/globalenv.h"
1922
20#include "diagnostics/xquery_diagnostics.h"23#include "diagnostics/xquery_diagnostics.h"
@@ -33,6 +36,7 @@
33{36{
34 store::Item_t lItem;37 store::Item_t lItem;
35 zstring lResultString;38 zstring lResultString;
39 zstring lEncoding("UTF-8");
36 const char* lContent;40 const char* lContent;
37 size_t lSize;41 size_t lSize;
38 result = NULL;42 result = NULL;
@@ -42,21 +46,45 @@
4246
43 consumeNext(lItem, theChildren[0].getp(), planState);47 consumeNext(lItem, theChildren[0].getp(), planState);
4448
49 if (theChildren.size() == 2)
50 {
51 store::Item_t lEncodingItem;
52 consumeNext(lEncodingItem, theChildren[1].getp(), planState);
53 lEncoding = lEncodingItem->getStringValue();
54
55 if (!transcode::is_supported(lEncoding.c_str()))
56 {
57 throw XQUERY_EXCEPTION(
58 zerr::ZXQP0006_UNKNOWN_ENCODING,
59 ERROR_PARAMS( lEncoding ),
60 ERROR_LOC( loc )
61 );
62 }
63 }
64
45 if (lItem->isStreamable())65 if (lItem->isStreamable())
46 {66 {
47 if (lItem->isEncoded())67 if (lItem->isEncoded())
48 {68 {
49 // decode and eventually transcode
50 lResultString = Base64::decode(lItem->getStream());69 lResultString = Base64::decode(lItem->getStream());
51 }70 }
52 else71 else
53 {72 {
54 // streamable string eventually transcoding73 if (transcode::is_necessary(lEncoding.c_str()))
55 GENV_ITEMFACTORY->createStreamableString(74 {
56 result,75 transcode::attach(lItem->getStream(), lEncoding.c_str());
57 lItem->getStream(),76 GENV_ITEMFACTORY->createStreamableString(
58 lItem->getStreamReleaser(),77 result,
59 lItem->isSeekable());78 lItem->getStream(),
79 lItem->getStreamReleaser(),
80 lItem->isSeekable());
81 }
82 else
83 {
84 GENV_ITEMFACTORY->createSharedStreamableString(
85 result,
86 lItem);
87 }
60 }88 }
61 }89 }
62 else90 else
@@ -74,10 +102,37 @@
74 {102 {
75 lResultString.insert(0, lContent, lSize);103 lResultString.insert(0, lContent, lSize);
76 }104 }
77 }105
78 if (!result) // otherwise it's a streamable string already106 if (transcode::is_necessary(lEncoding.c_str()))
79 {107 {
80 GENV_ITEMFACTORY->createString(result, lResultString);108 try
109 {
110 zstring lTranscodedString;
111 transcode::stream<std::istringstream> lTranscoder(
112 lEncoding.c_str(),
113 lResultString.c_str()
114 );
115 char buf[1024];
116 while (lTranscoder.good())
117 {
118 lTranscoder.read(buf, 1024);
119 lTranscodedString.append(buf, lTranscoder.gcount());
120 }
121 GENV_ITEMFACTORY->createString(result, lTranscodedString);
122 }
123 catch (ZorbaException& e)
124 {
125 throw XQUERY_EXCEPTION(
126 zerr::ZOSE0006_TRANSCODING_ERROR,
127 ERROR_PARAMS( e.what() ),
128 ERROR_LOC( loc )
129 );
130 }
131 }
132 else
133 {
134 GENV_ITEMFACTORY->createString(result, lResultString);
135 }
81 }136 }
82 STACK_PUSH (true, state);137 STACK_PUSH (true, state);
83138
84139
=== modified file 'src/runtime/spec/base64/base64.xml'
--- src/runtime/spec/base64/base64.xml 2012-05-03 12:31:51 +0000
+++ src/runtime/spec/base64/base64.xml 2012-05-08 03:24:31 +0000
@@ -25,8 +25,13 @@
25 <zorba:param>xs:base64Binary</zorba:param>25 <zorba:param>xs:base64Binary</zorba:param>
26 <zorba:output>xs:string</zorba:output>26 <zorba:output>xs:string</zorba:output>
27 </zorba:signature>27 </zorba:signature>
28 <zorba:signature localname="decode" prefix="fn-zorba-base64">
29 <zorba:param>xs:base64Binary</zorba:param>
30 <zorba:param>xs:string</zorba:param> <!-- encoding -->
31 <zorba:output>xs:string</zorba:output>
32 </zorba:signature>
28 </zorba:function>33 </zorba:function>
29 34
30</zorba:iterator>35</zorba:iterator>
3136
32<!--37<!--
3338
=== modified file 'src/store/api/item_factory.h'
--- src/store/api/item_factory.h 2012-05-03 12:31:51 +0000
+++ src/store/api/item_factory.h 2012-05-08 03:24:31 +0000
@@ -97,6 +97,19 @@
97 bool seekable = false) = 0;97 bool seekable = false) = 0;
9898
99 /**99 /**
100 * Create a StreamableStringItem which re-uses the stream from another
101 * Streamable*Item. This will maintain a reference to the original
102 * item to ensure the stream is not cleaned up before we are done with it.
103 *
104 * It only makes sense to use this method if either (a) the dependent item's
105 * stream is seekable and hence re-usable, or (b) you are sure that the
106 * dependent item will not be utilized after this new item is created.
107 */
108 virtual bool createSharedStreamableString(
109 Item_t& result,
110 Item_t& streamble_dependent) = 0;
111
112 /**
100 * Specification: [http://www.w3.org/TR/xmlschema-2/#normalizedString]113 * Specification: [http://www.w3.org/TR/xmlschema-2/#normalizedString]
101 * @param value string representation of the value114 * @param value string representation of the value
102 */115 */
103116
=== modified file 'src/store/naive/atomic_items.cpp'
--- src/store/naive/atomic_items.cpp 2012-05-04 14:32:28 +0000
+++ src/store/naive/atomic_items.cpp 2012-05-08 03:24:31 +0000
@@ -1673,6 +1673,36 @@
1673/*******************************************************************************1673/*******************************************************************************
1674 class StreamableStringItem1674 class StreamableStringItem
1675********************************************************************************/1675********************************************************************************/
1676StreamableStringItem::StreamableStringItem(
1677 std::istream& aStream,
1678 StreamReleaser streamReleaser,
1679 bool seekable) :
1680 theIstream(aStream),
1681 theIsMaterialized(false),
1682 theIsConsumed(false),
1683 theIsSeekable(seekable),
1684 theStreamReleaser(streamReleaser),
1685 theStreamableDependent(nullptr)
1686{
1687}
1688
1689StreamableStringItem::StreamableStringItem(
1690 store::Item_t& aStreamableDependent) :
1691 theIstream(aStreamableDependent->getStream()),
1692 theIsMaterialized(false),
1693 theIsConsumed(false),
1694 theIsSeekable(aStreamableDependent->isSeekable()),
1695 theStreamReleaser(nullptr),
1696 theStreamableDependent(aStreamableDependent)
1697{
1698 ZORBA_ASSERT(theStreamableDependent->isStreamable());
1699
1700 // We copied the dependent item's stream and seekable flag in the initializer
1701 // above, but did NOT copy the StreamReleaser. The dependent item maintains
1702 // memory ownership of the stream in this way.
1703}
1704
1705
1676void StreamableStringItem::appendStringValue(zstring& aBuf) const1706void StreamableStringItem::appendStringValue(zstring& aBuf) const
1677{1707{
1678 if (!theIsMaterialized) 1708 if (!theIsMaterialized)
16791709
=== modified file 'src/store/naive/atomic_items.h'
--- src/store/naive/atomic_items.h 2012-05-03 12:31:51 +0000
+++ src/store/naive/atomic_items.h 2012-05-08 03:24:31 +0000
@@ -875,6 +875,8 @@
875875
876 StreamReleaser theStreamReleaser;876 StreamReleaser theStreamReleaser;
877877
878 store::Item_t theStreamableDependent;
879
878public:880public:
879 bool equals(881 bool equals(
880 store::Item const*,882 store::Item const*,
@@ -922,15 +924,10 @@
922 StreamableStringItem(924 StreamableStringItem(
923 std::istream& aStream,925 std::istream& aStream,
924 StreamReleaser streamReleaser,926 StreamReleaser streamReleaser,
925 bool seekable = false)927 bool seekable = false);
926 :928
927 theIstream(aStream),929 StreamableStringItem(
928 theIsMaterialized(false),930 store::Item_t& aStreamableDependent);
929 theIsConsumed(false),
930 theIsSeekable(seekable),
931 theStreamReleaser(streamReleaser)
932 {
933 }
934931
935 void materialize() const;932 void materialize() const;
936};933};
937934
=== modified file 'src/store/naive/simple_item_factory.cpp'
--- src/store/naive/simple_item_factory.cpp 2012-05-03 12:31:51 +0000
+++ src/store/naive/simple_item_factory.cpp 2012-05-08 03:24:31 +0000
@@ -157,6 +157,14 @@
157 return true;157 return true;
158}158}
159159
160bool BasicItemFactory::createSharedStreamableString(
161 store::Item_t &result,
162 store::Item_t &streamable_dependent)
163{
164 result = new StreamableStringItem( streamable_dependent );
165 return true;
166}
167
160168
161bool BasicItemFactory::createNormalizedString(store::Item_t& result, zstring& value)169bool BasicItemFactory::createNormalizedString(store::Item_t& result, zstring& value)
162{170{
163171
=== modified file 'src/store/naive/simple_item_factory.h'
--- src/store/naive/simple_item_factory.h 2012-05-03 12:31:51 +0000
+++ src/store/naive/simple_item_factory.h 2012-05-08 03:24:31 +0000
@@ -106,6 +106,10 @@
106 StreamReleaser,106 StreamReleaser,
107 bool seekable = false);107 bool seekable = false);
108108
109 bool createSharedStreamableString(
110 store::Item_t& result,
111 store::Item_t& streamable_dependent);
112
109 bool createBase64Binary(store::Item_t& result, xs_base64Binary value);113 bool createBase64Binary(store::Item_t& result, xs_base64Binary value);
110114
111 bool createBase64Binary(115 bool createBase64Binary(
112116
=== added file 'test/rbkt/ExpQueryResults/zorba/base64/decode_iso-8859-1.xml.res'
--- test/rbkt/ExpQueryResults/zorba/base64/decode_iso-8859-1.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/base64/decode_iso-8859-1.xml.res 2012-05-08 03:24:31 +0000
@@ -0,0 +1,1 @@
1äöü
02
=== added file 'test/rbkt/ExpQueryResults/zorba/base64/decode_iso-8859-1_file.xml.res'
--- test/rbkt/ExpQueryResults/zorba/base64/decode_iso-8859-1_file.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/base64/decode_iso-8859-1_file.xml.res 2012-05-08 03:24:31 +0000
@@ -0,0 +1,1 @@
1äöü
02
=== added file 'test/rbkt/ExpQueryResults/zorba/base64/reuse-stream.xml.res'
--- test/rbkt/ExpQueryResults/zorba/base64/reuse-stream.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/base64/reuse-stream.xml.res 2012-05-08 03:24:31 +0000
@@ -0,0 +1,1 @@
1<file><content>f0VMRgEBAQAAAAAAAAAAAAMAAwABAAAAIPxDADQAAAD0JTMHAAAAADQAIAAHACgAKAAlAAEAAAAAAAAAAAAAAAAAAAAv22gBL9toAQUAAAAAEAAAAQAAAJTbaAGU62gBlOtoAehnBwAwpgcABgAAAAAQAAACAAAAvKBuAbywbgG8sG4BGAEAABgBAAAGAAAABAAAAAQAAAAUAQAAFAEAABQBAAAkAAAAJAAAAAQAAAAEAAAAUOV0ZKyHJwGshycBrIcnAfyBCAD8gQgABAAAAAQAAABR5XRkAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAAABAAAAFLldGSU22gBlOtoAZTraAFs5AUAbOQFAAQAAAABAAAABAAAABQAAAADAAAAR05VANMOFlHRDhyfmkw9H3+lYuAncwGhG0AAAAYDAAAAIAAAEgAAABBkRVIkEIgUIwhRukiBHLCOBAAEAgggoSCCg0CkED5YAAAGFAIgABkACJAAiQAwAFCQEwAQIABBAIIFYAIACAASAAZARACAABkTpAQB5EQIYEF0IBIAIgAhciYEoEICZGgAAQAABCAAkBACZAJAAQQUEhGAIIAAKBULIJYAAABRAKFV4AIWgQAEIYgAAIAAQECAMgBGiCIGiRAEkAABAMAIgEQAAAQAACgIJYAAAEAAAAGAAgtCpFwEAAZRQACAABAICAASiBBFgRhIAkEBMAApJchACQZDAIAAgABIAKQEgKEACGE05FgCAAAgACEAgEAAQoxkUAEAiBAGAAkCFiBoISRFFCBEBMV3gARBgBAosUJBQQAEEDIAUUCBAABAEAhgAEAAAAAAACApACIBBgHKkAWBQAAEAAAAAACDURggAkEEEIlEgIEADQZwAAATC5AQNYxCABABAAAAAAEAlQD0WGD3gAAAIEDKCCAQQMGNIAAQAAAACECCAADAbMAWABABaRAAUFQCgAAAgxJmDAEIAiIZCmIAIAIEgAESCSAjETEQIws2A8AIgAEAAAAAkGkAiEAKDEYEBRGJhFEAIACICAIBKMAGAAAHIAQBqIgAUAECgAAAAhoEER4BASMBBhEIIQGCAFbg8IiBYAgCAQgAgEBwCAAAIAEAQATGAj+QQaAIIQAIAAShAgg2AKQAAAQBkCoASAAAFAAgAYFqAQDCcoOEg0sAIhKAABQAAgpAAghAAIQgIBAkAAQBDA4gRAACAAIgAPBAUgBDARCAggB0GQBaEAg1Mk8CABEAAAQgBBgAECIAvEIhFCRAIBgAAEALyBEQAhACQoIKwAABkBiAVM4QAQlFgBAS4AASAIIkAZEkEgAsBMCABSCAKACAIBMAD4JSLEyAAGQBBqATAUECQUgACQGBGA==</content><md5>f027633a677f42caf1544f6913bc2dab</md5></file>
0\ No newline at end of file2\ No newline at end of file
13
=== added file 'test/rbkt/Queries/zorba/base64/decode_iso-8859-1.xq'
--- test/rbkt/Queries/zorba/base64/decode_iso-8859-1.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/base64/decode_iso-8859-1.xq 2012-05-08 03:24:31 +0000
@@ -0,0 +1,3 @@
1import module namespace b = "http://www.zorba-xquery.com/modules/converters/base64";
2
3b:decode(xs:base64Binary("5Pb8Cg=="), "ISO-8859-1")
04
=== added file 'test/rbkt/Queries/zorba/base64/decode_iso-8859-1_file.xq'
--- test/rbkt/Queries/zorba/base64/decode_iso-8859-1_file.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/base64/decode_iso-8859-1_file.xq 2012-05-08 03:24:31 +0000
@@ -0,0 +1,5 @@
1import module namespace f = "http://expath.org/ns/file";
2import module namespace b = "http://www.zorba-xquery.com/modules/converters/base64";
3
4b:decode(xs:base64Binary(f:read-text(resolve-uri("iso-8859-1.txt"))), "ISO-8859-1")
5
06
=== added file 'test/rbkt/Queries/zorba/base64/iso-8859-1.txt'
--- test/rbkt/Queries/zorba/base64/iso-8859-1.txt 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/base64/iso-8859-1.txt 2012-05-08 03:24:31 +0000
@@ -0,0 +1,1 @@
15Pb8Cg==
0\ No newline at end of file2\ No newline at end of file
13
=== added file 'test/rbkt/Queries/zorba/base64/reuse-stream.xq'
--- test/rbkt/Queries/zorba/base64/reuse-stream.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/base64/reuse-stream.xq 2012-05-08 03:24:31 +0000
@@ -0,0 +1,16 @@
1(: From bug 996084. We need to ensure that a streamable base64 item can be re-used. :)
2
3import module namespace base64="http://www.zorba-xquery.com/modules/converters/base64";
4import module namespace hash = "http://www.zorba-xquery.com/modules/cryptography/hash";
5import module namespace file = "http://expath.org/ns/file";
6
7declare variable $filename as xs:anyURI := resolve-uri("decoded");
8
9let $data as xs:base64Binary := file:read-binary ($filename)
10let $md5 as xs:string := hash:md5(base64:decode($data))
11
12return
13 <file>
14 <content>{$data}</content>
15 <md5>{$md5}</md5>
16 </file>

Subscribers

People subscribed via source and target branches