zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #24409
[Merge] lp:~zorba-coders/zorba/bug-1188033 into lp:zorba/archive-module
Luis Rodriguez Gonzalez has proposed merging lp:~zorba-coders/zorba/bug-1188033 into lp:zorba/archive-module.
Requested reviews:
Luis Rodriguez Gonzalez (kuraru)
Chris Hillery (ceejatec)
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-1188033/+merge/176523
--
https://code.launchpad.net/~zorba-coders/zorba/bug-1188033/+merge/176523
Your team Zorba Coders is subscribed to branch lp:zorba/archive-module.
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2012-07-27 03:43:13 +0000
+++ src/CMakeLists.txt 2013-07-23 21:38:29 +0000
@@ -17,11 +17,8 @@
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}/archive_module.xq.src")
DECLARE_ZORBA_MODULE (
- URI "http://www.zorba-xquery.com/modules/archive"
+ URI "http://zorba.io/modules/archive"
VERSION 1.0
FILE "archive_module.xq"
LINK_LIBRARIES "${LIBARCHIVE_LIBRARIES}")
-DECLARE_ZORBA_SCHEMA (
- URI "http://www.zorba-xquery.com/modules/archive"
- FILE "archive.xsd")
=== removed file 'src/archive.xsd'
--- src/archive.xsd 2012-09-06 20:40:47 +0000
+++ src/archive.xsd 1970-01-01 00:00:00 +0000
@@ -1,105 +0,0 @@
-<?xml version="1.0"?>
-
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
- targetNamespace="http://www.zorba-xquery.com/modules/archive"
- xmlns="http://www.zorba-xquery.com/modules/archive"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified">
-
- <xs:simpleType name="compression-type">
- <xs:restriction base="xs:string">
- <xs:enumeration value="store"/>
- <xs:enumeration value="deflate"/>
- <xs:enumeration value="bzip2"/>
- <xs:enumeration value="lzma"/>
- <xs:enumeration value="STORE"/>
- <xs:enumeration value="DEFLATE"/>
- <xs:enumeration value="BZIP2"/>
- <xs:enumeration value="LZMA"/>
- </xs:restriction>
- </xs:simpleType>
-
- <xs:simpleType name="format-type">
- <xs:restriction base="xs:string">
- <xs:enumeration value="zip"/>
- <xs:enumeration value="tar"/>
- <xs:enumeration value="pax"/>
- <xs:enumeration value="ZIP"/>
- <xs:enumeration value="TAR"/>
- <xs:enumeration value="PAX"/>
- </xs:restriction>
- </xs:simpleType>
-
- <xs:simpleType name="boolean-type">
- <xs:restriction base="xs:string">
- <xs:enumeration value="true"/>
- <xs:enumeration value="false"/>
- </xs:restriction>
- </xs:simpleType>
-
- <xs:simpleType name="entry-name-type">
- <xs:restriction base="xs:string"/>
- </xs:simpleType>
-
- <xs:simpleType name="entry-datetime-type">
- <xs:restriction base="xs:dateTime"/>
- </xs:simpleType>
-
- <xs:simpleType name="entry-size-type">
- <xs:restriction base="xs:short"/>
- </xs:simpleType>
-
- <xs:simpleType name="entry-encoding-type">
- <xs:restriction base="xs:string"/>
- </xs:simpleType>
-
- <xs:simpleType name="entry-type">
- <xs:restriction base="xs:string">
- <xs:enumeration value="regular"/>
- <xs:enumeration value="directory"/>
- </xs:restriction>
- </xs:simpleType>
-
- <!-- elements -->
- <xs:element name="archive-option-element"
- abstract="true" type="xs:string"/>
-
- <xs:element name="compression"
- type="compression-type"
- substitutionGroup="archive-option-element"/>
-
- <xs:element name="format" type="format-type"
- substitutionGroup="archive-option-element"/>
-
- <xs:element name="skip-extra-attributes" type="boolean-type"
- substitutionGroup="archive-option-element"/>
-
- <xs:element name="options">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="archive-option-element"
- minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
- <xs:element name="entry">
- <xs:complexType>
- <xs:simpleContent>
- <xs:extension base="entry-name-type">
- <xs:attributeGroup ref="entry-attributes"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- </xs:element>
-
- <!-- entry attributes -->
- <xs:attributeGroup name="entry-attributes">
- <xs:attribute name="type" type="entry-type"/>
- <xs:attribute name="size" type="entry-size-type"/>
- <xs:attribute name="last-modified" type="entry-datetime-type"/>
- <xs:attribute name="encoding" type="entry-encoding-type"/>
- <xs:attribute name="compression" type="compression-type"/>
- </xs:attributeGroup>
-
-</xs:schema>
=== modified file 'src/archive_module.xq'
--- src/archive_module.xq 2012-12-21 22:10:19 +0000
+++ src/archive_module.xq 2013-07-23 21:38:29 +0000
@@ -1,4 +1,4 @@
-xquery version "1.0";
+jsoniq version "1.0";
(:
: Copyright 2012 The FLWOR Foundation.
@@ -17,12 +17,12 @@
:)
(:~
- : <p>This module provides functionality to work with (possibly compressed)
+ : This module provides functionality to work with (possibly compressed)
: archives. For example, it provides functions to retrieve the names or
: extract the values of several entries in a ZIP archive. Moreover,
- : there exist functions that allow to create or update archives.</p>
+ : there exist functions that allow to create or update archives.<p/>
:
- : <p>The following archive formats and compression algorithms are supported:
+ : The following archive formats and compression algorithms are supported:
: <ul>
: <li>ZIP (with compression DEFLATE or STORE)</li>
: <li>TAR (with compression GZIP)</li>
@@ -34,45 +34,45 @@
: @library <a href="http://code.google.com/p/libarchive/">libarchive</a>
: @project Zorba/Archive
:)
-module namespace a = "http://www.zorba-xquery.com/modules/archive";
+module namespace a = "http://zorba.io/modules/archive";
-import schema namespace options = "http://www.zorba-xquery.com/modules/archive";
-
declare namespace ver = "http://www.zorba-xquery.com/options/versioning";
declare option ver:module-version "1.0";
(:~
- : Creates a new ZIP archive out of the given entries and contents.
+ : Creates a new ZIP archive out of the given entries and contents. <p/>
:
- : <p>All entries are compressed with the DEFLATE compression algorithm.</p>
+ : All entries are compressed with the DEFLATE compression algorithm.<p/>
:
- : <p>The parameters $entries and $contents have the same meaning as for
- : the function a:create with three arguments.</p>
+ : The parameters $entries and $contents have the same meaning as for
+ : the function a:create with three arguments.<p/>
:
- : <p>Entry entries can include a type attribute, this attribute can have one
+ : Entry entries can include a type element, this element can have one
: of two possible values: "regular" or "directory". If "regular" is
: specified then the entry will be created as a regular file; if "directory"
: is specified then the entry will be created as a directory, no contents
: will be read from $contents in this case. If no value is specified for type
- : then it will be set to "regular". Example:
+ : then it will be set to "regular". <p/>
+ : Example:
: <pre>
: $zip-file := a:create(
- : (<a:entry encoding="ISO-8859-1" type="directory">dir1</a:entry>, "dir1/file1"),
+ : ({ "encoding" : "ISO-8859-1", "type" : "directory", "entry" : "dir1" }, "dir1/file1"),
: ("file contents"))
: </pre>
- : </p>
+ : <p/>
:
: @param $entries the meta data for the entries in the archive. Each entry
- : can be of type xs:string or an element with name a:entry.
+ : can be of type xs:string or a JSON oibject describing the entry.
: @param $contents the content for the archive. Each item in the sequence
: can be of type xs:string or xs:base64Binary.
:
: @return the generated archive as xs:base64Binary
:
- : @error a:ARCH0001 if the number of entry elements differs from the number
- : of items in the $contents sequence: count($entries) ne count($contents)
- : @error a:ARCH0003 if a value for an entry element is invalid
- : @error a:ARCH0004 if a given encoding is invalid or not supported
+ : @error a:ENTRY-COUNT-MISMATCH if the number of entries that don't describe directories
+ : differs from the number of items in the $contents sequence:
+ : count($non-directory-entries) ne count($contents)
+ : @error a:INVALID-ENTRY-VALS if a values in an entry object are invalid
+ : @error a:INVALID-ENCODING if a given encoding is invalid or not supported
: @error err:FORG0006 if an item in the contents sequence is not of type xs:string
: or xs:base64Binary
:)
@@ -82,94 +82,106 @@
as xs:base64Binary external;
(:~
- : Creates a new archive out of the given entries and contents.
+ : Creates a new archive out of the given entries and contents. <p/>
:
- : <p>The $entries arguments provides meta data for each entry in the archive.
+ : The $entries arguments provides meta data for each entry in the archive.
: For example, the name of the entry (mandatory) or the last-modified date
: (optional). An entry can either be of type xs:string to describe the entry
- : name or of type xs:base64Binary to provide additional meta data.</p>
+ : name or of type xs:base64Binary to provide additional meta data.<p/>
:
- : <p>The $contents sequence provides the data (xs:string or xs:base64Binary) for
+ : The $contents sequence provides the data (xs:string or xs:base64Binary) for
: the entries that should be included in the archive. Its length needs to
- : match the length of the $entries sequence (a:ARCH0001). All items of type
- : xs:base64Binary are decoded before being added to the archive.</p>
+ : match the length of the entries in the $entries sequence that don't describe
+ : directory entries (a:ARCH0001). All items of type xs:base64Binary are decoded
+ : before being added to the archive.<p/>
:
- : <p>For each entry, the name, last-modified date and time, and compression
+ : For each entry, the name, last-modified date and time, and compression
: can be specified. In addition, an encoding can be specified which is used to
: store entries of type xs:string. If no last-modified attribute is given, the
: default is the current date and time. The compression is useful if various
: entries in a ZIP archive are compressed using different compression
- : algorithms (i.e. store or deflate).</p>
+ : algorithms (i.e. store or deflate).<p/>
:
- : <p>For example, the following sequence may be used to describe an archive
- : containing three elements:
- : <pre class="ace-static" ace-mode="xquery"><![CDATA[<a:entry last-modified="{fn:current-dateTime()}">myfile.txt</a:entry>
- : <a:entry encoding="ISO-8859-1" compression="store">dir/myfile.xml</a:entry>]]>
+ : For example, the following sequence may be used to describe an archive
+ : containing two elements: <p/>
+ : <pre class="ace-static" ace-mode="xquery">{
+ : "last-modified" : "{fn:current-dateTime()}"
+ : "name" : "myfile.txt"
+ : },
+ : {
+ : "encoding" : "ISO-8859-1",
+ : "compression" : "store",
+ : "name" : "dir/myfile.xml"
+ : }
: </pre>
: </p>
:
- : <p>The $options argument may be used to describe general options for the
- : archive. For example, the following option element can be used to create a ZIP
+ : The $options argument may be used to describe general options for the
+ : archive. For example, the following options can be used to create a ZIP
: archive in which all entries are compressed with the DEFLATE compression
- : algorithm:
- : <pre class="ace-static" ace-mode="xquery"><![CDATA[<archive:options>
- : <archive:format>ZIP</archive:format>
- : <archive:compression>DEFLATE</archive:compression>
- : </archive:options>]]>
+ : algorithm: <p/>
+ : <pre class="ace-static" ace-mode="xquery">{
+ : "format" : "ZIP",
+ : "compression" : "DEFLATE"
+ : }
: </pre>
- : </p>
+ : <p/>
:
- : <p>The result of the function is the generated archive as a item of type
- : xs:base64Binary.</p>
+ : The result of the function is the generated archive as a item of type
+ : xs:base64Binary.<p/>
:
:
: @param $entries the meta data for the entries in the archive. Each entry
- : can be of type xs:string or an element with name a:entry.
+ : can be of type xs:string or an JSON object describing the entry.
: @param $contents the content for the archive. Each item in the sequence
: can be of type xs:string or xs:base64Binary.
: @param $options the options used to generate the archive.
:
: @return the generated archive as xs:base64Binary
:
- : @error a:ARCH0001 if the number of entry elements differs from the number
- : of items in the $contents sequence: count($entries) ne count($contents)
- : @error a:ARCH0002 if the options argument contains invalid values
- : @error a:ARCH0003 if a value for an entry element is invalid
- : @error a:ARCH0004 if a given encoding is invalid or not supported
+ : @error a:ENTRY-COUNT-MISMATCH if the number of entries describing non-directories differs
+ : from the number of items in the $contents sequence:
+ : count($non-directoy-entries) ne count($contents)
+ : @error a:INVALID-OPTIONS if the options argument contains invalid values
+ : @error a:INVALID-ENTRY-VALS if any values in an entry are invalid
+ : @error a:INVALID-ENCODING if a given encoding is invalid or not supported
+ : @error a:DIFFERENT-COMPRESSIONS-NOT-SUPPORTED if different compression algorithms
+ : were selected but the actual version of libarchive doesn't support it.
: @error err:FORG0006 if an item in the contents sequence is not of type xs:string
: or xs:base64Binary
:)
declare function a:create(
$entries as item()*,
$contents as item()*,
- $options as element(a:options))
+ $options as object())
as xs:base64Binary external;
(:~
- : Returns the header information of all entries in the given archive.
+ : Returns the header information of all entries in the given archive as a JSON
+ : objects sequence. <p/>
:
- : <p>Such information includes the name of the entry, the uncompressed size,
+ : Such information includes the name of the entry, the uncompressed size,
: as well as the last-modified timestamp. Note that not all values are
- : available in every archive.</p>
+ : available in every archive.<p/>
:
: @param $archive the archive to list the entries from as xs:base64Binary
:
: @return a sequence of strings, one for each entry in the archive
:
- : @error a:ARCH9999 if $archive is not an archive or corrupted
+ : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted
:)
declare function a:entries($archive as xs:base64Binary)
- as element(a:entry)* external;
+ as object()* external;
(:~
: Extracts the contents of all entries in the given archive as text
- : using UTF-8 as default encoding.
+ : using UTF-8 as default encoding. <p/>
:
: @param $archive the archive to extract the entries from as xs:base64Binary
:
: @return one string for the contents of each entry in the archive
:
- : @error a:ARCH9999 if $archive is not an archive or corrupted
+ : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted
: @error err:FOCH0001 if any of the entries contains invalid utf-8 characters
:)
declare function a:extract-text($archive as xs:base64Binary)
@@ -178,7 +190,7 @@
(:~
: Extracts the contets of the entries identified by a given sequence of
: names as text.
- : The default encoding used to read the string is UTF-8.
+ : The default encoding used to read the string is UTF-8. <p/>
:
: @param $archive the archive to extract the entries from as xs:base64Binary
: @param $entry-names a sequence of names for entries which should be extracted
@@ -186,7 +198,7 @@
: @return a sequence of strings for the given sequence of names or the
: empty sequence if no entries match the given names.
:
- : @error a:ARCH9999 if $archive is not an archive or corrupted
+ : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted
: @error err:FOCH0001 if any of the entries requested contains invalid utf-8 characters
:)
declare function a:extract-text($archive as xs:base64Binary, $entry-names as xs:string*)
@@ -194,7 +206,7 @@
(:~
: Extracts the contets of the entries identified by a given sequence of
- : names as text. Each entry is treated with the given encoding.
+ : names as text. Each entry is treated with the given encoding. <p/>
:
: @param $archive the archive to extract the entries from as xs:base64Binary
: @param $entry-names a sequence of entry names that should be extracted
@@ -203,8 +215,8 @@
: @return a sequence of strings for the given sequence of names or the
: empty sequence if no entries match the given names.
:
- : @error a:ARCH9999 if $archive is not an archive or corrupted
- : @error a:ARCH0004 if the given $encoding is invalid or not supported
+ : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted
+ : @error a:INVALID-ENCODING if the given $encoding is invalid or not supported
: @error err:FOCH0001 if a transcoding error happens
:)
declare function a:extract-text(
@@ -215,20 +227,20 @@
(:~
: Returns the entries identified by the given paths from the archive
- : as base64Binary.
+ : as base64Binary. <p/>
:
: @param $archive the archive to extract the entries from as xs:base64Binary
:
: @return one xs:base64Binary item for the contents of each entry in the archive
:
- : @error a:ARCH9999 if $archive is not an archive or corrupted
+ : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted
:)
declare function a:extract-binary($archive as xs:base64Binary)
as xs:base64Binary* external;
(:~
: Returns the entries identified by the given paths from the archive
- : as base64Binary.
+ : as base64Binary. <p/>
:
: @param $archive the archive to extract the entries from as xs:base64Binary
:
@@ -237,66 +249,70 @@
: @return a sequence of xs:base64Binary itmes for the given sequence of names
: or the empty sequence if no entries match the given names.
:
- : @error a:ARCH9999 if $archive is not an archive or corrupted
+ : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted
:)
declare function a:extract-binary($archive as xs:base64Binary, $entry-names as xs:string*)
as xs:base64Binary* external;
(:~
: Adds and replaces entries in an archive according to
- : the given spec. The contents can be string and base64Binary items.
+ : the given spec. The contents can be string and base64Binary items. <p/>
:
- : <p>The parameters $entries and $contents have the same meaning as for
+ : The parameters $entries and $contents have the same meaning as for
: the function a:create with three arguments.</p>
:
: @param $archive the archive to add or replace content
: @param $entries the meta data for the entries in the archive. Each entry
- : can be of type xs:string or an element with name a:entry.
+ : can be of type xs:string or a JSON object. For mandatory fields in the
+ : JSON object see create function.
: @param $contents the content for the archive. Each item in the sequence
: can be of type xs:string or xs:base64Binary.
:
: @return the updated xs:base64Binary
:
- : @error a:ARCH0001 if the number of entry elements differs from the number
- : of items in the $contents sequence: count($entries) ne count($contents)
- : @error a:ARCH0003 if a value for an entry element is invalid
- : @error a:ARCH0004 if a given encoding is invalid or not supported
+ : @error a:ENTRY-COUNT-MISMATCH if the number of entry elements differs from the number
+ : of items in the $contents sequence: count($non-directory-entries) ne count($contents)
+ : @error a:INVALID-ENTRY-VALS if a value for an entry element is invalid
+ : @error a:INVALID-ENCODING if a given encoding is invalid or not supported
+ : @error a:DIFFERENT-COMPRESSIONS-NOT-SUPPORTED if different compression algorithms
+ : were selected but the actual version of libarchive doesn't support it.
: @error err:FORG0006 if an item in the contents sequence is not of type xs:string
: or xs:base64Binary
- : @error a:ARCH9999 if $archive is not an archive or corrupted
+ : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted
:
:)
declare function a:update($archive as xs:base64Binary, $entries as item()*, $contents as item()*)
as xs:base64Binary external;
(:~
- : Deletes entries from an archive.
+ : Deletes entries from an archive. <p/>
:
: @param $archive the archive to extract the entries from as xs:base64Binary
: @param $entry-names a sequence of names for entries which should be deleted
:
: @return the updated base64Binary
:
- : @error a:ARCH9999 if $archive is not an archive or corrupted
+ : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted
:)
declare function a:delete($archive as xs:base64Binary, $entry-names as xs:string*)
as xs:base64Binary external;
(:~
- : Returns the algorithm and format options of the given archive.
+ : Returns the algorithm and format options as a JSON object for a given archive.
: For example, for a ZIP archive, the following options element
- : would be returned:
- : <pre class="ace-static" ace-mode="xquery"><![CDATA[<archive:options>
- : <archive:format>ZIP</archive:format>
- : <archive:compressionDEFLATE</archive:compression>
- : </archive:options>]]>
+ : would be returned: <p/>
+ : <pre class="ace-static" ace-mode="xquery">{
+ : "format" : "ZIP",
+ : "compression" : "DEFLATE"
+ : }
: </pre>
+ : <p/>
:
: @param $archive the archive as xs:base64Binary
:
- : @return the algorithm and format options
+ : @return the algorithm and format options as a JSON object
:
- : @error a:ARCH9999 if $archive is not an archive or corrupted
+ : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted
:)
declare function a:options($archive as xs:base64Binary)
- as element(a:options) external;
+ as object() external;
=== modified file 'src/archive_module.xq.src/archive_module.cpp'
--- src/archive_module.xq.src/archive_module.cpp 2013-06-21 04:18:40 +0000
+++ src/archive_module.xq.src/archive_module.cpp 2013-07-23 21:38:29 +0000
@@ -45,6 +45,13 @@
#include "archive_module.h"
#include "config.h"
+#define ERROR_ENTRY_COUNT_MISMATCH "ENTRY-COUNT"
+#define ERROR_INVALID_OPTIONS "INVALID-OPTIONS"
+#define ERROR_INVALID_ENTRY_VALS "INVALID-ENTRY-VALS"
+#define ERROR_INVALID_ENCODING "INVALID-ENCODING"
+#define ERROR_CORRUPTED_ARCHIVE "CORRUPTED-ARCHIVE"
+#define ERROR_DIFFERENT_COMPRESSIONS_NOT_SUPPORTED "DIFFERENT-COMPRESSIONS-NOT-SUPPORTED"
+
namespace zorba { namespace archive {
@@ -146,7 +153,7 @@
std::ostringstream lMsg;
lMsg << i.getStringValue()
<< ": invalid value for last-modified attribute ";
- ArchiveFunction::throwError("ARCH0003", lMsg.str().c_str());
+ ArchiveFunction::throwError(ERROR_INVALID_ENTRY_VALS, lMsg.str().c_str());
}
}
@@ -209,34 +216,36 @@
void
ArchiveFunction::ArchiveEntry::setValues(zorba::Item& aEntry)
{
- theEntryPath = aEntry.getStringValue();
-
- if (aEntry.isNode())
+ if (aEntry.isJSONItem())
{
- Item lAttr;
+ Item lKey;
- Iterator_t lAttrIter = aEntry.getAttributes();
- lAttrIter->open();
- while (lAttrIter->next(lAttr))
+ Iterator_t lKeyIter = aEntry.getObjectKeys();
+ lKeyIter->open();
+ while (lKeyIter->next(lKey))
{
- Item lAttrName;
- lAttr.getNodeName(lAttrName);
+ Item lKeyValue;
+ lKeyValue = aEntry.getObjectValue(lKey.getStringValue());
- if(lAttrName.getLocalName() == "type")
- {
- String filetype = lAttr.getStringValue();
+ if(lKey.getStringValue() == "name")
+ {
+ theEntryPath = lKeyValue.getStringValue();
+ }
+ else if(lKey.getStringValue() == "type")
+ {
+ String filetype = lKeyValue.getStringValue();
if(filetype == "directory")
{
theEntryType = directory;
}
}
- else if (lAttrName.getLocalName() == "last-modified")
+ else if (lKey.getStringValue() == "last-modified")
{
- ArchiveModule::parseDateTimeItem(lAttr, theLastModified);
+ ArchiveModule::parseDateTimeItem(lKeyValue, theLastModified);
}
- else if (lAttrName.getLocalName() == "encoding")
+ else if (lKey.getStringValue() == "encoding")
{
- theEncoding = lAttr.getStringValue();
+ theEncoding = lKeyValue.getStringValue();
std::transform(
theEncoding.begin(), theEncoding.end(),
theEncoding.begin(), ::toupper);
@@ -245,19 +254,20 @@
std::ostringstream lMsg;
lMsg << theEncoding << ": unsupported encoding";
- throwError("ARCH0004", lMsg.str().c_str());
+ throwError(ERROR_INVALID_ENCODING, lMsg.str().c_str());
}
}
- else if (lAttrName.getLocalName() == "compression")
+ else if (lKey.getStringValue() == "compression")
{
- theCompression = lAttr.getStringValue();
+ theCompression = lKeyValue.getStringValue();
std::transform(
theCompression.begin(),
theCompression.end(),
theCompression.begin(), ::toupper);
}
}
- }
+ } else
+ theEntryPath = aEntry.getStringValue();
}
/********************
@@ -281,66 +291,68 @@
void
ArchiveFunction::ArchiveOptions::setValues(Item& aOptions)
{
- Item lOption;
-
- Iterator_t lOptionIter = aOptions.getChildren();
- lOptionIter->open();
-
- while (lOptionIter->next(lOption))
- {
- Item lOptionName;
- lOption.getNodeName(lOptionName);
-
- if (lOptionName.getLocalName() == "compression")
- {
- theCompression = lOption.getStringValue().c_str();
- std::transform(
- theCompression.begin(),
- theCompression.end(),
- theCompression.begin(), ::toupper);
- }
- else if (lOptionName.getLocalName() == "format")
- {
- theFormat = lOption.getStringValue().c_str();
- std::transform(
- theFormat.begin(),
- theFormat.end(),
- theFormat.begin(), ::toupper);
- }
- else if (lOptionName.getLocalName() == "skip-extra-attributes")
- {
- theSkipExtraAttrs = lOption.getStringValue() == "true" ? true : false;
- }
- }
- if (theFormat == "ZIP")
- {
- if (theCompression != "STORE" && theCompression != "DEFLATE" && theCompression != "NONE")
- {
- std::ostringstream lMsg;
- lMsg
- << theCompression
- << ": compression algorithm not supported for ZIP format (required: deflate, store)";
- throwError("ARCH0002", lMsg.str().c_str());
- }
- }
- if (theFormat == "TAR")
- {
- if (theCompression != "GZIP"
-#ifndef WIN32
- && theCompression != "BZIP2"
- && theCompression != "LZMA"
-#endif
- )
- {
- std::ostringstream lMsg;
- lMsg
- << theCompression
- << ": compression algorithm not supported for TAR format (required: gzip"
-#ifndef WIN32
- << ", bzip2, lzma"
-#endif
- << ")";
- throwError("ARCH0002", lMsg.str().c_str());
+ if(aOptions.isJSONItem())
+ {
+ Item lOptionKey;
+ Iterator_t lKeyIter = aOptions.getObjectKeys();
+ lKeyIter->open();
+
+ while (lKeyIter->next(lOptionKey))
+ {
+ Item lOptionValue;
+ lOptionValue = aOptions.getObjectValue(lOptionKey.getStringValue());
+
+ if (lOptionKey.getStringValue() == "compression")
+ {
+ theCompression = lOptionValue.getStringValue().c_str();
+ std::transform(
+ theCompression.begin(),
+ theCompression.end(),
+ theCompression.begin(), ::toupper);
+ }
+ else if (lOptionKey.getStringValue() == "format")
+ {
+ theFormat = lOptionValue.getStringValue().c_str();
+ std::transform(
+ theFormat.begin(),
+ theFormat.end(),
+ theFormat.begin(), ::toupper);
+ }
+ else if (lOptionKey.getStringValue() == "skip-extra-attributes")
+ {
+ theSkipExtraAttrs = lOptionValue.getStringValue() == "true" ? true : false;
+ }
+ }
+ if (theFormat == "ZIP")
+ {
+ if (theCompression != "STORE" && theCompression != "DEFLATE" && theCompression != "NONE")
+ {
+ std::ostringstream lMsg;
+ lMsg
+ << theCompression
+ << ": compression algorithm not supported for ZIP format (required: deflate, store)";
+ throwError(ERROR_INVALID_OPTIONS, lMsg.str().c_str());
+ }
+ }
+ if (theFormat == "TAR")
+ {
+ if (theCompression != "GZIP"
+#ifndef WIN32
+ && theCompression != "BZIP2"
+ && theCompression != "LZMA"
+#endif
+ )
+ {
+ std::ostringstream lMsg;
+ lMsg
+ << theCompression
+ << ": compression algorithm not supported for TAR format (required: gzip"
+#ifndef WIN32
+ << ", bzip2, lzma"
+#endif
+ << ")";
+ throwError(ERROR_INVALID_OPTIONS, lMsg.str().c_str());
+ }
}
}
}
@@ -550,7 +562,7 @@
if (!theArchive)
ArchiveFunction::throwError(
- "ARCH9999", "internal error (couldn't create archive)");
+ ERROR_CORRUPTED_ARCHIVE, "internal error (couldn't create archive)");
setOptions(aOptions);
}
@@ -572,7 +584,7 @@
std::ostringstream lMsg;
lMsg << "number of entries (" << aEntries.size()
<< ") doesn't match number of content arguments (" << i << ")";
- throwError("ARCH0001", lMsg.str().c_str());
+ throwError(ERROR_ENTRY_COUNT_MISMATCH, lMsg.str().c_str());
}
}
@@ -587,7 +599,7 @@
std::ostringstream lMsg;
lMsg << "number of entries (" << aEntries.size()
<< ") less than number of content arguments";
- throwError("ARCH0001", lMsg.str().c_str());
+ throwError(ERROR_ENTRY_COUNT_MISMATCH, lMsg.str().c_str());
}
aFiles->close();
@@ -601,7 +613,6 @@
archive_entry_set_pathname(theEntry, aEntry.getEntryPath().c_str());
archive_entry_set_mtime(theEntry, aEntry.getLastModified(), 0);
- // TODO: modified to allow the creation of empty directories
if(aEntry.getEntryType() == ArchiveEntry::regular){
archive_entry_set_filetype(theEntry, AE_IFREG);
lDeleteStream = getStream(
@@ -626,7 +637,7 @@
#ifndef ZORBA_LIBARCHIVE_HAVE_SET_COMPRESSION
std::ostringstream lMsg;
lMsg << lNextCompString << ": setting different compression algorithms for each entry is not supported by the used version of libarchive";
- throwError("ARCH0099", lMsg.str().c_str());
+ throwError(ERROR_DIFFERENT_COMPRESSIONS_NOT_SUPPORTED, lMsg.str().c_str());
#endif
}
else
@@ -638,7 +649,7 @@
{
std::ostringstream lMsg;
lMsg << lNextCompString << ": compression algorithm not supported for ZIP format (required: deflate, store)";
- throwError("ARCH0002", lMsg.str().c_str());
+ throwError(ERROR_INVALID_OPTIONS, lMsg.str().c_str());
}
#ifdef ZORBA_LIBARCHIVE_HAVE_SET_COMPRESSION
@@ -651,7 +662,7 @@
{
std::ostringstream lMsg;
lMsg << aEntry.getCompression() << ": compression attribute only allowed for zip format";
- throwError("ARCH0099", lMsg.str().c_str());
+ throwError(ERROR_DIFFERENT_COMPRESSIONS_NOT_SUPPORTED, lMsg.str().c_str());
}
}
@@ -718,7 +729,7 @@
{
if (!aLocalName)
{
- throwError("ARCH9999", archive_error_string(a));
+ throwError(ERROR_CORRUPTED_ARCHIVE, archive_error_string(a));
}
else
{
@@ -781,7 +792,7 @@
{
std::ostringstream lMsg;
lMsg << f << ": archive format not supported";
- throwError("ARCH0002", lMsg.str().c_str());
+ throwError(ERROR_INVALID_OPTIONS, lMsg.str().c_str());
}
return 0;
}
@@ -817,7 +828,7 @@
{
std::ostringstream lMsg;
lMsg << c << ": compression algorithm not supported";
- throwError("ARCH0002", lMsg.str().c_str());
+ throwError(ERROR_INVALID_OPTIONS, lMsg.str().c_str());
}
return 0;
}
@@ -897,7 +908,7 @@
if (!theArchive)
ArchiveFunction::throwError(
- "ARCH9999", "internal error (couldn't create archive)");
+ ERROR_CORRUPTED_ARCHIVE, "internal error (couldn't create archive)");
int lErr = archive_read_support_compression_all(theArchive);
ArchiveFunction::checkForError(lErr, 0, theArchive);
@@ -1039,15 +1050,6 @@
zorba::Item& aArchive)
: ArchiveIterator(aArchive)
{
- theUntypedQName = theFactory->createQName(
- "http://www.w3.org/2001/XMLSchema", "untyped");
-
- theEntryName = theFactory->createQName(
- ArchiveModule::getModuleURI(), "entry");
-
- theLastModifiedName = theFactory->createQName("", "last-modified");
- theUncompressedSizeName = theFactory->createQName("", "size");
- theEntryType = theFactory->createQName("", "type");
}
bool
@@ -1064,49 +1066,50 @@
ArchiveFunction::checkForError(lErr, 0, theArchive);
}
- Item lNoParent;
-
- Item lType = theUntypedQName;
-
- // create entry element
- aRes = theFactory->createElementNode(
- lNoParent, theEntryName, lType, true, false, NsBindings());
+ std::vector<std::pair<zorba::Item, zorba::Item> > lObjectArray;
+ std::pair<zorba::Item, zorba::Item> lElemPair;
+
+ //Item lMemberName;
// create text content (i.e. path name)
String lName = archive_entry_pathname(lEntry);
- Item lNameItem = theFactory->createString(lName);
- theFactory->assignElementTypedValue(aRes, lNameItem);
+ //Item lNameItem = theFactory->createString(lName);
+ //lMemberName = theFactory->createString("name");
+ lElemPair = std::make_pair<zorba::Item, zorba::Item>(theFactory->createString("name"),
+ theFactory->createString(lName));
+ lObjectArray.push_back(lElemPair);
// create size attr if the value is set in the archive
if (archive_entry_size_is_set(lEntry))
{
long long lSize = archive_entry_size(lEntry);
- Item lSizeItem = theFactory->createInteger(lSize);
- lType = theUntypedQName;
- theFactory->createAttributeNode(
- aRes, theUncompressedSizeName, lType, lSizeItem);
+ //Item lSizeItem = theFactory->createInteger(lSize);
+ //lMemberName = theFactory->createString("size");
+ lElemPair = std::make_pair<zorba::Item, zorba::Item>(theFactory->createString("size"),
+ theFactory->createInteger(lSize));
+ lObjectArray.push_back(lElemPair);
}
// create last-modified attr if the value is set in the archive
if (archive_entry_mtime_is_set(lEntry))
{
time_t lTime = archive_entry_mtime(lEntry);
- Item lModifiedItem = ArchiveModule::createDateTimeItem(lTime);
-
- lType = theUntypedQName;
- theFactory->createAttributeNode(
- aRes, theLastModifiedName, lType, lModifiedItem);
+ //Item lModifiedItem = ArchiveModule::createDateTimeItem(lTime);
+ //lMemberName = theFactory->createString("last-modified");
+ lElemPair = std::make_pair<zorba::Item, zorba::Item>(theFactory->createString("last-modified"),
+ ArchiveModule::createDateTimeItem(lTime));
+ lObjectArray.push_back(lElemPair);
}
- Item lEntryType;
+ std::string lEntryType;
if(archive_entry_filetype(lEntry) == AE_IFDIR)
{
// this entry is a directory
- lEntryType = theFactory->createString("directory");
+ lEntryType = "directory";
}
else if(archive_entry_filetype(lEntry) == AE_IFREG)
{
- lEntryType = theFactory->createString("regular");
+ lEntryType = "regular";
}
else
{
@@ -1114,14 +1117,17 @@
// for the time being don't do anything
}
- lType = theUntypedQName;
- theFactory->createAttributeNode(
- aRes, theEntryType, lType, lEntryType);
+ //lMemberName = theFactory->createString("type");
+ lElemPair = std::make_pair<zorba::Item, zorba::Item>(theFactory->createString("type"),
+ theFactory->createString(lEntryType));
+ lObjectArray.push_back(lElemPair);
// skip to the next entry and raise an error if that fails
lErr = archive_read_data_skip(theArchive);
ArchiveFunction::checkForError(lErr, 0, theArchive);
+ aRes = theFactory->createJSONObject(lObjectArray);
+
return true;
}
@@ -1190,7 +1196,7 @@
std::ostringstream lMsg;
lMsg << lEncoding << ": unsupported encoding";
- throwError("ARCH0004", lMsg.str().c_str());
+ throwError(ERROR_INVALID_ENCODING, lMsg.str().c_str());
}
}
@@ -1372,6 +1378,9 @@
lExhausted = true;
struct archive_entry *lEntry;
+ typedef std::pair<zorba::Item, zorba::Item> tArrElemt;
+ tArrElemt lElemt;
+ std::vector<tArrElemt> lJSONObject;
// to get the format, we need to peek into the first header
int lErr = archive_read_next_header(theArchive, &lEntry);
@@ -1391,33 +1400,15 @@
lCompression = "DEFLATE";
}
- zorba::Item lUntypedQName = theFactory->createQName(
- "http://www.w3.org/2001/XMLSchema", "untyped");
- zorba::Item lTmpQName = lUntypedQName;
-
- zorba::Item lOptionsQName = theFactory->createQName(
- ArchiveModule::getModuleURI(), "options");
-
- zorba::Item lFormatQName = theFactory->createQName(
- ArchiveModule::getModuleURI(), "format");
-
- zorba::Item lCompressionQName = theFactory->createQName(
- ArchiveModule::getModuleURI(), "compression");
-
- zorba::Item lNoParent;
- aRes = theFactory->createElementNode(
- lNoParent, lOptionsQName, lTmpQName, true, false, NsBindings());
-
- lTmpQName = lUntypedQName;
- zorba::Item lFormatItem = theFactory->createElementNode(
- aRes, lFormatQName, lTmpQName, true, false, NsBindings());
-
- lTmpQName = lUntypedQName;
- zorba::Item lCompressionItem = theFactory->createElementNode(
- aRes, lCompressionQName, lTmpQName, true, false, NsBindings());
-
- theFactory->createTextNode(lFormatItem, lFormat);
- theFactory->createTextNode(lCompressionItem, lCompression);
+ lElemt = std::make_pair<zorba::Item, zorba::Item>(theFactory->createString("format"),
+ theFactory->createString(lFormat));
+ lJSONObject.push_back(lElemt);
+
+ lElemt = std::make_pair<zorba::Item, zorba::Item>(theFactory->createString("compression"),
+ theFactory->createString(lCompression));
+ lJSONObject.push_back(lElemt);
+
+ aRes = theFactory->createJSONObject(lJSONObject);
return true;
}
=== modified file 'src/archive_module.xq.src/archive_module.h'
--- src/archive_module.xq.src/archive_module.h 2013-02-18 22:00:20 +0000
+++ src/archive_module.xq.src/archive_module.h 2013-07-23 21:38:29 +0000
@@ -71,7 +71,7 @@
}
static zorba::String
- getModuleURI() { return "http://www.zorba-xquery.com/modules/archive"; }
+ getModuleURI() { return "http://zorba.io/modules/archive"; }
static zorba::Item
createDateTimeItem(time_t&);
=== modified file 'test/ExpQueryResults/entries_01.xml.res'
--- test/ExpQueryResults/entries_01.xml.res 2012-09-17 17:56:29 +0000
+++ test/ExpQueryResults/entries_01.xml.res 2013-07-23 21:38:29 +0000
@@ -1,2 +1,1 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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>
\ No newline at end of file
+{ "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" }
\ No newline at end of file
=== modified file 'test/ExpQueryResults/entries_02.xml.res'
--- test/ExpQueryResults/entries_02.xml.res 2012-09-17 17:56:29 +0000
+++ test/ExpQueryResults/entries_02.xml.res 2013-07-23 21:38:29 +0000
@@ -1,2 +1,1 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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>
\ No newline at end of file
+{ "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" }
\ No newline at end of file
=== modified file 'test/ExpQueryResults/entries_03.xml.res'
--- test/ExpQueryResults/entries_03.xml.res 2012-09-17 17:56:29 +0000
+++ test/ExpQueryResults/entries_03.xml.res 2013-07-23 21:38:29 +0000
@@ -1,1 +1,1 @@
-<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>
+{ "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" }
\ No newline at end of file
=== modified file 'test/ExpQueryResults/options_01.xml.res'
--- test/ExpQueryResults/options_01.xml.res 2012-08-03 21:54:38 +0000
+++ test/ExpQueryResults/options_01.xml.res 2013-07-23 21:38:29 +0000
@@ -1,2 +1,1 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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>
\ No newline at end of file
+{ "format" : "ZIP", "compression" : "DEFLATE" }{ "format" : "TAR", "compression" : "GZIP" }
\ No newline at end of file
=== modified file 'test/ExpQueryResults/options_02.xml.res'
--- test/ExpQueryResults/options_02.xml.res 2012-09-17 18:17:09 +0000
+++ test/ExpQueryResults/options_02.xml.res 2013-07-23 21:38:29 +0000
@@ -1,2 +1,1 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<options xmlns="http://www.zorba-xquery.com/modules/archive"><format>TAR</format><compression>BZIP2</compression></options>
\ No newline at end of file
+{ "format" : "TAR", "compression" : "BZIP2" }
\ No newline at end of file
=== modified file 'test/Queries/create_01.xq'
--- test/Queries/create_01.xq 2012-07-27 03:43:13 +0000
+++ test/Queries/create_01.xq 2013-07-23 21:38:29 +0000
@@ -1,4 +1,4 @@
-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
+import module namespace a = "http://zorba.io/modules/archive";
let $foo-content := "<foo/>"
let $bar-content := "<bar/>"
@@ -8,6 +8,7 @@
)
return
string-join(
- for $a in a:entries($archive)
- return a:extract-text($archive, $a/text())
+ for $name in a:entries($archive)("name")
+ return a:extract-text($archive, $name)
) eq concat($foo-content, $bar-content)
+
=== modified file 'test/Queries/create_02.xq'
--- test/Queries/create_02.xq 2013-07-17 07:50:04 +0000
+++ test/Queries/create_02.xq 2013-07-23 21:38:29 +0000
@@ -1,10 +1,15 @@
+<<<<<<< TREE
import module namespace a = "http://www.zorba-xquery.com/modules/archive";
import module namespace b = "http://zorba.io/modules/base64";
+=======
+import module namespace a = "http://zorba.io/modules/archive";
+import module namespace b = "http://zorba.io/modules/base64";
+>>>>>>> MERGE-SOURCE
let $foo-content := "<foo/>"
let $bar-content := xs:base64Binary("5Pb8")
let $archive := a:create(
- ("foo.xml", <a:entry encoding="ISO-8859-1">bar.xml</a:entry>),
+ ("foo.xml", { "encoding" : "ISO-8859-1", "name" : "bar.xml" }),
($foo-content, $bar-content)
)
return
=== modified file 'test/Queries/create_03.spec'
--- test/Queries/create_03.spec 2012-07-27 03:43:13 +0000
+++ test/Queries/create_03.spec 2013-07-23 21:38:29 +0000
@@ -1,1 +1,1 @@
-Error: http://www.zorba-xquery.com/modules/archive:ARCH0099
+Error: http://zorba.io/modules/archive:DIFFERENT-COMPRESSIONS-NOT-SUPPORTED
=== modified file 'test/Queries/create_03.xq'
--- test/Queries/create_03.xq 2012-07-27 03:43:13 +0000
+++ test/Queries/create_03.xq 2013-07-23 21:38:29 +0000
@@ -1,9 +1,10 @@
-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
+import module namespace a = "http://zorba.io/modules/archive";
let $foo-content := "<foo/>"
let $bar-content := "<bar/>"
let $archive := a:create(
- (<a:entry compression="store">foo.xml</a:entry>, <a:entry compression="deflate">bar.xml</a:entry>),
+ ({ "compression" : "store", "name" : "foo.xml" },
+ { "compression" : "deflate", "name" : "bar.xml" }),
($foo-content, $bar-content)
)
return
=== modified file 'test/Queries/delete_01.xq'
--- test/Queries/delete_01.xq 2013-07-17 07:50:04 +0000
+++ test/Queries/delete_01.xq 2013-07-23 21:38:29 +0000
@@ -1,5 +1,10 @@
+<<<<<<< TREE
import module namespace a = "http://www.zorba-xquery.com/modules/archive";
import module namespace b = "http://zorba.io/modules/base64";
+=======
+import module namespace a = "http://zorba.io/modules/archive";
+import module namespace b = "http://zorba.io/modules/base64";
+>>>>>>> MERGE-SOURCE
let $foo-content := "<foo/>"
let $bar-content := xs:base64Binary("YWJj")
=== modified file 'test/Queries/delete_02.xq'
--- test/Queries/delete_02.xq 2012-07-27 03:43:13 +0000
+++ test/Queries/delete_02.xq 2013-07-23 21:38:29 +0000
@@ -1,5 +1,4 @@
-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
-import schema namespace as = "http://www.zorba-xquery.com/modules/archive";
+import module namespace a = "http://zorba.io/modules/archive";
import module namespace f = "http://expath.org/ns/file";
let $a := f:read-binary(resolve-uri("linear-algebra-20120306.epub"))
=== modified file 'test/Queries/delete_03.xq'
--- test/Queries/delete_03.xq 2012-07-27 03:43:13 +0000
+++ test/Queries/delete_03.xq 2013-07-23 21:38:29 +0000
@@ -1,12 +1,12 @@
-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
+import module namespace a = "http://zorba.io/modules/archive";
let $foo-content := "<foo/>"
let $bar-content := xs:base64Binary("YWJj")
let $options :=
-<a:options>
- <a:format>TAR</a:format>
- <a:compression>GZIP</a:compression>
-</a:options>
+{
+ "format" : "TAR",
+ "compression" : "GZIP"
+}
let $archive0 := a:create(
("foo.xml"),
($foo-content),
=== modified file 'test/Queries/delete_04.xq'
--- test/Queries/delete_04.xq 2012-07-27 03:43:13 +0000
+++ test/Queries/delete_04.xq 2013-07-23 21:38:29 +0000
@@ -1,13 +1,13 @@
-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
+import module namespace a = "http://zorba.io/modules/archive";
let $foo-content := "<foo/>"
let $bar-content := xs:base64Binary("YWJj")
let $foo2-content := "<foo2/>"
let $options :=
-<a:options>
- <a:format>TAR</a:format>
- <a:compression>GZIP</a:compression>
-</a:options>
+{
+ "format" : "TAR",
+ "compression" : "GZIP"
+}
let $archive0 := a:create(
("foo.xml"),
($foo-content),
=== modified file 'test/Queries/dir_01.xq'
--- test/Queries/dir_01.xq 2012-09-06 20:40:47 +0000
+++ test/Queries/dir_01.xq 2013-07-23 21:38:29 +0000
@@ -1,10 +1,10 @@
-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
+import module namespace a = "http://zorba.io/modules/archive";
let $foo-content := "<foo/>"
let $bar-content := "<bar/>"
let $archive := a:create(
- ("foo.xml", "bar.xml", <entry type="directory">dir1</entry>),
+ ("foo.xml", "bar.xml", { "type" : "directory", "name" : "dir1" }),
($foo-content, $bar-content)
)
return
- for $e in a:entries($archive) return concat($e/text(), ",")
+ for $e in a:entries($archive)("name") return concat($e, ",")
=== modified file 'test/Queries/dir_02.xq'
--- test/Queries/dir_02.xq 2012-09-06 20:40:47 +0000
+++ test/Queries/dir_02.xq 2013-07-23 21:38:29 +0000
@@ -1,11 +1,11 @@
-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
+import module namespace a = "http://zorba.io/modules/archive";
let $foo-content := "<foo/>"
let $bar-content := "<bar/>"
let $archive := a:create(
- ("foo.xml", "bar.xml", <entry type="directory">dir1</entry>),
+ ("foo.xml", "bar.xml", { "type" : "directory", "name" : "dir1" }),
($foo-content, $bar-content)
)
let $archive2 := a:delete($archive, "dir1/")
return
- for $e in a:entries($archive2) return concat($e/text(), ",")
+ for $e in a:entries($archive2)("name") return concat($e, ",")
=== modified file 'test/Queries/dir_03.xq'
--- test/Queries/dir_03.xq 2012-09-06 20:40:47 +0000
+++ test/Queries/dir_03.xq 2013-07-23 21:38:29 +0000
@@ -1,13 +1,13 @@
-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
+import module namespace a = "http://zorba.io/modules/archive";
let $foo-content := "<foo/>"
let $bar-content := "<bar/>"
let $archive := a:create(
- ("foo.xml", "bar.xml", <entry type="directory">dir1</entry>),
+ ("foo.xml", "bar.xml", { "type" : "directory", "name" : "dir1" }),
($foo-content, $bar-content)
)
let $archive2 := a:delete($archive, "nonexistent.xml")
let $entries := a:entries($archive)
let $entries2 := a:entries($archive2)
-return $entries=$entries2
+return count($entries)=count($entries2)
=== modified file 'test/Queries/dir_04.xq'
--- test/Queries/dir_04.xq 2012-09-06 20:40:47 +0000
+++ test/Queries/dir_04.xq 2013-07-23 21:38:29 +0000
@@ -1,13 +1,13 @@
-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
+import module namespace a = "http://zorba.io/modules/archive";
let $foo-content := "<foo/>"
let $bar-content := "<bar/>"
let $archive := a:create(
- ("foo.xml", "bar.xml", <entry type="directory">dir1</entry>),
+ ("foo.xml", "bar.xml", { "type" : "directory", "name" : "dir1" }),
($foo-content, $bar-content)
)
-let $archive2 := a:update($archive, <a:entry type="directory">newdir</a:entry>, ())
+let $archive2 := a:update($archive, { "type" : "directory", "name" : "newdir" }, ())
let $entries := a:entries($archive)
let $entries2 := a:entries($archive2)
-return for $e in $entries2 return concat($e/text(), ",")
+return for $e in $entries2("name") return concat($e, ",")
=== modified file 'test/Queries/entries_01.xq'
--- test/Queries/entries_01.xq 2012-07-27 03:43:13 +0000
+++ test/Queries/entries_01.xq 2013-07-23 21:38:29 +0000
@@ -1,6 +1,7 @@
-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
-import schema namespace as = "http://www.zorba-xquery.com/modules/archive";
+import module namespace a = "http://zorba.io/modules/archive";
+(: import schema namespace as = "http://zorba.io/modules/archive"; :)
import module namespace f = "http://expath.org/ns/file";
for $a in a:entries(f:read-binary(resolve-uri("simple.zip")))
-return validate { $a }
+(: return validate { $a } :)
+return $a
=== modified file 'test/Queries/entries_02.xq'
--- test/Queries/entries_02.xq 2012-07-27 03:43:13 +0000
+++ test/Queries/entries_02.xq 2013-07-23 21:38:29 +0000
@@ -1,7 +1,6 @@
-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
-import schema namespace as = "http://www.zorba-xquery.com/modules/archive";
+import module namespace a = "http://zorba.io/modules/archive";
import module namespace f = "http://expath.org/ns/file";
for $a in a:entries(f:read-binary(resolve-uri("simple.tar.gz")))
-return validate { $a }
+return $a
=== modified file 'test/Queries/entries_03.spec'
--- test/Queries/entries_03.spec 2012-09-06 20:40:47 +0000
+++ test/Queries/entries_03.spec 2013-07-23 21:38:29 +0000
@@ -1,1 +1,1 @@
-Error: http://www.zorba-xquery.com/modules/archive:ARCH9999
+Error: http://zorba.io/modules/archive:CORRUPTED-ARCHIVE
=== modified file 'test/Queries/entries_03.xq'
--- test/Queries/entries_03.xq 2012-07-27 03:43:13 +0000
+++ test/Queries/entries_03.xq 2013-07-23 21:38:29 +0000
@@ -1,7 +1,8 @@
-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
-import schema namespace as = "http://www.zorba-xquery.com/modules/archive";
+import module namespace a = "http://zorba.io/modules/archive";
+(: import schema namespace as = "http://zorba.io/modules/archive"; :)
import module namespace f = "http://expath.org/ns/file";
for $a in a:entries(f:read-binary(resolve-uri("simple.tar.bz2")))
-return validate { $a }
+(: return validate { $a } :)
+return $a
=== modified file 'test/Queries/entries_04.spec'
--- test/Queries/entries_04.spec 2012-07-27 03:43:13 +0000
+++ test/Queries/entries_04.spec 2013-07-23 21:38:29 +0000
@@ -1,1 +1,1 @@
-Error: http://www.zorba-xquery.com/modules/archive:ARCH9999
+Error: http://zorba.io/modules/archive:CORRUPTED-ARCHIVE
=== modified file 'test/Queries/entries_04.xq'
--- test/Queries/entries_04.xq 2012-07-27 03:43:13 +0000
+++ test/Queries/entries_04.xq 2013-07-23 21:38:29 +0000
@@ -1,7 +1,8 @@
-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
-import schema namespace as = "http://www.zorba-xquery.com/modules/archive";
+import module namespace a = "http://zorba.io/modules/archive";
+(: import schema namespace as = "http://zorba.io/modules/archive"; :)
import module namespace f = "http://expath.org/ns/file";
for $a in a:entries(f:read-binary(resolve-uri("invalid.zip")))
-return validate { $a }
+(: return validate { $a } :)
+return $a
=== modified file 'test/Queries/extract_01.xq'
--- test/Queries/extract_01.xq 2012-07-27 03:43:13 +0000
+++ test/Queries/extract_01.xq 2013-07-23 21:38:29 +0000
@@ -1,5 +1,4 @@
-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
-import schema namespace as = "http://www.zorba-xquery.com/modules/archive";
+import module namespace a = "http://zorba.io/modules/archive";
import module namespace f = "http://expath.org/ns/file";
for $a in a:extract-text(f:read-binary(resolve-uri("simple.zip")))
=== modified file 'test/Queries/extract_02.xq'
--- test/Queries/extract_02.xq 2012-07-27 03:43:13 +0000
+++ test/Queries/extract_02.xq 2013-07-23 21:38:29 +0000
@@ -1,4 +1,4 @@
-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
+import module namespace a = "http://zorba.io/modules/archive";
import module namespace f = "http://expath.org/ns/file";
for $a in a:extract-text(f:read-binary(fn:resolve-uri("simple.zip")), "dir1/file1")
=== modified file 'test/Queries/extract_03.spec'
--- test/Queries/extract_03.spec 2012-07-27 03:43:13 +0000
+++ test/Queries/extract_03.spec 2013-07-23 21:38:29 +0000
@@ -1,1 +1,1 @@
-Error: http://www.zorba-xquery.com/modules/archive:ARCH0004
+Error: http://zorba.io/modules/archive:INVALID-ENCODING
=== modified file 'test/Queries/extract_03.xq'
--- test/Queries/extract_03.xq 2012-07-27 03:43:13 +0000
+++ test/Queries/extract_03.xq 2013-07-23 21:38:29 +0000
@@ -1,4 +1,4 @@
-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
+import module namespace a = "http://zorba.io/modules/archive";
import module namespace f = "http://expath.org/ns/file";
for $a in a:extract-text(f:read-binary(fn:resolve-uri("simple.zip")), "dir1/file1", "foo")
=== modified file 'test/Queries/extract_04.xq'
--- test/Queries/extract_04.xq 2012-07-27 03:43:13 +0000
+++ test/Queries/extract_04.xq 2013-07-23 21:38:29 +0000
@@ -1,4 +1,4 @@
-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
+import module namespace a = "http://zorba.io/modules/archive";
import module namespace f = "http://expath.org/ns/file";
for $a in a:extract-text(f:read-binary(fn:resolve-uri("transcoding.zip")), "dir2/iso-8859-1.txt", "ISO-8859-1")
=== modified file 'test/Queries/extract_05.xq'
--- test/Queries/extract_05.xq 2012-07-27 03:43:13 +0000
+++ test/Queries/extract_05.xq 2013-07-23 21:38:29 +0000
@@ -1,7 +1,7 @@
-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
+import module namespace a = "http://zorba.io/modules/archive";
import module namespace f = "http://expath.org/ns/file";
let $f := f:read-binary(resolve-uri("linear-algebra-20120306.epub"))
-for $a in a:entries($f)
-where $a/text() eq "EPUB/xhtml/fcla-xml-2.30li91.html"
-return a:extract-text($f, $a/text())
+for $a in a:entries($f)("name")
+where $a eq "EPUB/xhtml/fcla-xml-2.30li91.html"
+return a:extract-text($f, $a)
=== modified file 'test/Queries/extract_06.xq'
--- test/Queries/extract_06.xq 2012-07-27 03:43:13 +0000
+++ test/Queries/extract_06.xq 2013-07-23 21:38:29 +0000
@@ -1,4 +1,4 @@
-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
+import module namespace a = "http://zorba.io/modules/archive";
import module namespace f = "http://expath.org/ns/file";
for $a in a:extract-binary(f:read-binary(fn:resolve-uri("simple.zip")), "dir1/file1")
=== modified file 'test/Queries/extract_07.xq'
--- test/Queries/extract_07.xq 2012-07-27 03:43:13 +0000
+++ test/Queries/extract_07.xq 2013-07-23 21:38:29 +0000
@@ -1,6 +1,6 @@
-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
+import module namespace a = "http://zorba.io/modules/archive";
import module namespace f = "http://expath.org/ns/file";
let $f := f:read-binary(fn:resolve-uri("linear-algebra-20120306.epub"))
-for $a in a:entries($f)[position() > 2 and position() < 5]
+for $a in a:entries($f)("name")[position() > 2 and position() < 5]
return <text>{a:extract-binary($f, $a)}</text>
=== modified file 'test/Queries/options_01.xq'
--- test/Queries/options_01.xq 2012-08-03 21:54:38 +0000
+++ test/Queries/options_01.xq 2013-07-23 21:38:29 +0000
@@ -1,4 +1,4 @@
-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
+import module namespace a = "http://zorba.io/modules/archive";
import module namespace f = "http://expath.org/ns/file";
let $zip := f:read-binary(fn:resolve-uri("linear-algebra-20120306.epub"))
=== modified file 'test/Queries/options_02.spec'
--- test/Queries/options_02.spec 2012-09-06 20:40:47 +0000
+++ test/Queries/options_02.spec 2013-07-23 21:38:29 +0000
@@ -1,1 +1,1 @@
-Error: http://www.zorba-xquery.com/modules/archive:ARCH9999
+Error: http://zorba.io/modules/archive:CORRUPTED-ARCHIVE
=== modified file 'test/Queries/options_02.xq'
--- test/Queries/options_02.xq 2012-09-06 20:40:47 +0000
+++ test/Queries/options_02.xq 2013-07-23 21:38:29 +0000
@@ -1,4 +1,4 @@
-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
+import module namespace a = "http://zorba.io/modules/archive";
import module namespace f = "http://expath.org/ns/file";
let $tar-bz2 := f:read-binary(fn:resolve-uri("simple.tar.bz2"))
=== modified file 'test/Queries/options_03.spec'
--- test/Queries/options_03.spec 2012-09-06 20:40:47 +0000
+++ test/Queries/options_03.spec 2013-07-23 21:38:29 +0000
@@ -1,1 +1,1 @@
-Error: http://www.zorba-xquery.com/modules/archive:ARCH9999
+Error: http://zorba.io/modules/archive:CORRUPTED-ARCHIVE
=== modified file 'test/Queries/options_03.xq'
--- test/Queries/options_03.xq 2012-09-06 20:40:47 +0000
+++ test/Queries/options_03.xq 2013-07-23 21:38:29 +0000
@@ -1,4 +1,4 @@
-import module namespace a = "http://www.zorba-xquery.com/modules/archive";
+import module namespace a = "http://zorba.io/modules/archive";
let $fake_archive := xs:base64Binary("5Pb8")
return
=== modified file 'test/Queries/update_01.xq'
--- test/Queries/update_01.xq 2013-07-17 07:50:04 +0000
+++ test/Queries/update_01.xq 2013-07-23 21:38:29 +0000
@@ -1,5 +1,10 @@
+<<<<<<< TREE
import module namespace a = "http://www.zorba-xquery.com/modules/archive";
import module namespace b = "http://zorba.io/modules/base64";
+=======
+import module namespace a = "http://zorba.io/modules/archive";
+import module namespace b = "http://zorba.io/modules/base64";
+>>>>>>> MERGE-SOURCE
let $foo-content := "<foo/>"
let $bar-content := xs:base64Binary("YWJj")
=== modified file 'test/Queries/update_02.xq'
--- test/Queries/update_02.xq 2013-07-17 07:50:04 +0000
+++ test/Queries/update_02.xq 2013-07-23 21:38:29 +0000
@@ -1,5 +1,10 @@
+<<<<<<< TREE
import module namespace a = "http://www.zorba-xquery.com/modules/archive";
import module namespace b = "http://zorba.io/modules/base64";
+=======
+import module namespace a = "http://zorba.io/modules/archive";
+import module namespace b = "http://zorba.io/modules/base64";
+>>>>>>> MERGE-SOURCE
let $foo-content := "<foo/>"
let $bar-content := xs:base64Binary("YWJj")
=== modified file 'test/Queries/update_03.spec'
--- test/Queries/update_03.spec 2012-09-06 20:40:47 +0000
+++ test/Queries/update_03.spec 2013-07-23 21:38:29 +0000
@@ -1,1 +1,1 @@
-Error: http://www.zorba-xquery.com/modules/archive:ARCH0001
+Error: http://zorba.io/modules/archive:ENTRY-COUNT
=== modified file 'test/Queries/update_03.xq'
--- test/Queries/update_03.xq 2013-07-17 07:50:04 +0000
+++ test/Queries/update_03.xq 2013-07-23 21:38:29 +0000
@@ -1,5 +1,10 @@
+<<<<<<< TREE
import module namespace a = "http://www.zorba-xquery.com/modules/archive";
import module namespace b = "http://zorba.io/modules/base64";
+=======
+import module namespace a = "http://zorba.io/modules/archive";
+import module namespace b = "http://zorba.io/modules/base64";
+>>>>>>> MERGE-SOURCE
let $foo-content := "<foo/>"
let $bar-content := xs:base64Binary("YWJj")
=== modified file 'test/Queries/update_04.spec'
--- test/Queries/update_04.spec 2012-09-06 20:40:47 +0000
+++ test/Queries/update_04.spec 2013-07-23 21:38:29 +0000
@@ -1,1 +1,1 @@
-Error: http://www.zorba-xquery.com/modules/archive:ARCH9999
+Error: http://zorba.io/modules/archive:CORRUPTED-ARCHIVE
=== modified file 'test/Queries/update_04.xq'
--- test/Queries/update_04.xq 2013-07-17 07:50:04 +0000
+++ test/Queries/update_04.xq 2013-07-23 21:38:29 +0000
@@ -1,5 +1,10 @@
+<<<<<<< TREE
import module namespace a = "http://www.zorba-xquery.com/modules/archive";
import module namespace b = "http://zorba.io/modules/base64";
+=======
+import module namespace a = "http://zorba.io/modules/archive";
+import module namespace b = "http://zorba.io/modules/base64";
+>>>>>>> MERGE-SOURCE
let $fake_archive := xs:base64Binary("YWJj")
let $new-archive := a:update($fake_archive, "foo2.xml", "<foo2/>")
Follow ups
-
[Merge] lp:~zorba-coders/zorba/bug-1188033 into lp:zorba/archive-module
From: noreply, 2013-07-30
-
[Merge] lp:~zorba-coders/zorba/bug-1188033 into lp:zorba/archive-module
From: Zorba Build Bot, 2013-07-30
-
[Merge] lp:~zorba-coders/zorba/bug-1188033 into lp:zorba/archive-module
From: Zorba Build Bot, 2013-07-30
-
[Merge] lp:~zorba-coders/zorba/bug-1188033 into lp:zorba/archive-module
From: Luis Rodriguez Gonzalez, 2013-07-30
-
[Merge] lp:~zorba-coders/zorba/bug-1188033 into lp:zorba/archive-module
From: Zorba Build Bot, 2013-07-30
-
[Merge] lp:~zorba-coders/zorba/bug-1188033 into lp:zorba/archive-module
From: Zorba Build Bot, 2013-07-30
-
Re: [Merge] lp:~zorba-coders/zorba/bug-1188033 into lp:zorba/archive-module
From: Luis Rodriguez Gonzalez, 2013-07-30
-
[Merge] lp:~zorba-coders/zorba/bug-1188033 into lp:zorba/archive-module
From: Zorba Build Bot, 2013-07-30
-
[Merge] lp:~zorba-coders/zorba/bug-1188033 into lp:zorba/archive-module
From: Zorba Build Bot, 2013-07-30
-
Re: [Merge] lp:~zorba-coders/zorba/bug-1188033 into lp:zorba/archive-module
From: Chris Hillery, 2013-07-30
-
Re: [Merge] lp:~zorba-coders/zorba/bug-1188033 into lp:zorba/archive-module
From: Chris Hillery, 2013-07-26
-
Re: [Merge] lp:~zorba-coders/zorba/bug-1188033 into lp:zorba/archive-module
From: Chris Hillery, 2013-07-23
-
Re: [Merge] lp:~zorba-coders/zorba/bug-1188033 into lp:zorba/archive-module
From: Chris Hillery, 2013-07-23