Paul J. Lucas has proposed merging lp:~zorba-coders/zorba/bug-1217140 into 
lp:zorba.

Commit message:
Added item-separator serializer option.

Requested reviews:
  Paul J. Lucas (paul-lucas)
Related bugs:
  Bug #1217140 in Zorba: "Support XQuery 3.0 item-separator serialization 
parameter"
  https://bugs.launchpad.net/zorba/+bug/1217140

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-1217140/+merge/184906

Added item-separator serializer option.
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1217140/+merge/184906
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog	2013-08-21 10:25:42 +0000
+++ ChangeLog	2013-09-11 01:45:14 +0000
@@ -44,6 +44,7 @@
   * Fixed bug #1189636 (transcoding hexBinary streambuf)
   * Fixed bug in hoisting through try-catch expr
   * Fixed bug #1162631 (format-integer 'w' format of negative numbers)
+  * Fixed bug #1217140 (Support XQuery 3.0 item-separator serialization parameter)
   * Fixed bug #942171 (file module to allow for arbitrary encodings)
   * Fixed bug #1192285 (Have JSON token know number subtype)
   * Fixed bug #1210628 (file:last-modified returns wrong month)

=== modified file 'include/zorba/options.h'
--- include/zorba/options.h	2013-08-13 23:32:22 +0000
+++ include/zorba/options.h	2013-09-11 01:45:14 +0000
@@ -222,6 +222,7 @@
   Zorba_opaque_char_ptr_t       doctype_system;
   Zorba_opaque_char_ptr_t       doctype_public;
   Zorba_opaque_char_ptr_t       cdata_section_elements;
+  Zorba_opaque_char_ptr_t       item_separator;
   Zorba_opaque_char_ptr_t       version;
 
   Zorba_jsoniq_multiple_items_t jsoniq_multiple_items;

=== modified file 'src/api/options.cpp'
--- src/api/options.cpp	2013-08-14 02:10:00 +0000
+++ src/api/options.cpp	2013-09-11 01:45:14 +0000
@@ -59,6 +59,8 @@
     to->doctype_public.ptr = ztd::new_strdup( from->doctype_public.ptr );
   if ( from->cdata_section_elements.ptr )
     to->cdata_section_elements.ptr = ztd::new_strdup( from->cdata_section_elements.ptr );
+  if ( from->item_separator.ptr )
+    to->item_separator.ptr = ztd::new_strdup( from->item_separator.ptr );
   if ( from->version.ptr )
     to->version.ptr = ztd::new_strdup( from->version.ptr );
 }
@@ -69,6 +71,7 @@
   opts->doctype_system.ptr = nullptr;
   opts->doctype_public.ptr = nullptr;
   opts->cdata_section_elements.ptr = nullptr;
+  opts->item_separator.ptr = nullptr;
   opts->version.ptr = nullptr;
 }
 
@@ -114,6 +117,7 @@
   opts->standalone = ZORBA_STANDALONE_OMIT;
   opts->undeclare_prefixes = ZORBA_UNDECLARE_PREFIXES_NO;
   null_ptrs( opts );
+  assign( opts->item_separator, " " );
 }
 
 void Zorba_SerializerOptions_free( Zorba_SerializerOptions_t *opts ) {
@@ -122,6 +126,7 @@
   delete[] opts->doctype_system.ptr;
   delete[] opts->doctype_public.ptr;
   delete[] opts->cdata_section_elements.ptr;
+  delete[] opts->item_separator.ptr;
   delete[] opts->version.ptr;
   null_ptrs( opts );
 }
@@ -165,6 +170,11 @@
   if ( strcmp( option, "indent" ) == 0 )
     return parse_yes_no( value, &opts->indent );
 
+  if ( strcmp( option, "item-separator" ) == 0 ) {
+    assign( opts->item_separator, value );
+    return true;
+  }
+
   if ( strcmp( option, "jsoniq-multiple-items" ) == 0 )
     return parse_yes_no( value, &opts->jsoniq_multiple_items );
 

=== modified file 'src/api/serialization/serializer.cpp'
--- src/api/serialization/serializer.cpp	2013-08-16 21:37:19 +0000
+++ src/api/serialization/serializer.cpp	2013-09-11 01:45:14 +0000
@@ -412,8 +412,7 @@
 
       rollover = emit_expanded_string(buffer, static_cast<zstring::size_type>(read_bytes + rollover));
       memmove(buffer, buffer + 1024 - rollover, rollover);
-    }
-    while (read_bytes > 0);
+    } while (read_bytes > 0);
     break;
   }
   case store::XS_BASE64BINARY:
@@ -448,7 +447,7 @@
   if (item->isAtomic())
   {
     if (thePreviousItemKind == PREVIOUS_ITEM_WAS_TEXT)
-      tr << " ";
+      tr << ser->item_separator;
 
     if (item->isStreamable())
     {
@@ -2090,7 +2089,7 @@
   if (item->isAtomic())
   {
     if (thePreviousItemKind == PREVIOUS_ITEM_WAS_TEXT)
-      tr << " ";
+      tr << ser->item_separator;
 
     if (item->isStreamable())
       emit_streamable_item(item);
@@ -2304,6 +2303,7 @@
 
   include_content_type = PARAMETER_VALUE_NO;
 
+  item_separator = ' ';
   media_type.clear();
 
   // This default should match the default for ser_method in Zorba_SerializerOptions
@@ -2469,6 +2469,10 @@
   {
     cdata_section_elements = aValue;
   }
+  else if (!strcmp(aName, "item-separator"))
+  {
+    item_separator = aValue;
+  }
   else if (!strcmp(aName, "jsoniq-multiple-items"))
   {
     if (!strcmp(aValue, "no"))

=== modified file 'src/api/serialization/serializer.h'
--- src/api/serialization/serializer.h	2013-08-13 17:43:02 +0000
+++ src/api/serialization/serializer.h	2013-09-11 01:45:14 +0000
@@ -95,6 +95,7 @@
   zstring encoding;
   short int escape_uri_attributes; // TODO: yes/no requires unicode normalization
   short int include_content_type;  // yes/no, implemented
+  zstring item_separator;
   zstring media_type;              // string, implemented
   short int method;                // an expanded QName: "xml", "html", "xhtml",
                                    // "text" and "binary"

=== modified file 'src/api/serializerimpl.cpp'
--- src/api/serializerimpl.cpp	2013-08-13 05:43:39 +0000
+++ src/api/serializerimpl.cpp	2013-09-11 01:45:14 +0000
@@ -206,6 +206,9 @@
   if (aSerializerOptions.cdata_section_elements)
     aInternalSerializer.setParameter("cdata-section-elements", aSerializerOptions.cdata_section_elements);
 
+  if (aSerializerOptions.item_separator)
+    aInternalSerializer.setParameter("item-separator", aSerializerOptions.item_separator);
+
   if (aSerializerOptions.version)
     aInternalSerializer.setParameter("version", aSerializerOptions.version);
 

=== added file 'test/rbkt/ExpQueryResults/zorba/serialization/item-separator-1.xml.res'
--- test/rbkt/ExpQueryResults/zorba/serialization/item-separator-1.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/serialization/item-separator-1.xml.res	2013-09-11 01:45:14 +0000
@@ -0,0 +1,1 @@
+123

=== added file 'test/rbkt/ExpQueryResults/zorba/serialization/item-separator-2.xml.res'
--- test/rbkt/ExpQueryResults/zorba/serialization/item-separator-2.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/serialization/item-separator-2.xml.res	2013-09-11 01:45:14 +0000
@@ -0,0 +1,1 @@
+1|2|3

=== added file 'test/rbkt/Queries/zorba/serialization/item-separator-1.spec'
--- test/rbkt/Queries/zorba/serialization/item-separator-1.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/serialization/item-separator-1.spec	2013-09-11 01:45:14 +0000
@@ -0,0 +1,1 @@
+Serialization: item-separator=

=== added file 'test/rbkt/Queries/zorba/serialization/item-separator-1.xq'
--- test/rbkt/Queries/zorba/serialization/item-separator-1.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/serialization/item-separator-1.xq	2013-09-11 01:45:14 +0000
@@ -0,0 +1,1 @@
+(1, 2, 3)

=== added file 'test/rbkt/Queries/zorba/serialization/item-separator-2.spec'
--- test/rbkt/Queries/zorba/serialization/item-separator-2.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/serialization/item-separator-2.spec	2013-09-11 01:45:14 +0000
@@ -0,0 +1,1 @@
+Serialization: item-separator=|

=== added file 'test/rbkt/Queries/zorba/serialization/item-separator-2.xq'
--- test/rbkt/Queries/zorba/serialization/item-separator-2.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/serialization/item-separator-2.xq	2013-09-11 01:45:14 +0000
@@ -0,0 +1,1 @@
+(1, 2, 3)

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to