Merge lp:~zorba-coders/zorba/bug-1188033 into lp:zorba/archive-module

Proposed by Luis Rodriguez Gonzalez
Status: Merged
Merged at revision: 52
Proposed branch: lp:~zorba-coders/zorba/bug-1188033
Merge into: lp:zorba/archive-module
Diff against target: 1647 lines (+375/-434)
47 files modified
src/CMakeLists.txt (+1/-4)
src/archive.xsd (+0/-105)
src/archive_module.xq (+103/-87)
src/archive_module.xq.src/archive_module.cpp (+168/-153)
src/archive_module.xq.src/archive_module.h (+24/-4)
test/ExpQueryResults/entries_01.xml.res (+1/-2)
test/ExpQueryResults/entries_02.xml.res (+1/-2)
test/ExpQueryResults/entries_03.xml.res (+1/-1)
test/ExpQueryResults/options_01.xml.res (+1/-2)
test/ExpQueryResults/options_02.xml.res (+1/-2)
test/Queries/create_01.xq (+4/-3)
test/Queries/create_02.xq (+2/-2)
test/Queries/create_03.spec (+1/-1)
test/Queries/create_03.xq (+3/-2)
test/Queries/delete_01.xq (+1/-1)
test/Queries/delete_02.xq (+1/-2)
test/Queries/delete_03.xq (+5/-5)
test/Queries/delete_04.xq (+5/-5)
test/Queries/dir_01.xq (+3/-3)
test/Queries/dir_02.xq (+3/-3)
test/Queries/dir_03.xq (+3/-3)
test/Queries/dir_04.xq (+4/-4)
test/Queries/entries_01.xq (+4/-3)
test/Queries/entries_02.xq (+2/-3)
test/Queries/entries_03.spec (+1/-1)
test/Queries/entries_03.xq (+4/-3)
test/Queries/entries_04.spec (+1/-1)
test/Queries/entries_04.xq (+4/-3)
test/Queries/extract_01.xq (+1/-2)
test/Queries/extract_02.xq (+1/-1)
test/Queries/extract_03.spec (+1/-1)
test/Queries/extract_03.xq (+1/-1)
test/Queries/extract_04.xq (+1/-1)
test/Queries/extract_05.xq (+4/-4)
test/Queries/extract_06.xq (+1/-1)
test/Queries/extract_07.xq (+2/-2)
test/Queries/options_01.xq (+1/-1)
test/Queries/options_02.spec (+1/-1)
test/Queries/options_02.xq (+1/-1)
test/Queries/options_03.spec (+1/-1)
test/Queries/options_03.xq (+1/-1)
test/Queries/update_01.xq (+1/-1)
test/Queries/update_02.xq (+1/-1)
test/Queries/update_03.spec (+1/-1)
test/Queries/update_03.xq (+1/-1)
test/Queries/update_04.spec (+1/-1)
test/Queries/update_04.xq (+1/-1)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug-1188033
Reviewer Review Type Date Requested Status
Luis Rodriguez Gonzalez Approve
Chris Hillery Approve
Review via email: mp+176523@code.launchpad.net

Commit message

JSONiqfication for Archive Module Done.

To post a comment you must log in.
lp:~zorba-coders/zorba/bug-1188033 updated
52. By Luis Rodriguez Gonzalez

Merge with trunk and resolved conflicts

Revision history for this message
Chris Hillery (ceejatec) wrote :

In archive_module.cpp:

1. Please don't leave commented-out code. Just delete it; it's in the version history if we ever need to refer back to it. For example, remove these lines:

+ //Item lNameItem = theFactory->createString(lName);
+ //lMemberName = theFactory->createString("name");

2. As discussed, if possible, create single zorba::Items for all the JSON object key strings, eg. "name", "size", etc. Possibly create those in the ArchiveModule constructor. Use those constants when creating JSON objects in EntriesIterator::next(), as well as comparing input values in ArchiveEntry::setValues() (and anywhere else it happens to be appropriate).

Also don't forget to assign a bug to yourself to create a JSON schema for this module, and to go back and update the module and test cases accordingly.

review: Needs Fixing
Revision history for this message
Chris Hillery (ceejatec) wrote :

Also, you have at least one </p> typo in archive.xq.

Always remember to run

  ctest -R moduleDocumentation

before committing, to be sure that your XQDoc is syntactically correct and that you didn't forget to document any parameters, etc.

review: Needs Fixing
lp:~zorba-coders/zorba/bug-1188033 updated
53. By Luis Rodriguez Gonzalez

All comments fixed

54. By Luis Rodriguez Gonzalez

Removed commented code

Revision history for this message
Luis Rodriguez Gonzalez (kuraru) wrote :

> In archive_module.cpp:
>
> 1. Please don't leave commented-out code. Just delete it; it's in the version
> history if we ever need to refer back to it. For example, remove these lines:
>
> + //Item lNameItem = theFactory->createString(lName);
> + //lMemberName = theFactory->createString("name");
>
>
> 2. As discussed, if possible, create single zorba::Items for all the JSON
> object key strings, eg. "name", "size", etc. Possibly create those in the
> ArchiveModule constructor. Use those constants when creating JSON objects in
> EntriesIterator::next(), as well as comparing input values in
> ArchiveEntry::setValues() (and anywhere else it happens to be appropriate).
>
>
> Also don't forget to assign a bug to yourself to create a JSON schema for this
> module, and to go back and update the module and test cases accordingly.

Done.

Revision history for this message
Luis Rodriguez Gonzalez (kuraru) wrote :

> Also, you have at least one </p> typo in archive.xq.
>
> Always remember to run
>
> ctest -R moduleDocumentation
>
> before committing, to be sure that your XQDoc is syntactically correct and
> that you didn't forget to document any parameters, etc.

Done.

Revision history for this message
Chris Hillery (ceejatec) wrote :

You didn't actually create singleton zorba::Items for the JSON object key strings. Using C++ #defines isn't the same. This code will still create a separate zorba::Item for the string "name" for every single entry in every archive passed to a:entries().

review: Needs Fixing
Revision history for this message
Luis Rodriguez Gonzalez (kuraru) wrote :

> You didn't actually create singleton zorba::Items for the JSON object key
> strings. Using C++ #defines isn't the same. This code will still create a
> separate zorba::Item for the string "name" for every single entry in every
> archive passed to a:entries().

I used #defines only for the strings that are into the Item, I tried to create static Items into ArchiveModule but at the end I got some linker errors at execution time, I did some research but couldn't fix it so I moved the Items to be created in EntriesIterator and OptionsIterator that in theory created only once insstead of creating one for each entry and options. I will upload a version with the Items created in ArchiveModule and if you have a chance pleaase take a look and let me know if you know how to fix it.

lp:~zorba-coders/zorba/bug-1188033 updated
55. By Luis Rodriguez Gonzalez

Testing global Items for Entries

56. By Chris Hillery

Definition of globalFormatName.

57. By Luis Rodriguez Gonzalez

Changes to have global Items from ArchiveModule class made

Revision history for this message
Chris Hillery (ceejatec) wrote :

Global Items code looks good now!

As a general rule, don't put actual function definitions into header files. Certain small methods (accessors, usually) can be inline for efficiency, but anything more significant can cause code bloat and other problems. I moved the ArchiveModule() constructor definition into archive_module.cpp. With that done, everything looks fine.

review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue starting for the following merge proposals:
https://code.launchpad.net/~zorba-coders/zorba/bug-1188033/+merge/176523

Progress dashboard at http://jenkins.lambda.nu/view/ValidationQueue

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting criteria failed for the following merge proposals:

https://code.launchpad.net/~zorba-coders/zorba/bug-1188033/+merge/176523 :
Votes: {'Approve': 1, 'Pending': 1, 'Needs commit message': 1}

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue result for https://code.launchpad.net/~zorba-coders/zorba/bug-1188033/+merge/176523

Stage "CommitZorba" failed.

Check console output at http://jenkins.lambda.nu/job/CommitZorba/66/console to view the results.

Revision history for this message
Luis Rodriguez Gonzalez (kuraru) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue starting for the following merge proposals:
https://code.launchpad.net/~zorba-coders/zorba/bug-1188033/+merge/176523

Progress dashboard at http://jenkins.lambda.nu/view/ValidationQueue

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting criteria failed for the following merge proposals:

https://code.launchpad.net/~zorba-coders/zorba/bug-1188033/+merge/176523 :
Votes: {'Approve': 2, 'Needs commit message': 1}

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue result for https://code.launchpad.net/~zorba-coders/zorba/bug-1188033/+merge/176523

Stage "CommitZorba" failed.

Check console output at http://jenkins.lambda.nu/job/CommitZorba/68/console to view the results.

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue starting for the following merge proposals:
https://code.launchpad.net/~zorba-coders/zorba/bug-1188033/+merge/176523

Progress dashboard at http://jenkins.lambda.nu/view/ValidationQueue

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue succeeded - proposal merged!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/CMakeLists.txt'
2--- src/CMakeLists.txt 2012-07-27 03:43:13 +0000
3+++ src/CMakeLists.txt 2013-07-29 19:28:26 +0000
4@@ -17,11 +17,8 @@
5 INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}/archive_module.xq.src")
6
7 DECLARE_ZORBA_MODULE (
8- URI "http://www.zorba-xquery.com/modules/archive"
9+ URI "http://zorba.io/modules/archive"
10 VERSION 1.0
11 FILE "archive_module.xq"
12 LINK_LIBRARIES "${LIBARCHIVE_LIBRARIES}")
13
14-DECLARE_ZORBA_SCHEMA (
15- URI "http://www.zorba-xquery.com/modules/archive"
16- FILE "archive.xsd")
17
18=== removed file 'src/archive.xsd'
19--- src/archive.xsd 2012-09-06 20:40:47 +0000
20+++ src/archive.xsd 1970-01-01 00:00:00 +0000
21@@ -1,105 +0,0 @@
22-<?xml version="1.0"?>
23-
24-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
25- targetNamespace="http://www.zorba-xquery.com/modules/archive"
26- xmlns="http://www.zorba-xquery.com/modules/archive"
27- elementFormDefault="qualified"
28- attributeFormDefault="unqualified">
29-
30- <xs:simpleType name="compression-type">
31- <xs:restriction base="xs:string">
32- <xs:enumeration value="store"/>
33- <xs:enumeration value="deflate"/>
34- <xs:enumeration value="bzip2"/>
35- <xs:enumeration value="lzma"/>
36- <xs:enumeration value="STORE"/>
37- <xs:enumeration value="DEFLATE"/>
38- <xs:enumeration value="BZIP2"/>
39- <xs:enumeration value="LZMA"/>
40- </xs:restriction>
41- </xs:simpleType>
42-
43- <xs:simpleType name="format-type">
44- <xs:restriction base="xs:string">
45- <xs:enumeration value="zip"/>
46- <xs:enumeration value="tar"/>
47- <xs:enumeration value="pax"/>
48- <xs:enumeration value="ZIP"/>
49- <xs:enumeration value="TAR"/>
50- <xs:enumeration value="PAX"/>
51- </xs:restriction>
52- </xs:simpleType>
53-
54- <xs:simpleType name="boolean-type">
55- <xs:restriction base="xs:string">
56- <xs:enumeration value="true"/>
57- <xs:enumeration value="false"/>
58- </xs:restriction>
59- </xs:simpleType>
60-
61- <xs:simpleType name="entry-name-type">
62- <xs:restriction base="xs:string"/>
63- </xs:simpleType>
64-
65- <xs:simpleType name="entry-datetime-type">
66- <xs:restriction base="xs:dateTime"/>
67- </xs:simpleType>
68-
69- <xs:simpleType name="entry-size-type">
70- <xs:restriction base="xs:short"/>
71- </xs:simpleType>
72-
73- <xs:simpleType name="entry-encoding-type">
74- <xs:restriction base="xs:string"/>
75- </xs:simpleType>
76-
77- <xs:simpleType name="entry-type">
78- <xs:restriction base="xs:string">
79- <xs:enumeration value="regular"/>
80- <xs:enumeration value="directory"/>
81- </xs:restriction>
82- </xs:simpleType>
83-
84- <!-- elements -->
85- <xs:element name="archive-option-element"
86- abstract="true" type="xs:string"/>
87-
88- <xs:element name="compression"
89- type="compression-type"
90- substitutionGroup="archive-option-element"/>
91-
92- <xs:element name="format" type="format-type"
93- substitutionGroup="archive-option-element"/>
94-
95- <xs:element name="skip-extra-attributes" type="boolean-type"
96- substitutionGroup="archive-option-element"/>
97-
98- <xs:element name="options">
99- <xs:complexType>
100- <xs:sequence>
101- <xs:element ref="archive-option-element"
102- minOccurs="0" maxOccurs="unbounded"/>
103- </xs:sequence>
104- </xs:complexType>
105- </xs:element>
106-
107- <xs:element name="entry">
108- <xs:complexType>
109- <xs:simpleContent>
110- <xs:extension base="entry-name-type">
111- <xs:attributeGroup ref="entry-attributes"/>
112- </xs:extension>
113- </xs:simpleContent>
114- </xs:complexType>
115- </xs:element>
116-
117- <!-- entry attributes -->
118- <xs:attributeGroup name="entry-attributes">
119- <xs:attribute name="type" type="entry-type"/>
120- <xs:attribute name="size" type="entry-size-type"/>
121- <xs:attribute name="last-modified" type="entry-datetime-type"/>
122- <xs:attribute name="encoding" type="entry-encoding-type"/>
123- <xs:attribute name="compression" type="compression-type"/>
124- </xs:attributeGroup>
125-
126-</xs:schema>
127
128=== modified file 'src/archive_module.xq'
129--- src/archive_module.xq 2012-12-21 22:10:19 +0000
130+++ src/archive_module.xq 2013-07-29 19:28:26 +0000
131@@ -1,4 +1,4 @@
132-xquery version "1.0";
133+jsoniq version "1.0";
134
135 (:
136 : Copyright 2012 The FLWOR Foundation.
137@@ -17,62 +17,62 @@
138 :)
139
140 (:~
141- : <p>This module provides functionality to work with (possibly compressed)
142+ : This module provides functionality to work with (possibly compressed)
143 : archives. For example, it provides functions to retrieve the names or
144 : extract the values of several entries in a ZIP archive. Moreover,
145- : there exist functions that allow to create or update archives.</p>
146+ : there exist functions that allow to create or update archives.<p/>
147 :
148- : <p>The following archive formats and compression algorithms are supported:
149+ : The following archive formats and compression algorithms are supported:
150 : <ul>
151 : <li>ZIP (with compression DEFLATE or STORE)</li>
152 : <li>TAR (with compression GZIP)</li>
153 : </ul>
154- : </p>
155+ : <p/>
156 :
157 : @author Luis Rodgriguez, Juan Zacarias, and Matthias Brantner
158 :
159 : @library <a href="http://code.google.com/p/libarchive/">libarchive</a>
160 : @project Zorba/Archive
161 :)
162-module namespace a = "http://www.zorba-xquery.com/modules/archive";
163+module namespace a = "http://zorba.io/modules/archive";
164
165-import schema namespace options = "http://www.zorba-xquery.com/modules/archive";
166-
167 declare namespace ver = "http://www.zorba-xquery.com/options/versioning";
168 declare option ver:module-version "1.0";
169
170 (:~
171- : Creates a new ZIP archive out of the given entries and contents.
172+ : Creates a new ZIP archive out of the given entries and contents. <p/>
173 :
174- : <p>All entries are compressed with the DEFLATE compression algorithm.</p>
175+ : All entries are compressed with the DEFLATE compression algorithm.<p/>
176 :
177- : <p>The parameters $entries and $contents have the same meaning as for
178- : the function a:create with three arguments.</p>
179+ : The parameters $entries and $contents have the same meaning as for
180+ : the function a:create with three arguments.<p/>
181 :
182- : <p>Entry entries can include a type attribute, this attribute can have one
183+ : Entry entries can include a type element, this element can have one
184 : of two possible values: "regular" or "directory". If "regular" is
185 : specified then the entry will be created as a regular file; if "directory"
186 : is specified then the entry will be created as a directory, no contents
187 : will be read from $contents in this case. If no value is specified for type
188- : then it will be set to "regular". Example:
189+ : then it will be set to "regular". <p/>
190+ : Example:
191 : <pre>
192 : $zip-file := a:create(
193- : (&lt;a:entry encoding="ISO-8859-1" type="directory">dir1&lt;/a:entry>, "dir1/file1"),
194+ : ({ "encoding" : "ISO-8859-1", "type" : "directory", "name" : "dir1" }, "dir1/file1"),
195 : ("file contents"))
196 : </pre>
197- : </p>
198+ : <p/>
199 :
200 : @param $entries the meta data for the entries in the archive. Each entry
201- : can be of type xs:string or an element with name a:entry.
202+ : can be of type xs:string or a JSON oibject describing the entry.
203 : @param $contents the content for the archive. Each item in the sequence
204 : can be of type xs:string or xs:base64Binary.
205 :
206 : @return the generated archive as xs:base64Binary
207 :
208- : @error a:ARCH0001 if the number of entry elements differs from the number
209- : of items in the $contents sequence: count($entries) ne count($contents)
210- : @error a:ARCH0003 if a value for an entry element is invalid
211- : @error a:ARCH0004 if a given encoding is invalid or not supported
212+ : @error a:ENTRY-COUNT-MISMATCH if the number of entries that don't describe directories
213+ : differs from the number of items in the $contents sequence:
214+ : count($non-directory-entries) ne count($contents)
215+ : @error a:INVALID-ENTRY-VALS if a values in an entry object are invalid
216+ : @error a:INVALID-ENCODING if a given encoding is invalid or not supported
217 : @error err:FORG0006 if an item in the contents sequence is not of type xs:string
218 : or xs:base64Binary
219 :)
220@@ -82,94 +82,106 @@
221 as xs:base64Binary external;
222
223 (:~
224- : Creates a new archive out of the given entries and contents.
225+ : Creates a new archive out of the given entries and contents. <p/>
226 :
227- : <p>The $entries arguments provides meta data for each entry in the archive.
228+ : The $entries arguments provides meta data for each entry in the archive.
229 : For example, the name of the entry (mandatory) or the last-modified date
230 : (optional). An entry can either be of type xs:string to describe the entry
231- : name or of type xs:base64Binary to provide additional meta data.</p>
232+ : name or of type xs:base64Binary to provide additional meta data.<p/>
233 :
234- : <p>The $contents sequence provides the data (xs:string or xs:base64Binary) for
235+ : The $contents sequence provides the data (xs:string or xs:base64Binary) for
236 : the entries that should be included in the archive. Its length needs to
237- : match the length of the $entries sequence (a:ARCH0001). All items of type
238- : xs:base64Binary are decoded before being added to the archive.</p>
239+ : match the length of the entries in the $entries sequence that don't describe
240+ : directory entries (a:ARCH0001). All items of type xs:base64Binary are decoded
241+ : before being added to the archive.<p/>
242 :
243- : <p>For each entry, the name, last-modified date and time, and compression
244+ : For each entry, the name, last-modified date and time, and compression
245 : can be specified. In addition, an encoding can be specified which is used to
246 : store entries of type xs:string. If no last-modified attribute is given, the
247 : default is the current date and time. The compression is useful if various
248 : entries in a ZIP archive are compressed using different compression
249- : algorithms (i.e. store or deflate).</p>
250+ : algorithms (i.e. store or deflate).<p/>
251 :
252- : <p>For example, the following sequence may be used to describe an archive
253- : containing three elements:
254- : <pre class="ace-static" ace-mode="xquery"><![CDATA[&lt;a:entry last-modified="{fn:current-dateTime()}">myfile.txt&lt;/a:entry>
255- : &lt;a:entry encoding="ISO-8859-1" compression="store">dir/myfile.xml&lt;/a:entry>]]>
256+ : For example, the following sequence may be used to describe an archive
257+ : containing two elements: <p/>
258+ : <pre class="ace-static" ace-mode="xquery">{
259+ : "last-modified" : "{fn:current-dateTime()}"
260+ : "name" : "myfile.txt"
261+ : },
262+ : {
263+ : "encoding" : "ISO-8859-1",
264+ : "compression" : "store",
265+ : "name" : "dir/myfile.xml"
266+ : }
267 : </pre>
268- : </p>
269+ : <p/>
270 :
271- : <p>The $options argument may be used to describe general options for the
272- : archive. For example, the following option element can be used to create a ZIP
273+ : The $options argument may be used to describe general options for the
274+ : archive. For example, the following options can be used to create a ZIP
275 : archive in which all entries are compressed with the DEFLATE compression
276- : algorithm:
277- : <pre class="ace-static" ace-mode="xquery"><![CDATA[&lt;archive:options>
278- : &lt;archive:format>ZIP&lt;/archive:format>
279- : &lt;archive:compression>DEFLATE&lt;/archive:compression>
280- : &lt;/archive:options>]]>
281+ : algorithm: <p/>
282+ : <pre class="ace-static" ace-mode="xquery">{
283+ : "format" : "ZIP",
284+ : "compression" : "DEFLATE"
285+ : }
286 : </pre>
287- : </p>
288+ : <p/>
289 :
290- : <p>The result of the function is the generated archive as a item of type
291- : xs:base64Binary.</p>
292+ : The result of the function is the generated archive as a item of type
293+ : xs:base64Binary.<p/>
294 :
295 :
296 : @param $entries the meta data for the entries in the archive. Each entry
297- : can be of type xs:string or an element with name a:entry.
298+ : can be of type xs:string or an JSON object describing the entry.
299 : @param $contents the content for the archive. Each item in the sequence
300 : can be of type xs:string or xs:base64Binary.
301 : @param $options the options used to generate the archive.
302 :
303 : @return the generated archive as xs:base64Binary
304 :
305- : @error a:ARCH0001 if the number of entry elements differs from the number
306- : of items in the $contents sequence: count($entries) ne count($contents)
307- : @error a:ARCH0002 if the options argument contains invalid values
308- : @error a:ARCH0003 if a value for an entry element is invalid
309- : @error a:ARCH0004 if a given encoding is invalid or not supported
310+ : @error a:ENTRY-COUNT-MISMATCH if the number of entries describing non-directories differs
311+ : from the number of items in the $contents sequence:
312+ : count($non-directoy-entries) ne count($contents)
313+ : @error a:INVALID-OPTIONS if the options argument contains invalid values
314+ : @error a:INVALID-ENTRY-VALS if any values in an entry are invalid
315+ : @error a:INVALID-ENCODING if a given encoding is invalid or not supported
316+ : @error a:DIFFERENT-COMPRESSIONS-NOT-SUPPORTED if different compression algorithms
317+ : were selected but the actual version of libarchive doesn't support it.
318 : @error err:FORG0006 if an item in the contents sequence is not of type xs:string
319 : or xs:base64Binary
320 :)
321 declare function a:create(
322 $entries as item()*,
323 $contents as item()*,
324- $options as element(a:options))
325+ $options as object())
326 as xs:base64Binary external;
327
328 (:~
329- : Returns the header information of all entries in the given archive.
330+ : Returns the header information of all entries in the given archive as a JSON
331+ : objects sequence. <p/>
332 :
333- : <p>Such information includes the name of the entry, the uncompressed size,
334+ : Such information includes the name of the entry, the uncompressed size,
335 : as well as the last-modified timestamp. Note that not all values are
336- : available in every archive.</p>
337+ : available in every archive.<p/>
338 :
339 : @param $archive the archive to list the entries from as xs:base64Binary
340 :
341 : @return a sequence of strings, one for each entry in the archive
342 :
343- : @error a:ARCH9999 if $archive is not an archive or corrupted
344+ : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted
345 :)
346 declare function a:entries($archive as xs:base64Binary)
347- as element(a:entry)* external;
348+ as object()* external;
349
350 (:~
351 : Extracts the contents of all entries in the given archive as text
352- : using UTF-8 as default encoding.
353+ : using UTF-8 as default encoding. <p/>
354 :
355 : @param $archive the archive to extract the entries from as xs:base64Binary
356 :
357 : @return one string for the contents of each entry in the archive
358 :
359- : @error a:ARCH9999 if $archive is not an archive or corrupted
360+ : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted
361 : @error err:FOCH0001 if any of the entries contains invalid utf-8 characters
362 :)
363 declare function a:extract-text($archive as xs:base64Binary)
364@@ -178,7 +190,7 @@
365 (:~
366 : Extracts the contets of the entries identified by a given sequence of
367 : names as text.
368- : The default encoding used to read the string is UTF-8.
369+ : The default encoding used to read the string is UTF-8. <p/>
370 :
371 : @param $archive the archive to extract the entries from as xs:base64Binary
372 : @param $entry-names a sequence of names for entries which should be extracted
373@@ -186,7 +198,7 @@
374 : @return a sequence of strings for the given sequence of names or the
375 : empty sequence if no entries match the given names.
376 :
377- : @error a:ARCH9999 if $archive is not an archive or corrupted
378+ : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted
379 : @error err:FOCH0001 if any of the entries requested contains invalid utf-8 characters
380 :)
381 declare function a:extract-text($archive as xs:base64Binary, $entry-names as xs:string*)
382@@ -194,7 +206,7 @@
383
384 (:~
385 : Extracts the contets of the entries identified by a given sequence of
386- : names as text. Each entry is treated with the given encoding.
387+ : names as text. Each entry is treated with the given encoding. <p/>
388 :
389 : @param $archive the archive to extract the entries from as xs:base64Binary
390 : @param $entry-names a sequence of entry names that should be extracted
391@@ -203,8 +215,8 @@
392 : @return a sequence of strings for the given sequence of names or the
393 : empty sequence if no entries match the given names.
394 :
395- : @error a:ARCH9999 if $archive is not an archive or corrupted
396- : @error a:ARCH0004 if the given $encoding is invalid or not supported
397+ : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted
398+ : @error a:INVALID-ENCODING if the given $encoding is invalid or not supported
399 : @error err:FOCH0001 if a transcoding error happens
400 :)
401 declare function a:extract-text(
402@@ -215,20 +227,20 @@
403
404 (:~
405 : Returns the entries identified by the given paths from the archive
406- : as base64Binary.
407+ : as base64Binary. <p/>
408 :
409 : @param $archive the archive to extract the entries from as xs:base64Binary
410 :
411 : @return one xs:base64Binary item for the contents of each entry in the archive
412 :
413- : @error a:ARCH9999 if $archive is not an archive or corrupted
414+ : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted
415 :)
416 declare function a:extract-binary($archive as xs:base64Binary)
417 as xs:base64Binary* external;
418
419 (:~
420 : Returns the entries identified by the given paths from the archive
421- : as base64Binary.
422+ : as base64Binary. <p/>
423 :
424 : @param $archive the archive to extract the entries from as xs:base64Binary
425 :
426@@ -237,66 +249,70 @@
427 : @return a sequence of xs:base64Binary itmes for the given sequence of names
428 : or the empty sequence if no entries match the given names.
429 :
430- : @error a:ARCH9999 if $archive is not an archive or corrupted
431+ : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted
432 :)
433 declare function a:extract-binary($archive as xs:base64Binary, $entry-names as xs:string*)
434 as xs:base64Binary* external;
435
436 (:~
437 : Adds and replaces entries in an archive according to
438- : the given spec. The contents can be string and base64Binary items.
439+ : the given spec. The contents can be string and base64Binary items. <p/>
440 :
441- : <p>The parameters $entries and $contents have the same meaning as for
442- : the function a:create with three arguments.</p>
443+ : The parameters $entries and $contents have the same meaning as for
444+ : the function a:create with three arguments.<p/>
445 :
446 : @param $archive the archive to add or replace content
447 : @param $entries the meta data for the entries in the archive. Each entry
448- : can be of type xs:string or an element with name a:entry.
449+ : can be of type xs:string or a JSON object. For mandatory fields in the
450+ : JSON object see create function.
451 : @param $contents the content for the archive. Each item in the sequence
452 : can be of type xs:string or xs:base64Binary.
453 :
454 : @return the updated xs:base64Binary
455 :
456- : @error a:ARCH0001 if the number of entry elements differs from the number
457- : of items in the $contents sequence: count($entries) ne count($contents)
458- : @error a:ARCH0003 if a value for an entry element is invalid
459- : @error a:ARCH0004 if a given encoding is invalid or not supported
460+ : @error a:ENTRY-COUNT-MISMATCH if the number of entry elements differs from the number
461+ : of items in the $contents sequence: count($non-directory-entries) ne count($contents)
462+ : @error a:INVALID-ENTRY-VALS if a value for an entry element is invalid
463+ : @error a:INVALID-ENCODING if a given encoding is invalid or not supported
464+ : @error a:DIFFERENT-COMPRESSIONS-NOT-SUPPORTED if different compression algorithms
465+ : were selected but the actual version of libarchive doesn't support it.
466 : @error err:FORG0006 if an item in the contents sequence is not of type xs:string
467 : or xs:base64Binary
468- : @error a:ARCH9999 if $archive is not an archive or corrupted
469+ : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted
470 :
471 :)
472 declare function a:update($archive as xs:base64Binary, $entries as item()*, $contents as item()*)
473 as xs:base64Binary external;
474
475 (:~
476- : Deletes entries from an archive.
477+ : Deletes entries from an archive. <p/>
478 :
479 : @param $archive the archive to extract the entries from as xs:base64Binary
480 : @param $entry-names a sequence of names for entries which should be deleted
481 :
482 : @return the updated base64Binary
483 :
484- : @error a:ARCH9999 if $archive is not an archive or corrupted
485+ : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted
486 :)
487 declare function a:delete($archive as xs:base64Binary, $entry-names as xs:string*)
488 as xs:base64Binary external;
489
490 (:~
491- : Returns the algorithm and format options of the given archive.
492+ : Returns the algorithm and format options as a JSON object for a given archive.
493 : For example, for a ZIP archive, the following options element
494- : would be returned:
495- : <pre class="ace-static" ace-mode="xquery"><![CDATA[&lt;archive:options>
496- : &lt;archive:format>ZIP&lt;/archive:format>
497- : &lt;archive:compressionDEFLATE&lt;/archive:compression>
498- : &lt;/archive:options>]]>
499+ : would be returned: <p/>
500+ : <pre class="ace-static" ace-mode="xquery">{
501+ : "format" : "ZIP",
502+ : "compression" : "DEFLATE"
503+ : }
504 : </pre>
505+ : <p/>
506 :
507 : @param $archive the archive as xs:base64Binary
508 :
509- : @return the algorithm and format options
510+ : @return the algorithm and format options as a JSON object
511 :
512- : @error a:ARCH9999 if $archive is not an archive or corrupted
513+ : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted
514 :)
515 declare function a:options($archive as xs:base64Binary)
516- as element(a:options) external;
517+ as object() external;
518
519=== modified file 'src/archive_module.xq.src/archive_module.cpp'
520--- src/archive_module.xq.src/archive_module.cpp 2013-06-21 04:18:40 +0000
521+++ src/archive_module.xq.src/archive_module.cpp 2013-07-29 19:28:26 +0000
522@@ -45,8 +45,23 @@
523 #include "archive_module.h"
524 #include "config.h"
525
526+#define ERROR_ENTRY_COUNT_MISMATCH "ENTRY-COUNT"
527+#define ERROR_INVALID_OPTIONS "INVALID-OPTIONS"
528+#define ERROR_INVALID_ENTRY_VALS "INVALID-ENTRY-VALS"
529+#define ERROR_INVALID_ENCODING "INVALID-ENCODING"
530+#define ERROR_CORRUPTED_ARCHIVE "CORRUPTED-ARCHIVE"
531+#define ERROR_DIFFERENT_COMPRESSIONS_NOT_SUPPORTED "DIFFERENT-COMPRESSIONS-NOT-SUPPORTED"
532+
533 namespace zorba { namespace archive {
534
535+// Allocating global keys
536+zorba::Item ArchiveModule::globalFormatKey;
537+zorba::Item ArchiveModule::globalCompressionKey;
538+zorba::Item ArchiveModule::globalNameKey;
539+zorba::Item ArchiveModule::globalTypeKey;
540+zorba::Item ArchiveModule::globalSizeKey;
541+zorba::Item ArchiveModule::globalLastModifiedKey;
542+zorba::Item ArchiveModule::globalEncodingKey;
543
544 /*******************************************************************************
545 ******************************************************************************/
546@@ -146,10 +161,26 @@
547 std::ostringstream lMsg;
548 lMsg << i.getStringValue()
549 << ": invalid value for last-modified attribute ";
550- ArchiveFunction::throwError("ARCH0003", lMsg.str().c_str());
551+ ArchiveFunction::throwError(ERROR_INVALID_ENTRY_VALS, lMsg.str().c_str());
552 }
553 }
554
555+ zorba::Item&
556+ ArchiveModule::getGlobalItems(enum ArchiveModule::GLOBAL_ITEMS g)
557+ {
558+ switch(g)
559+ {
560+ case FORMAT: return globalFormatKey;
561+ case COMPRESSION: return globalCompressionKey;
562+ case NAME: return globalNameKey;
563+ case TYPE: return globalTypeKey;
564+ case SIZE: return globalSizeKey;
565+ case LAST_MODIFIED: return globalLastModifiedKey;
566+ case ENCODING: return globalEncodingKey;
567+ // we should never touch the default clause but ...
568+ default: return globalFormatKey;
569+ }
570+ }
571
572 /*******************************************************************************
573 ****************************** ArchiveFunction ********************************
574@@ -209,34 +240,36 @@
575 void
576 ArchiveFunction::ArchiveEntry::setValues(zorba::Item& aEntry)
577 {
578- theEntryPath = aEntry.getStringValue();
579-
580- if (aEntry.isNode())
581+ if (aEntry.isJSONItem())
582 {
583- Item lAttr;
584+ Item lKey;
585
586- Iterator_t lAttrIter = aEntry.getAttributes();
587- lAttrIter->open();
588- while (lAttrIter->next(lAttr))
589+ Iterator_t lKeyIter = aEntry.getObjectKeys();
590+ lKeyIter->open();
591+ while (lKeyIter->next(lKey))
592 {
593- Item lAttrName;
594- lAttr.getNodeName(lAttrName);
595+ Item lKeyValue;
596+ lKeyValue = aEntry.getObjectValue(lKey.getStringValue());
597
598- if(lAttrName.getLocalName() == "type")
599- {
600- String filetype = lAttr.getStringValue();
601+ if(lKey.getStringValue() == ArchiveModule::getGlobalItems(ArchiveModule::NAME).getStringValue())
602+ {
603+ theEntryPath = lKeyValue.getStringValue();
604+ }
605+ else if(lKey.getStringValue() == ArchiveModule::getGlobalItems(ArchiveModule::TYPE).getStringValue())
606+ {
607+ String filetype = lKeyValue.getStringValue();
608 if(filetype == "directory")
609 {
610 theEntryType = directory;
611 }
612 }
613- else if (lAttrName.getLocalName() == "last-modified")
614+ else if (lKey.getStringValue() == ArchiveModule::getGlobalItems(ArchiveModule::LAST_MODIFIED).getStringValue())
615 {
616- ArchiveModule::parseDateTimeItem(lAttr, theLastModified);
617+ ArchiveModule::parseDateTimeItem(lKeyValue, theLastModified);
618 }
619- else if (lAttrName.getLocalName() == "encoding")
620+ else if (lKey.getStringValue() == ArchiveModule::getGlobalItems(ArchiveModule::ENCODING).getStringValue())
621 {
622- theEncoding = lAttr.getStringValue();
623+ theEncoding = lKeyValue.getStringValue();
624 std::transform(
625 theEncoding.begin(), theEncoding.end(),
626 theEncoding.begin(), ::toupper);
627@@ -245,19 +278,24 @@
628 std::ostringstream lMsg;
629 lMsg << theEncoding << ": unsupported encoding";
630
631- throwError("ARCH0004", lMsg.str().c_str());
632+ throwError(ERROR_INVALID_ENCODING, lMsg.str().c_str());
633 }
634 }
635- else if (lAttrName.getLocalName() == "compression")
636+ else if (lKey.getStringValue() == ArchiveModule::getGlobalItems(ArchiveModule::COMPRESSION).getStringValue())
637 {
638- theCompression = lAttr.getStringValue();
639+ theCompression = lKeyValue.getStringValue();
640 std::transform(
641 theCompression.begin(),
642 theCompression.end(),
643 theCompression.begin(), ::toupper);
644 }
645+ else if (lKey.getStringValue() == ArchiveModule::getGlobalItems(ArchiveModule::SIZE).getStringValue())
646+ {
647+ theSize = lKeyValue.getLongValue();
648+ }
649 }
650- }
651+ } else
652+ theEntryPath = aEntry.getStringValue();
653 }
654
655 /********************
656@@ -281,66 +319,67 @@
657 void
658 ArchiveFunction::ArchiveOptions::setValues(Item& aOptions)
659 {
660- Item lOption;
661-
662- Iterator_t lOptionIter = aOptions.getChildren();
663- lOptionIter->open();
664-
665- while (lOptionIter->next(lOption))
666- {
667- Item lOptionName;
668- lOption.getNodeName(lOptionName);
669-
670- if (lOptionName.getLocalName() == "compression")
671- {
672- theCompression = lOption.getStringValue().c_str();
673- std::transform(
674- theCompression.begin(),
675- theCompression.end(),
676- theCompression.begin(), ::toupper);
677- }
678- else if (lOptionName.getLocalName() == "format")
679- {
680- theFormat = lOption.getStringValue().c_str();
681- std::transform(
682- theFormat.begin(),
683- theFormat.end(),
684- theFormat.begin(), ::toupper);
685- }
686- else if (lOptionName.getLocalName() == "skip-extra-attributes")
687- {
688- theSkipExtraAttrs = lOption.getStringValue() == "true" ? true : false;
689- }
690- }
691- if (theFormat == "ZIP")
692- {
693- if (theCompression != "STORE" && theCompression != "DEFLATE" && theCompression != "NONE")
694- {
695- std::ostringstream lMsg;
696- lMsg
697- << theCompression
698- << ": compression algorithm not supported for ZIP format (required: deflate, store)";
699- throwError("ARCH0002", lMsg.str().c_str());
700- }
701- }
702- if (theFormat == "TAR")
703- {
704- if (theCompression != "GZIP"
705-#ifndef WIN32
706- && theCompression != "BZIP2"
707- && theCompression != "LZMA"
708-#endif
709- )
710- {
711- std::ostringstream lMsg;
712- lMsg
713- << theCompression
714- << ": compression algorithm not supported for TAR format (required: gzip"
715-#ifndef WIN32
716- << ", bzip2, lzma"
717-#endif
718- << ")";
719- throwError("ARCH0002", lMsg.str().c_str());
720+ if(aOptions.isJSONItem())
721+ {
722+ Item lOptionKey;
723+ Iterator_t lKeyIter = aOptions.getObjectKeys();
724+ lKeyIter->open();
725+
726+ while (lKeyIter->next(lOptionKey))
727+ {
728+ Item lOptionValue;
729+ lOptionValue = aOptions.getObjectValue(lOptionKey.getStringValue());
730+
731+ if (lOptionKey.getStringValue() == ArchiveModule::getGlobalItems(ArchiveModule::COMPRESSION).getStringValue())
732+ {
733+ theCompression = lOptionValue.getStringValue().c_str();
734+ std::transform(
735+ theCompression.begin(),
736+ theCompression.end(),
737+ theCompression.begin(), ::toupper);
738+ }
739+ else if (lOptionKey.getStringValue() == ArchiveModule::getGlobalItems(ArchiveModule::FORMAT).getStringValue())
740+ {
741+ theFormat = lOptionValue.getStringValue().c_str();
742+ std::transform(
743+ theFormat.begin(),
744+ theFormat.end(),
745+ theFormat.begin(), ::toupper);
746+ }
747+ else if (lOptionKey.getStringValue() == "skip-extra-attributes")
748+ {
749+ theSkipExtraAttrs = lOptionValue.getStringValue() == "true" ? true : false;
750+ }
751+ }
752+ if (theFormat == "ZIP")
753+ {
754+ if (theCompression != "STORE" && theCompression != "DEFLATE" && theCompression != "NONE")
755+ {
756+ std::ostringstream lMsg;
757+ lMsg
758+ << theCompression
759+ << ": compression algorithm not supported for ZIP format (required: deflate, store)";
760+ throwError(ERROR_INVALID_OPTIONS, lMsg.str().c_str());
761+ }
762+ }
763+ if (theFormat == "TAR")
764+ { if (theCompression != "GZIP"
765+#ifndef WIN32
766+ && theCompression != "BZIP2"
767+ && theCompression != "LZMA"
768+#endif
769+ )
770+ {
771+ std::ostringstream lMsg;
772+ lMsg
773+ << theCompression
774+ << ": compression algorithm not supported for TAR format (required: gzip"
775+#ifndef WIN32
776+ << ", bzip2, lzma"
777+#endif
778+ << ")";
779+ throwError(ERROR_INVALID_OPTIONS, lMsg.str().c_str());
780+ }
781 }
782 }
783 }
784@@ -550,7 +589,7 @@
785
786 if (!theArchive)
787 ArchiveFunction::throwError(
788- "ARCH9999", "internal error (couldn't create archive)");
789+ ERROR_CORRUPTED_ARCHIVE, "internal error (couldn't create archive)");
790
791 setOptions(aOptions);
792 }
793@@ -572,7 +611,7 @@
794 std::ostringstream lMsg;
795 lMsg << "number of entries (" << aEntries.size()
796 << ") doesn't match number of content arguments (" << i << ")";
797- throwError("ARCH0001", lMsg.str().c_str());
798+ throwError(ERROR_ENTRY_COUNT_MISMATCH, lMsg.str().c_str());
799 }
800 }
801
802@@ -587,7 +626,7 @@
803 std::ostringstream lMsg;
804 lMsg << "number of entries (" << aEntries.size()
805 << ") less than number of content arguments";
806- throwError("ARCH0001", lMsg.str().c_str());
807+ throwError(ERROR_ENTRY_COUNT_MISMATCH, lMsg.str().c_str());
808 }
809
810 aFiles->close();
811@@ -601,7 +640,6 @@
812
813 archive_entry_set_pathname(theEntry, aEntry.getEntryPath().c_str());
814 archive_entry_set_mtime(theEntry, aEntry.getLastModified(), 0);
815- // TODO: modified to allow the creation of empty directories
816 if(aEntry.getEntryType() == ArchiveEntry::regular){
817 archive_entry_set_filetype(theEntry, AE_IFREG);
818 lDeleteStream = getStream(
819@@ -626,7 +664,7 @@
820 #ifndef ZORBA_LIBARCHIVE_HAVE_SET_COMPRESSION
821 std::ostringstream lMsg;
822 lMsg << lNextCompString << ": setting different compression algorithms for each entry is not supported by the used version of libarchive";
823- throwError("ARCH0099", lMsg.str().c_str());
824+ throwError(ERROR_DIFFERENT_COMPRESSIONS_NOT_SUPPORTED, lMsg.str().c_str());
825 #endif
826 }
827 else
828@@ -638,7 +676,7 @@
829 {
830 std::ostringstream lMsg;
831 lMsg << lNextCompString << ": compression algorithm not supported for ZIP format (required: deflate, store)";
832- throwError("ARCH0002", lMsg.str().c_str());
833+ throwError(ERROR_INVALID_OPTIONS, lMsg.str().c_str());
834 }
835
836 #ifdef ZORBA_LIBARCHIVE_HAVE_SET_COMPRESSION
837@@ -651,7 +689,7 @@
838 {
839 std::ostringstream lMsg;
840 lMsg << aEntry.getCompression() << ": compression attribute only allowed for zip format";
841- throwError("ARCH0099", lMsg.str().c_str());
842+ throwError(ERROR_DIFFERENT_COMPRESSIONS_NOT_SUPPORTED, lMsg.str().c_str());
843 }
844 }
845
846@@ -718,7 +756,7 @@
847 {
848 if (!aLocalName)
849 {
850- throwError("ARCH9999", archive_error_string(a));
851+ throwError(ERROR_CORRUPTED_ARCHIVE, archive_error_string(a));
852 }
853 else
854 {
855@@ -781,7 +819,7 @@
856 {
857 std::ostringstream lMsg;
858 lMsg << f << ": archive format not supported";
859- throwError("ARCH0002", lMsg.str().c_str());
860+ throwError(ERROR_INVALID_OPTIONS, lMsg.str().c_str());
861 }
862 return 0;
863 }
864@@ -817,7 +855,7 @@
865 {
866 std::ostringstream lMsg;
867 lMsg << c << ": compression algorithm not supported";
868- throwError("ARCH0002", lMsg.str().c_str());
869+ throwError(ERROR_INVALID_OPTIONS, lMsg.str().c_str());
870 }
871 return 0;
872 }
873@@ -897,7 +935,7 @@
874
875 if (!theArchive)
876 ArchiveFunction::throwError(
877- "ARCH9999", "internal error (couldn't create archive)");
878+ ERROR_CORRUPTED_ARCHIVE, "internal error (couldn't create archive)");
879
880 int lErr = archive_read_support_compression_all(theArchive);
881 ArchiveFunction::checkForError(lErr, 0, theArchive);
882@@ -1039,15 +1077,6 @@
883 zorba::Item& aArchive)
884 : ArchiveIterator(aArchive)
885 {
886- theUntypedQName = theFactory->createQName(
887- "http://www.w3.org/2001/XMLSchema", "untyped");
888-
889- theEntryName = theFactory->createQName(
890- ArchiveModule::getModuleURI(), "entry");
891-
892- theLastModifiedName = theFactory->createQName("", "last-modified");
893- theUncompressedSizeName = theFactory->createQName("", "size");
894- theEntryType = theFactory->createQName("", "type");
895 }
896
897 bool
898@@ -1064,49 +1093,42 @@
899 ArchiveFunction::checkForError(lErr, 0, theArchive);
900 }
901
902- Item lNoParent;
903-
904- Item lType = theUntypedQName;
905-
906- // create entry element
907- aRes = theFactory->createElementNode(
908- lNoParent, theEntryName, lType, true, false, NsBindings());
909+ std::vector<std::pair<zorba::Item, zorba::Item> > lObjectArray;
910+ std::pair<zorba::Item, zorba::Item> lElemPair;
911
912 // create text content (i.e. path name)
913 String lName = archive_entry_pathname(lEntry);
914- Item lNameItem = theFactory->createString(lName);
915- theFactory->assignElementTypedValue(aRes, lNameItem);
916+ lElemPair = std::make_pair<zorba::Item, zorba::Item>(ArchiveModule::getGlobalItems(ArchiveModule::NAME),
917+ theFactory->createString(lName));
918+ lObjectArray.push_back(lElemPair);
919
920 // create size attr if the value is set in the archive
921 if (archive_entry_size_is_set(lEntry))
922 {
923 long long lSize = archive_entry_size(lEntry);
924- Item lSizeItem = theFactory->createInteger(lSize);
925- lType = theUntypedQName;
926- theFactory->createAttributeNode(
927- aRes, theUncompressedSizeName, lType, lSizeItem);
928+ lElemPair = std::make_pair<zorba::Item, zorba::Item>(ArchiveModule::getGlobalItems(ArchiveModule::SIZE),
929+ theFactory->createInteger(lSize));
930+ lObjectArray.push_back(lElemPair);
931 }
932
933 // create last-modified attr if the value is set in the archive
934 if (archive_entry_mtime_is_set(lEntry))
935 {
936 time_t lTime = archive_entry_mtime(lEntry);
937- Item lModifiedItem = ArchiveModule::createDateTimeItem(lTime);
938-
939- lType = theUntypedQName;
940- theFactory->createAttributeNode(
941- aRes, theLastModifiedName, lType, lModifiedItem);
942+ lElemPair = std::make_pair<zorba::Item, zorba::Item>(ArchiveModule::getGlobalItems(ArchiveModule::LAST_MODIFIED),
943+ ArchiveModule::createDateTimeItem(lTime));
944+ lObjectArray.push_back(lElemPair);
945 }
946
947- Item lEntryType;
948+ std::string lEntryType;
949 if(archive_entry_filetype(lEntry) == AE_IFDIR)
950 {
951 // this entry is a directory
952- lEntryType = theFactory->createString("directory");
953+ lEntryType = "directory";
954 }
955 else if(archive_entry_filetype(lEntry) == AE_IFREG)
956 {
957- lEntryType = theFactory->createString("regular");
958+ lEntryType = "regular";
959 }
960 else
961 {
962@@ -1114,14 +1136,16 @@
963 // for the time being don't do anything
964 }
965
966- lType = theUntypedQName;
967- theFactory->createAttributeNode(
968- aRes, theEntryType, lType, lEntryType);
969+ lElemPair = std::make_pair<zorba::Item, zorba::Item>(ArchiveModule::getGlobalItems(ArchiveModule::TYPE),
970+ theFactory->createString(lEntryType));
971+ lObjectArray.push_back(lElemPair);
972
973 // skip to the next entry and raise an error if that fails
974 lErr = archive_read_data_skip(theArchive);
975 ArchiveFunction::checkForError(lErr, 0, theArchive);
976
977+ aRes = theFactory->createJSONObject(lObjectArray);
978+
979 return true;
980 }
981
982@@ -1190,7 +1214,7 @@
983 std::ostringstream lMsg;
984 lMsg << lEncoding << ": unsupported encoding";
985
986- throwError("ARCH0004", lMsg.str().c_str());
987+ throwError(ERROR_INVALID_ENCODING, lMsg.str().c_str());
988 }
989 }
990
991@@ -1363,6 +1387,11 @@
992 return ItemSequence_t(new OptionsItemSequence(lArchive));
993 }
994
995+ OptionsFunction::OptionsItemSequence::OptionsIterator::OptionsIterator(Item &aArchive)
996+ :ArchiveIterator(aArchive)
997+ {
998+ }
999+
1000 bool
1001 OptionsFunction::OptionsItemSequence::OptionsIterator::next(
1002 zorba::Item& aRes)
1003@@ -1372,6 +1401,9 @@
1004 lExhausted = true;
1005
1006 struct archive_entry *lEntry;
1007+ typedef std::pair<zorba::Item, zorba::Item> tArrElemt;
1008+ tArrElemt lElemt;
1009+ std::vector<tArrElemt> lJSONObject;
1010
1011 // to get the format, we need to peek into the first header
1012 int lErr = archive_read_next_header(theArchive, &lEntry);
1013@@ -1391,33 +1423,15 @@
1014 lCompression = "DEFLATE";
1015 }
1016
1017- zorba::Item lUntypedQName = theFactory->createQName(
1018- "http://www.w3.org/2001/XMLSchema", "untyped");
1019- zorba::Item lTmpQName = lUntypedQName;
1020-
1021- zorba::Item lOptionsQName = theFactory->createQName(
1022- ArchiveModule::getModuleURI(), "options");
1023-
1024- zorba::Item lFormatQName = theFactory->createQName(
1025- ArchiveModule::getModuleURI(), "format");
1026-
1027- zorba::Item lCompressionQName = theFactory->createQName(
1028- ArchiveModule::getModuleURI(), "compression");
1029-
1030- zorba::Item lNoParent;
1031- aRes = theFactory->createElementNode(
1032- lNoParent, lOptionsQName, lTmpQName, true, false, NsBindings());
1033-
1034- lTmpQName = lUntypedQName;
1035- zorba::Item lFormatItem = theFactory->createElementNode(
1036- aRes, lFormatQName, lTmpQName, true, false, NsBindings());
1037-
1038- lTmpQName = lUntypedQName;
1039- zorba::Item lCompressionItem = theFactory->createElementNode(
1040- aRes, lCompressionQName, lTmpQName, true, false, NsBindings());
1041-
1042- theFactory->createTextNode(lFormatItem, lFormat);
1043- theFactory->createTextNode(lCompressionItem, lCompression);
1044+ lElemt = std::make_pair<zorba::Item, zorba::Item>(ArchiveModule::getGlobalItems(ArchiveModule::FORMAT),
1045+ theFactory->createString(lFormat));
1046+ lJSONObject.push_back(lElemt);
1047+
1048+ lElemt = std::make_pair<zorba::Item, zorba::Item>(ArchiveModule::getGlobalItems(ArchiveModule::COMPRESSION),
1049+ theFactory->createString(lCompression));
1050+ lJSONObject.push_back(lElemt);
1051+
1052+ aRes = theFactory->createJSONObject(lJSONObject);
1053
1054 return true;
1055 }
1056@@ -1647,6 +1661,7 @@
1057 }
1058 // else? if the entry represents a directory what are we
1059 // going to return??
1060+ // answer: nothing, the directory will have no contents at all
1061
1062 return true;
1063 }
1064
1065=== modified file 'src/archive_module.xq.src/archive_module.h'
1066--- src/archive_module.xq.src/archive_module.h 2013-02-18 22:00:20 +0000
1067+++ src/archive_module.xq.src/archive_module.h 2013-07-29 19:28:26 +0000
1068@@ -52,8 +52,29 @@
1069
1070 FuncMap_t theFunctions;
1071
1072+ static zorba::Item globalFormatKey;
1073+ static zorba::Item globalCompressionKey;
1074+ static zorba::Item globalNameKey;
1075+ static zorba::Item globalTypeKey;
1076+ static zorba::Item globalSizeKey;
1077+ static zorba::Item globalLastModifiedKey;
1078+ static zorba::Item globalEncodingKey;
1079+
1080 public:
1081
1082+ enum GLOBAL_ITEMS { FORMAT, COMPRESSION, NAME, TYPE, SIZE, LAST_MODIFIED, ENCODING };
1083+
1084+ ArchiveModule()
1085+ {
1086+ globalFormatKey = Zorba::getInstance(0)->getItemFactory()->createString("format");
1087+ globalCompressionKey = Zorba::getInstance(0)->getItemFactory()->createString("compression");
1088+ globalNameKey = Zorba::getInstance(0)->getItemFactory()->createString("name");
1089+ globalTypeKey = Zorba::getInstance(0)->getItemFactory()->createString("type");
1090+ globalSizeKey = Zorba::getInstance(0)->getItemFactory()->createString("size");
1091+ globalLastModifiedKey = Zorba::getInstance(0)->getItemFactory()->createString("last-modified");
1092+ globalEncodingKey = Zorba::getInstance(0)->getItemFactory()->createString("encoding");
1093+ }
1094+
1095 virtual ~ArchiveModule();
1096
1097 virtual zorba::String
1098@@ -71,7 +92,7 @@
1099 }
1100
1101 static zorba::String
1102- getModuleURI() { return "http://www.zorba-xquery.com/modules/archive"; }
1103+ getModuleURI() { return "http://zorba.io/modules/archive"; }
1104
1105 static zorba::Item
1106 createDateTimeItem(time_t&);
1107@@ -79,6 +100,7 @@
1108 static void
1109 parseDateTimeItem(const zorba::Item& i, time_t&);
1110
1111+ static zorba::Item& getGlobalItems(enum GLOBAL_ITEMS g);
1112 };
1113
1114
1115@@ -602,8 +624,7 @@
1116 class OptionsIterator : public ArchiveIterator
1117 {
1118 public:
1119- OptionsIterator(zorba::Item& aArchive)
1120- : ArchiveIterator(aArchive) {}
1121+ OptionsIterator(zorba::Item& aArchive);
1122
1123 virtual ~OptionsIterator() {}
1124
1125@@ -755,7 +776,6 @@
1126 ArchiveOptions& theOptions;
1127 };
1128
1129- //public:
1130 DeleteItemSequence(zorba::Item& aArchive)
1131 : ExtractFunction::ExtractItemSequence(aArchive, false) {}
1132
1133
1134=== modified file 'test/ExpQueryResults/entries_01.xml.res'
1135--- test/ExpQueryResults/entries_01.xml.res 2012-09-17 17:56:29 +0000
1136+++ test/ExpQueryResults/entries_01.xml.res 2013-07-29 19:28:26 +0000
1137@@ -1,2 +1,1 @@
1138-<?xml version="1.0" encoding="UTF-8"?>
1139-<entry xmlns="http://www.zorba-xquery.com/modules/archive" size="0" last-modified="2012-06-15T20:11:09Z" type="directory">dir1/</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="11" last-modified="2012-06-15T20:11:09Z" type="regular">dir1/file1</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="11" last-modified="2012-06-15T20:11:03Z" type="regular">dir1/file2</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="0" last-modified="2012-06-15T20:10:51Z" type="directory">dir2/</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="6" last-modified="2012-06-15T20:10:47Z" type="regular">file1</entry>
1140\ No newline at end of file
1141+{ "name" : "dir1/", "size" : 0, "last-modified" : "2012-06-15T20:11:09Z", "type" : "directory" }{ "name" : "dir1/file1", "size" : 11, "last-modified" : "2012-06-15T20:11:09Z", "type" : "regular" }{ "name" : "dir1/file2", "size" : 11, "last-modified" : "2012-06-15T20:11:03Z", "type" : "regular" }{ "name" : "dir2/", "size" : 0, "last-modified" : "2012-06-15T20:10:51Z", "type" : "directory" }{ "name" : "file1", "size" : 6, "last-modified" : "2012-06-15T20:10:47Z", "type" : "regular" }
1142\ No newline at end of file
1143
1144=== modified file 'test/ExpQueryResults/entries_02.xml.res'
1145--- test/ExpQueryResults/entries_02.xml.res 2012-09-17 17:56:29 +0000
1146+++ test/ExpQueryResults/entries_02.xml.res 2013-07-29 19:28:26 +0000
1147@@ -1,2 +1,1 @@
1148-<?xml version="1.0" encoding="UTF-8"?>
1149-<entry xmlns="http://www.zorba-xquery.com/modules/archive" size="0" last-modified="2012-06-15T20:11:09Z" type="directory">dir1/</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="11" last-modified="2012-06-15T20:11:09Z" type="regular">dir1/file1</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="11" last-modified="2012-06-15T20:11:03Z" type="regular">dir1/file2</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="0" last-modified="2012-06-15T20:10:51Z" type="directory">dir2/</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="6" last-modified="2012-06-15T20:10:47Z" type="regular">file1</entry>
1150\ No newline at end of file
1151+{ "name" : "dir1/", "size" : 0, "last-modified" : "2012-06-15T20:11:09Z", "type" : "directory" }{ "name" : "dir1/file1", "size" : 11, "last-modified" : "2012-06-15T20:11:09Z", "type" : "regular" }{ "name" : "dir1/file2", "size" : 11, "last-modified" : "2012-06-15T20:11:03Z", "type" : "regular" }{ "name" : "dir2/", "size" : 0, "last-modified" : "2012-06-15T20:10:51Z", "type" : "directory" }{ "name" : "file1", "size" : 6, "last-modified" : "2012-06-15T20:10:47Z", "type" : "regular" }
1152\ No newline at end of file
1153
1154=== modified file 'test/ExpQueryResults/entries_03.xml.res'
1155--- test/ExpQueryResults/entries_03.xml.res 2012-09-17 17:56:29 +0000
1156+++ test/ExpQueryResults/entries_03.xml.res 2013-07-29 19:28:26 +0000
1157@@ -1,1 +1,1 @@
1158-<entry xmlns="http://www.zorba-xquery.com/modules/archive" size="0" last-modified="2012-06-15T20:11:09Z" type="directory">dir1/</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="11" last-modified="2012-06-15T20:11:09Z" type="regular">dir1/file1</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="11" last-modified="2012-06-15T20:11:03Z" type="regular">dir1/file2</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="0" last-modified="2012-06-15T20:10:51Z" type="directory">dir2/</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="6" last-modified="2012-06-15T20:10:47Z" type="regular">file1</entry>
1159+{ "name" : "dir1/", "size" : 0, "last-modified" : "2012-06-15T20:11:09Z", "type" : "directory" }{ "name" : "dir1/file1", "size" : 11, "last-modified" : "2012-06-15T20:11:09Z", "type" : "regular" }{ "name" : "dir1/file2", "size" : 11, "last-modified" : "2012-06-15T20:11:03Z", "type" : "regular" }{ "name" : "dir2/", "size" : 0, "last-modified" : "2012-06-15T20:10:51Z", "type" : "directory" }{ "name" : "file1", "size" : 6, "last-modified" : "2012-06-15T20:10:47Z", "type" : "regular" }
1160\ No newline at end of file
1161
1162=== modified file 'test/ExpQueryResults/options_01.xml.res'
1163--- test/ExpQueryResults/options_01.xml.res 2012-08-03 21:54:38 +0000
1164+++ test/ExpQueryResults/options_01.xml.res 2013-07-29 19:28:26 +0000
1165@@ -1,2 +1,1 @@
1166-<?xml version="1.0" encoding="UTF-8"?>
1167-<options xmlns="http://www.zorba-xquery.com/modules/archive"><format>ZIP</format><compression>DEFLATE</compression></options><options xmlns="http://www.zorba-xquery.com/modules/archive"><format>TAR</format><compression>GZIP</compression></options>
1168\ No newline at end of file
1169+{ "format" : "ZIP", "compression" : "DEFLATE" }{ "format" : "TAR", "compression" : "GZIP" }
1170\ No newline at end of file
1171
1172=== modified file 'test/ExpQueryResults/options_02.xml.res'
1173--- test/ExpQueryResults/options_02.xml.res 2012-09-17 18:17:09 +0000
1174+++ test/ExpQueryResults/options_02.xml.res 2013-07-29 19:28:26 +0000
1175@@ -1,2 +1,1 @@
1176-<?xml version="1.0" encoding="UTF-8"?>
1177-<options xmlns="http://www.zorba-xquery.com/modules/archive"><format>TAR</format><compression>BZIP2</compression></options>
1178\ No newline at end of file
1179+{ "format" : "TAR", "compression" : "BZIP2" }
1180\ No newline at end of file
1181
1182=== modified file 'test/Queries/create_01.xq'
1183--- test/Queries/create_01.xq 2012-07-27 03:43:13 +0000
1184+++ test/Queries/create_01.xq 2013-07-29 19:28:26 +0000
1185@@ -1,4 +1,4 @@
1186-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1187+import module namespace a = "http://zorba.io/modules/archive";
1188
1189 let $foo-content := "<foo/>"
1190 let $bar-content := "<bar/>"
1191@@ -8,6 +8,7 @@
1192 )
1193 return
1194 string-join(
1195- for $a in a:entries($archive)
1196- return a:extract-text($archive, $a/text())
1197+ for $name in a:entries($archive)("name")
1198+ return a:extract-text($archive, $name)
1199 ) eq concat($foo-content, $bar-content)
1200+
1201
1202=== modified file 'test/Queries/create_02.xq'
1203--- test/Queries/create_02.xq 2013-07-17 07:50:04 +0000
1204+++ test/Queries/create_02.xq 2013-07-29 19:28:26 +0000
1205@@ -1,10 +1,10 @@
1206-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1207+import module namespace a = "http://zorba.io/modules/archive";
1208 import module namespace b = "http://zorba.io/modules/base64";
1209
1210 let $foo-content := "<foo/>"
1211 let $bar-content := xs:base64Binary("5Pb8")
1212 let $archive := a:create(
1213- ("foo.xml", <a:entry encoding="ISO-8859-1">bar.xml</a:entry>),
1214+ ("foo.xml", { "encoding" : "ISO-8859-1", "name" : "bar.xml" }),
1215 ($foo-content, $bar-content)
1216 )
1217 return
1218
1219=== modified file 'test/Queries/create_03.spec'
1220--- test/Queries/create_03.spec 2012-07-27 03:43:13 +0000
1221+++ test/Queries/create_03.spec 2013-07-29 19:28:26 +0000
1222@@ -1,1 +1,1 @@
1223-Error: http://www.zorba-xquery.com/modules/archive:ARCH0099
1224+Error: http://zorba.io/modules/archive:DIFFERENT-COMPRESSIONS-NOT-SUPPORTED
1225
1226=== modified file 'test/Queries/create_03.xq'
1227--- test/Queries/create_03.xq 2012-07-27 03:43:13 +0000
1228+++ test/Queries/create_03.xq 2013-07-29 19:28:26 +0000
1229@@ -1,9 +1,10 @@
1230-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1231+import module namespace a = "http://zorba.io/modules/archive";
1232
1233 let $foo-content := "<foo/>"
1234 let $bar-content := "<bar/>"
1235 let $archive := a:create(
1236- (<a:entry compression="store">foo.xml</a:entry>, <a:entry compression="deflate">bar.xml</a:entry>),
1237+ ({ "compression" : "store", "name" : "foo.xml" },
1238+ { "compression" : "deflate", "name" : "bar.xml" }),
1239 ($foo-content, $bar-content)
1240 )
1241 return
1242
1243=== modified file 'test/Queries/delete_01.xq'
1244--- test/Queries/delete_01.xq 2013-07-17 07:50:04 +0000
1245+++ test/Queries/delete_01.xq 2013-07-29 19:28:26 +0000
1246@@ -1,4 +1,4 @@
1247-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1248+import module namespace a = "http://zorba.io/modules/archive";
1249 import module namespace b = "http://zorba.io/modules/base64";
1250
1251 let $foo-content := "<foo/>"
1252
1253=== modified file 'test/Queries/delete_02.xq'
1254--- test/Queries/delete_02.xq 2012-07-27 03:43:13 +0000
1255+++ test/Queries/delete_02.xq 2013-07-29 19:28:26 +0000
1256@@ -1,5 +1,4 @@
1257-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1258-import schema namespace as = "http://www.zorba-xquery.com/modules/archive";
1259+import module namespace a = "http://zorba.io/modules/archive";
1260 import module namespace f = "http://expath.org/ns/file";
1261
1262 let $a := f:read-binary(resolve-uri("linear-algebra-20120306.epub"))
1263
1264=== modified file 'test/Queries/delete_03.xq'
1265--- test/Queries/delete_03.xq 2012-07-27 03:43:13 +0000
1266+++ test/Queries/delete_03.xq 2013-07-29 19:28:26 +0000
1267@@ -1,12 +1,12 @@
1268-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1269+import module namespace a = "http://zorba.io/modules/archive";
1270
1271 let $foo-content := "<foo/>"
1272 let $bar-content := xs:base64Binary("YWJj")
1273 let $options :=
1274-<a:options>
1275- <a:format>TAR</a:format>
1276- <a:compression>GZIP</a:compression>
1277-</a:options>
1278+{
1279+ "format" : "TAR",
1280+ "compression" : "GZIP"
1281+}
1282 let $archive0 := a:create(
1283 ("foo.xml"),
1284 ($foo-content),
1285
1286=== modified file 'test/Queries/delete_04.xq'
1287--- test/Queries/delete_04.xq 2012-07-27 03:43:13 +0000
1288+++ test/Queries/delete_04.xq 2013-07-29 19:28:26 +0000
1289@@ -1,13 +1,13 @@
1290-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1291+import module namespace a = "http://zorba.io/modules/archive";
1292
1293 let $foo-content := "<foo/>"
1294 let $bar-content := xs:base64Binary("YWJj")
1295 let $foo2-content := "<foo2/>"
1296 let $options :=
1297-<a:options>
1298- <a:format>TAR</a:format>
1299- <a:compression>GZIP</a:compression>
1300-</a:options>
1301+{
1302+ "format" : "TAR",
1303+ "compression" : "GZIP"
1304+}
1305 let $archive0 := a:create(
1306 ("foo.xml"),
1307 ($foo-content),
1308
1309=== modified file 'test/Queries/dir_01.xq'
1310--- test/Queries/dir_01.xq 2012-09-06 20:40:47 +0000
1311+++ test/Queries/dir_01.xq 2013-07-29 19:28:26 +0000
1312@@ -1,10 +1,10 @@
1313-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1314+import module namespace a = "http://zorba.io/modules/archive";
1315
1316 let $foo-content := "<foo/>"
1317 let $bar-content := "<bar/>"
1318 let $archive := a:create(
1319- ("foo.xml", "bar.xml", <entry type="directory">dir1</entry>),
1320+ ("foo.xml", "bar.xml", { "type" : "directory", "name" : "dir1" }),
1321 ($foo-content, $bar-content)
1322 )
1323 return
1324- for $e in a:entries($archive) return concat($e/text(), ",")
1325+ for $e in a:entries($archive)("name") return concat($e, ",")
1326
1327=== modified file 'test/Queries/dir_02.xq'
1328--- test/Queries/dir_02.xq 2012-09-06 20:40:47 +0000
1329+++ test/Queries/dir_02.xq 2013-07-29 19:28:26 +0000
1330@@ -1,11 +1,11 @@
1331-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1332+import module namespace a = "http://zorba.io/modules/archive";
1333
1334 let $foo-content := "<foo/>"
1335 let $bar-content := "<bar/>"
1336 let $archive := a:create(
1337- ("foo.xml", "bar.xml", <entry type="directory">dir1</entry>),
1338+ ("foo.xml", "bar.xml", { "type" : "directory", "name" : "dir1" }),
1339 ($foo-content, $bar-content)
1340 )
1341 let $archive2 := a:delete($archive, "dir1/")
1342 return
1343- for $e in a:entries($archive2) return concat($e/text(), ",")
1344+ for $e in a:entries($archive2)("name") return concat($e, ",")
1345
1346=== modified file 'test/Queries/dir_03.xq'
1347--- test/Queries/dir_03.xq 2012-09-06 20:40:47 +0000
1348+++ test/Queries/dir_03.xq 2013-07-29 19:28:26 +0000
1349@@ -1,13 +1,13 @@
1350-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1351+import module namespace a = "http://zorba.io/modules/archive";
1352
1353 let $foo-content := "<foo/>"
1354 let $bar-content := "<bar/>"
1355 let $archive := a:create(
1356- ("foo.xml", "bar.xml", <entry type="directory">dir1</entry>),
1357+ ("foo.xml", "bar.xml", { "type" : "directory", "name" : "dir1" }),
1358 ($foo-content, $bar-content)
1359 )
1360 let $archive2 := a:delete($archive, "nonexistent.xml")
1361 let $entries := a:entries($archive)
1362 let $entries2 := a:entries($archive2)
1363-return $entries=$entries2
1364+return count($entries)=count($entries2)
1365
1366
1367=== modified file 'test/Queries/dir_04.xq'
1368--- test/Queries/dir_04.xq 2012-09-06 20:40:47 +0000
1369+++ test/Queries/dir_04.xq 2013-07-29 19:28:26 +0000
1370@@ -1,13 +1,13 @@
1371-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1372+import module namespace a = "http://zorba.io/modules/archive";
1373
1374 let $foo-content := "<foo/>"
1375 let $bar-content := "<bar/>"
1376 let $archive := a:create(
1377- ("foo.xml", "bar.xml", <entry type="directory">dir1</entry>),
1378+ ("foo.xml", "bar.xml", { "type" : "directory", "name" : "dir1" }),
1379 ($foo-content, $bar-content)
1380 )
1381-let $archive2 := a:update($archive, <a:entry type="directory">newdir</a:entry>, ())
1382+let $archive2 := a:update($archive, { "type" : "directory", "name" : "newdir" }, ())
1383 let $entries := a:entries($archive)
1384 let $entries2 := a:entries($archive2)
1385-return for $e in $entries2 return concat($e/text(), ",")
1386+return for $e in $entries2("name") return concat($e, ",")
1387
1388
1389=== modified file 'test/Queries/entries_01.xq'
1390--- test/Queries/entries_01.xq 2012-07-27 03:43:13 +0000
1391+++ test/Queries/entries_01.xq 2013-07-29 19:28:26 +0000
1392@@ -1,6 +1,7 @@
1393-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1394-import schema namespace as = "http://www.zorba-xquery.com/modules/archive";
1395+import module namespace a = "http://zorba.io/modules/archive";
1396+(: import schema namespace as = "http://zorba.io/modules/archive"; :)
1397 import module namespace f = "http://expath.org/ns/file";
1398
1399 for $a in a:entries(f:read-binary(resolve-uri("simple.zip")))
1400-return validate { $a }
1401+(: return validate { $a } :)
1402+return $a
1403
1404=== modified file 'test/Queries/entries_02.xq'
1405--- test/Queries/entries_02.xq 2012-07-27 03:43:13 +0000
1406+++ test/Queries/entries_02.xq 2013-07-29 19:28:26 +0000
1407@@ -1,7 +1,6 @@
1408-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1409-import schema namespace as = "http://www.zorba-xquery.com/modules/archive";
1410+import module namespace a = "http://zorba.io/modules/archive";
1411 import module namespace f = "http://expath.org/ns/file";
1412
1413 for $a in a:entries(f:read-binary(resolve-uri("simple.tar.gz")))
1414-return validate { $a }
1415+return $a
1416
1417
1418=== modified file 'test/Queries/entries_03.spec'
1419--- test/Queries/entries_03.spec 2012-09-06 20:40:47 +0000
1420+++ test/Queries/entries_03.spec 2013-07-29 19:28:26 +0000
1421@@ -1,1 +1,1 @@
1422-Error: http://www.zorba-xquery.com/modules/archive:ARCH9999
1423+Error: http://zorba.io/modules/archive:CORRUPTED-ARCHIVE
1424
1425=== modified file 'test/Queries/entries_03.xq'
1426--- test/Queries/entries_03.xq 2012-07-27 03:43:13 +0000
1427+++ test/Queries/entries_03.xq 2013-07-29 19:28:26 +0000
1428@@ -1,7 +1,8 @@
1429-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1430-import schema namespace as = "http://www.zorba-xquery.com/modules/archive";
1431+import module namespace a = "http://zorba.io/modules/archive";
1432+(: import schema namespace as = "http://zorba.io/modules/archive"; :)
1433 import module namespace f = "http://expath.org/ns/file";
1434
1435 for $a in a:entries(f:read-binary(resolve-uri("simple.tar.bz2")))
1436-return validate { $a }
1437+(: return validate { $a } :)
1438+return $a
1439
1440
1441=== modified file 'test/Queries/entries_04.spec'
1442--- test/Queries/entries_04.spec 2012-07-27 03:43:13 +0000
1443+++ test/Queries/entries_04.spec 2013-07-29 19:28:26 +0000
1444@@ -1,1 +1,1 @@
1445-Error: http://www.zorba-xquery.com/modules/archive:ARCH9999
1446+Error: http://zorba.io/modules/archive:CORRUPTED-ARCHIVE
1447
1448=== modified file 'test/Queries/entries_04.xq'
1449--- test/Queries/entries_04.xq 2012-07-27 03:43:13 +0000
1450+++ test/Queries/entries_04.xq 2013-07-29 19:28:26 +0000
1451@@ -1,7 +1,8 @@
1452-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1453-import schema namespace as = "http://www.zorba-xquery.com/modules/archive";
1454+import module namespace a = "http://zorba.io/modules/archive";
1455+(: import schema namespace as = "http://zorba.io/modules/archive"; :)
1456 import module namespace f = "http://expath.org/ns/file";
1457
1458 for $a in a:entries(f:read-binary(resolve-uri("invalid.zip")))
1459-return validate { $a }
1460+(: return validate { $a } :)
1461+return $a
1462
1463
1464=== modified file 'test/Queries/extract_01.xq'
1465--- test/Queries/extract_01.xq 2012-07-27 03:43:13 +0000
1466+++ test/Queries/extract_01.xq 2013-07-29 19:28:26 +0000
1467@@ -1,5 +1,4 @@
1468-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1469-import schema namespace as = "http://www.zorba-xquery.com/modules/archive";
1470+import module namespace a = "http://zorba.io/modules/archive";
1471 import module namespace f = "http://expath.org/ns/file";
1472
1473 for $a in a:extract-text(f:read-binary(resolve-uri("simple.zip")))
1474
1475=== modified file 'test/Queries/extract_02.xq'
1476--- test/Queries/extract_02.xq 2012-07-27 03:43:13 +0000
1477+++ test/Queries/extract_02.xq 2013-07-29 19:28:26 +0000
1478@@ -1,4 +1,4 @@
1479-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1480+import module namespace a = "http://zorba.io/modules/archive";
1481 import module namespace f = "http://expath.org/ns/file";
1482
1483 for $a in a:extract-text(f:read-binary(fn:resolve-uri("simple.zip")), "dir1/file1")
1484
1485=== modified file 'test/Queries/extract_03.spec'
1486--- test/Queries/extract_03.spec 2012-07-27 03:43:13 +0000
1487+++ test/Queries/extract_03.spec 2013-07-29 19:28:26 +0000
1488@@ -1,1 +1,1 @@
1489-Error: http://www.zorba-xquery.com/modules/archive:ARCH0004
1490+Error: http://zorba.io/modules/archive:INVALID-ENCODING
1491
1492=== modified file 'test/Queries/extract_03.xq'
1493--- test/Queries/extract_03.xq 2012-07-27 03:43:13 +0000
1494+++ test/Queries/extract_03.xq 2013-07-29 19:28:26 +0000
1495@@ -1,4 +1,4 @@
1496-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1497+import module namespace a = "http://zorba.io/modules/archive";
1498 import module namespace f = "http://expath.org/ns/file";
1499
1500 for $a in a:extract-text(f:read-binary(fn:resolve-uri("simple.zip")), "dir1/file1", "foo")
1501
1502=== modified file 'test/Queries/extract_04.xq'
1503--- test/Queries/extract_04.xq 2012-07-27 03:43:13 +0000
1504+++ test/Queries/extract_04.xq 2013-07-29 19:28:26 +0000
1505@@ -1,4 +1,4 @@
1506-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1507+import module namespace a = "http://zorba.io/modules/archive";
1508 import module namespace f = "http://expath.org/ns/file";
1509
1510 for $a in a:extract-text(f:read-binary(fn:resolve-uri("transcoding.zip")), "dir2/iso-8859-1.txt", "ISO-8859-1")
1511
1512=== modified file 'test/Queries/extract_05.xq'
1513--- test/Queries/extract_05.xq 2012-07-27 03:43:13 +0000
1514+++ test/Queries/extract_05.xq 2013-07-29 19:28:26 +0000
1515@@ -1,7 +1,7 @@
1516-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1517+import module namespace a = "http://zorba.io/modules/archive";
1518 import module namespace f = "http://expath.org/ns/file";
1519
1520 let $f := f:read-binary(resolve-uri("linear-algebra-20120306.epub"))
1521-for $a in a:entries($f)
1522-where $a/text() eq "EPUB/xhtml/fcla-xml-2.30li91.html"
1523-return a:extract-text($f, $a/text())
1524+for $a in a:entries($f)("name")
1525+where $a eq "EPUB/xhtml/fcla-xml-2.30li91.html"
1526+return a:extract-text($f, $a)
1527
1528=== modified file 'test/Queries/extract_06.xq'
1529--- test/Queries/extract_06.xq 2012-07-27 03:43:13 +0000
1530+++ test/Queries/extract_06.xq 2013-07-29 19:28:26 +0000
1531@@ -1,4 +1,4 @@
1532-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1533+import module namespace a = "http://zorba.io/modules/archive";
1534 import module namespace f = "http://expath.org/ns/file";
1535
1536 for $a in a:extract-binary(f:read-binary(fn:resolve-uri("simple.zip")), "dir1/file1")
1537
1538=== modified file 'test/Queries/extract_07.xq'
1539--- test/Queries/extract_07.xq 2012-07-27 03:43:13 +0000
1540+++ test/Queries/extract_07.xq 2013-07-29 19:28:26 +0000
1541@@ -1,6 +1,6 @@
1542-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1543+import module namespace a = "http://zorba.io/modules/archive";
1544 import module namespace f = "http://expath.org/ns/file";
1545
1546 let $f := f:read-binary(fn:resolve-uri("linear-algebra-20120306.epub"))
1547-for $a in a:entries($f)[position() > 2 and position() < 5]
1548+for $a in a:entries($f)("name")[position() > 2 and position() < 5]
1549 return <text>{a:extract-binary($f, $a)}</text>
1550
1551=== modified file 'test/Queries/options_01.xq'
1552--- test/Queries/options_01.xq 2012-08-03 21:54:38 +0000
1553+++ test/Queries/options_01.xq 2013-07-29 19:28:26 +0000
1554@@ -1,4 +1,4 @@
1555-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1556+import module namespace a = "http://zorba.io/modules/archive";
1557 import module namespace f = "http://expath.org/ns/file";
1558
1559 let $zip := f:read-binary(fn:resolve-uri("linear-algebra-20120306.epub"))
1560
1561=== modified file 'test/Queries/options_02.spec'
1562--- test/Queries/options_02.spec 2012-09-06 20:40:47 +0000
1563+++ test/Queries/options_02.spec 2013-07-29 19:28:26 +0000
1564@@ -1,1 +1,1 @@
1565-Error: http://www.zorba-xquery.com/modules/archive:ARCH9999
1566+Error: http://zorba.io/modules/archive:CORRUPTED-ARCHIVE
1567
1568=== modified file 'test/Queries/options_02.xq'
1569--- test/Queries/options_02.xq 2012-09-06 20:40:47 +0000
1570+++ test/Queries/options_02.xq 2013-07-29 19:28:26 +0000
1571@@ -1,4 +1,4 @@
1572-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1573+import module namespace a = "http://zorba.io/modules/archive";
1574 import module namespace f = "http://expath.org/ns/file";
1575
1576 let $tar-bz2 := f:read-binary(fn:resolve-uri("simple.tar.bz2"))
1577
1578=== modified file 'test/Queries/options_03.spec'
1579--- test/Queries/options_03.spec 2012-09-06 20:40:47 +0000
1580+++ test/Queries/options_03.spec 2013-07-29 19:28:26 +0000
1581@@ -1,1 +1,1 @@
1582-Error: http://www.zorba-xquery.com/modules/archive:ARCH9999
1583+Error: http://zorba.io/modules/archive:CORRUPTED-ARCHIVE
1584
1585=== modified file 'test/Queries/options_03.xq'
1586--- test/Queries/options_03.xq 2012-09-06 20:40:47 +0000
1587+++ test/Queries/options_03.xq 2013-07-29 19:28:26 +0000
1588@@ -1,4 +1,4 @@
1589-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1590+import module namespace a = "http://zorba.io/modules/archive";
1591
1592 let $fake_archive := xs:base64Binary("5Pb8")
1593 return
1594
1595=== modified file 'test/Queries/update_01.xq'
1596--- test/Queries/update_01.xq 2013-07-17 07:50:04 +0000
1597+++ test/Queries/update_01.xq 2013-07-29 19:28:26 +0000
1598@@ -1,4 +1,4 @@
1599-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1600+import module namespace a = "http://zorba.io/modules/archive";
1601 import module namespace b = "http://zorba.io/modules/base64";
1602
1603 let $foo-content := "<foo/>"
1604
1605=== modified file 'test/Queries/update_02.xq'
1606--- test/Queries/update_02.xq 2013-07-17 07:50:04 +0000
1607+++ test/Queries/update_02.xq 2013-07-29 19:28:26 +0000
1608@@ -1,4 +1,4 @@
1609-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1610+import module namespace a = "http://zorba.io/modules/archive";
1611 import module namespace b = "http://zorba.io/modules/base64";
1612
1613 let $foo-content := "<foo/>"
1614
1615=== modified file 'test/Queries/update_03.spec'
1616--- test/Queries/update_03.spec 2012-09-06 20:40:47 +0000
1617+++ test/Queries/update_03.spec 2013-07-29 19:28:26 +0000
1618@@ -1,1 +1,1 @@
1619-Error: http://www.zorba-xquery.com/modules/archive:ARCH0001
1620+Error: http://zorba.io/modules/archive:ENTRY-COUNT
1621
1622=== modified file 'test/Queries/update_03.xq'
1623--- test/Queries/update_03.xq 2013-07-17 07:50:04 +0000
1624+++ test/Queries/update_03.xq 2013-07-29 19:28:26 +0000
1625@@ -1,4 +1,4 @@
1626-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1627+import module namespace a = "http://zorba.io/modules/archive";
1628 import module namespace b = "http://zorba.io/modules/base64";
1629
1630 let $foo-content := "<foo/>"
1631
1632=== modified file 'test/Queries/update_04.spec'
1633--- test/Queries/update_04.spec 2012-09-06 20:40:47 +0000
1634+++ test/Queries/update_04.spec 2013-07-29 19:28:26 +0000
1635@@ -1,1 +1,1 @@
1636-Error: http://www.zorba-xquery.com/modules/archive:ARCH9999
1637+Error: http://zorba.io/modules/archive:CORRUPTED-ARCHIVE
1638
1639=== modified file 'test/Queries/update_04.xq'
1640--- test/Queries/update_04.xq 2013-07-17 07:50:04 +0000
1641+++ test/Queries/update_04.xq 2013-07-29 19:28:26 +0000
1642@@ -1,4 +1,4 @@
1643-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
1644+import module namespace a = "http://zorba.io/modules/archive";
1645 import module namespace b = "http://zorba.io/modules/base64";
1646
1647 let $fake_archive := xs:base64Binary("YWJj")

Subscribers

People subscribed via source and target branches

to all changes: