zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #14589
[Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
Till Westmann has proposed merging lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba.
Commit message:
add jn:encode-for-roundtrip and jn:decode-from-roundtrip
adapt json serialiation to version 0.4.39 of the JSONiq specification
Requested reviews:
Paul J. Lucas (paul-lucas)
Matthias Brantner (matthias-brantner)
Chris Hillery (ceejatec)
Related bugs:
Bug #1041413 in Zorba: "JSONiq round-tripability"
https://bugs.launchpad.net/zorba/+bug/1041413
Bug #1041419 in Zorba: "Serializing atomic items in JSONiq"
https://bugs.launchpad.net/zorba/+bug/1041419
Bug #1048751 in Zorba: "jsoniq: serialization defaults"
https://bugs.launchpad.net/zorba/+bug/1048751
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/jsoniq-roundtrip/+merge/124316
add jn:encode-for-roundtrip and jn:decode-from-roundtrip
adapt json serialiation to version 0.4.39 of the JSONiq specification
--
https://code.launchpad.net/~zorba-coders/zorba/jsoniq-roundtrip/+merge/124316
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'include/zorba/options.h'
--- include/zorba/options.h 2012-09-17 00:36:37 +0000
+++ include/zorba/options.h 2012-09-21 03:00:26 +0000
@@ -86,7 +86,7 @@
ZORBA_SERIALIZATION_METHOD_BINARY,
#ifdef ZORBA_WITH_JSON
ZORBA_SERIALIZATION_METHOD_JSON,
- ZORBA_SERIALIZATION_METHOD_JSONIQ
+ ZORBA_SERIALIZATION_METHOD_JSON_XML_HYBRID
#endif
} Zorba_serialization_method_t;
@@ -161,15 +161,9 @@
typedef enum {
JSONIQ_MULTIPLE_ITEMS_NO,
- JSONIQ_MULTIPLE_ITEMS_ARRAY,
- JSONIQ_MULTIPLE_ITEMS_APPENDED
+ JSONIQ_MULTIPLE_ITEMS_YES
} Zorba_jsoniq_multiple_items_t;
-typedef enum {
- JSONIQ_ALLOW_MIXED_XDM_JDM_YES,
- JSONIQ_ALLOW_MIXED_XDM_JDM_NO
-} Zorba_jsoniq_allow_mixed_xdm_jdm_t;
-
/** \brief Options that configure the serialization process of a query result.
* See http://www.w3.org/TR/2005/CR-xslt-xquery-serialization-20051103/.
@@ -201,10 +195,8 @@
zorba::String version;
#ifdef ZORBA_WITH_JSON
- Zorba_jsoniq_extensions_t jsoniq_extensions;
Zorba_jsoniq_multiple_items_t jsoniq_multiple_items;
- Zorba_serialization_method_t jsoniq_xdm_method;
- Zorba_jsoniq_allow_mixed_xdm_jdm_t jsoniq_allow_mixed_xdm_jdm;
+ Zorba_serialization_method_t jsoniq_xdm_method;
#endif /* ZORBA_WITH_JSON */
/** \brief Default constructor for SerializerOptions which assigns default values to all
=== modified file 'include/zorba/pregenerated/diagnostic_list.h'
--- include/zorba/pregenerated/diagnostic_list.h 2012-09-18 16:29:31 +0000
+++ include/zorba/pregenerated/diagnostic_list.h 2012-09-21 03:00:26 +0000
@@ -837,8 +837,6 @@
extern ZORBA_DLL_PUBLIC JSONiqErrorCode JNSE0012;
-extern ZORBA_DLL_PUBLIC JSONiqErrorCode JNSE0013;
-
extern ZORBA_DLL_PUBLIC JSONiqErrorCode JNSE0014;
extern ZORBA_DLL_PUBLIC JSONiqErrorCode JNSE0022;
@@ -851,6 +849,8 @@
extern ZORBA_DLL_PUBLIC JSONiqErrorCode JNUP0019;
+extern ZORBA_DLL_PUBLIC JSONiqErrorCode JNTY0023;
+
extern ZORBA_DLL_PUBLIC JSONiqErrorCode JNTY0003;
extern ZORBA_DLL_PUBLIC JSONiqErrorCode JSDY0040;
=== modified file 'modules/org/jsoniq/www/functions.xq'
--- modules/org/jsoniq/www/functions.xq 2012-09-17 00:36:37 +0000
+++ modules/org/jsoniq/www/functions.xq 2012-09-21 03:00:26 +0000
@@ -44,6 +44,109 @@
(:~
+ : This function decodes non-JSON types previously encoded with
+ : jn:encode-for-roundtrip.
+ : Calling this version of the function is equivalent to calling the
+ : 2 argument version of the function with the second argument
+ :
+ : { "prefix" : "Q{http://www.jsoniq.org/roundtrip}" }
+ :
+ : @param $items the items to be decoded.
+ : @return the decoded items.
+ :)
+declare function jn:decode-from-roundtrip(
+ $items as json-item()*) as structured-item()* external;
+
+
+(:~
+ : This function decodes non-JSON types previously encoded with
+ : jn:encode-for-roundtrip.
+ : The $options parameter contains options for the decoding process.
+ : Currently the only supported option is "prefix". It specifies the prefix
+ : that determines if this function decodes an item.
+ :
+ : Example:
+ : jn:decode-from-roundtrip(
+ : { "nan" : { "pre-type" : "xs:double", "pre-value" : "NaN" } },
+ : { "prefix" : "pre-" }
+ : )
+ : returns the same instance that would be constructed by
+ : { "nan" : xs:double("NaN") }
+ :
+ : So
+ : let $decoded := jn:decode-from-roundtrip(
+ : { "nan" : { "pre-type" : "xs:double", "pre-value" : "NaN" } },
+ : { "prefix" : "pre-" }
+ : )
+ : let $nan := $decoded("nan")
+ : return
+ : ($nan instance of xs:double, $nan)
+ : returns
+ : true NaN
+ :
+ : @param $items the items to be decoded.
+ : @param $options the decoding options.
+ :
+ : @error jerr:JNTY0023 if $options("prefix") is not a string
+ :
+ : @return the decoded items.
+ :)
+declare function jn:decode-from-roundtrip(
+ $items as json-item()*,
+ $options as object()) as structured-item()* external;
+
+
+(:~
+ : This function recursively encodes non-JSON types in such a way that they
+ : can be serialized as JSON while keeping roundtrip capability.
+ : Calling this version of the function is equivalent to calling the
+ : 2 argument version of the function with the second argument
+ :
+ : {
+ : "prefix" : "Q{http://www.jsoniq.org/roundtrip}"
+ : "serialization-parameters" : <serialization-parameters xmlns="http://www.w3.org/2010/xslt-xquery-serialization"/>
+ : }
+ :
+ : Note: The computations are made with respect to the static context of the
+ : caller, so that the schema type definitions are available.
+ :
+ : @param $items the items to be encoded.
+ : @return the encoded items.
+ :)
+declare function jn:encode-for-roundtrip(
+ $items as structured-item()*) as json-item()* external;
+
+
+(:~
+ : This function recursively encodes non-JSON types in such a way that they
+ : can be serialized as JSON while keeping roundtrip capability.
+ :
+ : Note: The computations are made with respect to the static context of the
+ : caller, so that the schema type definitions are available.
+ :
+ : Example:
+ : jn:encode-for-roundtrip(
+ : { "nan" : xs:double("NaN") },
+ : { "prefix" : "pre-" }
+ : )
+ : returns
+ : { "nan" : { "pre-type" : "xs:double", "pre-value" : "NaN" } }
+ :
+ : @param $items the items to be encoded.
+ : @param $options the encoding options.
+ :
+ : @error jerr:JNTY0023 if $options("prefix") is not a string or
+ $options("serialization-parameters") is not an element node
+ : @error err:XQDY0027 if $options("serialization-parameters") is not a valid
+ : serialization-parameters element
+ : @return the encoded items.
+ :)
+declare function jn:encode-for-roundtrip(
+ $items as structured-item()*,
+ $options as object()) as json-item()* external;
+
+
+(:~
: This function parses a given string as JSON and returns a sequence
: of Objects or Arrays.
:
=== modified file 'modules/org/jsoniq/www/pregenerated/errors.xq'
--- modules/org/jsoniq/www/pregenerated/errors.xq 2012-09-17 00:36:37 +0000
+++ modules/org/jsoniq/www/pregenerated/errors.xq 2012-09-21 03:00:26 +0000
@@ -100,15 +100,7 @@
declare variable $jerr:JNSE0012 as xs:QName := fn:QName($jerr:NS, "jerr:JNSE0012");
(:~
- :It is a dynamic error to serialize an atomic value not
- : supported by JSON or a node with the JSON output method and with
- : the jsoniq-serialization-extensions serialization parameter
- : set to false.
-:)
-declare variable $jerr:JNSE0013 as xs:QName := fn:QName($jerr:NS, "jerr:JNSE0013");
-
-(:~
- :It is a dynamic error to serialize a function with the
+ :It is a dynamic error to serialize a function or a node with the
: JSON output method.
:)
declare variable $jerr:JNSE0014 as xs:QName := fn:QName($jerr:NS, "jerr:JNSE0014");
@@ -141,6 +133,12 @@
declare variable $jerr:JNUP0019 as xs:QName := fn:QName($jerr:NS, "jerr:JNUP0019");
(:~
+ :It is a type error if the prefix is not a string or if the
+ : serialization parameters are not an element.
+:)
+declare variable $jerr:JNTY0023 as xs:QName := fn:QName($jerr:NS, "jerr:JNTY0023");
+
+(:~
:objects or arrays don't have a string value
:)
declare variable $jerr:JNTY0003 as xs:QName := fn:QName($jerr:NS, "jerr:JNTY0003");
=== modified file 'schemas/xslt-xquery-serialization.xsd'
--- schemas/xslt-xquery-serialization.xsd 2012-09-17 00:36:37 +0000
+++ schemas/xslt-xquery-serialization.xsd 2012-09-21 03:00:26 +0000
@@ -61,6 +61,8 @@
<xs:enumeration value="text"/>
<xs:enumeration value="xml"/>
<xs:enumeration value="xhtml"/>
+ <xs:enumeration value="json"/>
+ <xs:enumeration value="json-xml-hybrid"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
=== modified file 'src/api/options.cpp'
--- src/api/options.cpp 2012-09-17 00:36:37 +0000
+++ src/api/options.cpp 2012-09-21 03:00:26 +0000
@@ -38,7 +38,7 @@
Zorba_SerializerOptions::Zorba_SerializerOptions()
:
#ifdef ZORBA_WITH_JSON
- ser_method(ZORBA_SERIALIZATION_METHOD_JSONIQ),
+ ser_method(ZORBA_SERIALIZATION_METHOD_JSON_XML_HYBRID),
#else
ser_method(ZORBA_SERIALIZATION_METHOD_XML),
#endif
@@ -53,10 +53,8 @@
encoding(ZORBA_ENCODING_UTF8)
#ifdef ZORBA_WITH_JSON
,
- jsoniq_extensions(JSONIQ_EXTENSIONS_NO),
- jsoniq_multiple_items(JSONIQ_MULTIPLE_ITEMS_NO),
- jsoniq_xdm_method(ZORBA_SERIALIZATION_METHOD_XML),
- jsoniq_allow_mixed_xdm_jdm(JSONIQ_ALLOW_MIXED_XDM_JDM_NO)
+ jsoniq_multiple_items(JSONIQ_MULTIPLE_ITEMS_YES),
+ jsoniq_xdm_method(ZORBA_SERIALIZATION_METHOD_XML)
#endif /* ZORBA_WITH_JSON */
{
}
@@ -70,7 +68,7 @@
else if (strcmp(value, "binary") == 0) return ZORBA_SERIALIZATION_METHOD_BINARY;
#ifdef ZORBA_WITH_JSON
else if (strcmp(value, "json") == 0) return ZORBA_SERIALIZATION_METHOD_JSON;
- else if (strcmp(value, "jsoniq") == 0) return ZORBA_SERIALIZATION_METHOD_JSONIQ;
+ else if (strcmp(value, "json-xml-hybrid") == 0) return ZORBA_SERIALIZATION_METHOD_JSON_XML_HYBRID;
#endif
else
{
@@ -149,29 +147,17 @@
version = value;
}
#ifdef ZORBA_WITH_JSON
- else if (strcmp(parameter, "jsoniq-extensions") == 0)
- {
- if (strcmp(value, "yes") == 0) jsoniq_extensions = JSONIQ_EXTENSIONS_YES;
- else if (strcmp(value, "no") == 0) jsoniq_extensions = JSONIQ_EXTENSIONS_NO;
- }
else if (strcmp(parameter, "jsoniq-multiple-items") == 0)
{
if (strcmp(value, "no") == 0)
jsoniq_multiple_items = JSONIQ_MULTIPLE_ITEMS_NO;
- else if (strcmp(value, "array") == 0)
- jsoniq_multiple_items = JSONIQ_MULTIPLE_ITEMS_ARRAY;
- else if (strcmp(value, "appended") == 0)
- jsoniq_multiple_items = JSONIQ_MULTIPLE_ITEMS_APPENDED;
+ else if (strcmp(value, "yes") == 0)
+ jsoniq_multiple_items = JSONIQ_MULTIPLE_ITEMS_YES;
}
else if (strcmp(parameter, "jsoniq-xdm-node-output-method") == 0)
{
jsoniq_xdm_method = convertMethodString(value, parameter);
}
- else if (strcmp(parameter, "jsoniq-allow-mixed-xdm-jdm") == 0)
- {
- if (strcmp(value, "yes") == 0) jsoniq_allow_mixed_xdm_jdm = JSONIQ_ALLOW_MIXED_XDM_JDM_YES;
- else if (strcmp(value, "no") == 0) jsoniq_allow_mixed_xdm_jdm = JSONIQ_ALLOW_MIXED_XDM_JDM_NO;
- }
#endif /* ZORBA_WITH_JSON */
}
=== modified file 'src/api/serialization/serializer.cpp'
--- src/api/serialization/serializer.cpp 2012-09-17 00:36:37 +0000
+++ src/api/serialization/serializer.cpp 2012-09-21 03:00:26 +0000
@@ -1006,15 +1006,13 @@
case store::XS_DOUBLE:
case store::XS_FLOAT:
if (item->isNaN()) {
- emit_jsoniq_value(type == store::XS_DOUBLE ? "double" : "float",
- "NaN", depth);
+ emit_json_string("NaN");
break;
}
else if (item->isPosOrNegInf()) {
// QQQ with Cloudscript, this is supposed to be INF or -INF - how can
// I tell which I have?
- emit_jsoniq_value(type == store::XS_DOUBLE ? "double" : "float",
- "INF", depth);
+ emit_json_string("INF");
break;
}
// else fall through
@@ -1045,8 +1043,7 @@
break;
default: {
- emit_jsoniq_value(item->getType()->getStringValue(),
- item->getStringValue(), depth);
+ emit_json_string(item->getStringValue());
break;
}
}
@@ -1104,7 +1101,6 @@
********************************************************************************/
void serializer::json_emitter::emit_json_array(store::Item* array, int depth)
{
- store::Item_t member;
xs_integer size = array->getArraySize();
tr << "[ ";
for (xs_integer i = xs_integer(1); i <= size; ++i) {
@@ -1121,64 +1117,16 @@
/*******************************************************************************
********************************************************************************/
-void serializer::json_emitter::emit_jsoniq_value(
- zstring type,
- zstring value,
- int depth)
-{
- // First make sure we should be doing these extended values
- if (ser->jsoniq_extensions == PARAMETER_VALUE_NO) {
- throw XQUERY_EXCEPTION(jerr::JNSE0013, ERROR_PARAMS(value));
- }
-
- // Create items for constant strings, if not already done
- if (!theJSONiqValueName)
- {
- zstring jsoniqvaluestring("JSONiq value");
- zstring typestring("type");
- zstring valuestring("value");
- GENV_ITEMFACTORY->createString(theJSONiqValueName, jsoniqvaluestring);
- GENV_ITEMFACTORY->createString(theTypeName, typestring);
- GENV_ITEMFACTORY->createString(theValueName, valuestring);
- }
-
- // Create the inner JSON object, which contains two pairs
- std::vector<store::Item_t> names(2);
- std::vector<store::Item_t> values(2);
-
- names[0] = theTypeName;
- names[1] = theValueName;
-
- GENV_ITEMFACTORY->createString(values[0], type);
- GENV_ITEMFACTORY->createString(values[1], value);
-
- store::Item_t inner;
- GENV_ITEMFACTORY->createJSONObject(inner, names, values);
-
- // Create the outer JSON object with one pair
- names.resize(1);
- values.resize(1);
- names[0] = theJSONiqValueName;
- values[0] = inner;
-
- store::Item_t outer;
- GENV_ITEMFACTORY->createJSONObject(outer, names, values);
-
- emit_json_object(outer, depth);
-}
-
void serializer::json_emitter::emit_jsoniq_xdm_node(
store::Item* item,
- int depth)
+ int)
{
- // First make sure we should be doing these extended values
- if (ser->jsoniq_extensions == PARAMETER_VALUE_NO) {
- // QQQ probably should put "XML node" in diagnostics_en.xml
- throw XQUERY_EXCEPTION(jerr::JNSE0013, ERROR_PARAMS("XML node"));
+ if (true) {
+ // It could be useful to have some form of serialization of nested XML nodes
+ // (if only for debugging purposes). However as this is not (yet?) specified
+ // we throw an error here.
+ throw XQUERY_EXCEPTION(jerr::JNSE0014);
}
-
- // OK, we've got a non-atomic non-JDM Item here, so serialize it as XML
- // and output it as a "JSONiq XDM node".
if (!theXMLEmitter) {
theXMLStringStream = new std::stringstream();
ser->attach_transcoder(*theXMLStringStream);
@@ -1188,24 +1136,7 @@
zstring xml(theXMLStringStream->str());
theXMLStringStream->str("");
- // Create item for constant string, if not already done
- if (!theJSONiqValueName)
- {
- zstring xdmnodestring("JSONiq XDM node");
- GENV_ITEMFACTORY->createString(theJSONiqXDMNodeName, xdmnodestring);
- }
-
- // Create the JSON object, which contains one pair
- std::vector<store::Item_t> names(1);
- std::vector<store::Item_t> values(1);
-
- names[0] = theJSONiqXDMNodeName;
- GENV_ITEMFACTORY->createString(values[0], xml);
-
- store::Item_t object;
- GENV_ITEMFACTORY->createJSONObject(object, names, values);
-
- emit_json_object(object, depth);
+ emit_json_string(xml);
}
@@ -1220,11 +1151,11 @@
////////////////////////////////////////////////////////////////////////////////
// //
-// JSONiq emitter (auto-detects JSON or XML) //
+// hybrid emitter (auto-detects JSON or XML) //
// //
////////////////////////////////////////////////////////////////////////////////
-serializer::jsoniq_emitter::jsoniq_emitter(
+serializer::hybrid_emitter::hybrid_emitter(
serializer* the_serializer,
std::ostream& the_stream,
bool aEmitAttributes)
@@ -1236,46 +1167,29 @@
{
}
-serializer::jsoniq_emitter::~jsoniq_emitter()
+serializer::hybrid_emitter::~hybrid_emitter()
{
delete theXMLEmitter;
delete theJSONEmitter;
}
-void serializer::jsoniq_emitter::emit_declaration()
+void serializer::hybrid_emitter::emit_declaration()
{
}
-void serializer::jsoniq_emitter::emit_item(store::Item *item)
+void serializer::hybrid_emitter::emit_item(store::Item *item)
{
-
- bool isJson = item->isJSONItem();
-
- if (ser->jsoniq_allow_mixed_xdm_jdm == PARAMETER_VALUE_NO)
- {
- if ((isJson && theEmitterState == JESTATE_XDM) ||
- (!isJson && theEmitterState == JESTATE_JDM))
- {
- throw XQUERY_EXCEPTION(zerr::ZAPI0045_CANNOT_SERIALIZE_MIXED_XDM_JDM);
- }
- }
-
- if (isJson) {
+ if (item->isJSONItem()) {
theEmitterState = JESTATE_JDM;
theJSONEmitter->emit_item(item);
}
else {
- if (theEmitterState == JESTATE_UNDETERMINED &&
- ser->jsoniq_allow_mixed_xdm_jdm == PARAMETER_VALUE_NO)
- {
- theXMLEmitter->emit_declaration();
- }
theEmitterState = JESTATE_XDM;
theXMLEmitter->emit_item(item);
}
}
-void serializer::jsoniq_emitter::emit_end()
+void serializer::hybrid_emitter::emit_end()
{
switch(theEmitterState)
{
@@ -2371,11 +2285,9 @@
// This default should match the default for ser_method in Zorba_SerializerOptions
#ifdef ZORBA_WITH_JSON
- method = PARAMETER_VALUE_JSONIQ;
- jsoniq_multiple_items = PARAMETER_VALUE_NO;
- jsoniq_extensions = PARAMETER_VALUE_NO;
+ method = PARAMETER_VALUE_JSON_XML_HYBRID;
+ jsoniq_multiple_items = PARAMETER_VALUE_YES;
jsoniq_xdm_method = PARAMETER_VALUE_XML;
- jsoniq_allow_mixed_xdm_jdm = PARAMETER_VALUE_NO;
#else
method = PARAMETER_VALUE_XML;
#endif
@@ -2410,8 +2322,8 @@
#ifdef ZORBA_WITH_JSON
else if (!strcmp(aValue, "json"))
return serializer::PARAMETER_VALUE_JSON;
- else if (!strcmp(aValue, "jsoniq"))
- return serializer::PARAMETER_VALUE_JSONIQ;
+ else if (!strcmp(aValue, "json-xml-hybrid"))
+ return serializer::PARAMETER_VALUE_JSON_XML_HYBRID;
#endif
else
throw XQUERY_EXCEPTION(
@@ -2541,25 +2453,12 @@
cdata_section_elements = aValue;
}
#ifdef ZORBA_WITH_JSON
- else if (!strcmp(aName, "jsoniq-extensions"))
- {
- if (!strcmp(aValue, "yes"))
- jsoniq_extensions = PARAMETER_VALUE_YES;
- else if (!strcmp(aValue, "no"))
- jsoniq_extensions = PARAMETER_VALUE_NO;
- else
- throw XQUERY_EXCEPTION(
- err::SEPM0016, ERROR_PARAMS( aValue, aName, ZED( GoodValuesAreYesNo ) )
- );
- }
else if (!strcmp(aName, "jsoniq-multiple-items"))
{
if (!strcmp(aValue, "no"))
jsoniq_multiple_items = PARAMETER_VALUE_NO;
- else if (!strcmp(aValue, "array"))
- jsoniq_multiple_items = PARAMETER_VALUE_ARRAY;
- else if (!strcmp(aValue, "appended"))
- jsoniq_multiple_items = PARAMETER_VALUE_APPENDED;
+ else if (!strcmp(aValue, "yes"))
+ jsoniq_multiple_items = PARAMETER_VALUE_YES;
else
throw XQUERY_EXCEPTION(
err::SEPM0016, ERROR_PARAMS( aValue, aName, ZED( GoodValuesAreYesNo ) )
@@ -2569,17 +2468,6 @@
{
jsoniq_xdm_method = convertMethodString(aValue, aName);
}
- else if (!strcmp(aName, "jsoniq-allow-mixed-xdm-jdm"))
- {
- if (!strcmp(aValue, "yes"))
- jsoniq_allow_mixed_xdm_jdm = PARAMETER_VALUE_YES;
- else if (!strcmp(aValue, "no"))
- jsoniq_allow_mixed_xdm_jdm = PARAMETER_VALUE_NO;
- else
- throw XQUERY_EXCEPTION(
- err::SEPM0016, ERROR_PARAMS( aValue, aName, ZED( GoodValuesAreYesNo ) )
- );
- }
#endif /* ZORBA_WITH_JSON */
else
{
@@ -2601,7 +2489,7 @@
case PARAMETER_VALUE_TEXT: m = "text"; break;
case PARAMETER_VALUE_BINARY: m = "binary"; break;
case PARAMETER_VALUE_JSON: m = "json"; break;
- case PARAMETER_VALUE_JSONIQ: m = "jsoniq"; break;
+ case PARAMETER_VALUE_JSON_XML_HYBRID: m = "json-xml-hybrid"; break;
default: ZORBA_ASSERT(false);
}
}
@@ -2693,8 +2581,8 @@
#ifdef ZORBA_WITH_JSON
else if (method == PARAMETER_VALUE_JSON)
e = new json_emitter(this, *tr);
- else if (method == PARAMETER_VALUE_JSONIQ)
- e = new jsoniq_emitter(this, *tr, aEmitAttributes);
+ else if (method == PARAMETER_VALUE_JSON_XML_HYBRID)
+ e = new hybrid_emitter(this, *tr, aEmitAttributes);
#endif
else
{
@@ -2769,12 +2657,12 @@
if (aHandler)
{
// Only allow XML-based methods for SAX notifications. For now at least,
- // the "JSONIQ" method is consider "XML-based", although you will
- // certainly get errors if you attempt to serialize JDM this way.
+ // the "JSON-XML-hybrid" method is considerd "XML-based", although you
+ // will certainly get errors if you attempt to serialize JDM this way.
if (method != PARAMETER_VALUE_XML &&
method != PARAMETER_VALUE_XHTML
#ifdef ZORBA_WITH_JSON
- && method != PARAMETER_VALUE_JSONIQ
+ && method != PARAMETER_VALUE_JSON_XML_HYBRID
#endif
) {
throw ZORBA_EXCEPTION(
=== modified file 'src/api/serialization/serializer.h'
--- src/api/serialization/serializer.h 2012-09-17 00:36:37 +0000
+++ src/api/serialization/serializer.h 2012-09-21 03:00:26 +0000
@@ -70,9 +70,7 @@
PARAMETER_VALUE_BINARY,
#ifdef ZORBA_WITH_JSON
PARAMETER_VALUE_JSON,
- PARAMETER_VALUE_JSONIQ,
- PARAMETER_VALUE_ARRAY,
- PARAMETER_VALUE_APPENDED,
+ PARAMETER_VALUE_JSON_XML_HYBRID,
#endif
PARAMETER_VALUE_UTF_8,
@@ -115,10 +113,8 @@
zstring version_string; // this the version as a string
short int indent; // "yes" or "no", implemented
#ifdef ZORBA_WITH_JSON
- short int jsoniq_multiple_items; // "no", "array", "appended", implemented
- short int jsoniq_extensions; // implemented
+ short int jsoniq_multiple_items; // "no", "yes", implemented
short int jsoniq_xdm_method; // A legal value for "method", implemented
- short int jsoniq_allow_mixed_xdm_jdm; // "yes" or "no", implemented
#endif /* ZORBA_WITH_JSON */
bool version_has_default_value; // Used during validation to set version to
// "4.0" when output method is "html"
@@ -404,8 +400,6 @@
void emit_json_value(store::Item* value, int depth);
- void emit_jsoniq_value(zstring type, zstring value, int depth);
-
void emit_jsoniq_xdm_node(store::Item *item, int depth);
void emit_json_string(zstring const &string);
@@ -427,15 +421,15 @@
// //
///////////////////////////////////////////////////////////
- class jsoniq_emitter : public emitter
+ class hybrid_emitter : public emitter
{
public:
- jsoniq_emitter(
+ hybrid_emitter(
serializer* the_serializer,
std::ostream& the_stream,
bool aEmitAttributes = false);
- virtual ~jsoniq_emitter();
+ virtual ~hybrid_emitter();
virtual void emit_declaration();
=== modified file 'src/api/serializerimpl.cpp'
--- src/api/serializerimpl.cpp 2012-09-17 00:36:37 +0000
+++ src/api/serializerimpl.cpp 2012-09-21 03:00:26 +0000
@@ -102,8 +102,8 @@
#ifdef ZORBA_WITH_JSON
case serializer::PARAMETER_VALUE_JSON:
return ZORBA_SERIALIZATION_METHOD_JSON;
- case serializer::PARAMETER_VALUE_JSONIQ:
- return ZORBA_SERIALIZATION_METHOD_JSONIQ;
+ case serializer::PARAMETER_VALUE_JSON_XML_HYBRID:
+ return ZORBA_SERIALIZATION_METHOD_JSON_XML_HYBRID;
#endif
default:
ZORBA_ASSERT(0);
@@ -131,8 +131,8 @@
#ifdef ZORBA_WITH_JSON
case ZORBA_SERIALIZATION_METHOD_JSON:
aInternalSerializer.setParameter(aParameter, "json"); break;
- case ZORBA_SERIALIZATION_METHOD_JSONIQ:
- aInternalSerializer.setParameter(aParameter, "jsoniq"); break;
+ case ZORBA_SERIALIZATION_METHOD_JSON_XML_HYBRID:
+ aInternalSerializer.setParameter(aParameter, "json-xml-hybrid"); break;
#endif
}
}
@@ -219,36 +219,13 @@
aInternalSerializer.setParameter("version", aSerializerOptions.version.c_str());
#ifdef ZORBA_WITH_JSON
- switch (aSerializerOptions.jsoniq_extensions)
- {
- case JSONIQ_EXTENSIONS_YES:
- aInternalSerializer.setParameter("jsoniq-extensions", "yes");
- break;
- case JSONIQ_EXTENSIONS_NO:
- aInternalSerializer.setParameter("jsoniq-extensions", "no");
- break;
- }
-
switch (aSerializerOptions.jsoniq_multiple_items)
{
case JSONIQ_MULTIPLE_ITEMS_NO:
aInternalSerializer.setParameter("jsoniq-multiple-items", "no");
break;
- case JSONIQ_MULTIPLE_ITEMS_ARRAY:
- aInternalSerializer.setParameter("jsoniq-multiple-items", "array");
- break;
- case JSONIQ_MULTIPLE_ITEMS_APPENDED:
- aInternalSerializer.setParameter("jsoniq-multiple-items", "appended");
- break;
- }
-
- switch (aSerializerOptions.jsoniq_allow_mixed_xdm_jdm)
- {
- case JSONIQ_ALLOW_MIXED_XDM_JDM_NO:
- aInternalSerializer.setParameter("jsoniq-allow-mixed-xdm-jdm", "no");
- break;
- case JSONIQ_ALLOW_MIXED_XDM_JDM_YES:
- aInternalSerializer.setParameter("jsoniq-allow-mixed-xdm-jdm", "yes");
+ case JSONIQ_MULTIPLE_ITEMS_YES:
+ aInternalSerializer.setParameter("jsoniq-multiple-items", "yes");
break;
}
=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml 2012-09-18 16:29:31 +0000
+++ src/diagnostics/diagnostic_en.xml 2012-09-21 03:00:26 +0000
@@ -2654,19 +2654,10 @@
<value>Cannot serialize multiple top-level items as JSON</value>
</diagnostic>
- <diagnostic code="JNSE0013" if="defined(ZORBA_WITH_JSON)">
- <comment>It is a dynamic error to serialize an atomic value not
- supported by JSON or a node with the JSON output method and with
- the jsoniq-serialization-extensions serialization parameter
- set to false.</comment>
-
- <value>Cannot serialize value as JSON: $1</value>
- </diagnostic>
-
<diagnostic code="JNSE0014" if="defined(ZORBA_WITH_JSON)">
- <comment>It is a dynamic error to serialize a function with the
+ <comment>It is a dynamic error to serialize a function or a node with the
JSON output method.</comment>
- <value>Cannot serialize a function item as JSON</value>
+ <value>Cannot serialize a node or function item as JSON</value>
</diagnostic>
<diagnostic code="JNSE0022" if="defined(ZORBA_WITH_JSON)">
@@ -2707,6 +2698,12 @@
<value>The content of an insert expression must evaluate to a sequence of objects.</value>
</diagnostic>
+ <diagnostic code="JNTY0023" if="defined(ZORBA_WITH_JSON)">
+ <comment>It is a type error if the prefix is not a string or if the
+ serialization parameters are not an element.</comment>
+ <value>$1: value of "$2" is not a $3</value>
+ </diagnostic>
+
<!--////////// JSONIQ ///////////////////////////////////////////-->
<diagnostic code="JNTY0003" if="defined(ZORBA_WITH_JSON)">
@@ -2999,6 +2996,10 @@
<value>element name</value>
</entry>
+ <entry key="ElementNode">
+ <value>element node</value>
+ </entry>
+
<entry key="EmptyPath">
<value>empty path</value>
</entry>
=== modified file 'src/diagnostics/pregenerated/diagnostic_list.cpp'
--- src/diagnostics/pregenerated/diagnostic_list.cpp 2012-09-18 16:29:31 +0000
+++ src/diagnostics/pregenerated/diagnostic_list.cpp 2012-09-21 03:00:26 +0000
@@ -1231,9 +1231,6 @@
JSONiqErrorCode JNSE0012( "JNSE0012" );
-JSONiqErrorCode JNSE0013( "JNSE0013" );
-
-
JSONiqErrorCode JNSE0014( "JNSE0014" );
@@ -1252,6 +1249,9 @@
JSONiqErrorCode JNUP0019( "JNUP0019" );
+JSONiqErrorCode JNTY0023( "JNTY0023" );
+
+
JSONiqErrorCode JNTY0003( "JNTY0003" );
=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp 2012-09-18 16:29:31 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp 2012-09-21 03:00:26 +0000
@@ -104,10 +104,7 @@
{ "JNSE0012", "Cannot serialize multiple top-level items as JSON" },
#endif
#if defined(ZORBA_WITH_JSON)
- { "JNSE0013", "Cannot serialize value as JSON: $1" },
-#endif
-#if defined(ZORBA_WITH_JSON)
- { "JNSE0014", "Cannot serialize a function item as JSON" },
+ { "JNSE0014", "Cannot serialize a node or function item as JSON" },
#endif
#if defined(ZORBA_WITH_JSON)
{ "JNSE0022", "$1: invalid serialization method for item type ($2)" },
@@ -128,6 +125,9 @@
{ "JNTY0018", "Object or array selection needs exactly one parameter." },
#endif
#if defined(ZORBA_WITH_JSON)
+ { "JNTY0023", "$1: value of \"$2\" is not a $3" },
+#endif
+#if defined(ZORBA_WITH_JSON)
{ "JNUP0005", "\"$1\": duplicate pair to insert" },
#endif
#if defined(ZORBA_WITH_JSON)
@@ -564,6 +564,7 @@
{ "~EBVNotDefSeq_5", "effective boolean value not defined for sequence of more than one item that starts with \"$5\"" },
{ "~EffectiveBooleanValue", "effective boolean value" },
{ "~ElementName", "element name" },
+ { "~ElementNode", "element node" },
{ "~EmptyPath", "empty path" },
{ "~EmptySeqNoCastToQName", "empty sequence can not be cast to QName" },
{ "~EmptySeqNoCastToTypeWithQuantOne", "empty sequence can not be cast to type with quantifier '1'" },
=== modified file 'src/functions/pregenerated/func_jsoniq_functions.cpp'
--- src/functions/pregenerated/func_jsoniq_functions.cpp 2012-09-17 00:36:37 +0000
+++ src/functions/pregenerated/func_jsoniq_functions.cpp 2012-09-21 03:00:26 +0000
@@ -31,6 +31,30 @@
#ifdef ZORBA_WITH_JSON
+PlanIter_t fn_jsoniq_decode_from_roundtrip::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ expr& ann) const
+{
+ return new JSONDecodeFromRoundtripIterator(sctx, loc, argv);
+}
+
+#endif
+#ifdef ZORBA_WITH_JSON
+PlanIter_t fn_jsoniq_encode_for_roundtrip::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ expr& ann) const
+{
+ return new JSONEncodeForRoundtripIterator(sctx, loc, argv);
+}
+
+#endif
+#ifdef ZORBA_WITH_JSON
#endif
#ifdef ZORBA_WITH_JSON
@@ -236,6 +260,72 @@
{
+ DECL_WITH_KIND(sctx, fn_jsoniq_decode_from_roundtrip,
+ (createQName("http://www.jsoniq.org/functions","","decode-from-roundtrip"),
+ GENV_TYPESYSTEM.JSON_ITEM_TYPE_STAR,
+ GENV_TYPESYSTEM.STRUCTURED_ITEM_TYPE_STAR),
+ FunctionConsts::FN_JSONIQ_DECODE_FROM_ROUNDTRIP_1);
+
+ }
+
+
+#endif
+
+
+#ifdef ZORBA_WITH_JSON
+
+
+ {
+ DECL_WITH_KIND(sctx, fn_jsoniq_decode_from_roundtrip,
+ (createQName("http://www.jsoniq.org/functions","","decode-from-roundtrip"),
+ GENV_TYPESYSTEM.JSON_ITEM_TYPE_STAR,
+ GENV_TYPESYSTEM.JSON_OBJECT_TYPE_ONE,
+ GENV_TYPESYSTEM.STRUCTURED_ITEM_TYPE_STAR),
+ FunctionConsts::FN_JSONIQ_DECODE_FROM_ROUNDTRIP_2);
+
+ }
+
+
+#endif
+
+
+#ifdef ZORBA_WITH_JSON
+
+
+ {
+ DECL_WITH_KIND(sctx, fn_jsoniq_encode_for_roundtrip,
+ (createQName("http://www.jsoniq.org/functions","","encode-for-roundtrip"),
+ GENV_TYPESYSTEM.STRUCTURED_ITEM_TYPE_STAR,
+ GENV_TYPESYSTEM.JSON_ITEM_TYPE_STAR),
+ FunctionConsts::FN_JSONIQ_ENCODE_FOR_ROUNDTRIP_1);
+
+ }
+
+
+#endif
+
+
+#ifdef ZORBA_WITH_JSON
+
+
+ {
+ DECL_WITH_KIND(sctx, fn_jsoniq_encode_for_roundtrip,
+ (createQName("http://www.jsoniq.org/functions","","encode-for-roundtrip"),
+ GENV_TYPESYSTEM.STRUCTURED_ITEM_TYPE_STAR,
+ GENV_TYPESYSTEM.JSON_OBJECT_TYPE_ONE,
+ GENV_TYPESYSTEM.JSON_ITEM_TYPE_STAR),
+ FunctionConsts::FN_JSONIQ_ENCODE_FOR_ROUNDTRIP_2);
+
+ }
+
+
+#endif
+
+
+#ifdef ZORBA_WITH_JSON
+
+
+ {
DECL_WITH_KIND(sctx, fn_jsoniq_parse_json,
(createQName("http://www.jsoniq.org/functions","","parse-json"),
GENV_TYPESYSTEM.STRING_TYPE_QUESTION,
=== modified file 'src/functions/pregenerated/func_jsoniq_functions.h'
--- src/functions/pregenerated/func_jsoniq_functions.h 2012-09-17 00:36:37 +0000
+++ src/functions/pregenerated/func_jsoniq_functions.h 2012-09-21 03:00:26 +0000
@@ -38,6 +38,46 @@
#ifdef ZORBA_WITH_JSON
+//fn-jsoniq:decode-from-roundtrip
+class fn_jsoniq_decode_from_roundtrip : public function
+{
+public:
+ fn_jsoniq_decode_from_roundtrip(const signature& sig, FunctionConsts::FunctionKind kind)
+ :
+ function(sig, kind)
+ {
+
+ }
+
+ bool propagatesInputNodes(expr* fo, csize producer) const { return false; }
+
+ bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
+
+ CODEGEN_DECL();
+};
+#endif
+#ifdef ZORBA_WITH_JSON
+
+//fn-jsoniq:encode-for-roundtrip
+class fn_jsoniq_encode_for_roundtrip : public function
+{
+public:
+ fn_jsoniq_encode_for_roundtrip(const signature& sig, FunctionConsts::FunctionKind kind)
+ :
+ function(sig, kind)
+ {
+
+ }
+
+ bool propagatesInputNodes(expr* fo, csize producer) const { return false; }
+
+ bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
+
+ CODEGEN_DECL();
+};
+#endif
+#ifdef ZORBA_WITH_JSON
+
//fn-jsoniq:parse-json
class fn_jsoniq_parse_json : public function
{
=== modified file 'src/functions/pregenerated/function_enum.h'
--- src/functions/pregenerated/function_enum.h 2012-09-18 16:29:31 +0000
+++ src/functions/pregenerated/function_enum.h 2012-09-21 03:00:26 +0000
@@ -227,6 +227,10 @@
FN_ZORBA_INTROSPECT_SCTX_FUNCTION_ANNOTATIONS_2,
FN_ZORBA_JSON_PARSE_INTERNAL_2,
FN_ZORBA_JSON_SERIALIZE_INTERNAL_2,
+ FN_JSONIQ_DECODE_FROM_ROUNDTRIP_1,
+ FN_JSONIQ_DECODE_FROM_ROUNDTRIP_2,
+ FN_JSONIQ_ENCODE_FOR_ROUNDTRIP_1,
+ FN_JSONIQ_ENCODE_FOR_ROUNDTRIP_2,
FN_JSONIQ_PARSE_JSON_1,
FN_JSONIQ_PARSE_JSON_2,
FN_JSONIQ_KEYS_1,
=== modified file 'src/runtime/json/jsoniq_functions_impl.cpp'
--- src/runtime/json/jsoniq_functions_impl.cpp 2012-09-17 00:36:37 +0000
+++ src/runtime/json/jsoniq_functions_impl.cpp 2012-09-21 03:00:26 +0000
@@ -23,9 +23,15 @@
#include "system/globalenv.h"
+#include "api/serialization/serializer.h"
+
+#include "compiler/api/compilercb.h"
+
#include "runtime/json/jsoniq_functions.h"
+#include "runtime/parsing_and_serializing/parsing_and_serializing.h"
#include "runtime/visitors/planiter_visitor.h"
#include "runtime/api/plan_iterator_wrapper.h"
+#include "runtime/util/item_iterator.h"
#include "diagnostics/diagnostic.h"
#include "diagnostics/xquery_diagnostics.h"
@@ -35,6 +41,7 @@
#include "context/static_context.h"
+#include "types/casting.h"
#include "types/typeimpl.h"
#include "types/typeops.h"
#include "types/root_typemanager.h"
@@ -49,6 +56,569 @@
namespace zorba {
+const zstring XS_URI("http://www.w3.org/2001/XMLSchema");
+
+const zstring ENCODE_DECODE_DEFAULT_PREFIX("Q{http://jsoniq.org/roundtrip}");
+
+const zstring NS_PREFIX_KEY("prefix");
+const zstring TYPE_KEY("type");
+const zstring VALUE_KEY("value");
+
+const char * OPTIONS_KEY_PREFIX = "prefix";
+const char * OPTIONS_KEY_SER_PARAMS = "serialization-parameters";
+
+/*******************************************************************************
+ json:decode-from-roundtrip($items as json-item()*,
+ $options as object()) as structured-item()*
+********************************************************************************/
+
+void
+parseQName(store::Item_t& aResult,
+ const zstring& aQNameString,
+ const zstring& aPrefix,
+ store::ItemFactory* aFactory)
+{
+ // TODO there probably is a better solution somewhere
+ if (aQNameString.substr(0, 3) == "xs:")
+ {
+ aFactory->createQName(aResult, XS_URI, "xs", aQNameString.substr(3));
+ }
+ else if (aQNameString.substr(0, 2) == "Q{")
+ {
+ zstring::size_type lPos = aQNameString.find('}');
+ aFactory->createQName(aResult,
+ aQNameString.substr(2, lPos - 2),
+ aPrefix,
+ aQNameString.substr(lPos + 1));
+ }
+ else
+ {
+ aFactory->createQName(aResult, "", "", aQNameString);
+ }
+}
+
+bool
+JSONDecodeFromRoundtripIterator::decodeXDM(
+ const store::Item_t& anObj,
+ store::Item_t& aResult,
+ JSONDecodeFromRoundtripIteratorState* aState) const
+{
+ store::Item_t lItem;
+
+ zstring lTypeKey = aState->thePrefix + TYPE_KEY;
+ GENV_ITEMFACTORY->createString(lItem, lTypeKey);
+ store::Item_t lTypeValueItem = anObj->getObjectValue(lItem);
+ if (lTypeValueItem.isNull())
+ {
+ // nothing to change, aResult is not set, the caller needs to use anObj
+ return false;
+ }
+
+ zstring lValueKey = aState->thePrefix + VALUE_KEY;
+ GENV_ITEMFACTORY->createString(lItem, lValueKey);
+ store::Item_t lValueValueItem = anObj->getObjectValue(lItem);
+ if (lValueValueItem.isNull())
+ {
+ // nothing to change, aResult is not set, the caller needs to use anObj
+ return false;
+ }
+
+ zstring lTypeNameString;
+ lTypeValueItem->getStringValue2(lTypeNameString);
+ if (lTypeNameString == "node()")
+ {
+ store::LoadProperties lProperties;
+ lProperties.setStoreDocument(false);
+ store::Item_t lDoc;
+ if (lValueValueItem->isStreamable())
+ {
+ lDoc = GENV.getStore().loadDocument(
+ "", "", lValueValueItem->getStream(), lProperties);
+ }
+ else
+ {
+ zstring lXmlString;
+ lValueValueItem->getStringValue2(lXmlString);
+ std::istringstream lStream(lXmlString.c_str());
+ lDoc = GENV.getStore().loadDocument("", "", lStream, lProperties);
+ }
+ store::Iterator_t lIt = lDoc->getChildren();
+ bool lFound = false;
+ lIt->open();
+ while (! lFound && lIt->next(aResult))
+ {
+ lFound = aResult->getNodeKind() == store::StoreConsts::elementNode;
+ }
+ lIt->close();
+ ZORBA_ASSERT(lFound);
+ }
+ else
+ {
+ store::Item_t lTypeQName;
+ parseQName(lTypeQName, lTypeNameString, "", GENV_ITEMFACTORY);
+ if (lTypeQName->getLocalName() == "QName"
+ && lTypeQName->getNamespace() == XS_URI)
+ {
+ zstring lPrefixKey = aState->thePrefix + NS_PREFIX_KEY;
+ GENV_ITEMFACTORY->createString(lItem, lPrefixKey);
+ store::Item_t lPrefixValue = anObj->getObjectValue(lItem);
+ zstring lPrefixString;
+ if (! lPrefixValue.isNull())
+ {
+ lPrefixValue->getStringValue2(lPrefixString);
+ }
+ zstring lValueValue;
+ lValueValueItem->getStringValue2(lValueValue);
+ parseQName(aResult, lValueValue, lPrefixString, GENV_ITEMFACTORY);
+ }
+ else
+ {
+ TypeManager* lTypeMgr = theSctx->get_typemanager();
+ xqtref_t lTargetType = lTypeMgr->create_named_type(
+ lTypeQName.getp(), TypeConstants::QUANT_ONE, loc);
+ namespace_context lTmpNsCtx(theSctx);
+ GenericCast::castToAtomic(aResult,
+ lValueValueItem,
+ lTargetType.getp(),
+ lTypeMgr,
+ &lTmpNsCtx,
+ loc);
+ }
+ }
+ return true;
+}
+
+bool
+JSONDecodeFromRoundtripIterator::decodeObject(
+ const store::Item_t& anObj,
+ store::Item_t& aResult,
+ JSONDecodeFromRoundtripIteratorState* aState) const
+{
+ if (decodeXDM(anObj, aResult, aState))
+ {
+ return true;
+ }
+
+ std::vector<store::Item_t> newNames;
+ std::vector<store::Item_t> newValues;
+ bool modified = false;
+
+ store::Item_t key;
+ store::Item_t value;
+ store::Item_t newValue;
+ store::Iterator_t it = anObj->getObjectKeys();
+ it->open();
+ while (it->next(key))
+ {
+ newNames.push_back(key);
+ value = anObj->getObjectValue(key);
+ const bool gotNew = decodeItem(value, newValue, aState);
+ newValues.push_back(gotNew ? newValue : value);
+ modified = modified || gotNew;
+ }
+ it->close();
+ if (modified)
+ {
+ GENV_ITEMFACTORY->createJSONObject(aResult, newNames, newValues);
+ return true;
+ }
+ // nothing to change, aResult is not set, the caller needs to use anObj
+ return false;
+}
+
+bool
+JSONDecodeFromRoundtripIterator::decodeArray(
+ const store::Item_t& anArray,
+ store::Item_t& aResult,
+ JSONDecodeFromRoundtripIteratorState* aState) const
+{
+ std::vector<store::Item_t> newItems;
+ bool modified = false;
+
+ store::Item_t item, newItem;
+ store::Iterator_t it = anArray->getArrayValues();
+ it->open();
+ while (it->next(item))
+ {
+ const bool gotNew = decodeItem(item, newItem, aState);
+ newItems.push_back(gotNew ? newItem : item);
+ modified = modified || gotNew;
+ }
+ it->close();
+ if (modified)
+ {
+ GENV_ITEMFACTORY->createJSONArray(aResult, newItems);
+ return true;
+ }
+ // nothing to change, aResult is not set, the caller needs to use anArray
+ return false;
+}
+
+bool
+JSONDecodeFromRoundtripIterator::decodeItem(
+ const store::Item_t& anItem,
+ store::Item_t& aResult,
+ JSONDecodeFromRoundtripIteratorState* aState) const
+{
+ if (anItem->isJSONObject())
+ {
+ return decodeObject(anItem, aResult, aState);
+ }
+ else if (anItem->isJSONArray())
+ {
+ return decodeArray(anItem, aResult, aState);
+ }
+ else
+ {
+ // nothing to change, aResult is not set, the caller needs to use anItem
+ return false;
+ }
+}
+
+bool
+JSONDecodeFromRoundtripIterator::nextImpl(
+ store::Item_t& aResult,
+ PlanState& aPlanState) const
+{
+ store::Item_t lInput;
+ store::Item_t lDecParams;
+
+ JSONDecodeFromRoundtripIteratorState* lState;
+ DEFAULT_STACK_INIT(JSONDecodeFromRoundtripIteratorState, lState, aPlanState);
+
+ // get decoding parameters
+ if (theChildren.size() == 2)
+ {
+ // the signature says that the second parameter has to be exactly one object
+ consumeNext(lDecParams, theChildren.at(1), aPlanState);
+ store::Item_t lPrefixKey;
+ zstring lPrefixNameStr = OPTIONS_KEY_PREFIX;
+ GENV_ITEMFACTORY->createString(lPrefixKey, lPrefixNameStr);
+ store::Item_t lPrefixValue = lDecParams->getObjectValue(lPrefixKey);
+ if (! lPrefixValue.isNull())
+ {
+ if (lPrefixValue->getTypeCode() != store::XS_STRING)
+ {
+ RAISE_ERROR(jerr::JNTY0023, loc,
+ ERROR_PARAMS(lPrefixValue->getStringValue(),
+ OPTIONS_KEY_PREFIX,
+ "string"));
+ }
+ lPrefixValue->getStringValue2(lState->thePrefix);
+ }
+ }
+ else
+ {
+ lState->thePrefix = ENCODE_DECODE_DEFAULT_PREFIX;
+ }
+
+ while (consumeNext(lInput, theChildren.at(0), aPlanState))
+ {
+ if (! decodeItem(lInput, aResult, lState))
+ {
+ aResult = lInput;
+ }
+ STACK_PUSH (true, lState);
+ }
+
+ STACK_END(lState);
+}
+
+
+/*******************************************************************************
+ jn:encode-for-roundtrip($items as structured-item()*,
+ $options as object()) as json-item()*
+********************************************************************************/
+bool
+JSONEncodeForRoundtripIterator::encodeObject(
+ const store::Item_t& anObj,
+ store::Item_t& aResult,
+ JSONEncodeForRoundtripIteratorState* aState) const
+{
+ std::vector<store::Item_t> newNames;
+ std::vector<store::Item_t> newValues;
+ bool modified = false;
+
+ store::Item_t key;
+ store::Item_t value;
+ store::Item_t newValue;
+ store::Iterator_t it = anObj->getObjectKeys();
+ it->open();
+ while (it->next(key))
+ {
+ newNames.push_back(key);
+ value = anObj->getObjectValue(key);
+ const bool gotNew = encodeItem(value, newValue, aState);
+ newValues.push_back(gotNew ? newValue : value);
+ modified = modified || gotNew;
+ }
+ it->close();
+ if (modified)
+ {
+ GENV_ITEMFACTORY->createJSONObject(aResult, newNames, newValues);
+ return true;
+ }
+ // nothing to change, aResult is not set, the caller needs to use anObj
+ return false;
+}
+
+bool
+JSONEncodeForRoundtripIterator::encodeArray(
+ const store::Item_t& anArray,
+ store::Item_t& aResult,
+ JSONEncodeForRoundtripIteratorState* aState) const
+{
+ std::vector<store::Item_t> newItems;
+ bool modified = false;
+
+ store::Item_t item, newItem;
+ store::Iterator_t it = anArray->getArrayValues();
+ it->open();
+ while (it->next(item))
+ {
+ const bool gotNew = encodeItem(item, newItem, aState);
+ newItems.push_back(gotNew ? newItem : item);
+ modified = modified || gotNew;
+ }
+ it->close();
+ if (modified)
+ {
+ GENV_ITEMFACTORY->createJSONArray(aResult, newItems);
+ return true;
+ }
+ // nothing to change, aResult is not set, the caller needs to use anArray
+ return false;
+}
+
+bool
+JSONEncodeForRoundtripIterator::encodeAtomic(
+ const store::Item_t& aValue,
+ store::Item_t& aResult,
+ JSONEncodeForRoundtripIteratorState* aState) const
+{
+ store::SchemaTypeCode typeCode = aValue->getTypeCode();
+ switch (typeCode) {
+ case store::XS_DOUBLE:
+ case store::XS_FLOAT:
+ if (aValue->getBaseItem() == NULL
+ && ! aValue->isNaN() && ! aValue->isPosOrNegInf())
+ {
+ // nothing to change, aResult is not set, the caller needs to use aValue
+ return false;
+ }
+ break;
+ case store::XS_STRING:
+ case store::XS_INTEGER:
+ case store::XS_DECIMAL:
+ case store::XS_BOOLEAN:
+ case store::JS_NULL:
+ if (aValue->getBaseItem() == NULL)
+ {
+ // nothing to change, aResult is not set, the caller needs to use aValue
+ return false;
+ }
+ break;
+ default:
+ break;
+ }
+
+ std::vector<store::Item_t> names(2);
+ std::vector<store::Item_t> values(2);
+
+ {
+ const store::Item_t& typeName = aValue->getType();
+
+ zstring typeKey = aState->thePrefix + TYPE_KEY;
+ const zstring ns = typeName->getNamespace();
+ const zstring local = typeName->getLocalName();
+ zstring typeValue = ns.compare(XS_URI)
+ ? "Q{" + ns + "}" + local : "xs:" + local;
+
+ GENV_ITEMFACTORY->createString(names.at(0), typeKey);
+ GENV_ITEMFACTORY->createString(values.at(0), typeValue);
+ }
+
+ {
+ zstring valueKey = aState->thePrefix + VALUE_KEY;
+ zstring valueValue;
+ if (typeCode == store::XS_QNAME)
+ {
+ // QNames are a special case, as the prefix should be maintained as well
+ // but it's not part of the EQName serialization
+ zstring prefixValue = aValue->getPrefix();
+ if (prefixValue.length() > 0)
+ {
+ zstring prefixKey = aState->thePrefix + NS_PREFIX_KEY;
+ store::Item_t lItem;
+ GENV_ITEMFACTORY->createString(lItem, prefixKey);
+ names.push_back(lItem);
+ GENV_ITEMFACTORY->createString(lItem, prefixValue);
+ values.push_back(lItem);
+ }
+
+ const zstring ns = aValue->getNamespace();
+ const zstring local = aValue->getLocalName();
+ valueValue = ns.empty() ? local : "Q{" + ns + "}" + local;
+ }
+ else
+ {
+ aValue->getStringValue2(valueValue);
+ }
+ GENV_ITEMFACTORY->createString(names.at(1), valueKey);
+ GENV_ITEMFACTORY->createString(values.at(1), valueValue);
+ }
+
+ GENV_ITEMFACTORY->createJSONObject(aResult, names, values);
+ return true;
+}
+
+bool
+JSONEncodeForRoundtripIterator::encodeNode(
+ const store::Item_t& aNode,
+ store::Item_t& aResult,
+ JSONEncodeForRoundtripIteratorState* aState) const
+{
+ if (aNode->getNodeKind() != store::StoreConsts::elementNode)
+ {
+ // this is a temporary solution until we decide if/how we encode
+ // node kinds
+ throw ZORBA_EXCEPTION(
+ zerr::ZXQP0004_NOT_IMPLEMENTED,
+ ERROR_PARAMS(store::StoreConsts::toString(aNode->getNodeKind()))
+ );
+ }
+
+ std::vector<store::Item_t> names(2);
+ std::vector<store::Item_t> values(2);
+
+ {
+ zstring typeKey = aState->thePrefix + TYPE_KEY;
+ zstring typeValue = "node()";
+ GENV_ITEMFACTORY->createString(names.at(0), typeKey);
+ GENV_ITEMFACTORY->createString(values.at(0), typeValue);
+ }
+
+ {
+ zstring valueKey = aState->thePrefix + VALUE_KEY;
+
+ store::Iterator_t lItemIt = new ItemIterator(aNode);
+ zorba::serializer lSerializer(aState->theDiag);
+ // TODO what do we set, if nothing is passed?
+ lSerializer.setParameter("omit-xml-declaration", "yes");
+
+ if (! aState->theSerParams.isNull())
+ {
+ FnSerializeIterator::setSerializationParams(
+ lSerializer,
+ aState->theSerParams,
+ theSctx,
+ loc);
+ }
+
+ // and now serialize
+ std::auto_ptr<std::stringstream> lResultStream(new std::stringstream());
+ lItemIt->open();
+ lSerializer.serialize(lItemIt, *lResultStream.get());
+ lItemIt->close();
+
+ GENV_ITEMFACTORY->createString(names.at(1), valueKey);
+ GENV_ITEMFACTORY->createStreamableString(
+ values.at(1), *lResultStream.release(),
+ FnSerializeIterator::streamReleaser, true);
+ }
+
+ GENV_ITEMFACTORY->createJSONObject(aResult, names, values);
+ return true;
+}
+
+bool
+JSONEncodeForRoundtripIterator::encodeItem(
+ const store::Item_t& anItem,
+ store::Item_t& aResult,
+ JSONEncodeForRoundtripIteratorState* aState) const
+{
+ if (anItem->isJSONObject())
+ {
+ return encodeObject(anItem, aResult, aState);
+ }
+ else if (anItem->isJSONArray())
+ {
+ return encodeArray(anItem, aResult, aState);
+ }
+ else if (anItem->isAtomic())
+ {
+ return encodeAtomic(anItem, aResult, aState);
+ }
+ else
+ {
+ return encodeNode(anItem, aResult, aState);
+ }
+}
+
+bool
+JSONEncodeForRoundtripIterator::nextImpl(
+ store::Item_t& aResult,
+ PlanState& aPlanState) const
+{
+ store::Item_t lInput;
+
+ JSONEncodeForRoundtripIteratorState* lState;
+ DEFAULT_STACK_INIT(JSONEncodeForRoundtripIteratorState, lState, aPlanState);
+
+ lState->thePrefix = ENCODE_DECODE_DEFAULT_PREFIX;
+ lState->theDiag = aPlanState.theCompilerCB->theXQueryDiagnostics;
+
+ // get encoding parameters
+ if (theChildren.size() == 2)
+ {
+ // the signature says that the second parameter has to be exactly one object
+ store::Item_t lEncParams;
+ consumeNext(lEncParams, theChildren.at(1), aPlanState);
+ store::Item_t lPrefixKey;
+ zstring lPrefixNameStr = OPTIONS_KEY_PREFIX;
+ GENV_ITEMFACTORY->createString(lPrefixKey, lPrefixNameStr);
+ store::Item_t lPrefixValue = lEncParams->getObjectValue(lPrefixKey);
+ if (! lPrefixValue.isNull())
+ {
+ if (lPrefixValue->getTypeCode() != store::XS_STRING)
+ {
+ RAISE_ERROR(jerr::JNTY0023, loc,
+ ERROR_PARAMS(lPrefixValue->getStringValue(),
+ OPTIONS_KEY_PREFIX,
+ "string"));
+ }
+ lPrefixValue->getStringValue2(lState->thePrefix);
+ }
+
+ store::Item_t lSerParamKey;
+ zstring lSerParamNameStr = OPTIONS_KEY_SER_PARAMS;
+ GENV_ITEMFACTORY->createString(lSerParamKey, lSerParamNameStr);
+ store::Item_t lSerParamValue = lEncParams->getObjectValue(lSerParamKey);
+ if (! lSerParamValue.isNull())
+ {
+ if (! lSerParamValue->isNode()
+ || lSerParamValue->getNodeKind() != store::StoreConsts::elementNode)
+ {
+ RAISE_ERROR(jerr::JNTY0023, loc,
+ ERROR_PARAMS(lSerParamValue->getStringValue(),
+ OPTIONS_KEY_SER_PARAMS,
+ ZED(ElementNode)));
+ }
+ lState->theSerParams = lSerParamValue;
+ }
+ }
+
+ while(consumeNext(lInput, theChildren.at(0), aPlanState))
+ {
+ if (! encodeItem(lInput, aResult, lState))
+ {
+ aResult = lInput;
+ }
+ STACK_PUSH (true, lState);
+ }
+ STACK_END(lState);
+}
+
/*******************************************************************************
=== modified file 'src/runtime/json/pregenerated/jsoniq_functions.cpp'
--- src/runtime/json/pregenerated/jsoniq_functions.cpp 2012-09-17 00:36:37 +0000
+++ src/runtime/json/pregenerated/jsoniq_functions.cpp 2012-09-21 03:00:26 +0000
@@ -33,6 +33,88 @@
namespace zorba {
#ifdef ZORBA_WITH_JSON
+// <JSONDecodeFromRoundtripIterator>
+SERIALIZABLE_CLASS_VERSIONS(JSONDecodeFromRoundtripIterator)
+
+void JSONDecodeFromRoundtripIterator::serialize(::zorba::serialization::Archiver& ar)
+{
+ serialize_baseclass(ar,
+ (NaryBaseIterator<JSONDecodeFromRoundtripIterator, JSONDecodeFromRoundtripIteratorState>*)this);
+}
+
+
+void JSONDecodeFromRoundtripIterator::accept(PlanIterVisitor& v) const
+{
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+JSONDecodeFromRoundtripIterator::~JSONDecodeFromRoundtripIterator() {}
+
+JSONDecodeFromRoundtripIteratorState::JSONDecodeFromRoundtripIteratorState() {}
+
+JSONDecodeFromRoundtripIteratorState::~JSONDecodeFromRoundtripIteratorState() {}
+
+
+void JSONDecodeFromRoundtripIteratorState::init(PlanState& planState) {
+ PlanIteratorState::init(planState);
+}
+
+void JSONDecodeFromRoundtripIteratorState::reset(PlanState& planState) {
+ PlanIteratorState::reset(planState);
+}
+// </JSONDecodeFromRoundtripIterator>
+
+#endif
+#ifdef ZORBA_WITH_JSON
+// <JSONEncodeForRoundtripIterator>
+SERIALIZABLE_CLASS_VERSIONS(JSONEncodeForRoundtripIterator)
+
+void JSONEncodeForRoundtripIterator::serialize(::zorba::serialization::Archiver& ar)
+{
+ serialize_baseclass(ar,
+ (NaryBaseIterator<JSONEncodeForRoundtripIterator, JSONEncodeForRoundtripIteratorState>*)this);
+}
+
+
+void JSONEncodeForRoundtripIterator::accept(PlanIterVisitor& v) const
+{
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+JSONEncodeForRoundtripIterator::~JSONEncodeForRoundtripIterator() {}
+
+JSONEncodeForRoundtripIteratorState::JSONEncodeForRoundtripIteratorState() {}
+
+JSONEncodeForRoundtripIteratorState::~JSONEncodeForRoundtripIteratorState() {}
+
+
+void JSONEncodeForRoundtripIteratorState::init(PlanState& planState) {
+ PlanIteratorState::init(planState);
+}
+
+void JSONEncodeForRoundtripIteratorState::reset(PlanState& planState) {
+ PlanIteratorState::reset(planState);
+}
+// </JSONEncodeForRoundtripIterator>
+
+#endif
+#ifdef ZORBA_WITH_JSON
// <JSONParseIterator>
SERIALIZABLE_CLASS_VERSIONS(JSONParseIterator)
=== modified file 'src/runtime/json/pregenerated/jsoniq_functions.h'
--- src/runtime/json/pregenerated/jsoniq_functions.h 2012-09-17 00:36:37 +0000
+++ src/runtime/json/pregenerated/jsoniq_functions.h 2012-09-21 03:00:26 +0000
@@ -38,6 +38,109 @@
*
* Author:
*/
+class JSONDecodeFromRoundtripIteratorState : public PlanIteratorState
+{
+public:
+ zstring thePrefix; //
+
+ JSONDecodeFromRoundtripIteratorState();
+
+ ~JSONDecodeFromRoundtripIteratorState();
+
+ void init(PlanState&);
+ void reset(PlanState&);
+};
+
+class JSONDecodeFromRoundtripIterator : public NaryBaseIterator<JSONDecodeFromRoundtripIterator, JSONDecodeFromRoundtripIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(JSONDecodeFromRoundtripIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(JSONDecodeFromRoundtripIterator,
+ NaryBaseIterator<JSONDecodeFromRoundtripIterator, JSONDecodeFromRoundtripIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar);
+
+ JSONDecodeFromRoundtripIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<JSONDecodeFromRoundtripIterator, JSONDecodeFromRoundtripIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~JSONDecodeFromRoundtripIterator();
+
+public:
+ bool decodeXDM(const store::Item_t& anObj, store::Item_t& aResult, JSONDecodeFromRoundtripIteratorState* aState) const;
+ bool decodeObject(const store::Item_t& anObj, store::Item_t& aResult, JSONDecodeFromRoundtripIteratorState* aState) const;
+ bool decodeArray(const store::Item_t& anArray, store::Item_t& aResult, JSONDecodeFromRoundtripIteratorState* aState) const;
+ bool decodeItem(const store::Item_t& anItem, store::Item_t& aResult, JSONDecodeFromRoundtripIteratorState* aState) const;
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+#endif
+
+#ifdef ZORBA_WITH_JSON
+/**
+ *
+ * Author:
+ */
+class JSONEncodeForRoundtripIteratorState : public PlanIteratorState
+{
+public:
+ zstring thePrefix; //
+ store::Item_t theSerParams; //
+ XQueryDiagnostics* theDiag; //
+
+ JSONEncodeForRoundtripIteratorState();
+
+ ~JSONEncodeForRoundtripIteratorState();
+
+ void init(PlanState&);
+ void reset(PlanState&);
+};
+
+class JSONEncodeForRoundtripIterator : public NaryBaseIterator<JSONEncodeForRoundtripIterator, JSONEncodeForRoundtripIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(JSONEncodeForRoundtripIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(JSONEncodeForRoundtripIterator,
+ NaryBaseIterator<JSONEncodeForRoundtripIterator, JSONEncodeForRoundtripIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar);
+
+ JSONEncodeForRoundtripIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<JSONEncodeForRoundtripIterator, JSONEncodeForRoundtripIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~JSONEncodeForRoundtripIterator();
+
+public:
+ bool encodeObject(const store::Item_t& anObj, store::Item_t& aResult, JSONEncodeForRoundtripIteratorState* aState) const;
+ bool encodeArray(const store::Item_t& anArray, store::Item_t& aResult, JSONEncodeForRoundtripIteratorState* aState) const;
+ bool encodeAtomic(const store::Item_t& aValue, store::Item_t& aResult, JSONEncodeForRoundtripIteratorState* aState) const;
+ bool encodeNode(const store::Item_t& aNode, store::Item_t& aResult, JSONEncodeForRoundtripIteratorState* aState) const;
+ bool encodeItem(const store::Item_t& anItem, store::Item_t& aResult, JSONEncodeForRoundtripIteratorState* aState) const;
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+#endif
+
+#ifdef ZORBA_WITH_JSON
+/**
+ *
+ * Author:
+ */
class JSONParseIteratorState : public PlanIteratorState
{
public:
=== modified file 'src/runtime/parsing_and_serializing/parsing_and_serializing_impl.cpp'
--- src/runtime/parsing_and_serializing/parsing_and_serializing_impl.cpp 2012-09-17 00:36:37 +0000
+++ src/runtime/parsing_and_serializing/parsing_and_serializing_impl.cpp 2012-09-21 03:00:26 +0000
@@ -127,6 +127,131 @@
delete s;
}
+void
+FnSerializeIterator::setSerializationParams(
+ zorba::serializer& aSerializer,
+ store::Item_t& aParamElem,
+ static_context* aSctx,
+ const QueryLoc& aLoc
+)
+{
+ store::Item_t lElemName = aParamElem->getNodeName();
+
+ // make sure the user does not pass children of the serialization-parameters
+ // element which would pass the schema validation below but break the logic after
+ if (lElemName->getLocalName() != "serialization-parameters")
+ {
+ ztd::string_builder lSb;
+ lSb << "the serialization parameters element must have the name \"serialization parameters\". "
+ << "\"" << lElemName->getLocalName() << "\" was found";
+ throw XQUERY_EXCEPTION(
+ err::XQDY0027,
+ ERROR_PARAMS(lSb.str()),
+ ERROR_LOC( aLoc ));
+ }
+
+ // the provided element must be in the correct namespace otherwise
+ // the user can pass a validated element from another namespace
+ // which would make the schema validation below fail
+ if (lElemName->getNamespace() != "http://www.w3.org/2010/xslt-xquery-serialization")
+ {
+ ztd::string_builder lSb;
+ zstring lFoundNs("No");
+ if (lElemName->getNamespace().size() > 0)
+ {
+ lFoundNs = "<";
+ lFoundNs += lElemName->getNamespace();
+ lFoundNs += ">";
+ }
+
+ lSb << "the serialization-parameters element must be in the <http://www.w3.org/2010/xslt-xquery-serialization> namespace. "
+ << lFoundNs << " namespace was found";
+ throw XQUERY_EXCEPTION(
+ err::XQDY0027,
+ ERROR_PARAMS(lSb .str()),
+ ERROR_LOC( aLoc ));
+ }
+
+#ifndef ZORBA_NO_XMLSCHEMA
+ // this will throw an error if the validation fails
+ aSctx->validate(aParamElem, aParamElem, StaticContextConsts::strict_validation);
+#endif
+
+ // get the children iterator
+ store::Iterator_t lElemIter = aParamElem->getChildren();
+ lElemIter->open();
+ store::Item_t lChildElem;
+
+ // iterate over the children
+ while (lElemIter->next(lChildElem))
+ {
+#ifdef ZORBA_NO_XMLSCHEMA
+ // if zorba is compiled without schema support
+ // consider only the child elements
+ if (lChildElem->isNode() && lChildElem->getNodeKind() == store::StoreConsts::elementNode)
+ {
+#endif
+ if (lChildElem->getNodeKind() != store::StoreConsts::elementNode)
+ {
+ continue;
+ }
+
+ store::Item_t lChildName = lChildElem->getNodeName();
+ if (lChildName->getLocalName() == "use-character-maps")
+ {
+ // TODO: once zorba the serializer supports character maps
+ }
+ else
+ {
+ store::Iterator_t lAttrIter = lChildElem->getAttributes();
+ lAttrIter->open();
+ store::Item_t lAttribute;
+ // iterate over the attributes
+ while (lAttrIter->next(lAttribute))
+ {
+ store::Item_t lAttributeQName = lAttribute->getNodeName();
+
+ // the attribute must have the local name "value" (this should be taken care of by the schema)
+ if (lAttributeQName->getLocalName() == "value")
+ {
+ store::Item_t lChildElemQName = lChildElem->getNodeName();
+ // the serializer throws an exception if the parameter name is not correct
+ aSerializer.setParameter(lChildElemQName->getLocalName().c_str(), lAttribute->getStringValue().c_str());
+ break;
+ }
+#ifdef ZORBA_NO_XMLSCHEMA
+ // if zorba is compiled without schema support
+ // consider only the child elements
+ else
+ {
+ ztd::string_builder lSb;
+ lSb << "serialization-parameters element has an invalid attribute: \""
+ << lAttributeQName->getLocalName() << "\"";
+ throw XQUERY_EXCEPTION(
+ err::XQDY0027,
+ ERROR_PARAMS(lSb.str()),
+ ERROR_LOC( loc ));
+ }
+#endif
+ }
+ lAttrIter->close();
+ }
+#ifdef ZORBA_NO_XMLSCHEMA
+ }
+ else
+ {
+ ztd::string_builder lSb;
+ lSb << "serialization-parameters element can only element child nodes";
+ throw XQUERY_EXCEPTION(
+ err::XQDY0027,
+ ERROR_PARAMS(lSb.str()),
+ ERROR_LOC( loc ));
+ }
+#endif
+ }
+ lElemIter->close();
+}
+
bool
FnSerializeIterator::nextImpl(store::Item_t& aResult, PlanState& aPlanState) const
{
@@ -145,121 +270,7 @@
// if have serialization parameters
if (theChildren.size() == 2 && consumeNext(lParams, theChildren[1].getp(), aPlanState))
{
- store::Item_t lElemName = lParams->getNodeName();
-
- // make sure the user does not pass children of the serialization-parameters
- // element which would pass the schema validation below but break the logic after
- if (lElemName->getLocalName() != "serialization-parameters")
- {
- ztd::string_builder lSb;
- lSb << "the serialization parameters element must have the name \"serialization parameters\". "
- << "\"" << lElemName->getLocalName() << "\" was found";
- throw XQUERY_EXCEPTION(
- err::XQDY0027,
- ERROR_PARAMS(lSb.str()),
- ERROR_LOC( loc ));
- }
-
- // the provided element must be in the correct namespace otherwise
- // the user can pass a validated element from another namespace
- // which would make the schema validation below fail
- if (lElemName->getNamespace() != "http://www.w3.org/2010/xslt-xquery-serialization")
- {
- ztd::string_builder lSb;
- zstring lFoundNs("No");
- if (lElemName->getNamespace().size() > 0)
- {
- lFoundNs = "<";
- lFoundNs += lElemName->getNamespace();
- lFoundNs += ">";
- }
-
- lSb << "the serialization-parameters element must be in the <http://www.w3.org/2010/xslt-xquery-serialization> namespace. "
- << lFoundNs << " namespace was found";
- throw XQUERY_EXCEPTION(
- err::XQDY0027,
- ERROR_PARAMS(lSb .str()),
- ERROR_LOC( loc ));
- }
-
-#ifndef ZORBA_NO_XMLSCHEMA
- // this will throw an error if te validation fails
- theSctx->validate(lParams, lParams, StaticContextConsts::strict_validation);
-#endif
-
- // get the children iterator
- store::Iterator_t lElemIter = lParams->getChildren();
- lElemIter->open();
- store::Item_t lChildElem;
-
- // iterate over the children
- while (lElemIter->next(lChildElem))
- {
-#ifdef ZORBA_NO_XMLSCHEMA
- // if zorba is compiled without schema support
- // consider only the child elements
- if (lChildElem->isNode() && lChildElem->getNodeKind() == store::StoreConsts::elementNode)
- {
-#endif
- if (lChildElem->getNodeKind() != store::StoreConsts::elementNode)
- {
- continue;
- }
-
- store::Item_t lChildName = lChildElem->getNodeName();
- if (lChildName->getLocalName() == "use-character-maps")
- {
- // TODO: once zorba the serializer supports character maps
- }
- else
- {
- store::Iterator_t lAttrIter = lChildElem->getAttributes();
- lAttrIter->open();
- store::Item_t lAttribute;
- // iterate over the attributes
- while (lAttrIter->next(lAttribute))
- {
- store::Item_t lAttributeQName = lAttribute->getNodeName();
-
- // the attribute must have the local name "value" (this should be taken care of by the schema)
- if (lAttributeQName->getLocalName() == "value")
- {
- store::Item_t lChildElemQName = lChildElem->getNodeName();
- // the serializer throws an exception if the parameter name is not correct
- lSerializer.setParameter(lChildElemQName->getLocalName().c_str(), lAttribute->getStringValue().c_str());
- break;
- }
-#ifdef ZORBA_NO_XMLSCHEMA
- // if zorba is compiled without schema support
- // consider only the child elements
- else
- {
- ztd::string_builder lSb;
- lSb << "serialization-parameters element has an invalid attribute: \""
- << lAttributeQName->getLocalName() << "\"";
- throw XQUERY_EXCEPTION(
- err::XQDY0027,
- ERROR_PARAMS(lSb.str()),
- ERROR_LOC( loc ));
- }
-#endif
- }
- lAttrIter->close();
- }
-#ifdef ZORBA_NO_XMLSCHEMA
- }
- else
- {
- ztd::string_builder lSb;
- lSb << "serialization-parameters element can only element child nodes";
- throw XQUERY_EXCEPTION(
- err::XQDY0027,
- ERROR_PARAMS(lSb.str()),
- ERROR_LOC( loc ));
- }
-#endif
- }
- lElemIter->close();
+ setSerializationParams(lSerializer, lParams, theSctx, loc);
}
{
=== modified file 'src/runtime/parsing_and_serializing/pregenerated/parsing_and_serializing.h'
--- src/runtime/parsing_and_serializing/pregenerated/parsing_and_serializing.h 2012-09-17 00:36:37 +0000
+++ src/runtime/parsing_and_serializing/pregenerated/parsing_and_serializing.h 2012-09-21 03:00:26 +0000
@@ -89,6 +89,7 @@
public:
static void streamReleaser(std::istream* stream);
+ static void setSerializationParams(zorba::serializer& aSerializer, store::Item_t& aParamElem, static_context* aSctx, const QueryLoc& aLoc);
void accept(PlanIterVisitor& v) const;
bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
=== modified file 'src/runtime/pregenerated/iterator_enum.h'
--- src/runtime/pregenerated/iterator_enum.h 2012-09-17 00:36:37 +0000
+++ src/runtime/pregenerated/iterator_enum.h 2012-09-21 03:00:26 +0000
@@ -151,6 +151,8 @@
TYPE_FunctionAnnotationsIterator,
TYPE_JSONParseInternal,
TYPE_JSONSerializeInternal,
+ TYPE_JSONDecodeFromRoundtripIterator,
+ TYPE_JSONEncodeForRoundtripIterator,
TYPE_JSONParseIterator,
TYPE_JSONObjectNamesIterator,
TYPE_JSONObjectValueIterator,
=== modified file 'src/runtime/spec/json/jsoniq_functions.xml'
--- src/runtime/spec/json/jsoniq_functions.xml 2012-09-17 00:36:37 +0000
+++ src/runtime/spec/json/jsoniq_functions.xml 2012-09-21 03:00:26 +0000
@@ -13,6 +13,130 @@
/*******************************************************************************
********************************************************************************/
-->
+<zorba:iterator name="JSONDecodeFromRoundtripIterator"
+ preprocessorGuard="#ifdef ZORBA_WITH_JSON">
+
+ <zorba:function isDeterministic="true">
+
+ <zorba:signature localname="decode-from-roundtrip" prefix="fn-jsoniq">
+ <zorba:param>json-item()*</zorba:param>
+ <zorba:output>structured-item()*</zorba:output>
+ </zorba:signature>
+
+ <zorba:signature localname="decode-from-roundtrip" prefix="fn-jsoniq">
+ <zorba:param>json-item()*</zorba:param>
+ <zorba:param>object()</zorba:param>
+ <zorba:output>structured-item()*</zorba:output>
+ </zorba:signature>
+
+ <zorba:methods>
+ <zorba:propagatesInputNodes value="false"/>
+ <zorba:mustCopyInputNodes value="false"/>
+ </zorba:methods>
+
+ </zorba:function>
+
+ <zorba:state>
+ <zorba:member type="zstring" name="thePrefix" brief=""/>
+ </zorba:state>
+
+ <zorba:method const="true" name="decodeXDM" return="bool">
+ <zorba:param type="const store::Item_t&" name="anObj"/>
+ <zorba:param type="store::Item_t&" name="aResult"/>
+ <zorba:param type="JSONDecodeFromRoundtripIteratorState*" name="aState"/>
+ </zorba:method>
+
+ <zorba:method const="true" name="decodeObject" return="bool">
+ <zorba:param type="const store::Item_t&" name="anObj"/>
+ <zorba:param type="store::Item_t&" name="aResult"/>
+ <zorba:param type="JSONDecodeFromRoundtripIteratorState*" name="aState"/>
+ </zorba:method>
+
+ <zorba:method const="true" name="decodeArray" return="bool">
+ <zorba:param type="const store::Item_t&" name="anArray"/>
+ <zorba:param type="store::Item_t&" name="aResult"/>
+ <zorba:param type="JSONDecodeFromRoundtripIteratorState*" name="aState"/>
+ </zorba:method>
+
+ <zorba:method const="true" name="decodeItem" return="bool">
+ <zorba:param type="const store::Item_t&" name="anItem"/>
+ <zorba:param type="store::Item_t&" name="aResult"/>
+ <zorba:param type="JSONDecodeFromRoundtripIteratorState*" name="aState"/>
+ </zorba:method>
+
+</zorba:iterator>
+
+
+<!--
+/*******************************************************************************
+********************************************************************************/
+-->
+<zorba:iterator name="JSONEncodeForRoundtripIterator"
+ preprocessorGuard="#ifdef ZORBA_WITH_JSON">
+
+ <zorba:function isDeterministic="true">
+
+ <zorba:signature localname="encode-for-roundtrip" prefix="fn-jsoniq">
+ <zorba:param>structured-item()*</zorba:param>
+ <zorba:output>json-item()*</zorba:output>
+ </zorba:signature>
+
+ <zorba:signature localname="encode-for-roundtrip" prefix="fn-jsoniq">
+ <zorba:param>structured-item()*</zorba:param>
+ <zorba:param>object()</zorba:param>
+ <zorba:output>json-item()*</zorba:output>
+ </zorba:signature>
+
+ <zorba:methods>
+ <zorba:propagatesInputNodes value="false"/>
+ <zorba:mustCopyInputNodes value="false"/>
+ </zorba:methods>
+
+ </zorba:function>
+
+ <zorba:state>
+ <zorba:member type="zstring" name="thePrefix" brief=""/>
+ <zorba:member type="store::Item_t" name="theSerParams" brief=""/>
+ <zorba:member type="XQueryDiagnostics*" name="theDiag" brief=""/>
+ </zorba:state>
+
+ <zorba:method const="true" name="encodeObject" return="bool">
+ <zorba:param type="const store::Item_t&" name="anObj"/>
+ <zorba:param type="store::Item_t&" name="aResult"/>
+ <zorba:param type="JSONEncodeForRoundtripIteratorState*" name="aState"/>
+ </zorba:method>
+
+ <zorba:method const="true" name="encodeArray" return="bool">
+ <zorba:param type="const store::Item_t&" name="anArray"/>
+ <zorba:param type="store::Item_t&" name="aResult"/>
+ <zorba:param type="JSONEncodeForRoundtripIteratorState*" name="aState"/>
+ </zorba:method>
+
+ <zorba:method const="true" name="encodeAtomic" return="bool">
+ <zorba:param type="const store::Item_t&" name="aValue"/>
+ <zorba:param type="store::Item_t&" name="aResult"/>
+ <zorba:param type="JSONEncodeForRoundtripIteratorState*" name="aState"/>
+ </zorba:method>
+
+ <zorba:method const="true" name="encodeNode" return="bool">
+ <zorba:param type="const store::Item_t&" name="aNode"/>
+ <zorba:param type="store::Item_t&" name="aResult"/>
+ <zorba:param type="JSONEncodeForRoundtripIteratorState*" name="aState"/>
+ </zorba:method>
+
+ <zorba:method const="true" name="encodeItem" return="bool">
+ <zorba:param type="const store::Item_t&" name="anItem"/>
+ <zorba:param type="store::Item_t&" name="aResult"/>
+ <zorba:param type="JSONEncodeForRoundtripIteratorState*" name="aState"/>
+ </zorba:method>
+
+</zorba:iterator>
+
+
+<!--
+/*******************************************************************************
+********************************************************************************/
+-->
<zorba:iterator name="JSONParseIterator" arity="nary"
preprocessorGuard="#ifdef ZORBA_WITH_JSON">
=== modified file 'src/runtime/spec/parsing_and_serializing/parsing_and_serializing.xml'
--- src/runtime/spec/parsing_and_serializing/parsing_and_serializing.xml 2012-09-17 00:36:37 +0000
+++ src/runtime/spec/parsing_and_serializing/parsing_and_serializing.xml 2012-09-21 03:00:26 +0000
@@ -77,6 +77,13 @@
<zorba:param type="std::istream*" name="stream"/>
</zorba:method>
+ <zorba:method static="true" name="setSerializationParams" return="void">
+ <zorba:param type="zorba::serializer&" name="aSerializer"/>
+ <zorba:param type="store::Item_t&" name="aParamElem"/>
+ <zorba:param type="static_context*" name="aSctx"/>
+ <zorba:param type="const QueryLoc&" name="aLoc"/>
+ </zorba:method>
+
</zorba:iterator>
=== modified file 'src/runtime/visitors/pregenerated/planiter_visitor.h'
--- src/runtime/visitors/pregenerated/planiter_visitor.h 2012-09-17 00:36:37 +0000
+++ src/runtime/visitors/pregenerated/planiter_visitor.h 2012-09-21 03:00:26 +0000
@@ -309,6 +309,12 @@
class JSONSerializeInternal;
#ifdef ZORBA_WITH_JSON
+ class JSONDecodeFromRoundtripIterator;
+#endif
+#ifdef ZORBA_WITH_JSON
+ class JSONEncodeForRoundtripIterator;
+#endif
+#ifdef ZORBA_WITH_JSON
class JSONParseIterator;
#endif
#ifdef ZORBA_WITH_JSON
@@ -1145,6 +1151,14 @@
virtual void endVisit ( const JSONSerializeInternal& ) = 0;
#ifdef ZORBA_WITH_JSON
+ virtual void beginVisit ( const JSONDecodeFromRoundtripIterator& ) = 0;
+ virtual void endVisit ( const JSONDecodeFromRoundtripIterator& ) = 0;
+#endif
+#ifdef ZORBA_WITH_JSON
+ virtual void beginVisit ( const JSONEncodeForRoundtripIterator& ) = 0;
+ virtual void endVisit ( const JSONEncodeForRoundtripIterator& ) = 0;
+#endif
+#ifdef ZORBA_WITH_JSON
virtual void beginVisit ( const JSONParseIterator& ) = 0;
virtual void endVisit ( const JSONParseIterator& ) = 0;
#endif
=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp'
--- src/runtime/visitors/pregenerated/printer_visitor.cpp 2012-09-19 21:40:38 +0000
+++ src/runtime/visitors/pregenerated/printer_visitor.cpp 2012-09-21 03:00:26 +0000
@@ -1824,6 +1824,36 @@
// </JSONSerializeInternal>
#ifdef ZORBA_WITH_JSON
+// <JSONDecodeFromRoundtripIterator>
+void PrinterVisitor::beginVisit ( const JSONDecodeFromRoundtripIterator& a) {
+ thePrinter.startBeginVisit("JSONDecodeFromRoundtripIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const JSONDecodeFromRoundtripIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </JSONDecodeFromRoundtripIterator>
+
+#endif
+#ifdef ZORBA_WITH_JSON
+// <JSONEncodeForRoundtripIterator>
+void PrinterVisitor::beginVisit ( const JSONEncodeForRoundtripIterator& a) {
+ thePrinter.startBeginVisit("JSONEncodeForRoundtripIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const JSONEncodeForRoundtripIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </JSONEncodeForRoundtripIterator>
+
+#endif
+#ifdef ZORBA_WITH_JSON
// <JSONParseIterator>
void PrinterVisitor::beginVisit ( const JSONParseIterator& a) {
thePrinter.startBeginVisit("JSONParseIterator", ++theId);
=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.h'
--- src/runtime/visitors/pregenerated/printer_visitor.h 2012-09-17 00:36:37 +0000
+++ src/runtime/visitors/pregenerated/printer_visitor.h 2012-09-21 03:00:26 +0000
@@ -473,6 +473,16 @@
void endVisit ( const JSONSerializeInternal& );
#ifdef ZORBA_WITH_JSON
+ void beginVisit( const JSONDecodeFromRoundtripIterator& );
+ void endVisit ( const JSONDecodeFromRoundtripIterator& );
+#endif
+
+#ifdef ZORBA_WITH_JSON
+ void beginVisit( const JSONEncodeForRoundtripIterator& );
+ void endVisit ( const JSONEncodeForRoundtripIterator& );
+#endif
+
+#ifdef ZORBA_WITH_JSON
void beginVisit( const JSONParseIterator& );
void endVisit ( const JSONParseIterator& );
#endif
=== modified file 'test/rbkt/ExpQueryResults/zorba/jsoniq/jn_accumulate.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/jn_accumulate.xml.res 2012-09-06 23:55:13 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/jn_accumulate.xml.res 2012-09-21 03:00:26 +0000
@@ -1,1 +1,1 @@
-{ "n1" : { "JSONiq XDM node" : "<node>10</node>" }, "n2" : { "JSONiq XDM node" : "<node>20</node>" } }
+{ "n1" : { "type" : "node()", "value" : "<node>10</node>" }, "n2" : { "type" : "node()", "value" : "<node>20</node>" } }
=== modified file 'test/rbkt/ExpQueryResults/zorba/jsoniq/obj_constr_02.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/obj_constr_02.xml.res 2012-09-17 00:36:37 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/obj_constr_02.xml.res 2012-09-21 03:00:26 +0000
@@ -1,1 +1,1 @@
-{ "n1" : { "JSONiq XDM node" : "<node>10</node>" }, "n2" : { "JSONiq XDM node" : "<node>20</node>" } }
+{ "n1" : { "type" : "node()", "value" : "<node>10</node>" }, "n2" : { "type" : "node()", "value" : "<node>20</node>" } }
=== modified file 'test/rbkt/ExpQueryResults/zorba/jsoniq/obj_constr_04.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/obj_constr_04.xml.res 2012-09-17 00:36:37 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/obj_constr_04.xml.res 2012-09-21 03:00:26 +0000
@@ -1,1 +1,1 @@
-{ "n1" : [ { "JSONiq XDM node" : "<node>10</node>" }, 1 ], "n2" : { "JSONiq XDM node" : "<node>20</node>" } }
+{ "n1" : [ { "type" : "node()", "value" : "<node>10</node>" }, 1 ], "n2" : { "type" : "node()", "value" : "<node>20</node>" } }
=== added directory 'test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip'
=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/decode_01.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/decode_01.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/decode_01.xml.res 2012-09-21 03:00:26 +0000
@@ -0,0 +1,1 @@
+true true true true true
=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/decode_02.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/decode_02.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/decode_02.xml.res 2012-09-21 03:00:26 +0000
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<para>
+ A pair named "[$prefix]value" (where [$prefix] is replaced with the
+ value of the parameter $prefix) and whose value is a serialization
+ of the XML node according to the XML output method and with the
+ serialization parameters specified by $param.
+ </para>
\ No newline at end of file
=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/decode_04.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/decode_04.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/decode_04.xml.res 2012-09-21 03:00:26 +0000
@@ -0,0 +1,1 @@
+true
=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/decode_05.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/decode_05.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/decode_05.xml.res 2012-09-21 03:00:26 +0000
@@ -0,0 +1,1 @@
+true true true true true
\ No newline at end of file
=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/encode_01.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/encode_01.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/encode_01.xml.res 2012-09-21 03:00:26 +0000
@@ -0,0 +1,1 @@
+{ "nan" : { "Q{http://jsoniq.org/roundtrip}type" : "xs:double", "Q{http://jsoniq.org/roundtrip}value" : "NaN" }, "inf" : { "Q{http://jsoniq.org/roundtrip}type" : "xs:double", "Q{http://jsoniq.org/roundtrip}value" : "INF" }, "date" : { "Q{http://jsoniq.org/roundtrip}type" : "xs:date", "Q{http://jsoniq.org/roundtrip}value" : "1066-10-14" }, "QName" : { "Q{http://jsoniq.org/roundtrip}type" : "xs:QName", "Q{http://jsoniq.org/roundtrip}value" : "Q{http://www.jsoniq.org/functions}encode-for-roundtrip", "Q{http://jsoniq.org/roundtrip}prefix" : "jn" }, "EQName" : { "Q{http://jsoniq.org/roundtrip}type" : "xs:QName", "Q{http://jsoniq.org/roundtrip}value" : "Q{http://jsoniq.org/roundtrip}value" } }
=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/encode_02.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/encode_02.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/encode_02.xml.res 2012-09-21 03:00:26 +0000
@@ -0,0 +1,1 @@
+[ { "Q{http://jsoniq.org/roundtrip}type" : "xs:double", "Q{http://jsoniq.org/roundtrip}value" : "NaN" }, { "Q{http://jsoniq.org/roundtrip}type" : "xs:double", "Q{http://jsoniq.org/roundtrip}value" : "INF" }, { "Q{http://jsoniq.org/roundtrip}type" : "xs:date", "Q{http://jsoniq.org/roundtrip}value" : "1066-10-14" } ]
=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/encode_03.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/encode_03.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/encode_03.xml.res 2012-09-21 03:00:26 +0000
@@ -0,0 +1,1 @@
+{ "serialized XML" : { "Q{http://jsoniq.org/roundtrip}type" : "node()", "Q{http://jsoniq.org/roundtrip}value" : "<para>\n A pair named \"[$prefix]value\" (where [$prefix] is replaced with the\n value of the parameter $prefix) and whose value is a serialization\n of the XML node according to the XML output method and with the\n serialization parameters specified by $param.\n </para>" } }
\ No newline at end of file
=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/encode_04.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/encode_04.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/encode_04.xml.res 2012-09-21 03:00:26 +0000
@@ -0,0 +1,1 @@
+{ "serialized XML" : { "pre-type" : "node()", "pre-value" : "<a>\n <b>text<c>more text</c>\n </b>\n</a>" } }
\ No newline at end of file
=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/encode_08.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/encode_08.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/encode_08.xml.res 2012-09-21 03:00:26 +0000
@@ -0,0 +1,1 @@
+{ "nan" : { "Q{http://jsoniq.org/roundtrip}type" : "xs:double", "Q{http://jsoniq.org/roundtrip}value" : "NaN" }, "inf" : { "Q{http://jsoniq.org/roundtrip}type" : "xs:double", "Q{http://jsoniq.org/roundtrip}value" : "INF" } }{ "date" : { "Q{http://jsoniq.org/roundtrip}type" : "xs:date", "Q{http://jsoniq.org/roundtrip}value" : "1066-10-14" } }{ "QName" : { "Q{http://jsoniq.org/roundtrip}type" : "xs:QName", "Q{http://jsoniq.org/roundtrip}value" : "Q{http://www.jsoniq.org/functions}encode-for-roundtrip", "Q{http://jsoniq.org/roundtrip}prefix" : "jn" }, "EQName" : { "Q{http://jsoniq.org/roundtrip}type" : "xs:QName", "Q{http://jsoniq.org/roundtrip}value" : "Q{http://jsoniq.org/roundtrip}value" } }
\ No newline at end of file
=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/encode_09.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/encode_09.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/encode_09.xml.res 2012-09-21 03:00:26 +0000
@@ -0,0 +1,1 @@
+{ "hatSize" : { "Q{http://jsoniq.org/roundtrip}type" : "Q{http://www.zorba-xquery.com/simple}HatSizeType", "Q{http://jsoniq.org/roundtrip}value" : "10" } }
\ No newline at end of file
=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/roundtrip_01.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/roundtrip_01.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/roundtrip_01.xml.res 2012-09-21 03:00:26 +0000
@@ -0,0 +1,1 @@
+{ "nan" : { "Q{http://jsoniq.org/roundtrip}type" : "xs:double", "Q{http://jsoniq.org/roundtrip}value" : "NaN" }, "inf" : { "Q{http://jsoniq.org/roundtrip}type" : "xs:double", "Q{http://jsoniq.org/roundtrip}value" : "INF" }, "date" : { "Q{http://jsoniq.org/roundtrip}type" : "xs:date", "Q{http://jsoniq.org/roundtrip}value" : "1066-10-14" }, "QName" : { "Q{http://jsoniq.org/roundtrip}type" : "xs:QName", "Q{http://jsoniq.org/roundtrip}value" : "Q{http://www.jsoniq.org/functions}encode-for-roundtrip", "Q{http://jsoniq.org/roundtrip}prefix" : "jn" }, "EQName" : { "Q{http://jsoniq.org/roundtrip}type" : "xs:QName", "Q{http://jsoniq.org/roundtrip}value" : "Q{http://jsoniq.org/roundtrip}value" } }
=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/roundtrip_02.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/roundtrip_02.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/roundtrip_02.xml.res 2012-09-21 03:00:26 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+true true true true true
\ No newline at end of file
=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/roundtrip_03.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/roundtrip_03.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/roundtrip_03.xml.res 2012-09-21 03:00:26 +0000
@@ -0,0 +1,1 @@
+{ "foo" : { "Q{http://jsoniq.org/roundtrip}type" : "node()", "Q{http://jsoniq.org/roundtrip}value" : "<a id=\"bar\"/>" } }
=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/roundtrip_04.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/roundtrip_04.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/roundtrip/roundtrip_04.xml.res 2012-09-21 03:00:26 +0000
@@ -0,0 +1,1 @@
+{ "hatSize" : 10 }true
\ No newline at end of file
=== added file 'test/rbkt/ExpQueryResults/zorba/serialization/cloudscript/extensions1.xml.res'
--- test/rbkt/ExpQueryResults/zorba/serialization/cloudscript/extensions1.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/serialization/cloudscript/extensions1.xml.res 2012-09-21 03:00:26 +0000
@@ -0,0 +1,1 @@
+"NaN"
=== removed file 'test/rbkt/ExpQueryResults/zorba/serialization/cloudscript/extensions1a.xml.res'
--- test/rbkt/ExpQueryResults/zorba/serialization/cloudscript/extensions1a.xml.res 2012-09-17 00:36:37 +0000
+++ test/rbkt/ExpQueryResults/zorba/serialization/cloudscript/extensions1a.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-{ "JSONiq value" : { "type" : "double", "value" : "NaN" } }
=== added file 'test/rbkt/ExpQueryResults/zorba/serialization/cloudscript/extensions2.xml.res'
--- test/rbkt/ExpQueryResults/zorba/serialization/cloudscript/extensions2.xml.res 1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/serialization/cloudscript/extensions2.xml.res 2012-09-21 03:00:26 +0000
@@ -0,0 +1,1 @@
+"INF"
=== removed file 'test/rbkt/ExpQueryResults/zorba/serialization/cloudscript/extensions2a.xml.res'
--- test/rbkt/ExpQueryResults/zorba/serialization/cloudscript/extensions2a.xml.res 2012-09-17 00:36:37 +0000
+++ test/rbkt/ExpQueryResults/zorba/serialization/cloudscript/extensions2a.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-{ "JSONiq value" : { "type" : "double", "value" : "INF" } }
=== modified file 'test/rbkt/ExpQueryResults/zorba/serialization/cloudscript/extensions3a.xml.res'
--- test/rbkt/ExpQueryResults/zorba/serialization/cloudscript/extensions3a.xml.res 2012-09-17 00:36:37 +0000
+++ test/rbkt/ExpQueryResults/zorba/serialization/cloudscript/extensions3a.xml.res 2012-09-21 03:00:26 +0000
@@ -1,1 +1,1 @@
-{ "JSONiq XDM node" : "<a/>" }
+<a></a>
=== modified file 'test/rbkt/Queries/zorba/jsoniq/arr_insert_01.spec'
--- test/rbkt/Queries/zorba/jsoniq/arr_insert_01.spec 2012-09-17 00:36:37 +0000
+++ test/rbkt/Queries/zorba/jsoniq/arr_insert_01.spec 2012-09-21 03:00:26 +0000
@@ -1,1 +1,1 @@
-Serialization: method=json jsoniq-multiple-items=appended
+Serialization: method=json
=== modified file 'test/rbkt/Queries/zorba/jsoniq/arr_insert_02.spec'
--- test/rbkt/Queries/zorba/jsoniq/arr_insert_02.spec 2012-09-17 00:36:37 +0000
+++ test/rbkt/Queries/zorba/jsoniq/arr_insert_02.spec 2012-09-21 03:00:26 +0000
@@ -1,1 +1,1 @@
-Serialization: method=json jsoniq-multiple-items=appended
+Serialization: method=json
=== modified file 'test/rbkt/Queries/zorba/jsoniq/arr_replace_01.spec'
--- test/rbkt/Queries/zorba/jsoniq/arr_replace_01.spec 2012-09-17 00:36:37 +0000
+++ test/rbkt/Queries/zorba/jsoniq/arr_replace_01.spec 2012-09-21 03:00:26 +0000
@@ -1,1 +1,1 @@
-Serialization: method=json jsoniq-multiple-items=appended
+Serialization: method=json
=== modified file 'test/rbkt/Queries/zorba/jsoniq/coll_dyn_02.spec'
--- test/rbkt/Queries/zorba/jsoniq/coll_dyn_02.spec 2012-02-01 15:03:27 +0000
+++ test/rbkt/Queries/zorba/jsoniq/coll_dyn_02.spec 2012-09-21 03:00:26 +0000
@@ -1,1 +1,2 @@
-Error: http://www.zorba-xquery.com/errors:ZAPI0045
+Serialization: method=json
+Error: http://www.jsoniq.org/errors:JNSE0014
=== modified file 'test/rbkt/Queries/zorba/jsoniq/coll_dyn_03.spec'
--- test/rbkt/Queries/zorba/jsoniq/coll_dyn_03.spec 2012-09-17 00:36:37 +0000
+++ test/rbkt/Queries/zorba/jsoniq/coll_dyn_03.spec 2012-09-21 03:00:26 +0000
@@ -1,1 +1,1 @@
-Serialization: method=json jsoniq-multiple-items=appended
+Serialization: method=json
=== modified file 'test/rbkt/Queries/zorba/jsoniq/collection-and-index/foaf-collection-update.spec'
--- test/rbkt/Queries/zorba/jsoniq/collection-and-index/foaf-collection-update.spec 2012-06-15 08:40:21 +0000
+++ test/rbkt/Queries/zorba/jsoniq/collection-and-index/foaf-collection-update.spec 2012-09-21 03:00:26 +0000
@@ -1,1 +1,1 @@
-Serialization: method=json jsoniq-multiple-items=appended
+Serialization: method=json
=== modified file 'test/rbkt/Queries/zorba/jsoniq/collection-and-index/foaf-collection.spec'
--- test/rbkt/Queries/zorba/jsoniq/collection-and-index/foaf-collection.spec 2012-06-15 08:40:21 +0000
+++ test/rbkt/Queries/zorba/jsoniq/collection-and-index/foaf-collection.spec 2012-09-21 03:00:26 +0000
@@ -1,1 +1,1 @@
-Serialization: method=json jsoniq-multiple-items=appended
+Serialization: method=json
=== modified file 'test/rbkt/Queries/zorba/jsoniq/collection-and-index/foaf-index-general-point.spec'
--- test/rbkt/Queries/zorba/jsoniq/collection-and-index/foaf-index-general-point.spec 2012-06-15 08:40:21 +0000
+++ test/rbkt/Queries/zorba/jsoniq/collection-and-index/foaf-index-general-point.spec 2012-09-21 03:00:26 +0000
@@ -1,1 +1,1 @@
-Serialization: method=json jsoniq-multiple-items=appended
+Serialization: method=json
=== modified file 'test/rbkt/Queries/zorba/jsoniq/collection-and-index/foaf-index-point-maintenance.spec'
--- test/rbkt/Queries/zorba/jsoniq/collection-and-index/foaf-index-point-maintenance.spec 2012-06-15 14:37:19 +0000
+++ test/rbkt/Queries/zorba/jsoniq/collection-and-index/foaf-index-point-maintenance.spec 2012-09-21 03:00:26 +0000
@@ -1,1 +1,1 @@
-Serialization: method=json jsoniq-multiple-items=appended
+Serialization: method=json
=== modified file 'test/rbkt/Queries/zorba/jsoniq/collection-and-index/foaf-index-point.spec'
--- test/rbkt/Queries/zorba/jsoniq/collection-and-index/foaf-index-point.spec 2012-06-15 08:40:21 +0000
+++ test/rbkt/Queries/zorba/jsoniq/collection-and-index/foaf-index-point.spec 2012-09-21 03:00:26 +0000
@@ -1,1 +1,1 @@
-Serialization: method=json jsoniq-multiple-items=appended
+Serialization: method=json
=== modified file 'test/rbkt/Queries/zorba/jsoniq/collection-and-index/foaf-index-range.spec'
--- test/rbkt/Queries/zorba/jsoniq/collection-and-index/foaf-index-range.spec 2012-06-15 08:40:21 +0000
+++ test/rbkt/Queries/zorba/jsoniq/collection-and-index/foaf-index-range.spec 2012-09-21 03:00:26 +0000
@@ -1,1 +1,1 @@
-Serialization: method=json jsoniq-multiple-items=appended
+Serialization: method=json
=== modified file 'test/rbkt/Queries/zorba/jsoniq/jn_accumulate.spec'
--- test/rbkt/Queries/zorba/jsoniq/jn_accumulate.spec 2012-09-06 23:55:13 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jn_accumulate.spec 2012-09-21 03:00:26 +0000
@@ -1,1 +1,1 @@
-Serialization: method=json jsoniq-extensions=yes
+Serialization: method=json
=== modified file 'test/rbkt/Queries/zorba/jsoniq/jn_accumulate.xq'
--- test/rbkt/Queries/zorba/jsoniq/jn_accumulate.xq 2012-09-06 23:55:13 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jn_accumulate.xq 2012-09-21 03:00:26 +0000
@@ -6,11 +6,10 @@
<node>20</node>
</nodes>;
-variable $obj :=
-libjn:accumulate(
- for $node at $pos in $xdoc//node
- return { concat("n", $pos) : $node }
+variable $obj :=
+libjn:accumulate(
+ for $node at $pos in $xdoc//node
+ return { concat("n", $pos) : $node }
);
-$obj
-
+jn:encode-for-roundtrip($obj, { "prefix" : "" })
=== modified file 'test/rbkt/Queries/zorba/jsoniq/jn_descendant_objects.spec'
--- test/rbkt/Queries/zorba/jsoniq/jn_descendant_objects.spec 2012-09-06 23:55:13 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jn_descendant_objects.spec 2012-09-21 03:00:26 +0000
@@ -1,1 +1,1 @@
-Serialization: method=json jsoniq-multiple-items=appended
+Serialization: method=json
=== modified file 'test/rbkt/Queries/zorba/jsoniq/jn_descendant_pairs.spec'
--- test/rbkt/Queries/zorba/jsoniq/jn_descendant_pairs.spec 2012-09-06 23:55:13 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jn_descendant_pairs.spec 2012-09-21 03:00:26 +0000
@@ -1,1 +1,1 @@
-Serialization: method=json jsoniq-multiple-items=appended
+Serialization: method=json
=== removed file 'test/rbkt/Queries/zorba/jsoniq/jn_values.spec'
--- test/rbkt/Queries/zorba/jsoniq/jn_values.spec 2012-09-06 23:55:13 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jn_values.spec 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-Serialization: jsoniq-allow-mixed-xdm-jdm=yes jsoniq-multiple-items=appended
=== modified file 'test/rbkt/Queries/zorba/jsoniq/obj_constr_02.spec'
--- test/rbkt/Queries/zorba/jsoniq/obj_constr_02.spec 2012-09-17 00:36:37 +0000
+++ test/rbkt/Queries/zorba/jsoniq/obj_constr_02.spec 2012-09-21 03:00:26 +0000
@@ -1,1 +1,1 @@
-Serialization: method=json jsoniq-extensions=yes
+Serialization: method=json
=== modified file 'test/rbkt/Queries/zorba/jsoniq/obj_constr_02.xq'
--- test/rbkt/Queries/zorba/jsoniq/obj_constr_02.xq 2012-03-12 17:04:56 +0000
+++ test/rbkt/Queries/zorba/jsoniq/obj_constr_02.xq 2012-09-21 03:00:26 +0000
@@ -4,11 +4,10 @@
<node>20</node>
</nodes>;
-variable $obj :=
-{|
- for $node at $pos in $xdoc//node
- return { concat("n", $pos) : $node }
+variable $obj :=
+{|
+ for $node at $pos in $xdoc//node
+ return { concat("n", $pos) : $node }
|};
-$obj
-
+jn:encode-for-roundtrip($obj, { "prefix" : "" })
=== modified file 'test/rbkt/Queries/zorba/jsoniq/obj_constr_04.spec'
--- test/rbkt/Queries/zorba/jsoniq/obj_constr_04.spec 2012-09-17 00:36:37 +0000
+++ test/rbkt/Queries/zorba/jsoniq/obj_constr_04.spec 2012-09-21 03:00:26 +0000
@@ -1,1 +1,1 @@
-Serialization: method=json jsoniq-extensions=yes
+Serialization: method=json
=== modified file 'test/rbkt/Queries/zorba/jsoniq/obj_constr_04.xq'
--- test/rbkt/Queries/zorba/jsoniq/obj_constr_04.xq 2012-03-13 15:35:20 +0000
+++ test/rbkt/Queries/zorba/jsoniq/obj_constr_04.xq 2012-09-21 03:00:26 +0000
@@ -4,12 +4,12 @@
<node>20</node>
</nodes>;
-variable $obj :=
-{[
- for $node at $pos in $xdoc//node
- return { concat("n", $pos) : $node }
+variable $obj :=
+{[
+ for $node at $pos in $xdoc//node
+ return { concat("n", $pos) : $node }
,
{ "n1" : 1 }
]};
-$obj
+jn:encode-for-roundtrip($obj, { "prefix" : "" })
=== modified file 'test/rbkt/Queries/zorba/jsoniq/project_01.spec'
--- test/rbkt/Queries/zorba/jsoniq/project_01.spec 2012-09-17 00:36:37 +0000
+++ test/rbkt/Queries/zorba/jsoniq/project_01.spec 2012-09-21 03:00:26 +0000
@@ -1,1 +1,1 @@
-Serialization: method=json jsoniq-multiple-items=appended
+Serialization: method=json
=== added directory 'test/rbkt/Queries/zorba/jsoniq/roundtrip'
=== added file 'test/rbkt/Queries/zorba/jsoniq/roundtrip/decode_01.xq'
--- test/rbkt/Queries/zorba/jsoniq/roundtrip/decode_01.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/roundtrip/decode_01.xq 2012-09-21 03:00:26 +0000
@@ -0,0 +1,32 @@
+let $obj := jn:decode-from-roundtrip(
+ {
+ "nan" : {
+ "Q{http://jsoniq.org/roundtrip}type" : "xs:double",
+ "Q{http://jsoniq.org/roundtrip}value" : "NaN"
+ },
+ "inf" : {
+ "Q{http://jsoniq.org/roundtrip}type" : "xs:double",
+ "Q{http://jsoniq.org/roundtrip}value" : "INF"
+ },
+ "date" : {
+ "Q{http://jsoniq.org/roundtrip}type" : "xs:date",
+ "Q{http://jsoniq.org/roundtrip}value" : "1066-10-14"
+ },
+ "QName" : {
+ "Q{http://jsoniq.org/roundtrip}type" : "xs:QName",
+ "Q{http://jsoniq.org/roundtrip}value" : "Q{http://www.jsoniq.org/functions}encode-for-roundtrip",
+ "Q{http://jsoniq.org/roundtrip}prefix" : "jn"
+ },
+ "EQName" : {
+ "Q{http://jsoniq.org/roundtrip}type" : "xs:QName",
+ "Q{http://jsoniq.org/roundtrip}value" : "Q{http://jsoniq.org/roundtrip}value"
+ }
+ })
+return
+ (
+ $obj("nan") instance of xs:double and xs:string($obj("nan")) eq "NaN",
+ $obj("inf") instance of xs:double and xs:string($obj("inf")) eq "INF",
+ $obj("date") instance of xs:date and year-from-date($obj("date")) eq 1066,
+ $obj("QName") instance of xs:QName and prefix-from-QName($obj("QName")) eq "jn",
+ $obj("EQName") instance of xs:QName and namespace-uri-from-QName($obj("EQName")) eq "http://jsoniq.org/roundtrip"
+ )
=== added file 'test/rbkt/Queries/zorba/jsoniq/roundtrip/decode_02.xq'
--- test/rbkt/Queries/zorba/jsoniq/roundtrip/decode_02.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/roundtrip/decode_02.xq 2012-09-21 03:00:26 +0000
@@ -0,0 +1,6 @@
+import module namespace f = "http://expath.org/ns/file";
+
+let $json := jn:parse-json(f:read-text(fn:resolve-uri("encoded_01.json")))
+let $obj := jn:decode-from-roundtrip($json)
+return
+ $obj("serialized XML")
=== added file 'test/rbkt/Queries/zorba/jsoniq/roundtrip/decode_03.spec'
--- test/rbkt/Queries/zorba/jsoniq/roundtrip/decode_03.spec 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/roundtrip/decode_03.spec 2012-09-21 03:00:26 +0000
@@ -0,0 +1,1 @@
+Error: http://www.jsoniq.org/errors:JNTY0023
=== added file 'test/rbkt/Queries/zorba/jsoniq/roundtrip/decode_03.xq'
--- test/rbkt/Queries/zorba/jsoniq/roundtrip/decode_03.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/roundtrip/decode_03.xq 2012-09-21 03:00:26 +0000
@@ -0,0 +1,1 @@
+jn:decode-from-roundtrip({||}, { "prefix" : 1 })
=== added file 'test/rbkt/Queries/zorba/jsoniq/roundtrip/decode_04.xq'
--- test/rbkt/Queries/zorba/jsoniq/roundtrip/decode_04.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/roundtrip/decode_04.xq 2012-09-21 03:00:26 +0000
@@ -0,0 +1,1 @@
+jn:decode-from-roundtrip(jn:encode-for-roundtrip(<a/>)) instance of element()
=== added file 'test/rbkt/Queries/zorba/jsoniq/roundtrip/decode_05.xq'
--- test/rbkt/Queries/zorba/jsoniq/roundtrip/decode_05.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/roundtrip/decode_05.xq 2012-09-21 03:00:26 +0000
@@ -0,0 +1,37 @@
+let $objs := jn:decode-from-roundtrip((
+ {
+ "nan" : {
+ "Q{http://jsoniq.org/roundtrip}type" : "xs:double",
+ "Q{http://jsoniq.org/roundtrip}value" : "NaN"
+ },
+ "inf" : {
+ "Q{http://jsoniq.org/roundtrip}type" : "xs:double",
+ "Q{http://jsoniq.org/roundtrip}value" : "INF"
+ }
+ }, {
+ "date" : {
+ "Q{http://jsoniq.org/roundtrip}type" : "xs:date",
+ "Q{http://jsoniq.org/roundtrip}value" : "1066-10-14"
+ }
+ }, {
+ "QName" : {
+ "Q{http://jsoniq.org/roundtrip}type" : "xs:QName",
+ "Q{http://jsoniq.org/roundtrip}value" : "Q{http://www.jsoniq.org/functions}encode-for-roundtrip",
+ "Q{http://jsoniq.org/roundtrip}prefix" : "jn"
+ },
+ "EQName" : {
+ "Q{http://jsoniq.org/roundtrip}type" : "xs:QName",
+ "Q{http://jsoniq.org/roundtrip}value" : "Q{http://jsoniq.org/roundtrip}value"
+ }
+ }))
+let $doub := $objs[1]
+let $date := $objs[2]
+let $qnam := $objs[3]
+return
+ (
+ $doub("nan") instance of xs:double and xs:string($doub("nan")) eq "NaN",
+ $doub("inf") instance of xs:double and xs:string($doub("inf")) eq "INF",
+ $date("date") instance of xs:date and year-from-date($date("date")) eq 1066,
+ $qnam("QName") instance of xs:QName and prefix-from-QName($qnam("QName")) eq "jn",
+ $qnam("EQName") instance of xs:QName and namespace-uri-from-QName($qnam("EQName")) eq "http://jsoniq.org/roundtrip"
+ )
=== added file 'test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_01.xq'
--- test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_01.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_01.xq 2012-09-21 03:00:26 +0000
@@ -0,0 +1,5 @@
+jn:encode-for-roundtrip({ "nan" : xs:double("NaN"),
+ "inf" : xs:double("INF"),
+ "date" : xs:date("1066-10-14"),
+ "QName" : xs:QName("jn:encode-for-roundtrip"),
+ "EQName" : fn:QName("http://jsoniq.org/roundtrip", "value") })
=== added file 'test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_02.xq'
--- test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_02.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_02.xq 2012-09-21 03:00:26 +0000
@@ -0,0 +1,1 @@
+jn:encode-for-roundtrip([ xs:double("NaN"), xs:double("INF"), xs:date("1066-10-14") ])
=== added file 'test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_03.xq'
--- test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_03.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_03.xq 2012-09-21 03:00:26 +0000
@@ -0,0 +1,9 @@
+{
+ "serialized XML" :
+ jn:encode-for-roundtrip(<para>
+ A pair named "[$prefix]value" (where [$prefix] is replaced with the
+ value of the parameter $prefix) and whose value is a serialization
+ of the XML node according to the XML output method and with the
+ serialization parameters specified by $param.
+ </para>)
+}
=== added file 'test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_04.xq'
--- test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_04.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_04.xq 2012-09-21 03:00:26 +0000
@@ -0,0 +1,15 @@
+import schema namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
+
+{
+ "serialized XML" :
+ jn:encode-for-roundtrip(<a><b>text<c>more text</c></b></a>,
+ {
+ "prefix" : "pre-",
+ "serialization-parameters" :
+ <output:serialization-parameters>
+ <output:indent value="yes"/>
+ <output:omit-xml-declaration value="yes"/>
+ </output:serialization-parameters>
+ }
+ )
+}
=== added file 'test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_05.spec'
--- test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_05.spec 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_05.spec 2012-09-21 03:00:26 +0000
@@ -0,0 +1,1 @@
+Error: http://www.jsoniq.org/errors:JNTY0023
=== added file 'test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_05.xq'
--- test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_05.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_05.xq 2012-09-21 03:00:26 +0000
@@ -0,0 +1,1 @@
+jn:encode-for-roundtrip({||}, { "prefix" : 1 })
=== added file 'test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_06.spec'
--- test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_06.spec 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_06.spec 2012-09-21 03:00:26 +0000
@@ -0,0 +1,1 @@
+Error: http://www.jsoniq.org/errors:JNTY0023
=== added file 'test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_06.xq'
--- test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_06.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_06.xq 2012-09-21 03:00:26 +0000
@@ -0,0 +1,3 @@
+jn:encode-for-roundtrip(
+ <a/>, { "serialization-parameters" : comment { "not an element" } }
+)
=== added file 'test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_07.spec'
--- test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_07.spec 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_07.spec 2012-09-21 03:00:26 +0000
@@ -0,0 +1,1 @@
+Error: http://www.w3.org/2005/xqt-errors:XQDY0027
\ No newline at end of file
=== added file 'test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_07.xq'
--- test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_07.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_07.xq 2012-09-21 03:00:26 +0000
@@ -0,0 +1,3 @@
+jn:encode-for-roundtrip(
+ <a/>, { "serialization-parameters" : <a>bad element name</a> }
+)
=== added file 'test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_08.xq'
--- test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_08.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_08.xq 2012-09-21 03:00:26 +0000
@@ -0,0 +1,11 @@
+jn:encode-for-roundtrip((
+ {
+ "nan" : xs:double("NaN"),
+ "inf" : xs:double("INF")
+ }, {
+ "date" : xs:date("1066-10-14")
+ }, {
+ "QName" : xs:QName("jn:encode-for-roundtrip"),
+ "EQName" : fn:QName("http://jsoniq.org/roundtrip", "value")
+ }
+))
\ No newline at end of file
=== added file 'test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_09.xq'
--- test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_09.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/roundtrip/encode_09.xq 2012-09-21 03:00:26 +0000
@@ -0,0 +1,5 @@
+import schema namespace s = "http://www.zorba-xquery.com/simple" at "simple.xsd";
+
+jn:encode-for-roundtrip({
+ "hatSize" : s:HatSizeType("10")
+})
\ No newline at end of file
=== added file 'test/rbkt/Queries/zorba/jsoniq/roundtrip/encoded_01.json'
--- test/rbkt/Queries/zorba/jsoniq/roundtrip/encoded_01.json 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/roundtrip/encoded_01.json 2012-09-21 03:00:26 +0000
@@ -0,0 +1,1 @@
+{ "serialized XML" : { "Q{http://jsoniq.org/roundtrip}type" : "node()", "Q{http://jsoniq.org/roundtrip}value" : "<para>\n A pair named \"[$prefix]value\" (where [$prefix] is replaced with the\n value of the parameter $prefix) and whose value is a serialization\n of the XML node according to the XML output method and with the\n serialization parameters specified by $param.\n </para>" } }
\ No newline at end of file
=== added file 'test/rbkt/Queries/zorba/jsoniq/roundtrip/roundtrip_01.xq'
--- test/rbkt/Queries/zorba/jsoniq/roundtrip/roundtrip_01.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/roundtrip/roundtrip_01.xq 2012-09-21 03:00:26 +0000
@@ -0,0 +1,10 @@
+let $obj := {
+ "nan" : xs:double("NaN"),
+ "inf" : xs:double("INF"),
+ "date" : xs:date("1066-10-14"),
+ "QName" : xs:QName("jn:encode-for-roundtrip"),
+ "EQName" : fn:QName("http://jsoniq.org/roundtrip", "value")
+ }
+let $enc := jn:encode-for-roundtrip($obj)
+let $dec := jn:decode-from-roundtrip($enc)
+return jn:encode-for-roundtrip($dec)
=== added file 'test/rbkt/Queries/zorba/jsoniq/roundtrip/roundtrip_02.xq'
--- test/rbkt/Queries/zorba/jsoniq/roundtrip/roundtrip_02.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/roundtrip/roundtrip_02.xq 2012-09-21 03:00:26 +0000
@@ -0,0 +1,27 @@
+import module namespace f = "http://expath.org/ns/file";
+import module namespace r = "http://www.zorba-xquery.com/modules/random";
+
+import schema namespace o = "http://www.w3.org/2010/xslt-xquery-serialization";
+
+variable $filename := r:uuid() || ".json";
+
+variable $obj := {
+ "nan" : xs:double("NaN"),
+ "inf" : xs:double("INF"),
+ "date" : xs:date("1066-10-14"),
+ "QName" : xs:QName("jn:encode-for-roundtrip"),
+ "EQName" : fn:QName("http://jsoniq.org/roundtrip", "value")
+ };
+variable $enc := jn:encode-for-roundtrip($obj);
+f:write($filename, $enc, <o:serialization-parameters><o:method value="json"/></o:serialization-parameters>);
+variable $read := f:read-text($filename);
+variable $dec := jn:decode-from-roundtrip(jn:parse-json($read));
+f:delete($filename);
+
+(
+ $dec("nan") instance of xs:double and xs:string($dec("nan")) eq "NaN",
+ $dec("inf") instance of xs:double and xs:string($dec("inf")) eq "INF",
+ $dec("date") instance of xs:date and year-from-date($dec("date")) eq 1066,
+ $dec("QName") instance of xs:QName and prefix-from-QName($dec("QName")) eq "jn",
+ $dec("EQName") instance of xs:QName and namespace-uri-from-QName($dec("EQName")) eq "http://jsoniq.org/roundtrip"
+)
=== added file 'test/rbkt/Queries/zorba/jsoniq/roundtrip/roundtrip_03.xq'
--- test/rbkt/Queries/zorba/jsoniq/roundtrip/roundtrip_03.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/roundtrip/roundtrip_03.xq 2012-09-21 03:00:26 +0000
@@ -0,0 +1,5 @@
+jn:encode-for-roundtrip(
+ jn:decode-from-roundtrip(
+ jn:encode-for-roundtrip({ "foo" : <a id="bar"/> })
+ )
+)
=== added file 'test/rbkt/Queries/zorba/jsoniq/roundtrip/roundtrip_04.xq'
--- test/rbkt/Queries/zorba/jsoniq/roundtrip/roundtrip_04.xq 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/roundtrip/roundtrip_04.xq 2012-09-21 03:00:26 +0000
@@ -0,0 +1,8 @@
+import schema namespace s = "http://www.zorba-xquery.com/simple" at "simple.xsd";
+
+let $encoded := jn:encode-for-roundtrip({
+ "hatSize" : s:HatSizeType("10")
+ })
+let $decoded := jn:decode-from-roundtrip($encoded)
+return
+ ($decoded, $decoded("hatSize") instance of s:HatSizeType)
\ No newline at end of file
=== added file 'test/rbkt/Queries/zorba/jsoniq/roundtrip/simple.xsd'
--- test/rbkt/Queries/zorba/jsoniq/roundtrip/simple.xsd 1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/roundtrip/simple.xsd 2012-09-21 03:00:26 +0000
@@ -0,0 +1,14 @@
+<xs:schema
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.zorba-xquery.com/simple"
+ xmlns="http://www.zorba-xquery.com/simple"
+ elementFormDefault="qualified">
+
+ <xs:simpleType name="HatSizeType">
+ <xs:restriction base="xs:int">
+ <xs:minInclusive value="7"/>
+ <xs:maxInclusive value="12"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+</xs:schema>
=== removed file 'test/rbkt/Queries/zorba/jsoniq/serializer-jsoniq-allow-mixed-1.spec'
--- test/rbkt/Queries/zorba/jsoniq/serializer-jsoniq-allow-mixed-1.spec 2012-06-19 14:58:25 +0000
+++ test/rbkt/Queries/zorba/jsoniq/serializer-jsoniq-allow-mixed-1.spec 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-Serialization: jsoniq-allow-mixed-xdm-jdm=yes
=== removed file 'test/rbkt/Queries/zorba/jsoniq/serializer-jsoniq-allow-mixed-2.spec'
--- test/rbkt/Queries/zorba/jsoniq/serializer-jsoniq-allow-mixed-2.spec 2012-06-19 14:58:25 +0000
+++ test/rbkt/Queries/zorba/jsoniq/serializer-jsoniq-allow-mixed-2.spec 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-Serialization: jsoniq-allow-mixed-xdm-jdm=yes
\ No newline at end of file
=== modified file 'test/rbkt/Queries/zorba/jsoniq/serializer-jsoniq-disallow-mixed-1.spec'
--- test/rbkt/Queries/zorba/jsoniq/serializer-jsoniq-disallow-mixed-1.spec 2012-06-19 14:58:25 +0000
+++ test/rbkt/Queries/zorba/jsoniq/serializer-jsoniq-disallow-mixed-1.spec 2012-09-21 03:00:26 +0000
@@ -1,1 +1,2 @@
-Error: http://www.zorba-xquery.com/errors:ZAPI0045
+Serialization: method=json
+Error: http://www.jsoniq.org/errors:JNSE0014
=== modified file 'test/rbkt/Queries/zorba/jsoniq/serializer-jsoniq-disallow-mixed-2.spec'
--- test/rbkt/Queries/zorba/jsoniq/serializer-jsoniq-disallow-mixed-2.spec 2012-06-19 14:58:25 +0000
+++ test/rbkt/Queries/zorba/jsoniq/serializer-jsoniq-disallow-mixed-2.spec 2012-09-21 03:00:26 +0000
@@ -1,1 +1,2 @@
-Error: http://www.zorba-xquery.com/errors:ZAPI0045
+Serialization: method=json
+Error: http://www.jsoniq.org/errors:JNSE0014
=== modified file 'test/rbkt/Queries/zorba/jsoniq/serializer-jsoniq-disallow-mixed-3.spec'
--- test/rbkt/Queries/zorba/jsoniq/serializer-jsoniq-disallow-mixed-3.spec 2012-07-09 16:02:55 +0000
+++ test/rbkt/Queries/zorba/jsoniq/serializer-jsoniq-disallow-mixed-3.spec 2012-09-21 03:00:26 +0000
@@ -1,2 +1,2 @@
-Error: http://www.zorba-xquery.com/errors:ZAPI0045
-Error: http://www.jsoniq.org/errors:JNSE0012
+Serialization: method=json
+Error: http://www.jsoniq.org/errors:JNSE0014
=== modified file 'test/rbkt/Queries/zorba/jsoniq/serializer-jsoniq-disallow-mixed-4.spec'
--- test/rbkt/Queries/zorba/jsoniq/serializer-jsoniq-disallow-mixed-4.spec 2012-07-09 16:02:55 +0000
+++ test/rbkt/Queries/zorba/jsoniq/serializer-jsoniq-disallow-mixed-4.spec 2012-09-21 03:00:26 +0000
@@ -1,2 +1,2 @@
-Error: http://www.zorba-xquery.com/errors:ZAPI0045
-Error: http://www.jsoniq.org/errors:JNSE0012
+Serialization: method=json
+Error: http://www.jsoniq.org/errors:JNSE0014
=== modified file 'test/rbkt/Queries/zorba/jsoniq/true_false_null.spec'
--- test/rbkt/Queries/zorba/jsoniq/true_false_null.spec 2012-09-17 00:36:37 +0000
+++ test/rbkt/Queries/zorba/jsoniq/true_false_null.spec 2012-09-21 03:00:26 +0000
@@ -1,1 +1,1 @@
-Serialization: method=json jsoniq-multiple-items=appended
+Serialization: method=json
=== modified file 'test/rbkt/Queries/zorba/jsoniq/use_case05.spec'
--- test/rbkt/Queries/zorba/jsoniq/use_case05.spec 2012-09-17 00:36:37 +0000
+++ test/rbkt/Queries/zorba/jsoniq/use_case05.spec 2012-09-21 03:00:26 +0000
@@ -1,1 +1,1 @@
-Serialization: method=json jsoniq-multiple-items=appended
+Serialization: method=json
=== modified file 'test/rbkt/Queries/zorba/serialization/cloudscript/extensions1.spec'
--- test/rbkt/Queries/zorba/serialization/cloudscript/extensions1.spec 2012-03-20 08:29:58 +0000
+++ test/rbkt/Queries/zorba/serialization/cloudscript/extensions1.spec 2012-09-21 03:00:26 +0000
@@ -1,2 +1,1 @@
-Error: http://www.jsoniq.org/errors:JNSE0013
Serialization: method=json
=== modified file 'test/rbkt/Queries/zorba/serialization/cloudscript/extensions1.xq'
--- test/rbkt/Queries/zorba/serialization/cloudscript/extensions1.xq 2012-03-20 08:29:58 +0000
+++ test/rbkt/Queries/zorba/serialization/cloudscript/extensions1.xq 2012-09-21 03:00:26 +0000
@@ -1,3 +1,1 @@
-(: Serializing NaN should be an error by default :)
-
xs:double("NaN")
=== removed file 'test/rbkt/Queries/zorba/serialization/cloudscript/extensions1a.spec'
--- test/rbkt/Queries/zorba/serialization/cloudscript/extensions1a.spec 2012-09-17 00:36:37 +0000
+++ test/rbkt/Queries/zorba/serialization/cloudscript/extensions1a.spec 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-Serialization: method=json jsoniq-extensions=yes
=== removed file 'test/rbkt/Queries/zorba/serialization/cloudscript/extensions1a.xq'
--- test/rbkt/Queries/zorba/serialization/cloudscript/extensions1a.xq 2012-09-17 00:36:37 +0000
+++ test/rbkt/Queries/zorba/serialization/cloudscript/extensions1a.xq 1970-01-01 00:00:00 +0000
@@ -1,3 +0,0 @@
-(: Serializing NaN is OK with jsoniq-extensions :)
-
-xs:double("NaN")
=== modified file 'test/rbkt/Queries/zorba/serialization/cloudscript/extensions2.spec'
--- test/rbkt/Queries/zorba/serialization/cloudscript/extensions2.spec 2012-03-20 08:29:58 +0000
+++ test/rbkt/Queries/zorba/serialization/cloudscript/extensions2.spec 2012-09-21 03:00:26 +0000
@@ -1,2 +1,1 @@
-Error: http://www.jsoniq.org/errors:JNSE0013
Serialization: method=json
=== modified file 'test/rbkt/Queries/zorba/serialization/cloudscript/extensions2.xq'
--- test/rbkt/Queries/zorba/serialization/cloudscript/extensions2.xq 2012-03-20 08:29:58 +0000
+++ test/rbkt/Queries/zorba/serialization/cloudscript/extensions2.xq 2012-09-21 03:00:26 +0000
@@ -1,3 +1,1 @@
-(: Serializing infinity should be an error by default :)
-
xs:double("-INF")
=== removed file 'test/rbkt/Queries/zorba/serialization/cloudscript/extensions2a.spec'
--- test/rbkt/Queries/zorba/serialization/cloudscript/extensions2a.spec 2012-09-17 00:36:37 +0000
+++ test/rbkt/Queries/zorba/serialization/cloudscript/extensions2a.spec 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-Serialization: method=json jsoniq-extensions=yes
=== removed file 'test/rbkt/Queries/zorba/serialization/cloudscript/extensions2a.xq'
--- test/rbkt/Queries/zorba/serialization/cloudscript/extensions2a.xq 2012-09-17 00:36:37 +0000
+++ test/rbkt/Queries/zorba/serialization/cloudscript/extensions2a.xq 1970-01-01 00:00:00 +0000
@@ -1,3 +0,0 @@
-(: Serializing infinity is OK with jsoniq-extensions :)
-
-xs:double("-INF")
=== modified file 'test/rbkt/Queries/zorba/serialization/cloudscript/extensions3.spec'
--- test/rbkt/Queries/zorba/serialization/cloudscript/extensions3.spec 2012-03-20 08:29:58 +0000
+++ test/rbkt/Queries/zorba/serialization/cloudscript/extensions3.spec 2012-09-21 03:00:26 +0000
@@ -1,2 +1,2 @@
-Error: http://www.jsoniq.org/errors:JNSE0013
+Error: http://www.jsoniq.org/errors:JNSE0014
Serialization: method=json
=== modified file 'test/rbkt/Queries/zorba/serialization/cloudscript/extensions3.xq'
--- test/rbkt/Queries/zorba/serialization/cloudscript/extensions3.xq 2012-03-20 08:29:58 +0000
+++ test/rbkt/Queries/zorba/serialization/cloudscript/extensions3.xq 2012-09-21 03:00:26 +0000
@@ -1,4 +1,1 @@
-(: Serializing XML should be an error by default :)
-
<a/>
-
=== removed file 'test/rbkt/Queries/zorba/serialization/cloudscript/extensions3a.spec'
--- test/rbkt/Queries/zorba/serialization/cloudscript/extensions3a.spec 2012-09-17 00:36:37 +0000
+++ test/rbkt/Queries/zorba/serialization/cloudscript/extensions3a.spec 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-Serialization: method=json jsoniq-extensions=yes
=== modified file 'test/rbkt/Queries/zorba/serialization/cloudscript/extensions3a.xq'
--- test/rbkt/Queries/zorba/serialization/cloudscript/extensions3a.xq 2012-09-17 00:36:37 +0000
+++ test/rbkt/Queries/zorba/serialization/cloudscript/extensions3a.xq 2012-09-21 03:00:26 +0000
@@ -1,3 +1,1 @@
-(: Serializing XML is OK with jsoniq-extensions :)
-
<a/>
=== modified file 'test/rbkt/Queries/zorba/serialization/cloudscript/multiple1.spec'
--- test/rbkt/Queries/zorba/serialization/cloudscript/multiple1.spec 2012-03-20 08:29:58 +0000
+++ test/rbkt/Queries/zorba/serialization/cloudscript/multiple1.spec 2012-09-21 03:00:26 +0000
@@ -1,2 +1,2 @@
Error: http://www.jsoniq.org/errors:JNSE0012
-Serialization: method=json
+Serialization: method=json jsoniq-multiple-items=no
=== modified file 'test/rbkt/Queries/zorba/serialization/cloudscript/multiple2.spec'
--- test/rbkt/Queries/zorba/serialization/cloudscript/multiple2.spec 2012-09-17 00:36:37 +0000
+++ test/rbkt/Queries/zorba/serialization/cloudscript/multiple2.spec 2012-09-21 03:00:26 +0000
@@ -1,1 +1,1 @@
-Serialization: method=json jsoniq-multiple-items=appended
+Serialization: method=json
=== modified file 'test/rbkt/Queries/zorba/serialization/cloudscript/multiple2.xq'
--- test/rbkt/Queries/zorba/serialization/cloudscript/multiple2.xq 2012-09-17 00:36:37 +0000
+++ test/rbkt/Queries/zorba/serialization/cloudscript/multiple2.xq 2012-09-21 03:00:26 +0000
@@ -1,3 +1,1 @@
-(: With jsoniq-multiple-items="appended", all items are serialized :)
-
[1], [2]
=== modified file 'test/rbkt/testdriver.cpp'
--- test/rbkt/testdriver.cpp 2012-09-17 00:36:37 +0000
+++ test/rbkt/testdriver.cpp 2012-09-21 03:00:26 +0000
@@ -435,7 +435,7 @@
// testdriver_mt as well
// Initialize default serialization method
#ifdef ZORBA_WITH_JSON
- lSerOptions.ser_method = ZORBA_SERIALIZATION_METHOD_JSONIQ;
+ lSerOptions.ser_method = ZORBA_SERIALIZATION_METHOD_JSON_XML_HYBRID;
#else /* ZORBA_WITH_JSON */
lSerOptions.ser_method = ZORBA_SERIALIZATION_METHOD_XML;
#endif /* ZORBA_WITH_JSON */
Follow ups
-
[Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: noreply, 2012-09-21
-
[Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Zorba Build Bot, 2012-09-21
-
[Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Zorba Build Bot, 2012-09-21
-
[Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Till Westmann, 2012-09-21
-
Re: [Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Paul J. Lucas, 2012-09-21
-
[Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Zorba Build Bot, 2012-09-21
-
Re: [Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Zorba Build Bot, 2012-09-21
-
[Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Zorba Build Bot, 2012-09-21
-
[Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Zorba Build Bot, 2012-09-21
-
[Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Matthias Brantner, 2012-09-21
-
Re: [Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Matthias Brantner, 2012-09-21
-
Re: [Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Matthias Brantner, 2012-09-21
-
Re: [Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Chris Hillery, 2012-09-21
-
[Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Zorba Build Bot, 2012-09-21
-
Re: [Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Zorba Build Bot, 2012-09-21
-
[Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Zorba Build Bot, 2012-09-21
-
[Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Zorba Build Bot, 2012-09-21
-
[Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Till Westmann, 2012-09-21
-
[Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Zorba Build Bot, 2012-09-21
-
Re: [Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Zorba Build Bot, 2012-09-21
-
[Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Zorba Build Bot, 2012-09-21
-
[Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Till Westmann, 2012-09-21
-
[Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Zorba Build Bot, 2012-09-21
-
Re: [Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Zorba Build Bot, 2012-09-21
-
[Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Zorba Build Bot, 2012-09-21
-
Re: [Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Paul J. Lucas, 2012-09-21
-
Re: [Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Paul J. Lucas, 2012-09-21
-
[Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Zorba Build Bot, 2012-09-21
-
[Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Till Westmann, 2012-09-21
-
[Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Zorba Build Bot, 2012-09-21
-
Re: [Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Zorba Build Bot, 2012-09-21
-
[Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Zorba Build Bot, 2012-09-21
-
[Merge] lp:~zorba-coders/zorba/jsoniq-roundtrip into lp:zorba
From: Till Westmann, 2012-09-21