Merge lp:~zorba-coders/zorba/jsoniq into lp:zorba

Proposed by Matthias Brantner
Status: Superseded
Proposed branch: lp:~zorba-coders/zorba/jsoniq
Merge into: lp:zorba
Diff against target: 79233 lines (+39574/-18462) (has conflicts)
481 files modified
.bzrignore (+2/-0)
CMakeConfiguration.txt (+3/-0)
ChangeLog (+1/-0)
NOTICE.txt (+0/-740)
doc/cxx/examples/CMakeLists.txt (+9/-0)
doc/cxx/examples/jsoniq.cpp (+392/-0)
doc/zorba/CMakeLists.txt (+4/-0)
doc/zorba/JSONforXQuery.html (+1/-0)
doc/zorba/XQueryforJSON.html (+1/-0)
doc/zorba/indexpage.dox.in (+9/-1)
include/zorba/config.h.cmake (+1/-0)
include/zorba/diagnostic.h (+9/-1)
include/zorba/error.h (+7/-0)
include/zorba/identtypes.h (+16/-4)
include/zorba/internal/qname.h (+40/-0)
include/zorba/item.h (+92/-0)
include/zorba/item_factory.h (+46/-1)
include/zorba/options.h (+5/-1)
include/zorba/pregenerated/diagnostic_list.h (+70/-0)
include/zorba/store_consts.h (+42/-8)
include/zorba/typeident.h (+44/-34)
modules/ExternalModules.conf (+1/-1)
modules/com/zorba-xquery/www/modules/CMakeLists.txt (+5/-0)
modules/com/zorba-xquery/www/modules/converters/json-options.xsd (+47/-0)
modules/com/zorba-xquery/www/modules/converters/json.xq (+231/-0)
modules/com/zorba-xquery/www/modules/pregenerated/errors.xq (+73/-1)
modules/com/zorba-xquery/www/modules/store/jsoniq/dynamic/collections/ddl.xq (+122/-0)
modules/com/zorba-xquery/www/modules/store/jsoniq/dynamic/collections/dml.xq (+354/-0)
modules/org/CMakeLists.txt (+2/-0)
modules/org/jsoniq/CMakeLists.txt (+15/-0)
modules/org/jsoniq/www/CMakeLists.txt (+21/-0)
modules/org/jsoniq/www/functions.xq (+389/-0)
modules/org/jsoniq/www/pregenerated/errors.xq (+109/-0)
src/annotations/annotations.h (+1/-1)
src/api/collectionimpl.cpp (+11/-6)
src/api/dynamiccontextimpl.cpp (+2/-1)
src/api/item.cpp (+108/-0)
src/api/itemfactoryimpl.cpp (+61/-0)
src/api/itemfactoryimpl.h (+18/-0)
src/api/options.cpp (+12/-1)
src/api/serialization/serializer.cpp (+390/-26)
src/api/serialization/serializer.h (+116/-19)
src/api/serializerimpl.cpp (+18/-3)
src/api/typeidentimpl.cpp (+61/-7)
src/compiler/codegen/plan_visitor.cpp (+110/-6)
src/compiler/expression/CMakeLists.txt (+1/-0)
src/compiler/expression/abstract_expr_visitor.h (+9/-2)
src/compiler/expression/expr.cpp (+4/-6)
src/compiler/expression/expr.h (+6/-0)
src/compiler/expression/expr_annotations.cpp (+0/-71)
src/compiler/expression/expr_annotations.h (+0/-54)
src/compiler/expression/expr_base.cpp (+5/-0)
src/compiler/expression/expr_base.h (+6/-0)
src/compiler/expression/expr_classes.h (+6/-0)
src/compiler/expression/expr_iter.cpp (+40/-0)
src/compiler/expression/expr_put.cpp (+44/-14)
src/compiler/expression/expr_type.cpp (+40/-26)
src/compiler/expression/expr_visitor.h (+6/-0)
src/compiler/expression/flwor_expr.cpp (+1/-1)
src/compiler/expression/fo_expr.cpp (+1/-2)
src/compiler/expression/json_exprs.cpp (+197/-0)
src/compiler/expression/json_exprs.h (+156/-0)
src/compiler/expression/script_exprs.h (+0/-14)
src/compiler/parser/location.hh (+4/-11)
src/compiler/parser/position.hh (+11/-22)
src/compiler/parser/stack.hh (+6/-14)
src/compiler/parser/xquery_parser.cpp (+9027/-8592)
src/compiler/parser/xquery_parser.hpp (+39/-75)
src/compiler/parser/xquery_parser.y (+182/-58)
src/compiler/parser/xquery_scanner.cpp (+3215/-3117)
src/compiler/parser/xquery_scanner.l (+35/-12)
src/compiler/parsetree/parsenode_print_dot_visitor.h (+6/-0)
src/compiler/parsetree/parsenode_print_xml_visitor.cpp (+84/-27)
src/compiler/parsetree/parsenode_print_xqdoc_visitor.cpp (+9/-2)
src/compiler/parsetree/parsenode_print_xquery_visitor.cpp (+31/-13)
src/compiler/parsetree/parsenode_visitor.h (+8/-0)
src/compiler/parsetree/parsenodes.cpp (+121/-3)
src/compiler/parsetree/parsenodes.h (+123/-5)
src/compiler/rewriter/rules/flwor_rules.cpp (+4/-9)
src/compiler/rewriter/rules/fold_rules.cpp (+4/-8)
src/compiler/rewriter/rules/hoist_rules.cpp (+2/-4)
src/compiler/rewriter/rules/index_join_rule.cpp (+3/-3)
src/compiler/rewriter/rules/nodeid_rules.cpp (+85/-12)
src/compiler/rewriter/rules/type_rules.cpp (+19/-2)
src/compiler/rewriter/tools/dataflow_annotations.cpp (+15/-3)
src/compiler/translator/translator.cpp (+566/-106)
src/compiler/xqddf/value_index.cpp (+1/-1)
src/context/default_url_resolvers.cpp (+1/-1)
src/context/root_static_context.cpp (+12/-11)
src/context/static_context.cpp (+54/-7)
src/context/static_context.h (+9/-0)
src/diagnostics/CMakeLists.txt (+22/-3)
src/diagnostics/diagnostic.cpp (+8/-0)
src/diagnostics/diagnostic_en.xml (+218/-19)
src/diagnostics/diagnostic_list_cpp.xq (+1/-0)
src/diagnostics/diagnostic_list_h.xq (+1/-0)
src/diagnostics/diagnostic_list_xq.xq (+3/-1)
src/diagnostics/pregenerated/diagnostic_list.cpp (+102/-0)
src/diagnostics/pregenerated/dict_en.cpp (+80/-7)
src/diagnostics/qname.cpp (+41/-0)
src/functions/CMakeLists.txt (+6/-0)
src/functions/func_accessors_impl.cpp (+1/-1)
src/functions/func_arithmetic.cpp (+5/-5)
src/functions/func_booleans_impl.cpp (+1/-1)
src/functions/func_collections_impl.cpp (+651/-331)
src/functions/func_enclosed.cpp (+41/-1)
src/functions/func_jsoniq_functions_impl.cpp (+99/-0)
src/functions/func_sequences_impl.cpp (+8/-4)
src/functions/function.cpp (+3/-5)
src/functions/library.cpp (+10/-0)
src/functions/pregenerated/func_accessors.cpp (+36/-36)
src/functions/pregenerated/func_any_uri.cpp (+6/-6)
src/functions/pregenerated/func_base64.cpp (+6/-6)
src/functions/pregenerated/func_booleans.cpp (+9/-9)
src/functions/pregenerated/func_collections.cpp (+641/-291)
src/functions/pregenerated/func_collections.h (+348/-348)
src/functions/pregenerated/func_context.cpp (+24/-24)
src/functions/pregenerated/func_documents.cpp (+15/-15)
src/functions/pregenerated/func_durations_dates_times.cpp (+63/-63)
src/functions/pregenerated/func_errors_and_diagnostics.cpp (+15/-15)
src/functions/pregenerated/func_fetch.cpp (+6/-6)
src/functions/pregenerated/func_fnput.cpp (+3/-3)
src/functions/pregenerated/func_function_item_iter.cpp (+12/-12)
src/functions/pregenerated/func_ic_ddl.cpp (+9/-9)
src/functions/pregenerated/func_json.cpp (+87/-0)
src/functions/pregenerated/func_json.h (+79/-0)
src/functions/pregenerated/func_jsoniq_functions.cpp (+707/-0)
src/functions/pregenerated/func_jsoniq_functions.h (+523/-0)
src/functions/pregenerated/func_maps.cpp (+28/-28)
src/functions/pregenerated/func_maths.cpp (+78/-78)
src/functions/pregenerated/func_node_position.cpp (+72/-72)
src/functions/pregenerated/func_nodes.cpp (+75/-75)
src/functions/pregenerated/func_numerics.cpp (+33/-33)
src/functions/pregenerated/func_other_diagnostics.cpp (+6/-6)
src/functions/pregenerated/func_parse_fragment.cpp (+6/-6)
src/functions/pregenerated/func_parsing_and_serializing.cpp (+12/-12)
src/functions/pregenerated/func_qnames.cpp (+24/-24)
src/functions/pregenerated/func_random.cpp (+12/-12)
src/functions/pregenerated/func_schema.cpp (+12/-12)
src/functions/pregenerated/func_sctx.cpp (+75/-75)
src/functions/pregenerated/func_sequences.cpp (+121/-121)
src/functions/pregenerated/func_strings.cpp (+136/-136)
src/functions/pregenerated/func_xqdoc.cpp (+6/-6)
src/functions/pregenerated/function_enum.h (+94/-46)
src/precompiled/stdafx.h (+1/-1)
src/runtime/CMakeLists.txt (+7/-0)
src/runtime/accessors/accessors_impl.cpp (+22/-3)
src/runtime/base/plan_iterator.h (+4/-0)
src/runtime/booleans/BooleanImpl.cpp (+55/-36)
src/runtime/collections/collections_base.cpp (+25/-18)
src/runtime/collections/collections_base.h (+45/-56)
src/runtime/collections/collections_impl.cpp (+506/-658)
src/runtime/collections/collections_impl.h (+12/-3)
src/runtime/collections/pregenerated/collections.h (+137/-84)
src/runtime/core/constructors.cpp (+15/-17)
src/runtime/core/constructors.h (+12/-0)
src/runtime/core/path_iterators.cpp (+39/-33)
src/runtime/core/path_iterators.h (+2/-2)
src/runtime/core/sequencetypes.cpp (+15/-15)
src/runtime/json/jansson_wrapper.cpp (+729/-0)
src/runtime/json/jansson_wrapper.h (+56/-0)
src/runtime/json/json_constructors.cpp (+276/-0)
src/runtime/json/json_constructors.h (+135/-0)
src/runtime/json/json_impl.cpp (+527/-0)
src/runtime/json/jsoniq_functions_impl.cpp (+1048/-0)
src/runtime/json/pregenerated/json.cpp (+94/-0)
src/runtime/json/pregenerated/json.h (+114/-0)
src/runtime/json/pregenerated/jsoniq_functions.cpp (+679/-0)
src/runtime/json/pregenerated/jsoniq_functions.h (+928/-0)
src/runtime/scripting/scripting.cpp (+61/-2)
src/runtime/scripting/scripting.h (+8/-0)
src/runtime/spec/codegen-cpp.xq (+20/-7)
src/runtime/spec/codegen-h.xq (+13/-0)
src/runtime/spec/collections/collections.xml (+436/-316)
src/runtime/spec/json/json.xml (+52/-0)
src/runtime/spec/json/jsoniq_functions.xml (+638/-0)
src/runtime/spec/mappings.xml (+35/-15)
src/runtime/update/update.cpp (+5/-1)
src/runtime/visitors/planiter_visitor_impl_code.h (+8/-0)
src/runtime/visitors/planiter_visitor_impl_include.h (+7/-0)
src/runtime/visitors/pregenerated/planiter_visitor.h (+164/-0)
src/runtime/visitors/pregenerated/printer_visitor.cpp (+360/-0)
src/runtime/visitors/pregenerated/printer_visitor.h (+116/-0)
src/runtime/visitors/printer_visitor_impl.cpp (+8/-0)
src/runtime/visitors/printer_visitor_impl.h (+5/-0)
src/store/api/collection.h (+7/-4)
src/store/api/item.h (+105/-13)
src/store/api/item_factory.h (+21/-0)
src/store/api/pul.h (+66/-8)
src/store/api/store.h (+25/-6)
src/store/api/update_consts.h (+23/-0)
src/store/api/xs_type_codes.h (+2/-0)
src/store/naive/CMakeLists.txt (+8/-0)
src/store/naive/collection_set.cpp (+41/-25)
src/store/naive/collection_set.h (+86/-85)
src/store/naive/item.cpp (+177/-29)
src/store/naive/json_items.cpp (+704/-0)
src/store/naive/json_items.h (+482/-0)
src/store/naive/json_loader.cpp (+312/-0)
src/store/naive/json_loader.h (+72/-0)
src/store/naive/name_iterator.h (+68/-62)
src/store/naive/node_items.cpp (+2/-3)
src/store/naive/node_items.h (+2/-2)
src/store/naive/pul_primitive_factory.cpp (+245/-169)
src/store/naive/pul_primitive_factory.h (+74/-8)
src/store/naive/pul_primitives.cpp (+380/-68)
src/store/naive/pul_primitives.h (+197/-27)
src/store/naive/shared_types.h (+22/-0)
src/store/naive/simple_collection.cpp (+411/-184)
src/store/naive/simple_collection.h (+29/-37)
src/store/naive/simple_item_factory.cpp (+106/-18)
src/store/naive/simple_item_factory.h (+24/-0)
src/store/naive/simple_pul.cpp (+439/-42)
src/store/naive/simple_pul.h (+88/-9)
src/store/naive/simple_store.cpp (+116/-24)
src/store/naive/simple_store.h (+29/-4)
src/types/casting.cpp (+124/-87)
src/types/casting.h (+2/-2)
src/types/root_typemanager.cpp (+254/-156)
src/types/root_typemanager.h (+72/-30)
src/types/schema/EventSchemaValidator.cpp (+3/-1)
src/types/schema/revalidateUtils.cpp (+3/-2)
src/types/schema/validate.cpp (+5/-2)
src/types/typeimpl.cpp (+416/-59)
src/types/typeimpl.h (+253/-175)
src/types/typemanager.h (+24/-16)
src/types/typemanagerimpl.cpp (+140/-95)
src/types/typemanagerimpl.h (+31/-23)
src/types/typeops.cpp (+663/-502)
src/types/typeops.h (+0/-39)
src/unit_tests/CMakeLists.txt (+2/-0)
src/unit_tests/json_parser.cpp (+636/-0)
src/unit_tests/json_parser.cpp.moved (+623/-0)
src/unit_tests/unit_test_list.h (+1/-0)
src/unit_tests/unit_tests.cpp (+1/-0)
src/util/CMakeLists.txt (+1/-0)
src/util/json_parser.cpp (+634/-0)
src/util/json_parser.h (+553/-0)
src/util/stl_util.h (+2/-0)
src/zorbamisc/ns_consts.h (+4/-0)
test/parser/parsertestdriver.cpp (+2/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx4.iter (+24/-22)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-idx4.iter (+24/-22)
test/rbkt/ExpQueryResults/zorba/json/json-parse-array-01.xml.res (+3/-0)
test/rbkt/ExpQueryResults/zorba/json/json-parse-array-02.xml.res (+3/-0)
test/rbkt/ExpQueryResults/zorba/json/json-parse-array-03.xml.res (+3/-0)
test/rbkt/ExpQueryResults/zorba/json/json-parse-array-04.xml.res (+3/-0)
test/rbkt/ExpQueryResults/zorba/json/json-parse-array-05.xml.res (+4/-0)
test/rbkt/ExpQueryResults/zorba/json/json-parse-object-01.xml.res (+3/-0)
test/rbkt/ExpQueryResults/zorba/json/json-parse-object-02.xml.res (+4/-0)
test/rbkt/ExpQueryResults/zorba/json/json-parse-snelson.xml.res (+14/-0)
test/rbkt/ExpQueryResults/zorba/json/json-serialize-array-01.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_01.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_02.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_03.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_14.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_15.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_16.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_17.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_18.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_21.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_210.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_211.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_212.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_213.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_22.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_23.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_24.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_25.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_26.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_27.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_28.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_29.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_3_1.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_3_2.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_3_3.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_3_4.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_3_5.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_3_6.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_3_7.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_4_1.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_4_2.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_4_3.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_5_1.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_5_2.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_6_1.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_6_3.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_7_1.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_7_2.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_7_3.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_7_5.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/arr_constr_7_6.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/coll_dyn_01.xml.res (+7/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/coll_dyn_03.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/delete01.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/delete02.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/delete10.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/delete11.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/ebv01.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/ebv02.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/ebv04.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/empty_member01.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/empty_member02.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/flatten_01.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/fn_boolean_01.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/insert01.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/insert03.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/insert04.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/insert05.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/insert06.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/member_01.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/names_01.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/names_02.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/null01.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/null02.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/null03.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/obj_constr_01.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/object_01.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/object_02.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/pair_01.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/rename01.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/replace01.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/string01.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/true_false_null.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/use_case01.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/use_case01_2.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/use_case02.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/use_case03.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/use_case04.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/use_case05.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/use_case06.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/use_case07.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/use_case08.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/use_case09.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/use_case10.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/use_case11.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/value_01.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/jsoniq/values_01.xml.res (+1/-0)
test/rbkt/Queries/CMakeLists.txt (+7/-0)
test/rbkt/Queries/zorba/json/json-parse-array-01.xq (+5/-0)
test/rbkt/Queries/zorba/json/json-parse-array-02.xq (+5/-0)
test/rbkt/Queries/zorba/json/json-parse-array-03.xq (+5/-0)
test/rbkt/Queries/zorba/json/json-parse-array-04.xq (+5/-0)
test/rbkt/Queries/zorba/json/json-parse-array-05.xq (+5/-0)
test/rbkt/Queries/zorba/json/json-parse-object-01.xq (+5/-0)
test/rbkt/Queries/zorba/json/json-parse-object-02.xq (+5/-0)
test/rbkt/Queries/zorba/json/json-parse-snelson.xq (+20/-0)
test/rbkt/Queries/zorba/json/json-serialize-array-01.xq (+8/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_01.xq (+4/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_02.xq (+2/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_03.xq (+2/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_14.xq (+2/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_15.xq (+7/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_16.xq (+4/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_17.xq (+5/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_18.xq (+4/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_21.xq (+6/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_210.xq (+9/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_211.xq (+9/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_212.xq (+9/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_213.xq (+9/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_22.xq (+7/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_23.xq (+6/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_24.xq (+6/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_25.xq (+6/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_26.xq (+10/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_27.xq (+10/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_28.xq (+10/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_29.xq (+9/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_3_1.xq (+11/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_3_2.xq (+10/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_3_3.xq (+10/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_3_4.xq (+14/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_3_5.xq (+6/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_3_6.xq (+6/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_3_7.xq (+6/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_4_1.xq (+3/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_4_2.xq (+2/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_4_3.xq (+1/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_5_1.xq (+2/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_5_2.xq (+2/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_6_1.xq (+2/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_6_2.xq (+2/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_6_3.xq (+2/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_7_1.xq (+2/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_7_2.xq (+2/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_7_3.xq (+2/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_7_4.xq (+2/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_7_5.xq (+2/-0)
test/rbkt/Queries/zorba/jsoniq/arr_constr_7_6.xq (+2/-0)
test/rbkt/Queries/zorba/jsoniq/coll_dyn_01.xq (+57/-0)
test/rbkt/Queries/zorba/jsoniq/coll_dyn_02.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/coll_dyn_02.xq (+16/-0)
test/rbkt/Queries/zorba/jsoniq/coll_dyn_03.xq (+95/-0)
test/rbkt/Queries/zorba/jsoniq/data01.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/data01.xq (+1/-0)
test/rbkt/Queries/zorba/jsoniq/data02.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/data02.xq (+1/-0)
test/rbkt/Queries/zorba/jsoniq/data03.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/data03.xq (+1/-0)
test/rbkt/Queries/zorba/jsoniq/data04.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/data04.xq (+1/-0)
test/rbkt/Queries/zorba/jsoniq/delete01.xq (+7/-0)
test/rbkt/Queries/zorba/jsoniq/delete02.xq (+8/-0)
test/rbkt/Queries/zorba/jsoniq/delete03.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/delete03.xq (+5/-0)
test/rbkt/Queries/zorba/jsoniq/delete04.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/delete04.xq (+6/-0)
test/rbkt/Queries/zorba/jsoniq/delete05.spec (+2/-0)
test/rbkt/Queries/zorba/jsoniq/delete05.xq (+5/-0)
test/rbkt/Queries/zorba/jsoniq/delete06.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/delete06.xq (+5/-0)
test/rbkt/Queries/zorba/jsoniq/delete07.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/delete07.xq (+5/-0)
test/rbkt/Queries/zorba/jsoniq/delete08.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/delete08.xq (+5/-0)
test/rbkt/Queries/zorba/jsoniq/delete09.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/delete09.xq (+5/-0)
test/rbkt/Queries/zorba/jsoniq/delete10.xq (+6/-0)
test/rbkt/Queries/zorba/jsoniq/delete11.xq (+11/-0)
test/rbkt/Queries/zorba/jsoniq/ebv01.xq (+3/-0)
test/rbkt/Queries/zorba/jsoniq/ebv02.xq (+5/-0)
test/rbkt/Queries/zorba/jsoniq/ebv03.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/ebv03.xq (+6/-0)
test/rbkt/Queries/zorba/jsoniq/ebv04.xq (+5/-0)
test/rbkt/Queries/zorba/jsoniq/empty_member01.xq (+7/-0)
test/rbkt/Queries/zorba/jsoniq/empty_member02.xq (+10/-0)
test/rbkt/Queries/zorba/jsoniq/flatten_01.xq (+3/-0)
test/rbkt/Queries/zorba/jsoniq/fn_boolean_01.xq (+5/-0)
test/rbkt/Queries/zorba/jsoniq/insert01.xq (+7/-0)
test/rbkt/Queries/zorba/jsoniq/insert02.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/insert02.xq (+3/-0)
test/rbkt/Queries/zorba/jsoniq/insert03.xq (+8/-0)
test/rbkt/Queries/zorba/jsoniq/insert04.xq (+12/-0)
test/rbkt/Queries/zorba/jsoniq/insert05.xq (+10/-0)
test/rbkt/Queries/zorba/jsoniq/insert06.xq (+27/-0)
test/rbkt/Queries/zorba/jsoniq/insert07.spec (+2/-0)
test/rbkt/Queries/zorba/jsoniq/insert07.xq (+9/-0)
test/rbkt/Queries/zorba/jsoniq/member_01.xq (+4/-0)
test/rbkt/Queries/zorba/jsoniq/member_03.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/member_03.xq (+5/-0)
test/rbkt/Queries/zorba/jsoniq/names_01.xq (+3/-0)
test/rbkt/Queries/zorba/jsoniq/names_02.xq (+4/-0)
test/rbkt/Queries/zorba/jsoniq/null01.xq (+3/-0)
test/rbkt/Queries/zorba/jsoniq/null02.xq (+3/-0)
test/rbkt/Queries/zorba/jsoniq/null03.xq (+4/-0)
test/rbkt/Queries/zorba/jsoniq/obj_constr_01.xq (+3/-0)
test/rbkt/Queries/zorba/jsoniq/object_01.xq (+4/-0)
test/rbkt/Queries/zorba/jsoniq/object_02.xq (+16/-0)
test/rbkt/Queries/zorba/jsoniq/pair_01.xq (+5/-0)
test/rbkt/Queries/zorba/jsoniq/parser_01.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/parser_01.xq (+3/-0)
test/rbkt/Queries/zorba/jsoniq/rename01.xq (+7/-0)
test/rbkt/Queries/zorba/jsoniq/rename02.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/rename02.xq (+5/-0)
test/rbkt/Queries/zorba/jsoniq/rename03.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/rename03.xq (+5/-0)
test/rbkt/Queries/zorba/jsoniq/replace01.xq (+8/-0)
test/rbkt/Queries/zorba/jsoniq/string01.xq (+1/-0)
test/rbkt/Queries/zorba/jsoniq/string02.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/string02.xq (+1/-0)
test/rbkt/Queries/zorba/jsoniq/true_false_null.xq (+3/-0)
test/rbkt/Queries/zorba/jsoniq/use_case01.xq (+30/-0)
test/rbkt/Queries/zorba/jsoniq/use_case01_2.xq (+29/-0)
test/rbkt/Queries/zorba/jsoniq/use_case02.xq (+26/-0)
test/rbkt/Queries/zorba/jsoniq/use_case03.xq (+59/-0)
test/rbkt/Queries/zorba/jsoniq/use_case04.xq (+32/-0)
test/rbkt/Queries/zorba/jsoniq/use_case05.xml (+44/-0)
test/rbkt/Queries/zorba/jsoniq/use_case05.xq (+10/-0)
test/rbkt/Queries/zorba/jsoniq/use_case06.xq (+16/-0)
test/rbkt/Queries/zorba/jsoniq/use_case07.xq (+33/-0)
test/rbkt/Queries/zorba/jsoniq/use_case08.xq (+24/-0)
test/rbkt/Queries/zorba/jsoniq/use_case09.xq (+33/-0)
test/rbkt/Queries/zorba/jsoniq/use_case10.xq (+20/-0)
test/rbkt/Queries/zorba/jsoniq/use_case11.xq (+53/-0)
test/rbkt/Queries/zorba/jsoniq/value_01.xq (+3/-0)
test/rbkt/Queries/zorba/jsoniq/values_01.xq (+4/-0)
test/rbkt/Queries/zorba/xqddf/daniel/i1.xq (+3/-1)
test/rbkt/specification.h (+7/-1)
test/rbkt/testdriver.cpp (+5/-0)
test/unit/CMakeLists.txt (+1/-0)
Text conflict in src/store/naive/item.cpp
Text conflict in src/store/naive/pul_primitives.cpp
Text conflict in src/store/naive/simple_collection.cpp
Text conflict in src/store/naive/simple_pul.cpp
Text conflict in src/store/naive/simple_store.cpp
To merge this branch: bzr merge lp:~zorba-coders/zorba/jsoniq
Reviewer Review Type Date Requested Status
Zorba Coders Pending
Review via email: mp+91966@code.launchpad.net

This proposal supersedes a proposal from 2012-02-07.

This proposal has been superseded by a proposal from 2012-02-09.

Commit message

...

Description of the change

Adds JSONiq.

To post a comment you must log in.
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

Validation queue starting for merge proposal.
Log at: http://zorbatest.lambda.nu:8080/remotequeue/-2012-01-31T00-53-26.285Z/log.html

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

The attempt to merge lp:zorba/3.0 into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:71 (list):
  list index: 2 out of range (-2, 1)

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job -2012-01-31T00-53-26.285Z is finished. The final
  status was:

  43 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

Validation queue starting for merge proposal.
Log at: http://zorbatest.lambda.nu:8080/remotequeue/-2012-01-31T01-44-59.475Z/log.html

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

The attempt to merge lp:zorba/3.0 into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:71 (list):
  list index: 2 out of range (-2, 1)

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job -2012-01-31T01-44-59.475Z is finished. The final
  status was:

  17 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

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

Attempt to merge into lp:zorba failed due to conflicts:

text conflict in src/store/naive/item.cpp
text conflict in src/store/naive/simple_pul.cpp

lp:~zorba-coders/zorba/jsoniq updated
10645. By Chris Hillery

Adding documentation for all functions.

10646. By Chris Hillery

Merge from trunk.

10647. By Chris Hillery

Added ItemFactory methods to create JSON items, along with test cases.

10648. By Markos Zaharioudakis

predeclared jn prefix

10649. By Markos Zaharioudakis

predeclared jn prefix (2nd try)

10650. By Matthias Brantner

commit the pre-generated parser files

10651. By Matthias Brantner

fixed jsoniq namespace + always process the jsoniq module because it contains udfs

10652. By Matthias Brantner

build fixes for without json

10653. By Matthias Brantner

added two tutorials as html. also temporarily removed the json module declaration
in order to make xqdoc work

10654. By Matthias Brantner

merge with trunk

10655. By Matthias Brantner

always indent by default in the swig bindings (this is a hack to get a nicer output in the web interface)

10656. By Matthias Brantner

fixed output of JSON_Test in xqdoc (e.g. array())

10657. By Chris Hillery

Allow "jsoniq" serialization method to serve for SAX output.

10658. By Chris Hillery

There are now 6 built-in namespace bindings (including jn: ).

10659. By Chris Hillery

Use Store::populateJSONArray() in ItemFactory.

10660. By Matthias Brantner

updated namespace prefix in the jsoniq module to jn

10661. By Matthias Brantner

- revert rev. 10655
- in execute, make the default indent + no xml decl

10662. By Matthias Brantner

updated jsoniq tutorials to latest drafts

10663. By Nicolae Brinza

Implementation of the new Cloudscript grammar.

10664. By Markos Zaharioudakis

removed pairs from type system and compiler

10665. By Markos Zaharioudakis

merge from trunk

10666. By Markos Zaharioudakis

forbid json items in xml constructors

10667. By Markos Zaharioudakis

translation of json constructor exprs

10668. By Markos Zaharioudakis

re-implemented json constructors

10669. By Markos Zaharioudakis

fixed EBV for jsoniq

10670. By Markos Zaharioudakis

work on jsoniq functions

10671. By Markos Zaharioudakis

fixed error codes and tests

10672. By Markos Zaharioudakis

implemented values( as object()) function

10673. By Markos Zaharioudakis

implemented accumulating object constructor

10674. By Markos Zaharioudakis

implemented the project function

10675. By Markos Zaharioudakis

implemented object insertions

10676. By Markos Zaharioudakis

more work on jsoniq updates

10677. By Markos Zaharioudakis

more work on jsoniq updates

10678. By Chris Hillery

Add Cloudscript-defined serialization parameters (boilerplate; not all
features implemented fully yet). Enable setting of serialization
parameters via .spec files.

10679. By Chris Hillery

Added CloudScript serialization error codes, and implementation checks to
throw them when appropriate. Several test cases.

10680. By Markos Zaharioudakis

done with object updates

10681. By Markos Zaharioudakis

fixed tests failing due to serialization changes

10682. By Markos Zaharioudakis

more work on array updates

10683. By Markos Zaharioudakis

done with array updates

10684. By Markos Zaharioudakis

renamed jn:names to jn:keys + removed 0-arity navigation

10685. By Markos Zaharioudakis

removed array(ItemType) type

10686. By Markos Zaharioudakis

introduced JNTY0002 error

10687. By Markos Zaharioudakis

merge from trunk + work on static and dynamic collection modules

10688. By Markos Zaharioudakis

merged with trunk

10689. By Markos Zaharioudakis

fixed no-copy rule omission

10690. By Chris Hillery

Re-enable support for "old-style" Serialization: .spec file options
(should be deprecated, but still used by some non-core modules)

10691. By Chris Hillery

Remove public API methods that are specific to Object Pairs (no longer part
of the JSONiq spec).

10692. By Ghislain Fourny

Merged jsoniq-plan_serialization branch.

10693. By Ghislain Fourny

Merged trunk back.

10694. By Ghislain Fourny

Fixed flwor expression clause getter.

10695. By Ghislain Fourny

Now compiles and links.

10696. By Ghislain Fourny

Merged trunk back (10838).

10697. By Ghislain Fourny

Fixed some tests.

10698. By Chris Hillery

Additional fixes to handle old-style --method Serialization args correctly.

10699. By Ghislain Fourny

Copied pregenerated scanner and parser files.

10700. By Ghislain Fourny

Merged changes from child branch.

10701. By Ghislain Fourny

Merged trunk back.

10702. By Ghislain Fourny

Added curly braces in JSON insert expressions.

10703. By Ghislain Fourny

Extended update syntax to general FilterExprs.

10704. By Ghislain Fourny

Solved memory leak.

10705. By Ghislain Fourny

Adding tests.

10706. By Ghislain Fourny

Collection functions now work with general items.

10707. By Ghislain Fourny

Began removing pairs in the implementation. Still build errors.

10708. By Ghislain Fourny

Now compiles, but does not link yet.

10709. By Ghislain Fourny

Now links.

10710. By Ghislain Fourny

All JSONiq tests now pass.

10711. By Ghislain Fourny

Renamed cloudscript-extensions to jsoniq-extensions

10712. By Ghislain Fourny

Renamed cloudscript to jsoniq.

10713. By Ghislain Fourny

Renamed cloudscript to jsoniq.

10714. By Ghislain Fourny

Renamed cloudscript to jsoniq.

10715. By Ghislain Fourny

Now outputs INF upon positive infinity.

10716. By Ghislain Fourny

Using the pre-imported jn: prefix in some tests.

10717. By Ghislain Fourny

JSON items are now pointing to the root of their tree.

10718. By Ghislain Fourny

Indices should now work.

10719. By Ghislain Fourny

Index creation and probe should now work.

10720. By Ghislain Fourny

Reverted rename.

10721. By Ghislain Fourny

Reverted renaming.

10722. By Ghislain Fourny

Merged trunk back.

10723. By Ghislain Fourny

Merged jsoniq-deactivated back.

10724. By Ghislain Fourny

Fixed index maintenance.

10725. By Ghislain Fourny

Fixed tests.

10726. By Ghislain Fourny

Merged trunk back.

10727. By Ghislain Fourny

Synced error codes.

10728. By Ghislain Fourny

Added guards.

10729. By Ghislain Fourny

Deactivating JSON for merge proposal and one more fix.

10730. By Ghislain Fourny

Synced error codes.

10731. By Ghislain Fourny

Solved bug 918151 by allowing mixed items if a flag is set.

10732. By Ghislain Fourny

Removed useless and obsolete code that still contained JSON Pairs.

10733. By Ghislain Fourny

Fixed comment.

10734. By Ghislain Fourny

Added files.

10735. By Markos Zaharioudakis

small cosmetic changes

10736. By Ghislain Fourny

Implemented Markos' comments 1 through 5.

10737. By Ghislain Fourny

Implemented Markos' comments 7, 8 and 9.

10738. By Ghislain Fourny

Changed signature of getArraySize() to xs_integer.

10739. By Ghislain Fourny

Corrected bug and reverted mappings.xml to JSONiq deactivated version.

10740. By Ghislain Fourny

Adding tests.

10741. By Ghislain Fourny

Updated pregenerated parser files.

10742. By Ghislain Fourny

Generating preprocessor guards for STRUCTURED_ITEM.

10743. By Ghislain Fourny

Fixed emit_end().

10744. By Ghislain Fourny

Updated updating error code and adding wrappers.

10745. By Ghislain Fourny

Now back to original order when outputting keys.

10746. By Ghislain Fourny

Optimized JSON root management system.

10747. By Ghislain Fourny

Optimized JSON item value memory management.

10748. By Ghislain Fourny

Using items instead of zstrings as keys in JSON objects.

10749. By Ghislain Fourny

Replaced dynamic casts with static casts and added dynamic cast assertions for debug mode.

10750. By Ghislain Fourny

Merged trunk back.

10751. By Markos Zaharioudakis

compilation fixes

10752. By Markos Zaharioudakis

compilation fixes

10753. By Markos Zaharioudakis

added all variants of getStringValue() for JSONNull + cosmetic

10754. By Markos Zaharioudakis

merge from trunk

10755. By Ghislain Fourny

Implemented Markos' comments, except 10.

10756. By Ghislain Fourny

Merged trunk back.

10757. By Ghislain Fourny

Fixed tests.

10758. By Ghislain Fourny

Merged trunk back.

10759. By Ghislain Fourny

Implemented more efficient data structure on objects.

10760. By Ghislain Fourny

Changed parameter of getObjectValue() to an item.

10761. By Ghislain Fourny

Removed free list.

10762. By Ghislain Fourny

changed 1st param of setJSONRoot() to Item* to save some ref counting + eliminated some compiler warnings

10763. By Ghislain Fourny

Fixed compilation error on Windows.

10764. By Ghislain Fourny

Improved efficiency of removing an object pair.

10765. By Markos Zaharioudakis

a better implementation for SimpleJSONObject::remove()

10766. By Markos Zaharioudakis

small optimizations + cosmetic

10767. By Markos Zaharioudakis

commented out ZORBA_TEST_PLAN_SERIALIZATION flag in testdriver.cpp

10768. By Markos Zaharioudakis

fixed compiler warnings

10769. By Markos Zaharioudakis

fixed print out of jsoniq errors

10770. By Markos Zaharioudakis

added missing <value> to a couple of jsoniq errors

10771. By Ghislain Fourny

Deactivated invariant assertions for the moment.

10772. By Ghislain Fourny

Merged trunk back.

10773. By Ghislain Fourny

Regenerated files.

10774. By Ghislain Fourny

A small fix (already in trunk).

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file '.bzrignore'
2--- .bzrignore 1970-01-01 00:00:00 +0000
3+++ .bzrignore 2012-02-08 21:22:19 +0000
4@@ -0,0 +1,2 @@
5+CMakeLists.txt.user
6+build
7
8=== modified file 'CMakeConfiguration.txt'
9--- CMakeConfiguration.txt 2012-01-11 17:30:25 +0000
10+++ CMakeConfiguration.txt 2012-02-08 21:22:19 +0000
11@@ -152,6 +152,9 @@
12 SET(ZORBA_WITH_BIG_INTEGER OFF CACHE BOOL "enable arbitrary precision integers")
13 MESSAGE(STATUS "ZORBA_WITH_BIG_INTEGER: " ${ZORBA_WITH_BIG_INTEGER})
14
15+SET(ZORBA_WITH_JSON ON CACHE BOOL "enable integrated JSON support")
16+MESSAGE(STATUS "ZORBA_WITH_JSON: " ${ZORBA_WITH_JSON})
17+
18 IF (ZORBA_SUPPRESS_SWIG)
19 SET (no_swig ON)
20 ELSE (ZORBA_SUPPRESS_SWIG)
21
22=== modified file 'ChangeLog'
23--- ChangeLog 2012-02-07 14:26:42 +0000
24+++ ChangeLog 2012-02-08 21:22:19 +0000
25@@ -36,6 +36,7 @@
26 * Fixed bug #918157 (Add XQFTTS to validation queue)
27 * Fixed bug with unversioned modules with C++ external functions
28
29+
30 version 2.1
31
32 New Features:
33
34=== added file 'NOTICE.txt'
35--- NOTICE.txt 1970-01-01 00:00:00 +0000
36+++ NOTICE.txt 2012-02-08 21:22:19 +0000
37@@ -0,0 +1,740 @@
38+-----------
39+Zorba 2.1.0
40+-----------
41+
42+(Note: This file is generated automatically from NOTICE.xml.
43+Please do not modify this file directly.)
44+
45+
46+
47+
48+Apache 2
49+
50+ Copyright 2006-2011 The FLWOR Foundation
51+
52+ See LICENSE.txt for license information.
53+
54+ ------------------------
55+ This product includes software developed at
56+ The FLWOR Foundation (http://www.flworfound.org/).
57+
58+ ------------------------
59+ Portions of this software were developed at the Systems
60+ Group of the ETH Zurich, Switzerland.
61+
62+
63+Other files used by this project:
64+----------------------------------------------------
65+
66+src/zorbatypes/m_apm.h
67+src/zorbatypes/mapm/
68+
69+Copyright: 1999-2007 Michael C. Ring
70+Website: http://www.tc.umn.edu/~ringx004/mapm-main.html
71+
72+ This software is Freeware.
73+
74+ Permission to use, copy, and distribute this software and its
75+ documentation for any purpose with or without fee is hereby granted,
76+ provided that the above copyright notice appear in all copies and
77+ that both that copyright notice and this permission notice appear
78+ in supporting documentation.
79+
80+ Permission to modify the software is granted. Permission to distribute
81+ the modified code is granted. Modifications are to be distributed by
82+ using the file 'license.txt' as a template to modify the file header.
83+ 'license.txt' is available in the official MAPM distribution.
84+
85+ To distribute modified source code, insert the file 'license.txt'
86+ at the top of all modified source code files and edit accordingly.
87+
88+ This software is provided "as is" without express or implied warranty.
89+
90+----------------------------------------------------
91+
92+src/zorbamisc/config/stdint.h
93+
94+Copyright: 2006 Alexander Chemeris
95+
96+
97+ Redistribution and use in source and binary forms, with or without
98+ modification, are permitted provided that the following conditions are met:
99+
100+ 1. Redistributions of source code must retain the above copyright notice,
101+ this list of conditions and the following disclaimer.
102+
103+ 2. Redistributions in binary form must reproduce the above copyright
104+ notice, this list of conditions and the following disclaimer in the
105+ documentation and/or other materials provided with the distribution.
106+
107+ 3. The name of the author may be used to endorse or promote products
108+ derived from this software without specific prior written permission.
109+
110+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
111+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
112+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
113+ EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
114+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
115+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
116+ OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
117+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
118+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
119+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
120+
121+----------------------------------------------------
122+
123+src/zorbautils/stemmer/
124+
125+Copyright: 2001 Dr. Martin Porter
126+
127+
128+ All the software given out on this Snowball site is covered by the BSD
129+ License (see http://www.opensource.org/licenses/bsd-license.html), with
130+ Copyright (c) 2001, Dr Martin Porter, and (for the Java developments)
131+ Copyright (c) 2002, Richard Boulton.
132+
133+ Essentially, all this means is that you can do what you like with the code,
134+ except claim another Copyright for it, or claim that it is issued under a
135+ different license. The software is also issued without warranties, which
136+ means that if anyone suffers through its use, they cannot come back and sue
137+ you. You also have to alert anyone to whom you give the Snowball software to
138+ the fact that it is covered by the BSD license.
139+
140+ We have not bothered to insert the licensing arrangement into the text of
141+ the Snowball software.
142+
143+----------------------------------------------------
144+
145+src/util/less.h
146+
147+Copyright: 1998 Paul J. Lucas
148+
149+
150+ Redistribution and use in source and binary forms, with or without
151+ modification, are permitted provided that the following conditions are met:
152+
153+ o Redistributions of source code must retain the above copyright notice,
154+ this list of conditions and the following disclaimer.
155+
156+ o Redistributions in binary form must reproduce the above copyright
157+ notice, this list of conditions and the following disclaimer in the
158+ documentation and/or other materials provided with the distribution.
159+
160+ o The name of the author may not be used to endorse or promote products
161+ derived from this software without specific prior written permission.
162+
163+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
164+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
165+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
166+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
167+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
168+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
169+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
170+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
171+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
172+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
173+ POSSIBILITY OF SUCH DAMAGE.
174+
175+----------------------------------------------------
176+
177+src/util/auto_vector.h (has been modified)
178+
179+Copyright: 2003 Reliable Software
180+
181+
182+ Redistribution and use in source and binary forms, with or without
183+ modification, are permitted provided that the following conditions are met:
184+
185+ o Redistributions of source code must retain the above copyright notice,
186+ this list of conditions and the following disclaimer.
187+
188+ o Redistributions in binary form must reproduce the above copyright
189+ notice, this list of conditions and the following disclaimer in the
190+ documentation and/or other materials provided with the distribution.
191+
192+ o The name of the author may not be used to endorse or promote products
193+ derived from this software without specific prior written permission.
194+
195+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
196+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
197+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
198+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
199+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
200+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
201+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
202+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
203+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
204+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
205+ POSSIBILITY OF SUCH DAMAGE.
206+
207+----------------------------------------------------
208+
209+cmake_modules/FindBoost.cmake
210+
211+Copyright:
212+ 2006-2008 Andreas Schneider <mail@cynapses.org>
213+ 2007 Wengo
214+ 2007 Mike Jackson
215+ 2008 Andreas Pakulat <apaku@gmx.de>
216+
217+
218+
219+ Redistribution AND use is allowed according to the terms of the New BSD license.
220+ For details see the accompanying COPYING-CMAKE-SCRIPTS file.
221+
222+----------------------------------------------------
223+
224+cmake_modules/FindJNI.cmake
225+cmake_modules/FindPythonLibs.cmake
226+cmake_modules/FindSWIG.cmake
227+
228+Copyright: 2001-2009 Kitware, Inc.
229+
230+
231+ Distributed under the OSI-approved BSD License (the "License");
232+ see accompanying file Copyright.txt for details.
233+
234+ This software is distributed WITHOUT ANY WARRANTY; without even the
235+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
236+ See the License for more information.
237+
238+ CMake - Cross Platform Makefile Generator
239+ Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
240+ All rights reserved.
241+
242+ Redistribution and use in source and binary forms, with or without
243+ modification, are permitted provided that the following conditions
244+ are met:
245+
246+ * Redistributions of source code must retain the above copyright
247+ notice, this list of conditions and the following disclaimer.
248+
249+ * Redistributions in binary form must reproduce the above copyright
250+ notice, this list of conditions and the following disclaimer in the
251+ documentation and/or other materials provided with the distribution.
252+
253+ * Neither the names of Kitware, Inc., the Insight Software Consortium,
254+ nor the names of their contributors may be used to endorse or promote
255+ products derived from this software without specific prior written
256+ permission.
257+
258+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
259+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
260+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
261+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
262+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
263+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
264+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
265+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
266+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
267+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
268+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
269+
270+ ------------------------------------------------------------------------------
271+
272+ The above copyright and license notice applies to distributions of
273+ CMake in source and binary form. Some source files contain additional
274+ notices of original copyright by their contributors; see each source
275+ for details. Third-party software packages supplied with CMake under
276+ compatible licenses provide their own copyright notices documented in
277+ corresponding subdirectories.
278+
279+ ------------------------------------------------------------------------------
280+
281+ CMake was initially developed by Kitware with the following sponsorship:
282+
283+ * National Library of Medicine at the National Institutes of Health
284+ as part of the Insight Segmentation and Registration Toolkit (ITK).
285+
286+ * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel
287+ Visualization Initiative.
288+
289+ * National Alliance for Medical Image Computing (NAMIC) is funded by the
290+ National Institutes of Health through the NIH Roadmap for Medical Research,
291+ Grant U54 EB005149.
292+
293+ * Kitware, Inc.
294+
295+----------------------------------------------------
296+
297+/xml.xsd
298+
299+Copyright: 2001 World Wide Web Consortium, (Massachusetts Institute of Technology, European Research Consortium for Informatics and Mathematics, Keio University)
300+
301+
302+ All Rights Reserved. This work is distributed under the W3C Software License [1] in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
303+
304+ W3C Software Notice and License
305+
306+ This work (and included software, documentation such as READMEs, or other related items) is being provided by the copyright holders under the following license.
307+
308+ License
309+
310+ By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.
311+
312+ Permission to copy, modify, and distribute this software and its documentation, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the software and documentation or portions thereof, including modifications:
313+ •The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
314+ •Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software Short Notice should be included (hypertext is preferred, text is permitted) within the body of any redistributed or derivative code.
315+ •Notice of any changes or modifications to the files, including the date changes were made. (We recommend you provide URIs to the location from which the code is derived.)
316+
317+ Disclaimers
318+
319+ THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
320+
321+ COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
322+
323+ The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.
324+
325+----------------------------------------------------
326+
327+schemas/xslt-xquery-serialization.xsd
328+
329+Copyright: 2010 World Wide Web Consortium, (Massachusetts Institute of Technology, European Research Consortium for Informatics and Mathematics, Keio University)
330+
331+
332+ All Rights Reserved. This work is distributed under the W3C Software License [1] in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
333+
334+ W3C Software Notice and License
335+
336+ This work (and included software, documentation such as READMEs, or other related items) is being provided by the copyright holders under the following license.
337+
338+ License
339+
340+ By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.
341+
342+ Permission to copy, modify, and distribute this software and its documentation, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the software and documentation or portions thereof, including modifications:
343+ •The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
344+ •Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software Short Notice should be included (hypertext is preferred, text is permitted) within the body of any redistributed or derivative code.
345+ •Notice of any changes or modifications to the files, including the date changes were made. (We recommend you provide URIs to the location from which the code is derived.)
346+
347+ Disclaimers
348+
349+ THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
350+
351+ COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
352+
353+ The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.
354+
355+----------------------------------------------------
356+
357+modules/w3c/xpath-functions.xsd
358+
359+Copyright: 2005 World Wide Web Consortium, (Massachusetts Institute of Technology, European Research Consortium for Informatics and Mathematics, Keio University)
360+
361+
362+ All Rights Reserved. This work is distributed under the W3C Software License [1] in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
363+
364+ W3C Software Notice and License
365+
366+ This work (and included software, documentation such as READMEs, or other related items) is being provided by the copyright holders under the following license.
367+
368+ License
369+
370+ By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.
371+
372+ Permission to copy, modify, and distribute this software and its documentation, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the software and documentation or portions thereof, including modifications:
373+ •The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
374+ •Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software Short Notice should be included (hypertext is preferred, text is permitted) within the body of any redistributed or derivative code.
375+ •Notice of any changes or modifications to the files, including the date changes were made. (We recommend you provide URIs to the location from which the code is derived.)
376+
377+ Disclaimers
378+
379+ THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
380+
381+ COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
382+
383+ The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.
384+
385+----------------------------------------------------
386+
387+include/xqc.h
388+
389+Copyright: 2008, Matthias Brantner, John Snelson
390+
391+
392+ * All rights reserved.
393+ *
394+ * Redistribution and use in source and binary forms, with or without
395+ * modification, are permitted provided that the following conditions are met:
396+ *
397+ * * Redistributions of source code must retain the above copyright notice,
398+ * this list of conditions and the following disclaimer.
399+ * * Redistributions in binary form must reproduce the above copyright
400+ * notice, this list of conditions and the following disclaimer in the
401+ * documentation and/or other materials provided with the distribution.
402+ * * Neither the name of the developers nor the names of contributors may be
403+ * used to endorse or promote products derived from this software without
404+ * specific prior written permission.
405+ *
406+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
407+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
408+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
409+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
410+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
411+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
412+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
413+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
414+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
415+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
416+ * POSSIBILITY OF SUCH DAMAGE.
417+
418+----------------------------------------------------
419+
420+modules/functx/functx.xq
421+
422+Copyright: 2007 Datypic
423+
424+
425+ : This library is free software; you can redistribute it and/or
426+ : modify it under the terms of the GNU Lesser General Public
427+ : License as published by the Free Software Foundation; either
428+ : version 2.1 of the License.
429+
430+ : This library is distributed in the hope that it will be useful,
431+ : but WITHOUT ANY WARRANTY; without even the implied warranty of
432+ : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
433+ : Lesser General Public License for more details.
434+
435+ : You should have received a copy of the GNU Lesser General Public
436+ : License along with this library; if not, write to the Free Software
437+ : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
438+
439+----------------------------------------------------
440+
441+src/compiler/parser/FlexLexer.h
442+
443+Copyright: 1993 The Regents of the University of California
444+
445+
446+ // All rights reserved.
447+ //
448+ // This code is derived from software contributed to Berkeley by
449+ // Kent Williams and Tom Epperly.
450+ //
451+ // Redistribution and use in source and binary forms, with or without
452+ // modification, are permitted provided that the following conditions
453+ // are met:
454+
455+ // 1. Redistributions of source code must retain the above copyright
456+ // notice, this list of conditions and the following disclaimer.
457+ // 2. Redistributions in binary form must reproduce the above copyright
458+ // notice, this list of conditions and the following disclaimer in the
459+ // documentation and/or other materials provided with the distribution.
460+
461+ // Neither the name of the University nor the names of its contributors
462+ // may be used to endorse or promote products derived from this software
463+ // without specific prior written permission.
464+
465+ // THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
466+ // IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
467+ // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
468+ // PURPOSE.
469+
470+----------------------------------------------------
471+
472+src/diagnostics/StackWalker.cpp
473+src/diagnostics/StackWalker.h
474+
475+Copyright: 2005 Jochen Kalmbach
476+
477+
478+ Under BSD License: http://www.opensource.org/licenses/bsd-license.php
479+
480+----------------------------------------------------
481+
482+src/util/singleton.h
483+src/util/threads.h
484+
485+Copyright: 2001 Andrei Alexandrescu
486+
487+
488+ This code accompanies the book:
489+ Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
490+ Patterns Applied". Copyright (c) 2001. Addison-Wesley.
491+ Permission to use, copy, modify, distribute and sell this software for any
492+ purpose is hereby granted without fee, provided that the above copyright
493+ notice appear in all copies and that both that copyright notice and this
494+ permission notice appear in supporting documentation.
495+ The author or Addison-Wesley Longman make no representations about the
496+ suitability of this software for any purpose. It is provided "as is"
497+ without express or implied warranty.
498+
499+
500+External libraries used by this project:
501+----------------------------------------------------
502+
503+Name: LIBXML2
504+Preferred version: 2.2.16 or higher
505+Is mandatory: true
506+Website: http://xmlsoft.org/
507+License: MIT
508+Copyright: 1998-2002 Daniel Veillard. All Rights Reserved.
509+External notice:
510+
511+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
512+
513+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
514+
515+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
516+
517+ Except as contained in this notice, the name of Daniel Veillard shall not
518+ be used in advertising or otherwise to promote the sale, use or other deal-
519+ ings in this Software without prior written authorization from him.
520+
521+----------------------------------------------------
522+
523+Name: LIBXSLT
524+Preferred version: 1.1.26
525+Is mandatory: false
526+Website: http://xmlsoft.org/XSLT/
527+License: MIT
528+Copyright: 2001-2002 Daniel Veillard. All Rights Reserved.
529+External notice:
530+
531+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
532+
533+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
534+
535+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL DANIEL VEILLARD BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
536+
537+
538+ Except as contained in this notice, the name of Daniel Veillard shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from him.
539+
540+
541+----------------------------------------------------
542+
543+Name: ICU4C
544+Preferred version: 3.6 or higher
545+Is mandatory: true
546+Website: http://www.icu-project.org/
547+License: ICU License
548+Copyright: 1995-2011 International Business Machines Corporation and others
549+External notice:
550+
551+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, provided that the above copyright notice(s) and this permission notice appear in all copies of the Software and that both the above copyright notice(s) and this permission notice appear in supporting documentation.
552+
553+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
554+
555+ Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder.
556+
557+----------------------------------------------------
558+
559+Name: CURL
560+Preferred version: above 7.12
561+Is mandatory: false
562+Website: http://curl.haxx.se/
563+License: MIT/X derivate license
564+Copyright: 1996 - 2011, Daniel Stenberg, <daniel@haxx.se>.
565+External notice:
566+
567+ All rights reserved.
568+
569+ Permission to use, copy, modify, and distribute this software for any purpose
570+ with or without fee is hereby granted, provided that the above copyright
571+ notice and this permission notice appear in all copies.
572+
573+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
574+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
575+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN
576+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
577+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
578+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
579+ OR OTHER DEALINGS IN THE SOFTWARE.
580+
581+ Except as contained in this notice, the name of a copyright holder shall not
582+ be used in advertising or otherwise to promote the sale, use or other dealings
583+ in this Software without prior written authorization of the copyright holder.
584+
585+----------------------------------------------------
586+
587+Name: ICONV
588+Preferred version: above 1.12
589+Is mandatory: true
590+Website: http://www.gnu.org/software/libiconv/
591+License: LGPL
592+Copyright: 1998, 2010 Free Software Foundation, Inc.
593+External notice:
594+
595+----------------------------------------------------
596+
597+Name: ZLIB
598+Preferred version: 1.2.5
599+Is mandatory: true
600+Website: http://www.zlib.net/
601+Copyright: 1995-2004 Jean-loup Gailly and Mark Adler
602+External notice:
603+
604+ This software is provided 'as-is', without any express or implied
605+ warranty. In no event will the authors be held liable for any damages
606+ arising from the use of this software.
607+
608+ Permission is granted to anyone to use this software for any purpose,
609+ including commercial applications, and to alter it and redistribute it
610+ freely, subject to the following restrictions:
611+
612+ 1. The origin of this software must not be misrepresented; you must not
613+ claim that you wrote the original software. If you use this software
614+ in a product, an acknowledgment in the product documentation would be
615+ appreciated but is not required.
616+ 2. Altered source versions must be plainly marked as such, and must not be
617+ misrepresented as being the original software.
618+ 3. This notice may not be removed or altered from any source distribution.
619+
620+ Jean-loup Gailly jloup@gzip.org
621+ Mark Adler madler@alumni.caltech.edu
622+
623+----------------------------------------------------
624+
625+Name: XERCES
626+Preferred version: 2.8.0 or higher
627+Is mandatory: true
628+Website: http://xerces.apache.org/xerces-c/
629+License: Apache 2
630+Copyright: Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.
631+External notice:
632+
633+ http://www.apache.org/licenses/LICENSE-2.0
634+
635+----------------------------------------------------
636+
637+Name: BOOST (boost_filesystem)
638+Preferred version: 1.32 or higher
639+Is mandatory: false
640+Website: http://www.boost.org/
641+License: Boost Software License v1.0
642+Copyright:
643+ Beman Dawes, David Abrahams, 1998-2005.
644+ Rene Rivera 2004-2007
645+
646+External notice:
647+
648+ Permission is hereby granted, free of charge, to any person or organization
649+ obtaining a copy of the software and accompanying documentation covered by
650+ this license (the "Software") to use, reproduce, display, distribute,
651+ execute, and transmit the Software, and to prepare derivative works of the
652+ Software, and to permit third-parties to whom the Software is furnished to
653+ do so, all subject to the following:
654+
655+ The copyright notices in the Software and this entire statement, including
656+ the above license grant, this restriction and the following disclaimer,
657+ must be included in all copies of the Software, in whole or in part, and
658+ all derivative works of the Software, unless such copies or derivative
659+ works are solely in the form of machine-executable object code generated by
660+ a source language processor.
661+
662+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
663+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
664+ FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
665+ SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
666+ FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
667+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
668+ DEALINGS IN THE SOFTWARE.
669+
670+
671+External applications used by this project:
672+----------------------------------------------------
673+
674+Name: FLEX
675+Preferred version: 2.5.33
676+Is mandatory: false
677+Website: http://flex.sourceforge.net/
678+Copyright:
679+ 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 The Flex Project.
680+ 1990, 1997 The Regents of the University of California. All rights reserved.
681+
682+External notice:
683+
684+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
685+
686+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
687+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
688+
689+ Neither the name of the University nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
690+
691+ THIS SOFTWARE IS PROVIDED “AS IS” AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
692+
693+----------------------------------------------------
694+
695+Name: BISON
696+Preferred version: 2.4 or higher
697+Is mandatory: false
698+Website: http://www.gnu.org/software/bison/
699+License: GPL
700+Copyright: 1998, 2001, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
701+External notice:
702+
703+----------------------------------------------------
704+
705+Name: DOXYGEN
706+Preferred version: v1.7.4
707+Is mandatory: false
708+Website: www.doxygen.org
709+License: GPL
710+Copyright: 1997-2011 by Dimitri van Heesch
711+External notice:
712+
713+ Permission to use, copy, modify, and distribute this software and its documentation under the terms of the GNU General Public License is hereby granted.
714+ No representations are made about the suitability of this software for any purpose.
715+ It is provided "as is" without express or implied warranty.
716+ See the GNU General Public License for more details.
717+
718+ Documents produced by doxygen are derivative works derived from the input used in their production; they are not affected by this license.
719+
720+----------------------------------------------------
721+
722+Name: CMAKE
723+Preferred version: 2.8.4
724+Is mandatory: true
725+Website: http://www.cmake.org/
726+License: Creative Commons Attribution-NoDerivs 3.0 Unported License
727+Copyright: 2000-2009 Kitware, Inc., Insight Software Consortium. All rights reserved.
728+External notice:
729+
730+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
731+
732+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
733+
734+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
735+
736+ Neither the names of Kitware, Inc., the Insight Software Consortium, nor the names of their contributors may be used to endorse or promote products derived from this software without specific prior written permission.
737+
738+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
739+
740+----------------------------------------------------
741+
742+Name: SWIG
743+Preferred version: 2.0.4 or above
744+Is mandatory: false
745+Website: http://www.swig.org/
746+License: GPL
747+Copyright:
748+ 1995-2011 The SWIG Developers
749+ 2005-2006 Arizona Board of Regents (University of Arizona).
750+ 1998-2005 University of Chicago.
751+ 1995-1998 The University of Utah and the Regents of the University of California
752+
753+External notice:
754+
755+ SWIG is free software: you can redistribute it and/or modify it
756+ under the terms of the GNU General Public License as published by
757+ the Free Software Foundation, either version 3 of the License, or
758+ (at your option) any later version. See the LICENSE-GPL file for
759+ the full terms of the GNU General Public license version 3.
760+
761+ Portions of SWIG are also licensed under the terms of the licenses
762+ in the file LICENSE-UNIVERSITIES. You must observe the terms of
763+ these licenses, as well as the terms of the GNU General Public License,
764+ when you distribute SWIG.
765+
766+ The SWIG library and examples, under the Lib and Examples top level
767+ directories, are distributed under the following terms:
768+
769+ You may copy, modify, distribute, and make derivative works based on
770+ this software, in source code or object code form, without
771+ restriction. If you distribute the software to others, you may do
772+ so according to the terms of your choice. This software is offered as
773+ is, without warranty of any kind.
774+
775+ See the COPYRIGHT file for a list of contributors to SWIG and their
776+ copyright notices.
777+
778\ No newline at end of file
779
780=== removed file 'NOTICE.txt'
781--- NOTICE.txt 2011-10-21 08:09:17 +0000
782+++ NOTICE.txt 1970-01-01 00:00:00 +0000
783@@ -1,740 +0,0 @@
784------------
785-Zorba 2.1.0
786------------
787-
788-(Note: This file is generated automatically from NOTICE.xml.
789-Please do not modify this file directly.)
790-
791-
792-
793-
794-Apache 2
795-
796- Copyright 2006-2011 The FLWOR Foundation
797-
798- See LICENSE.txt for license information.
799-
800- ------------------------
801- This product includes software developed at
802- The FLWOR Foundation (http://www.flworfound.org/).
803-
804- ------------------------
805- Portions of this software were developed at the Systems
806- Group of the ETH Zurich, Switzerland.
807-
808-
809-Other files used by this project:
810-----------------------------------------------------
811-
812-src/zorbatypes/m_apm.h
813-src/zorbatypes/mapm/
814-
815-Copyright: 1999-2007 Michael C. Ring
816-Website: http://www.tc.umn.edu/~ringx004/mapm-main.html
817-
818- This software is Freeware.
819-
820- Permission to use, copy, and distribute this software and its
821- documentation for any purpose with or without fee is hereby granted,
822- provided that the above copyright notice appear in all copies and
823- that both that copyright notice and this permission notice appear
824- in supporting documentation.
825-
826- Permission to modify the software is granted. Permission to distribute
827- the modified code is granted. Modifications are to be distributed by
828- using the file 'license.txt' as a template to modify the file header.
829- 'license.txt' is available in the official MAPM distribution.
830-
831- To distribute modified source code, insert the file 'license.txt'
832- at the top of all modified source code files and edit accordingly.
833-
834- This software is provided "as is" without express or implied warranty.
835-
836-----------------------------------------------------
837-
838-src/zorbamisc/config/stdint.h
839-
840-Copyright: 2006 Alexander Chemeris
841-
842-
843- Redistribution and use in source and binary forms, with or without
844- modification, are permitted provided that the following conditions are met:
845-
846- 1. Redistributions of source code must retain the above copyright notice,
847- this list of conditions and the following disclaimer.
848-
849- 2. Redistributions in binary form must reproduce the above copyright
850- notice, this list of conditions and the following disclaimer in the
851- documentation and/or other materials provided with the distribution.
852-
853- 3. The name of the author may be used to endorse or promote products
854- derived from this software without specific prior written permission.
855-
856- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
857- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
858- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
859- EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
860- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
861- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
862- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
863- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
864- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
865- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
866-
867-----------------------------------------------------
868-
869-src/zorbautils/stemmer/
870-
871-Copyright: 2001 Dr. Martin Porter
872-
873-
874- All the software given out on this Snowball site is covered by the BSD
875- License (see http://www.opensource.org/licenses/bsd-license.html), with
876- Copyright (c) 2001, Dr Martin Porter, and (for the Java developments)
877- Copyright (c) 2002, Richard Boulton.
878-
879- Essentially, all this means is that you can do what you like with the code,
880- except claim another Copyright for it, or claim that it is issued under a
881- different license. The software is also issued without warranties, which
882- means that if anyone suffers through its use, they cannot come back and sue
883- you. You also have to alert anyone to whom you give the Snowball software to
884- the fact that it is covered by the BSD license.
885-
886- We have not bothered to insert the licensing arrangement into the text of
887- the Snowball software.
888-
889-----------------------------------------------------
890-
891-src/util/less.h
892-
893-Copyright: 1998 Paul J. Lucas
894-
895-
896- Redistribution and use in source and binary forms, with or without
897- modification, are permitted provided that the following conditions are met:
898-
899- o Redistributions of source code must retain the above copyright notice,
900- this list of conditions and the following disclaimer.
901-
902- o Redistributions in binary form must reproduce the above copyright
903- notice, this list of conditions and the following disclaimer in the
904- documentation and/or other materials provided with the distribution.
905-
906- o The name of the author may not be used to endorse or promote products
907- derived from this software without specific prior written permission.
908-
909- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
910- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
911- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
912- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
913- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
914- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
915- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
916- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
917- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
918- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
919- POSSIBILITY OF SUCH DAMAGE.
920-
921-----------------------------------------------------
922-
923-src/util/auto_vector.h (has been modified)
924-
925-Copyright: 2003 Reliable Software
926-
927-
928- Redistribution and use in source and binary forms, with or without
929- modification, are permitted provided that the following conditions are met:
930-
931- o Redistributions of source code must retain the above copyright notice,
932- this list of conditions and the following disclaimer.
933-
934- o Redistributions in binary form must reproduce the above copyright
935- notice, this list of conditions and the following disclaimer in the
936- documentation and/or other materials provided with the distribution.
937-
938- o The name of the author may not be used to endorse or promote products
939- derived from this software without specific prior written permission.
940-
941- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
942- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
943- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
944- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
945- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
946- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
947- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
948- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
949- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
950- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
951- POSSIBILITY OF SUCH DAMAGE.
952-
953-----------------------------------------------------
954-
955-cmake_modules/FindBoost.cmake
956-
957-Copyright:
958- 2006-2008 Andreas Schneider <mail@cynapses.org>
959- 2007 Wengo
960- 2007 Mike Jackson
961- 2008 Andreas Pakulat <apaku@gmx.de>
962-
963-
964-
965- Redistribution AND use is allowed according to the terms of the New BSD license.
966- For details see the accompanying COPYING-CMAKE-SCRIPTS file.
967-
968-----------------------------------------------------
969-
970-cmake_modules/FindJNI.cmake
971-cmake_modules/FindPythonLibs.cmake
972-cmake_modules/FindSWIG.cmake
973-
974-Copyright: 2001-2009 Kitware, Inc.
975-
976-
977- Distributed under the OSI-approved BSD License (the "License");
978- see accompanying file Copyright.txt for details.
979-
980- This software is distributed WITHOUT ANY WARRANTY; without even the
981- implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
982- See the License for more information.
983-
984- CMake - Cross Platform Makefile Generator
985- Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
986- All rights reserved.
987-
988- Redistribution and use in source and binary forms, with or without
989- modification, are permitted provided that the following conditions
990- are met:
991-
992- * Redistributions of source code must retain the above copyright
993- notice, this list of conditions and the following disclaimer.
994-
995- * Redistributions in binary form must reproduce the above copyright
996- notice, this list of conditions and the following disclaimer in the
997- documentation and/or other materials provided with the distribution.
998-
999- * Neither the names of Kitware, Inc., the Insight Software Consortium,
1000- nor the names of their contributors may be used to endorse or promote
1001- products derived from this software without specific prior written
1002- permission.
1003-
1004- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1005- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1006- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1007- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1008- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1009- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1010- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1011- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1012- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1013- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1014- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1015-
1016- ------------------------------------------------------------------------------
1017-
1018- The above copyright and license notice applies to distributions of
1019- CMake in source and binary form. Some source files contain additional
1020- notices of original copyright by their contributors; see each source
1021- for details. Third-party software packages supplied with CMake under
1022- compatible licenses provide their own copyright notices documented in
1023- corresponding subdirectories.
1024-
1025- ------------------------------------------------------------------------------
1026-
1027- CMake was initially developed by Kitware with the following sponsorship:
1028-
1029- * National Library of Medicine at the National Institutes of Health
1030- as part of the Insight Segmentation and Registration Toolkit (ITK).
1031-
1032- * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel
1033- Visualization Initiative.
1034-
1035- * National Alliance for Medical Image Computing (NAMIC) is funded by the
1036- National Institutes of Health through the NIH Roadmap for Medical Research,
1037- Grant U54 EB005149.
1038-
1039- * Kitware, Inc.
1040-
1041-----------------------------------------------------
1042-
1043-/xml.xsd
1044-
1045-Copyright: 2001 World Wide Web Consortium, (Massachusetts Institute of Technology, European Research Consortium for Informatics and Mathematics, Keio University)
1046-
1047-
1048- All Rights Reserved. This work is distributed under the W3C Software License [1] in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1049-
1050- W3C Software Notice and License
1051-
1052- This work (and included software, documentation such as READMEs, or other related items) is being provided by the copyright holders under the following license.
1053-
1054- License
1055-
1056- By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.
1057-
1058- Permission to copy, modify, and distribute this software and its documentation, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the software and documentation or portions thereof, including modifications:
1059- •The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
1060- •Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software Short Notice should be included (hypertext is preferred, text is permitted) within the body of any redistributed or derivative code.
1061- •Notice of any changes or modifications to the files, including the date changes were made. (We recommend you provide URIs to the location from which the code is derived.)
1062-
1063- Disclaimers
1064-
1065- THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
1066-
1067- COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
1068-
1069- The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.
1070-
1071-----------------------------------------------------
1072-
1073-schemas/xslt-xquery-serialization.xsd
1074-
1075-Copyright: 2010 World Wide Web Consortium, (Massachusetts Institute of Technology, European Research Consortium for Informatics and Mathematics, Keio University)
1076-
1077-
1078- All Rights Reserved. This work is distributed under the W3C Software License [1] in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1079-
1080- W3C Software Notice and License
1081-
1082- This work (and included software, documentation such as READMEs, or other related items) is being provided by the copyright holders under the following license.
1083-
1084- License
1085-
1086- By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.
1087-
1088- Permission to copy, modify, and distribute this software and its documentation, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the software and documentation or portions thereof, including modifications:
1089- •The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
1090- •Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software Short Notice should be included (hypertext is preferred, text is permitted) within the body of any redistributed or derivative code.
1091- •Notice of any changes or modifications to the files, including the date changes were made. (We recommend you provide URIs to the location from which the code is derived.)
1092-
1093- Disclaimers
1094-
1095- THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
1096-
1097- COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
1098-
1099- The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.
1100-
1101-----------------------------------------------------
1102-
1103-modules/w3c/xpath-functions.xsd
1104-
1105-Copyright: 2005 World Wide Web Consortium, (Massachusetts Institute of Technology, European Research Consortium for Informatics and Mathematics, Keio University)
1106-
1107-
1108- All Rights Reserved. This work is distributed under the W3C Software License [1] in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1109-
1110- W3C Software Notice and License
1111-
1112- This work (and included software, documentation such as READMEs, or other related items) is being provided by the copyright holders under the following license.
1113-
1114- License
1115-
1116- By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.
1117-
1118- Permission to copy, modify, and distribute this software and its documentation, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the software and documentation or portions thereof, including modifications:
1119- •The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
1120- •Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software Short Notice should be included (hypertext is preferred, text is permitted) within the body of any redistributed or derivative code.
1121- •Notice of any changes or modifications to the files, including the date changes were made. (We recommend you provide URIs to the location from which the code is derived.)
1122-
1123- Disclaimers
1124-
1125- THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
1126-
1127- COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
1128-
1129- The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.
1130-
1131-----------------------------------------------------
1132-
1133-include/xqc.h
1134-
1135-Copyright: 2008, Matthias Brantner, John Snelson
1136-
1137-
1138- * All rights reserved.
1139- *
1140- * Redistribution and use in source and binary forms, with or without
1141- * modification, are permitted provided that the following conditions are met:
1142- *
1143- * * Redistributions of source code must retain the above copyright notice,
1144- * this list of conditions and the following disclaimer.
1145- * * Redistributions in binary form must reproduce the above copyright
1146- * notice, this list of conditions and the following disclaimer in the
1147- * documentation and/or other materials provided with the distribution.
1148- * * Neither the name of the developers nor the names of contributors may be
1149- * used to endorse or promote products derived from this software without
1150- * specific prior written permission.
1151- *
1152- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1153- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1154- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1155- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
1156- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1157- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1158- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1159- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1160- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1161- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1162- * POSSIBILITY OF SUCH DAMAGE.
1163-
1164-----------------------------------------------------
1165-
1166-modules/functx/functx.xq
1167-
1168-Copyright: 2007 Datypic
1169-
1170-
1171- : This library is free software; you can redistribute it and/or
1172- : modify it under the terms of the GNU Lesser General Public
1173- : License as published by the Free Software Foundation; either
1174- : version 2.1 of the License.
1175-
1176- : This library is distributed in the hope that it will be useful,
1177- : but WITHOUT ANY WARRANTY; without even the implied warranty of
1178- : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1179- : Lesser General Public License for more details.
1180-
1181- : You should have received a copy of the GNU Lesser General Public
1182- : License along with this library; if not, write to the Free Software
1183- : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1184-
1185-----------------------------------------------------
1186-
1187-src/compiler/parser/FlexLexer.h
1188-
1189-Copyright: 1993 The Regents of the University of California
1190-
1191-
1192- // All rights reserved.
1193- //
1194- // This code is derived from software contributed to Berkeley by
1195- // Kent Williams and Tom Epperly.
1196- //
1197- // Redistribution and use in source and binary forms, with or without
1198- // modification, are permitted provided that the following conditions
1199- // are met:
1200-
1201- // 1. Redistributions of source code must retain the above copyright
1202- // notice, this list of conditions and the following disclaimer.
1203- // 2. Redistributions in binary form must reproduce the above copyright
1204- // notice, this list of conditions and the following disclaimer in the
1205- // documentation and/or other materials provided with the distribution.
1206-
1207- // Neither the name of the University nor the names of its contributors
1208- // may be used to endorse or promote products derived from this software
1209- // without specific prior written permission.
1210-
1211- // THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1212- // IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1213- // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1214- // PURPOSE.
1215-
1216-----------------------------------------------------
1217-
1218-src/diagnostics/StackWalker.cpp
1219-src/diagnostics/StackWalker.h
1220-
1221-Copyright: 2005 Jochen Kalmbach
1222-
1223-
1224- Under BSD License: http://www.opensource.org/licenses/bsd-license.php
1225-
1226-----------------------------------------------------
1227-
1228-src/util/singleton.h
1229-src/util/threads.h
1230-
1231-Copyright: 2001 Andrei Alexandrescu
1232-
1233-
1234- This code accompanies the book:
1235- Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
1236- Patterns Applied". Copyright (c) 2001. Addison-Wesley.
1237- Permission to use, copy, modify, distribute and sell this software for any
1238- purpose is hereby granted without fee, provided that the above copyright
1239- notice appear in all copies and that both that copyright notice and this
1240- permission notice appear in supporting documentation.
1241- The author or Addison-Wesley Longman make no representations about the
1242- suitability of this software for any purpose. It is provided "as is"
1243- without express or implied warranty.
1244-
1245-
1246-External libraries used by this project:
1247-----------------------------------------------------
1248-
1249-Name: LIBXML2
1250-Preferred version: 2.2.16 or higher
1251-Is mandatory: true
1252-Website: http://xmlsoft.org/
1253-License: MIT
1254-Copyright: 1998-2002 Daniel Veillard. All Rights Reserved.
1255-External notice:
1256-
1257- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1258-
1259- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
1260-
1261- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1262-
1263- Except as contained in this notice, the name of Daniel Veillard shall not
1264- be used in advertising or otherwise to promote the sale, use or other deal-
1265- ings in this Software without prior written authorization from him.
1266-
1267-----------------------------------------------------
1268-
1269-Name: LIBXSLT
1270-Preferred version: 1.1.26
1271-Is mandatory: false
1272-Website: http://xmlsoft.org/XSLT/
1273-License: MIT
1274-Copyright: 2001-2002 Daniel Veillard. All Rights Reserved.
1275-External notice:
1276-
1277- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1278-
1279- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
1280-
1281- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL DANIEL VEILLARD BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1282-
1283-
1284- Except as contained in this notice, the name of Daniel Veillard shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from him.
1285-
1286-
1287-----------------------------------------------------
1288-
1289-Name: ICU4C
1290-Preferred version: 3.6 or higher
1291-Is mandatory: true
1292-Website: http://www.icu-project.org/
1293-License: ICU License
1294-Copyright: 1995-2011 International Business Machines Corporation and others
1295-External notice:
1296-
1297- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, provided that the above copyright notice(s) and this permission notice appear in all copies of the Software and that both the above copyright notice(s) and this permission notice appear in supporting documentation.
1298-
1299- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1300-
1301- Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder.
1302-
1303-----------------------------------------------------
1304-
1305-Name: CURL
1306-Preferred version: above 7.12
1307-Is mandatory: false
1308-Website: http://curl.haxx.se/
1309-License: MIT/X derivate license
1310-Copyright: 1996 - 2011, Daniel Stenberg, <daniel@haxx.se>.
1311-External notice:
1312-
1313- All rights reserved.
1314-
1315- Permission to use, copy, modify, and distribute this software for any purpose
1316- with or without fee is hereby granted, provided that the above copyright
1317- notice and this permission notice appear in all copies.
1318-
1319- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1320- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1321- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN
1322- NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
1323- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
1324- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
1325- OR OTHER DEALINGS IN THE SOFTWARE.
1326-
1327- Except as contained in this notice, the name of a copyright holder shall not
1328- be used in advertising or otherwise to promote the sale, use or other dealings
1329- in this Software without prior written authorization of the copyright holder.
1330-
1331-----------------------------------------------------
1332-
1333-Name: ICONV
1334-Preferred version: above 1.12
1335-Is mandatory: true
1336-Website: http://www.gnu.org/software/libiconv/
1337-License: LGPL
1338-Copyright: 1998, 2010 Free Software Foundation, Inc.
1339-External notice:
1340-
1341-----------------------------------------------------
1342-
1343-Name: ZLIB
1344-Preferred version: 1.2.5
1345-Is mandatory: true
1346-Website: http://www.zlib.net/
1347-Copyright: 1995-2004 Jean-loup Gailly and Mark Adler
1348-External notice:
1349-
1350- This software is provided 'as-is', without any express or implied
1351- warranty. In no event will the authors be held liable for any damages
1352- arising from the use of this software.
1353-
1354- Permission is granted to anyone to use this software for any purpose,
1355- including commercial applications, and to alter it and redistribute it
1356- freely, subject to the following restrictions:
1357-
1358- 1. The origin of this software must not be misrepresented; you must not
1359- claim that you wrote the original software. If you use this software
1360- in a product, an acknowledgment in the product documentation would be
1361- appreciated but is not required.
1362- 2. Altered source versions must be plainly marked as such, and must not be
1363- misrepresented as being the original software.
1364- 3. This notice may not be removed or altered from any source distribution.
1365-
1366- Jean-loup Gailly jloup@gzip.org
1367- Mark Adler madler@alumni.caltech.edu
1368-
1369-----------------------------------------------------
1370-
1371-Name: XERCES
1372-Preferred version: 2.8.0 or higher
1373-Is mandatory: true
1374-Website: http://xerces.apache.org/xerces-c/
1375-License: Apache 2
1376-Copyright: Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.
1377-External notice:
1378-
1379- http://www.apache.org/licenses/LICENSE-2.0
1380-
1381-----------------------------------------------------
1382-
1383-Name: BOOST (boost_filesystem)
1384-Preferred version: 1.32 or higher
1385-Is mandatory: false
1386-Website: http://www.boost.org/
1387-License: Boost Software License v1.0
1388-Copyright:
1389- Beman Dawes, David Abrahams, 1998-2005.
1390- Rene Rivera 2004-2007
1391-
1392-External notice:
1393-
1394- Permission is hereby granted, free of charge, to any person or organization
1395- obtaining a copy of the software and accompanying documentation covered by
1396- this license (the "Software") to use, reproduce, display, distribute,
1397- execute, and transmit the Software, and to prepare derivative works of the
1398- Software, and to permit third-parties to whom the Software is furnished to
1399- do so, all subject to the following:
1400-
1401- The copyright notices in the Software and this entire statement, including
1402- the above license grant, this restriction and the following disclaimer,
1403- must be included in all copies of the Software, in whole or in part, and
1404- all derivative works of the Software, unless such copies or derivative
1405- works are solely in the form of machine-executable object code generated by
1406- a source language processor.
1407-
1408- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1409- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1410- FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
1411- SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
1412- FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
1413- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1414- DEALINGS IN THE SOFTWARE.
1415-
1416-
1417-External applications used by this project:
1418-----------------------------------------------------
1419-
1420-Name: FLEX
1421-Preferred version: 2.5.33
1422-Is mandatory: false
1423-Website: http://flex.sourceforge.net/
1424-Copyright:
1425- 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 The Flex Project.
1426- 1990, 1997 The Regents of the University of California. All rights reserved.
1427-
1428-External notice:
1429-
1430- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1431-
1432- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
1433- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
1434-
1435- Neither the name of the University nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
1436-
1437- THIS SOFTWARE IS PROVIDED “AS IS” AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1438-
1439-----------------------------------------------------
1440-
1441-Name: BISON
1442-Preferred version: 2.4 or higher
1443-Is mandatory: false
1444-Website: http://www.gnu.org/software/bison/
1445-License: GPL
1446-Copyright: 1998, 2001, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
1447-External notice:
1448-
1449-----------------------------------------------------
1450-
1451-Name: DOXYGEN
1452-Preferred version: v1.7.4
1453-Is mandatory: false
1454-Website: www.doxygen.org
1455-License: GPL
1456-Copyright: 1997-2011 by Dimitri van Heesch
1457-External notice:
1458-
1459- Permission to use, copy, modify, and distribute this software and its documentation under the terms of the GNU General Public License is hereby granted.
1460- No representations are made about the suitability of this software for any purpose.
1461- It is provided "as is" without express or implied warranty.
1462- See the GNU General Public License for more details.
1463-
1464- Documents produced by doxygen are derivative works derived from the input used in their production; they are not affected by this license.
1465-
1466-----------------------------------------------------
1467-
1468-Name: CMAKE
1469-Preferred version: 2.8.4
1470-Is mandatory: true
1471-Website: http://www.cmake.org/
1472-License: Creative Commons Attribution-NoDerivs 3.0 Unported License
1473-Copyright: 2000-2009 Kitware, Inc., Insight Software Consortium. All rights reserved.
1474-External notice:
1475-
1476- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1477-
1478- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
1479-
1480- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
1481-
1482- Neither the names of Kitware, Inc., the Insight Software Consortium, nor the names of their contributors may be used to endorse or promote products derived from this software without specific prior written permission.
1483-
1484- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1485-
1486-----------------------------------------------------
1487-
1488-Name: SWIG
1489-Preferred version: 2.0.4 or above
1490-Is mandatory: false
1491-Website: http://www.swig.org/
1492-License: GPL
1493-Copyright:
1494- 1995-2011 The SWIG Developers
1495- 2005-2006 Arizona Board of Regents (University of Arizona).
1496- 1998-2005 University of Chicago.
1497- 1995-1998 The University of Utah and the Regents of the University of California
1498-
1499-External notice:
1500-
1501- SWIG is free software: you can redistribute it and/or modify it
1502- under the terms of the GNU General Public License as published by
1503- the Free Software Foundation, either version 3 of the License, or
1504- (at your option) any later version. See the LICENSE-GPL file for
1505- the full terms of the GNU General Public license version 3.
1506-
1507- Portions of SWIG are also licensed under the terms of the licenses
1508- in the file LICENSE-UNIVERSITIES. You must observe the terms of
1509- these licenses, as well as the terms of the GNU General Public License,
1510- when you distribute SWIG.
1511-
1512- The SWIG library and examples, under the Lib and Examples top level
1513- directories, are distributed under the following terms:
1514-
1515- You may copy, modify, distribute, and make derivative works based on
1516- this software, in source code or object code form, without
1517- restriction. If you distribute the software to others, you may do
1518- so according to the terms of your choice. This software is offered as
1519- is, without warranty of any kind.
1520-
1521- See the COPYRIGHT file for a list of contributors to SWIG and their
1522- copyright notices.
1523-
1524\ No newline at end of file
1525
1526=== modified file 'doc/cxx/examples/CMakeLists.txt'
1527--- doc/cxx/examples/CMakeLists.txt 2011-08-19 00:03:31 +0000
1528+++ doc/cxx/examples/CMakeLists.txt 2012-02-08 21:22:19 +0000
1529@@ -36,6 +36,10 @@
1530 # LIST(APPEND API_EXAMPLES debugger.cpp)
1531 ENDIF(ZORBA_WITH_DEBUGGER)
1532
1533+IF (ZORBA_WITH_JSON)
1534+ LIST (APPEND API_EXAMPLES jsoniq.cpp)
1535+ENDIF (ZORBA_WITH_JSON)
1536+
1537 CREATE_TEST_SOURCELIST(
1538 examples
1539 examples.cpp
1540@@ -63,6 +67,11 @@
1541 ZORBA_ADD_TEST(${TName} examples ${NAME_WITHOUT_EXT})
1542 ENDFOREACH(test)
1543
1544+# Any known bugs
1545+IF (ZORBA_WITH_JSON)
1546+ EXPECTED_FAILURE(doc/cxx/examples/jsoniq.cpp 928710)
1547+ENDIF (ZORBA_WITH_JSON)
1548+
1549 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/Makefile.cmake ${CMAKE_CURRENT_BINARY_DIR}/Makefile.zorba)
1550 MESSAGE(STATUS "configured ${CMAKE_CURRENT_SOURCE_DIR}/Makefile.cmake ${CMAKE_CURRENT_BINARY_DIR}/Makefile.zorba")
1551
1552
1553=== added file 'doc/cxx/examples/jsoniq.cpp'
1554--- doc/cxx/examples/jsoniq.cpp 1970-01-01 00:00:00 +0000
1555+++ doc/cxx/examples/jsoniq.cpp 2012-02-08 21:22:19 +0000
1556@@ -0,0 +1,392 @@
1557+/*
1558+ * Copyright 2006-2008 The FLWOR Foundation.
1559+ *
1560+ * Licensed under the Apache License, Version 2.0 (the "License");
1561+ * you may not use this file except in compliance with the License.
1562+ * You may obtain a copy of the License at
1563+ *
1564+ * http://www.apache.org/licenses/LICENSE-2.0
1565+ *
1566+ * Unless required by applicable law or agreed to in writing, software
1567+ * distributed under the License is distributed on an "AS IS" BASIS,
1568+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1569+ * See the License for the specific language governing permissions and
1570+ * limitations under the License.
1571+ */
1572+
1573+#include <iostream>
1574+#include <sstream>
1575+
1576+#include <zorba/zorba.h>
1577+#include <zorba/store_manager.h>
1578+#include <zorba/serializer.h>
1579+#include <zorba/singleton_item_sequence.h>
1580+#include <zorba/zorba_exception.h>
1581+
1582+using namespace zorba;
1583+
1584+namespace jsoniq_test {
1585+
1586+/**
1587+ * Test accessing a JSONArray's members
1588+ */
1589+bool
1590+example_1(Zorba* aZorba)
1591+{
1592+ Iterator_t lIterator, lMembers;
1593+ XQuery_t lQuery = aZorba->compileQuery("[ 1, 2, 3 ]");
1594+ lIterator = lQuery->iterator();
1595+ lIterator->open();
1596+ Item lItem;
1597+ lIterator->next(lItem);
1598+
1599+ // Ensure we got a JSON array
1600+ if (!lItem.isJSONItem() ||
1601+ lItem.getJSONItemKind() != store::StoreConsts::jsonArray) {
1602+ std::cerr << "Item is not JSON Array!" << std::endl;
1603+ return false;
1604+ }
1605+
1606+ // Ensure array has 3 integer members
1607+ lMembers = lItem.getArrayMembers();
1608+ lMembers->open();
1609+ Item lMember;
1610+ int count = 0;
1611+ while (lMembers->next(lMember)) {
1612+ // This will throw an exception if the item isn't an integer
1613+ std::cout << lMember.getLongValue() << std::endl;
1614+ count++;
1615+ }
1616+ if (count != 3) {
1617+ std::cerr << count << " array members returned, expecting 3" << std::endl;
1618+ return false;
1619+ }
1620+ lMembers->close();
1621+ lIterator->close();
1622+
1623+ return true;
1624+}
1625+
1626+
1627+/**
1628+ * Test accessing a JSONObject's Object Pairs, as well as the Pairs'
1629+ * names and values
1630+ */
1631+bool
1632+example_2(Zorba* aZorba)
1633+{
1634+ Iterator_t lIterator, lPairs;
1635+ XQuery_t lQuery = aZorba->compileQuery("{ \"one\" : 1, \"two\" : 2 }");
1636+ lIterator = lQuery->iterator();
1637+ lIterator->open();
1638+ Item lItem;
1639+ lIterator->next(lItem);
1640+
1641+ // Ensure we got a JSON object
1642+ if (!lItem.isJSONItem() ||
1643+ lItem.getJSONItemKind() != store::StoreConsts::jsonObject) {
1644+ std::cerr << "Item is not JSON object!" << std::endl;
1645+ return false;
1646+ }
1647+
1648+ // Ensure object has 2 pairs with integer values
1649+ lPairs = lItem.getObjectPairs();
1650+ lPairs->open();
1651+ Item lPair;
1652+ int count = 0;
1653+ while (lPairs->next(lPair)) {
1654+ if (!lPair.isJSONItem() ||
1655+ lPair.getJSONItemKind() != store::StoreConsts::jsonPair) {
1656+ std::cerr << "Item is not a JSON pair!" << std::endl;
1657+ }
1658+ Item lName = lPair.getPairName();
1659+ std::cout << " \"" << lName.getStringValue() << "\": ";
1660+ Item lValue = lPair.getPairValue();
1661+ std::cout << lValue.getLongValue() << std::endl;
1662+ count++;
1663+ }
1664+ if (count != 2) {
1665+ std::cerr << count << " object pairs returned, expecting 2" << std::endl;
1666+ return false;
1667+ }
1668+ lPairs->close();
1669+ lIterator->close();
1670+
1671+ return true;}
1672+
1673+
1674+/**
1675+ * Test accessing a JSONArray's members directly by index
1676+ */
1677+bool
1678+example_3(Zorba* aZorba)
1679+{
1680+ Iterator_t lIterator;
1681+ XQuery_t lQuery = aZorba->compileQuery("[ 1, 2, 3 ]");
1682+ lIterator = lQuery->iterator();
1683+ lIterator->open();
1684+ Item lItem;
1685+ lIterator->next(lItem);
1686+
1687+ Item lMember;
1688+ for (int i = 1; i <= 3; i++) {
1689+ lMember = lItem.getArrayMember(i);
1690+ std::cout << lMember.getLongValue() << std::endl;
1691+ }
1692+
1693+ lIterator->close();
1694+
1695+ return true;
1696+}
1697+
1698+
1699+/**
1700+ * Test accessing a JSONObject's values directly by name
1701+ */
1702+bool
1703+example_4(Zorba* aZorba)
1704+{
1705+ Iterator_t lIterator;
1706+ XQuery_t lQuery = aZorba->compileQuery("{ \"one\" : 1, \"two\" : 2 }");
1707+ lIterator = lQuery->iterator();
1708+ lIterator->open();
1709+ Item lItem;
1710+ lIterator->next(lItem);
1711+
1712+ Item lValue;
1713+ lValue = lItem.getObjectValue("one");
1714+ std::cout << lValue.getLongValue() << std::endl;
1715+ lValue = lItem.getObjectValue("two");
1716+ std::cout << lValue.getLongValue() << std::endl;
1717+
1718+ lIterator->close();
1719+
1720+ return true;
1721+}
1722+
1723+/**
1724+ * Test accessing a non-existent JSONArray member
1725+ */
1726+bool
1727+example_5(Zorba* aZorba)
1728+{
1729+ Iterator_t lIterator, lMembers;
1730+ XQuery_t lQuery = aZorba->compileQuery("[ 1, 2, 3 ]");
1731+ lIterator = lQuery->iterator();
1732+ lIterator->open();
1733+ Item lItem;
1734+ lIterator->next(lItem);
1735+
1736+ Item lNonMember = lItem.getArrayMember(4);
1737+ lIterator->close();
1738+
1739+ if (!lNonMember.isNull()) {
1740+ return false;
1741+ }
1742+
1743+ return true;
1744+}
1745+
1746+/**
1747+ * Test accessing a non-existent JSONObject pair value
1748+ */
1749+bool
1750+example_6(Zorba* aZorba)
1751+{
1752+ Iterator_t lIterator;
1753+ XQuery_t lQuery = aZorba->compileQuery("{ \"one\" : 1, \"two\" : 2 }");
1754+ lIterator = lQuery->iterator();
1755+ lIterator->open();
1756+ Item lItem;
1757+ lIterator->next(lItem);
1758+
1759+ Item lNonValue = lItem.getObjectValue("three");
1760+ lIterator->close();
1761+
1762+ if (!lNonValue.isNull()) {
1763+ return false;
1764+ }
1765+ return true;
1766+}
1767+
1768+/**
1769+ * Utility function: Given an item, bind that item to a simple query and
1770+ * serialize the result, then ensure the result matches the expected string.
1771+ */
1772+bool
1773+serialize(Zorba* aZorba, Item aItem, std::string aExpected)
1774+{
1775+ Zorba_SerializerOptions lSerialOpt;
1776+ lSerialOpt.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;
1777+ XQuery_t lQuery = aZorba->compileQuery("declare variable $i external; $i");
1778+ lQuery->getDynamicContext()->setVariable("i", aItem);
1779+ std::stringstream lStream;
1780+ lQuery->execute(lStream, &lSerialOpt);
1781+ std::string lResult = lStream.str();
1782+ std::cout << lResult << std::endl;
1783+ if (lResult.compare(aExpected) != 0) {
1784+ std::cout << "Wrong value! Expected " << aExpected << std::endl;
1785+ return false;
1786+ }
1787+ return true;
1788+}
1789+
1790+/**
1791+ * Test creating a JSON null value.
1792+ */
1793+bool
1794+example_7(Zorba* aZorba)
1795+{
1796+ Item lNull = aZorba->getItemFactory()->createJSONNull();
1797+ return serialize(aZorba, lNull, "null");
1798+}
1799+
1800+/**
1801+ * Test creating some JSON numbers.
1802+ */
1803+bool
1804+example_8(Zorba* aZorba)
1805+{
1806+ Item lNum = aZorba->getItemFactory()->createJSONNumber(String("12345"));
1807+ if (lNum.getType().getLocalName().compare("integer") != 0) {
1808+ std::cout << "Didn't create an xs:integer!";
1809+ return false;
1810+ }
1811+ if (!serialize(aZorba, lNum, "12345")) {
1812+ return false;
1813+ }
1814+
1815+ lNum = aZorba->getItemFactory()->createJSONNumber(String("123.345"));
1816+ if (lNum.getType().getLocalName().compare("decimal") != 0) {
1817+ std::cout << "Didn't create an xs:decimal!";
1818+ return false;
1819+ }
1820+ if (!serialize(aZorba, lNum, "123.345")) {
1821+ return false;
1822+ }
1823+
1824+ lNum = aZorba->getItemFactory()->createJSONNumber(String("12.34e5"));
1825+ if (lNum.getType().getLocalName().compare("double") != 0) {
1826+ std::cout << "Didn't create an xs:double!";
1827+ return false;
1828+ }
1829+ if (!serialize(aZorba, lNum, "1.234E6")) {
1830+ return false;
1831+ }
1832+
1833+ return true;
1834+}
1835+
1836+/**
1837+ * Test creating a JSON pair.
1838+ */
1839+bool example_9(Zorba* aZorba)
1840+{
1841+ Item lValue = aZorba->getItemFactory()->createJSONNumber("1234");
1842+ Item lPair = aZorba->getItemFactory()->createJSONPair("name", lValue);
1843+ // Standalone Pairs get boxed into a JSON Object
1844+ return serialize(aZorba, lPair, "{ \"name\" : 1234 }");
1845+}
1846+
1847+/**
1848+ * Test creating a JSON array.
1849+ */
1850+bool example_10(Zorba* aZorba)
1851+{
1852+ std::vector<Item> lMembers;
1853+ for (int i = 1; i <= 4; i++) {
1854+ // xs:int is fine for JSON arrays
1855+ lMembers.push_back(aZorba->getItemFactory()->createInt(i));
1856+ }
1857+ Item lArray = aZorba->getItemFactory()->createJSONArray(lMembers);
1858+ return serialize(aZorba, lArray, "[ 1, 2, 3, 4 ]");
1859+}
1860+
1861+/**
1862+ * Test creating a JSON object.
1863+ */
1864+bool example_11(Zorba* aZorba)
1865+{
1866+ Item lValue = aZorba->getItemFactory()->createInt(1234);
1867+ std::vector<Item> lPairs;
1868+ lPairs.push_back(aZorba->getItemFactory()->createJSONPair("foo", lValue));
1869+
1870+ Item lObject = aZorba->getItemFactory()->createJSONObject(lPairs);
1871+ return serialize(aZorba, lObject, "{ \"foo\" : 1234 }");
1872+}
1873+
1874+} /* namespace jsoniq-test */
1875+
1876+int
1877+jsoniq(int argc, char* argv[])
1878+{
1879+ void* lStore = StoreManager::getStore();
1880+ Zorba *lZorba = Zorba::getInstance(lStore);
1881+
1882+ bool res = false;
1883+
1884+ try {
1885+ std::cout << "executing jsoniq example 1" << std::endl;
1886+ res = jsoniq_test::example_1(lZorba);
1887+ if (!res) return 1;
1888+ std::cout << std::endl;
1889+
1890+ std::cout << "executing jsoniq example 2" << std::endl;
1891+ res = jsoniq_test::example_2(lZorba);
1892+ if (!res) return 1;
1893+ std::cout << std::endl;
1894+
1895+ std::cout << "executing jsoniq example 3" << std::endl;
1896+ res = jsoniq_test::example_3(lZorba);
1897+ if (!res) return 1;
1898+ std::cout << std::endl;
1899+
1900+ std::cout << "executing jsoniq example 4" << std::endl;
1901+ res = jsoniq_test::example_4(lZorba);
1902+ if (!res) return 1;
1903+ std::cout << std::endl;
1904+
1905+ std::cout << "executing jsoniq example 5" << std::endl;
1906+ res = jsoniq_test::example_5(lZorba);
1907+ if (!res) return 1;
1908+ std::cout << std::endl;
1909+
1910+ std::cout << "executing jsoniq example 6" << std::endl;
1911+ res = jsoniq_test::example_6(lZorba);
1912+ if (!res) return 1;
1913+ std::cout << std::endl;
1914+
1915+ std::cout << "executing jsoniq example 7" << std::endl;
1916+ res = jsoniq_test::example_7(lZorba);
1917+ if (!res) return 1;
1918+ std::cout << std::endl;
1919+
1920+ std::cout << "executing jsoniq example 8" << std::endl;
1921+ res = jsoniq_test::example_8(lZorba);
1922+ if (!res) return 1;
1923+ std::cout << std::endl;
1924+
1925+ std::cout << "executing jsoniq example 9" << std::endl;
1926+ res = jsoniq_test::example_9(lZorba);
1927+ if (!res) return 1;
1928+ std::cout << std::endl;
1929+
1930+ std::cout << "executing jsoniq example 10" << std::endl;
1931+ res = jsoniq_test::example_10(lZorba);
1932+ if (!res) return 1;
1933+ std::cout << std::endl;
1934+
1935+ std::cout << "executing jsoniq example 11" << std::endl;
1936+ res = jsoniq_test::example_11(lZorba);
1937+ if (!res) return 1;
1938+ std::cout << std::endl;
1939+ }
1940+ catch (ZorbaException& e) {
1941+ std::cout << "ZorbaException raised: " << e.what() << std::endl;
1942+ return 2;
1943+ }
1944+
1945+ lZorba->shutdown();
1946+ StoreManager::shutdownStore(lStore);
1947+ return 0;
1948+}
1949
1950=== modified file 'doc/zorba/CMakeLists.txt'
1951--- doc/zorba/CMakeLists.txt 2011-10-07 08:28:43 +0000
1952+++ doc/zorba/CMakeLists.txt 2012-02-08 21:22:19 +0000
1953@@ -46,6 +46,10 @@
1954 ${CMAKE_CURRENT_BINARY_DIR}/html/noisepattern.png COPYONLY)
1955 CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/scripting_spec.html
1956 ${CMAKE_CURRENT_BINARY_DIR}/html/scripting_spec.html COPYONLY)
1957+ CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/XQueryforJSON.html
1958+ ${CMAKE_CURRENT_BINARY_DIR}/html/XQueryforJSON.html COPYONLY)
1959+ CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/JSONforXQuery.html
1960+ ${CMAKE_CURRENT_BINARY_DIR}/html/JSONforXQuery.html COPYONLY)
1961 CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/W3C-WD.css
1962 ${CMAKE_CURRENT_BINARY_DIR}/html/W3C-WD.css COPYONLY)
1963
1964
1965=== added file 'doc/zorba/JSONforXQuery.html'
1966--- doc/zorba/JSONforXQuery.html 1970-01-01 00:00:00 +0000
1967+++ doc/zorba/JSONforXQuery.html 2012-02-08 21:22:19 +0000
1968@@ -0,0 +1,1 @@
1969+<html><head><title>JSON for XQuery</title><style type="text/css">@import url('https://themes.googleusercontent.com/fonts/css?kit=lhDjYqiy3mZ0x6ROQEUoUw');ol{margin:0;padding:0}p{margin:0}.c8{padding-left:0pt;text-align:justify;margin-left:36pt}.c19{max-width:468pt;background-color:#ffffff;padding:72pt 72pt 72pt 72pt}.c20{list-style-type:disc;margin:0;padding:0}.c0{color:#1155cc;text-decoration:underline}.c13{color:inherit;text-decoration:inherit}.c1{text-indent:139.5pt;direction:ltr}.c17{text-align:center}.c11{margin-left:36pt}.c10{margin-left:18pt}.c14{text-indent:144pt}.c15{font-weight:bold}.c22{color:#4a86e8}.c18{height:18pt}.c6{margin-left:144pt}.c9{height:11pt}.c3{direction:ltr}.c4{text-align:right}.c7{font-style:italic}.c16{margin-left:58.5pt}.c12{text-align:justify}.c5{color:#38761d}.c2{font-family:Consolas}.c21{margin-left:49.5pt}.title{padding-top:24pt;line-height:1.15;text-align:center;color:#4a86e8;font-size:36pt;font-family:Arial;font-weight:bold;padding-bottom:6pt}.subtitle{padding-top:18pt;line-height:1.15;text-align:left;color:#666666;font-style:italic;font-size:24pt;font-family:Georgia;padding-bottom:4pt}body{color:#000000;font-size:11pt;font-family:Arial}h1{padding-top:24pt;line-height:1.15;text-align:left;color:#4a86e8;font-size:24pt;font-family:Arial;font-weight:bold;padding-bottom:6pt}h2{padding-top:18pt;line-height:1.15;text-align:left;color:#ff9900;font-size:18pt;font-family:Arial;font-weight:bold;padding-bottom:4pt}h3{padding-top:14pt;line-height:1.15;text-align:left;color:#000000;font-size:14pt;font-family:Arial;font-weight:bold;padding-bottom:4pt}h4{padding-top:12pt;line-height:1.15;text-align:left;color:#000000;font-size:12pt;font-family:Arial;font-weight:bold;padding-bottom:2pt}h5{padding-top:11pt;line-height:1.15;text-align:left;color:#000000;font-size:11pt;font-family:Arial;font-weight:bold;padding-bottom:2pt}h6{padding-top:10pt;line-height:1.15;text-align:left;color:#000000;font-size:10pt;font-family:Arial;font-weight:bold;padding-bottom:2pt}</style></head><body class="c19"><p class="c3 title"><a name="h.li2wdq8unbq"></a><span>JSONiq for XQuery users</span></p><p class="c3 title"><a name="h.5ipqqclfxk4n"></a><span class="c5">JSON for XQuery</span></p><hr><p class="c17 c3"><span>This tutorial introduces the JSONiq language, which declaratively manipulates JSON data.</span></p><p class="c17 c3"><span>Why don&#39;t you go ahead can try the queries of this document on our online demo interface?</span></p><p class="c3 c17"><span>&nbsp;</span><span class="c0 c15"><a class="c13" href="http://jsoniq.zorba-xquery.com/">http://jsoniq.zorba-xquery.com/</a></span></p><hr><p class="c9 c3"><span></span></p><h2 class="c3 c18"><a name="h.8gra0ylxutrv"></a></h2><p class="c10 c3"><span class="c0"><a class="c13" href="#h.f453h84m2u1a">JSON</a></span></p><p class="c3 c10"><span class="c0"><a class="c13" href="#h.qtfakecy3fr7">Elevator Pitch</a></span></p><p class="c10 c3"><span class="c0"><a class="c13" href="#h.yugk1mszt0re">And here you go</a></span></p><p class="c3 c11"><span class="c0"><a class="c13" href="#h.39rm37noeh9g">JSONiq types</a></span></p><p class="c11 c3"><span class="c0"><a class="c13" href="#h.j0wg8654ivtw">JSON Constructors</a></span></p><p class="c11 c3"><span class="c0"><a class="c13" href="#h.qe57mgdf5ql">JSON as a subset of JSONiq</a></span></p><p class="c10 c3"><span class="c0"><a class="c13" href="#h.mjv7kyjurri2">JSON Navigation</a></span></p><p class="c11 c3"><span class="c0"><a class="c13" href="#h.xosiyb17dh24">Objects</a></span></p><p class="c11 c3"><span class="c0"><a class="c13" href="#h.mrf42gizl3y6">Arrays</a></span></p><p class="c11 c3"><span class="c0"><a class="c13" href="#h.hdc3dgohtdut">Pairs</a></span></p><p class="c10 c3"><span class="c0"><a class="c13" href="#h.eb0bxle2oykl">Relational Algebra</a></span></p><p class="c10 c3"><span class="c0"><a class="c13" href="#h.oii6pvliilhi">Access external data</a></span></p><p class="c10 c3"><span class="c0"><a class="c13" href="#h.bm3buqmzhtko">I want more</a></span></p><p><span></span></p><p class="c9 c3"><span></span></p><h1 class="c3"><a name="h.f453h84m2u1a"></a><span>JSON</span></h1><p class="c3 c12"><span>As explained on </span><span class="c0"><a class="c13" href="http://www.json.org/">http://www.json.org/</a></span><span>, JSON is a lightweight data-interchange format designed for humans as well as for computers. It supports as values:</span></p><ol class="c20" start="1"><li class="c8 c3"><span>objects (string-to-value map)</span></li><li class="c8 c3"><span>arrays (ordered sequence of values)</span></li><li class="c8 c3"><span>strings</span></li><li class="c8 c3"><span>numbers</span></li><li class="c8 c3"><span>booleans (true, false)</span></li><li class="c8 c3"><span>null</span></li></ol><p class="c9 c3"><span></span></p><p class="c3"><span>JSONiq extends XQuery to query and update JSON data, like XML data.</span></p><h1 class="c3"><a name="h.qtfakecy3fr7"></a><span>Elevator Pitch</span></h1><p class="c3 c12"><span>Here is an appetizer before we start the tutorial from scratch.</span></p><p class="c9 c3"><span></span></p><p class="c3"><span class="c2">let $stores :=</span></p><p class="c3"><span class="c2">[</span></p><p class="c3"><span class="c2">&nbsp; { &quot;store number&quot; : 1, &quot;state&quot; : &quot;MA&quot; },</span></p><p class="c3"><span class="c2">&nbsp; { &quot;store number&quot; : 2, &quot;state&quot; : &quot;MA&quot; },</span></p><p class="c3"><span class="c2">&nbsp; { &quot;store number&quot; : 3, &quot;state&quot; : &quot;CA&quot; },</span></p><p class="c3"><span class="c2">&nbsp; { &quot;store number&quot; : 4, &quot;state&quot; : &quot;CA&quot; }</span></p><p class="c3"><span class="c2">]</span></p><p class="c3"><span class="c2">let $sales := [</span></p><p class="c3"><span class="c2">&nbsp; &nbsp;{ &quot;product&quot; : &quot;broiler&quot;, &quot;store number&quot; : 1, &quot;quantity&quot; : 20 &nbsp;},</span></p><p class="c3"><span class="c2">&nbsp; &nbsp;{ &quot;product&quot; : &quot;toaster&quot;, &quot;store number&quot; : 2, &quot;quantity&quot; : 100 },</span></p><p class="c3"><span class="c2">&nbsp; &nbsp;{ &quot;product&quot; : &quot;toaster&quot;, &quot;store number&quot; : 2, &quot;quantity&quot; : 50 },</span></p><p class="c3"><span class="c2">&nbsp; &nbsp;{ &quot;product&quot; : &quot;toaster&quot;, &quot;store number&quot; : 3, &quot;quantity&quot; : 50 },</span></p><p class="c3"><span class="c2">&nbsp; &nbsp;{ &quot;product&quot; : &quot;blender&quot;, &quot;store number&quot; : 3, &quot;quantity&quot; : 100 },</span></p><p class="c3"><span class="c2">&nbsp; &nbsp;{ &quot;product&quot; : &quot;blender&quot;, &quot;store number&quot; : 3, &quot;quantity&quot; : 150 },</span></p><p class="c3"><span class="c2">&nbsp; &nbsp;{ &quot;product&quot; : &quot;socks&quot;, &quot;store number&quot; : 1, &quot;quantity&quot; : 500 },</span></p><p class="c3"><span class="c2">&nbsp; &nbsp;{ &quot;product&quot; : &quot;socks&quot;, &quot;store number&quot; : 2, &quot;quantity&quot; : 10 },</span></p><p class="c3"><span class="c2">&nbsp; &nbsp;{ &quot;product&quot; : &quot;shirt&quot;, &quot;store number&quot; : 3, &quot;quantity&quot; : 10 }</span></p><p class="c3"><span class="c2">]</span></p><p class="c3"><span class="c2">let $join :=</span></p><p class="c3"><span class="c2">&nbsp; for $store in jn:values($stores), $sale in jn:values($sales)</span></p><p class="c3"><span class="c2">&nbsp; where $store(&quot;store number&quot;) = $sale(&quot;store number&quot;)</span></p><p class="c3"><span class="c2">&nbsp; return {</span></p><p class="c3"><span class="c2">&nbsp; &nbsp; &quot;nb&quot; : $store(&quot;store number&quot;),</span></p><p class="c3"><span class="c2">&nbsp; &nbsp; &quot;state&quot; : $store(&quot;state&quot;),</span></p><p class="c3"><span class="c2">&nbsp; &nbsp; &quot;sold&quot; : $sale(&quot;product&quot;)</span></p><p class="c3"><span class="c2">&nbsp; }</span></p><p class="c3"><span class="c2">return [$join]</span></p><p class="c6 c3"><span class="c5 c2">[ </span></p><p class="c6 c3"><span class="c5 c2">&nbsp; { &quot;nb&quot; : 1, &quot;state&quot; : &quot;MA&quot;, &quot;sold&quot; : &quot;broiler&quot; },</span></p><p class="c6 c3"><span class="c5 c2">&nbsp; { &quot;nb&quot; : 1, &quot;state&quot; : &quot;MA&quot;, &quot;sold&quot; : &quot;socks&quot; },</span></p><p class="c6 c3"><span class="c5 c2">&nbsp; { &quot;nb&quot; : 2, &quot;state&quot; : &quot;MA&quot;, &quot;sold&quot; : &quot;toaster&quot; },</span></p><p class="c6 c3"><span class="c5 c2">&nbsp; { &quot;nb&quot; : 2, &quot;state&quot; : &quot;MA&quot;, &quot;sold&quot; : &quot;toaster&quot; },</span></p><p class="c6 c3"><span class="c5 c2">&nbsp; { &quot;nb&quot; : 2, &quot;state&quot; : &quot;MA&quot;, &quot;sold&quot; : &quot;socks&quot; },</span></p><p class="c6 c3"><span class="c5 c2">&nbsp; { &quot;nb&quot; : 3, &quot;state&quot; : &quot;CA&quot;, &quot;sold&quot; : &quot;toaster&quot; },</span></p><p class="c6 c3"><span class="c5 c2">&nbsp; { &quot;nb&quot; : 3, &quot;state&quot; : &quot;CA&quot;, &quot;sold&quot; : &quot;blender&quot; },</span></p><p class="c6 c3"><span class="c5 c2">&nbsp; { &quot;nb&quot; : 3, &quot;state&quot; : &quot;CA&quot;, &quot;sold&quot; : &quot;blender&quot; },</span></p><p class="c6 c3"><span class="c5 c2">&nbsp; { &quot;nb&quot; : 3, &quot;state&quot; : &quot;CA&quot;, &quot;sold&quot; : &quot;shirt&quot; }</span></p><p class="c6 c3"><span class="c5 c2">&nbsp;]</span></p><p class="c9 c3"><span></span></p><h1 class="c3"><a name="h.yugk1mszt0re"></a><span>And here you go</span></h1><h2 class="c3"><a name="h.39rm37noeh9g"></a><span>JSONiq types</span></h2><p class="c3"><span>JSONiq maps JSON types to XQuery. Numbers are xs:integer or xs:decimal, strings are xs:string, true and false are xs:boolean and null is a new atomic type jn:null.</span></p><p class="c9 c3"><span></span></p><p class="c3"><span>JSONiq introduces new items: objects, arrays and pairs. Objects have pairs. Pairs have a string name and a value. Array have members which are values. Values are objects, arrays, XML nodes or atomic items.</span></p><p class="c9 c3"><span></span></p><p class="c3"><span>The new item types for objects and arrays are object() and array(). json-item() is a supertype of both, and json-pair() is the item type for pairs.</span></p><h2 class="c3"><a name="h.j0wg8654ivtw"></a><span>JSON Constructors</span></h2><p class="c3"><span>JSONiq introduces JSON constructors, in a similar way to XML constructors.</span></p><p class="c9 c3"><span></span></p><p class="c3"><span>You can put any expression in a array. The items in the sequence produced by the expression will become members of the array:</span></p><p class="c9 c3"><span></span></p><p class="c3"><span class="c2">[ 1 to 10 ]</span></p><p class="c3 c4"><span class="c5 c2">[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]</span></p><p class="c9 c3 c4"><span class="c5 c2"></span></p><p class="c3"><span>Or you can dynamically compute an object:</span></p><p class="c9 c3"><span></span></p><p class="c3"><span class="c2">{</span></p><p class="c3"><span class="c2">&nbsp; &quot;Greeting&quot; : let $d := &quot;Mister Spock&quot;</span></p><p class="c3"><span class="c2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return concat(&quot;Hello, &quot;, $d),</span></p><p class="c3"><span class="c2">&nbsp; &quot;Farewell&quot; : string-join((&quot;Live&quot;, &quot;long&quot;, &quot;and&quot;, &quot;prosper&quot;),</span></p><p class="c3"><span class="c2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot; &quot;)</span></p><p class="c3"><span class="c2">}</span></p><p class="c9 c3"><span class="c2 c5"></span></p><p class="c3 c4"><span class="c5 c2">{ &quot;Greeting&quot; : &quot;Hello, Mister Spock&quot;, &quot;Farewell&quot; : &quot;Live long and prosper&quot; }</span></p><p class="c9 c3"><span class="c5"></span></p><p class="c3"><span>You can also dynamically generate pairs:</span></p><p class="c9 c3"><span class="c2"></span></p><p class="c3"><span class="c2">concat(&quot;Integer &quot;, 2) : 2 * 2</span></p><p class="c3 c4"><span class="c5 c2">&quot;Integer 2&quot; : 4</span></p><p class="c9 c3 c4"><span class="c5 c2"></span></p><p class="c3"><span>and then wrap lots of them in an object:</span></p><p class="c9 c3"><span class="c2"></span></p><p class="c3"><span class="c2">{</span></p><p class="c3"><span class="c2">&nbsp; for $i in 1 to 10</span></p><p class="c3"><span class="c2">&nbsp; return concat(&quot;Square of &quot;, $i) : $i * $i</span></p><p class="c3"><span class="c2">}</span></p><p class="c6 c3"><span class="c5 c2">{</span></p><p class="c6 c3"><span class="c5 c2">&quot;Square of 1&quot; : 1,</span></p><p class="c6 c3"><span class="c5 c2">&quot;Square of 2&quot; : 4,</span></p><p class="c6 c3"><span class="c5 c2">&quot;Square of 3&quot; : 9,</span></p><p class="c6 c3"><span class="c5 c2">&quot;Square of 4&quot; : 16,</span></p><p class="c3 c6"><span class="c5 c2">&quot;Square of 5&quot; : 25,</span></p><p class="c6 c3"><span class="c5 c2">&quot;Square of 6&quot; : 36,</span></p><p class="c6 c3"><span class="c5 c2">&quot;Square of 7&quot; : 49,</span></p><p class="c6 c3"><span class="c5 c2">&quot;Square of 8&quot; : 64,</span></p><p class="c6 c3"><span class="c5 c2">&quot;Square of 9&quot; : 81,</span></p><p class="c6 c3"><span class="c5 c2">&quot;Square of 10&quot; : 100</span></p><p class="c6 c3"><span class="c5 c2">}</span></p><p class="c9 c3"><span></span></p><h2 class="c3"><a name="h.qe57mgdf5ql"></a><span>JSON as a subset of JSONiq</span></h2><p class="c3 c12"><span>Every well-formed JSON document is a JSONiq query as well, because This means that you can copy-and-paste a JSON document into a query. The following are JSONiq queries that are &quot;idempotent&quot; (they just output themselves):</span></p><p class="c9 c3"><span></span></p><p class="c3"><span class="c2">{ &quot;pi&quot; : 3.14, &quot;sq2&quot; : 1.4 }</span></p><p class="c3 c4"><span class="c5 c2">{ &quot;pi&quot; : 3.14, &quot;sq2&quot; : 1.4 }</span></p><p class="c9 c3"><span class="c5 c2"></span></p><p class="c3"><span class="c2">[ 2, 3, 5, 7, 11, 13 ]</span></p><p class="c3 c4"><span class="c5 c2">[ 2, 3, 5, 7, 11, 13 ]</span></p><p class="c9 c3"><span class="c2"></span></p><p class="c3"><span class="c2">{</span></p><p class="c3"><span class="c2">&nbsp; &quot;operations&quot; : [</span></p><p class="c3"><span class="c2">&nbsp; &nbsp; { &quot;binary&quot; : [ &quot;and&quot;, &quot;or&quot;] },</span></p><p class="c3"><span class="c2">&nbsp; &nbsp; { &quot;unary&quot; : [&quot;not&quot;] }</span></p><p class="c3"><span class="c2">&nbsp; ],</span></p><p class="c3"><span class="c2">&nbsp; &quot;bits&quot; : [</span></p><p class="c3"><span class="c2">&nbsp; &nbsp; 0, 1</span></p><p class="c3"><span class="c2">&nbsp; ]</span></p><p class="c3"><span class="c2">}</span></p><p class="c14 c3"><span class="c5 c2">{</span></p><p class="c14 c3"><span class="c5 c2">&nbsp; &quot;operations&quot; : [</span></p><p class="c14 c3"><span class="c5 c2">&nbsp; &nbsp; { &quot;binary&quot; : [ &quot;and&quot;, &quot;or&quot; ] },</span></p><p class="c14 c3"><span class="c5 c2">&nbsp; &nbsp; { &quot;unary&quot; : [ &quot;not&quot; ] }</span></p><p class="c14 c3"><span class="c5 c2">&nbsp; ],</span></p><p class="c14 c3"><span class="c5 c2">&nbsp; &quot;bits&quot; : [</span></p><p class="c14 c3"><span class="c5 c2">&nbsp; &nbsp; 0, 1</span></p><p class="c3 c14"><span class="c5 c2">&nbsp; ]</span></p><p class="c14 c3"><span class="c5 c2">}</span></p><p class="c9 c3 c4"><span class="c5 c2"></span></p><p class="c3 c12"><span>This works with objects, arrays (even nested), strings, numbers, booleans, null. </span><span class="c7">The exceptions to this rule (but we are working on it!) are that:</span></p><p class="c3 c12"><span class="c7">(i) if a pair has a true, false or null value, there must be a space on at least one side of the colon (this will be fixed).</span></p><p class="c3 c12"><span class="c7">(ii) empty objects are not recognized</span></p><p class="c3 c12"><span class="c7">(iii) characters escaped with the \ in JSON strings are not recognized</span></p><p class="c3 c9"><span class="c7 c2"></span></p><p class="c3 c12"><span>It also works the other way round: if your query outputs an object or an array, you can readily use it as a JSON document.</span></p><p class="c9 c3 c4"><span class="c5 c2"></span></p><h1 class="c3"><a name="h.mjv7kyjurri2"></a><span>JSON Navigation</span></h1><p class="c3 c12"><span>I</span><span>f you have some JSON data, you can access it and navigate.</span></p><p class="c9 c3 c12"><span></span></p><p class="c3 c12"><span>All you need to know is, again: JSONiq views</span></p><ol class="c20" start="1"><li class="c3 c8"><span>an array as a sequence of values,</span></li><li class="c8 c3"><span>an object as a set of pairs,</span></li><li class="c8 c3"><span>a pair as a (name, value) tuple.</span></li></ol><h2 class="c3 c12"><a name="h.xosiyb17dh24"></a><span>Objects</span></h2><p class="c3 c12"><span>If you use an object as a functor and provide it with a string, it will return the pair named after its parameter:</span></p><p class="c9 c3"><span class="c2"></span></p><p class="c3"><span class="c2">let $person := {</span></p><p class="c3"><span class="c2">&nbsp; &quot;first name&quot; : &quot;Sarah&quot;,</span></p><p class="c3"><span class="c2">&nbsp; &quot;age&quot; : 13,</span></p><p class="c3"><span class="c2">&nbsp; &quot;gender&quot; : &quot;female&quot;,</span></p><p class="c3"><span class="c2">&nbsp; &quot;friends&quot; : [ &quot;Jim&quot;, &quot;Mary&quot;, &quot;Jennifer&quot;]</span></p><p class="c3"><span class="c2">}</span></p><p class="c3"><span class="c2">return $person(&quot;first name&quot;)</span></p><p class="c3 c4"><span class="c5 c2">&quot;first name&quot; : &quot;Sarah&quot;</span></p><p class="c9 c3 c4"><span class="c5 c2"></span></p><h2 class="c3"><a name="h.mrf42gizl3y6"></a><span>Arrays</span></h2><p class="c3 c12"><span>If you use an array as a functor and provide it with an integer, it will return the corresponding entry:</span></p><p class="c9 c3"><span class="c2"></span></p><p class="c3"><span class="c2">let $friends := [ &quot;Jim&quot;, &quot;Mary&quot;, &quot;Jennifer&quot;]</span></p><p class="c3"><span class="c2">return $friends(2)</span></p><p class="c3 c4"><span class="c5 c2">Mary</span></p><h2 class="c3"><a name="h.hdc3dgohtdut"></a><span>Pairs</span></h2><p class="c3"><span>Given a pair, you can get its name and value using the functions jn:name and jn:value:</span></p><p class="c9 c3"><span></span></p><p class="c3"><span class="c2">let $pair := &quot;name of the pair&quot; : &quot;value of the pair&quot;</span></p><p class="c3"><span class="c2">return { &nbsp;&quot;name&quot; : jn:name($pair), &quot;value&quot; : jn:value($pair) }</span></p><p class="c9 c3"><span class="c2"></span></p><p class="c3 c4"><span class="c5 c2">{ &quot;name&quot; : &quot;name of the pair&quot;, &quot;value&quot; : &quot;value of the pair&quot; }</span></p><p class="c9 c3"><span class="c5"></span></p><p class="c3"><span>This functions also exist in plural form for objects:</span></p><p class="c9 c3"><span></span></p><p class="c3"><span class="c2">let $person := {</span></p><p class="c3"><span class="c2">&nbsp; &quot;name&quot; : &quot;Sarah&quot;,</span></p><p class="c3"><span class="c2">&nbsp; &quot;age&quot; : 13,</span></p><p class="c3"><span class="c2">&nbsp; &quot;gender&quot; : &quot;female&quot;,</span></p><p class="c3"><span class="c2">&nbsp; &quot;friends&quot; : [ &quot;Jim&quot;, &quot;Mary&quot;, &quot;Jennifer&quot;]</span></p><p class="c3"><span class="c2">}</span></p><p class="c3"><span class="c2">return { &quot;names&quot; : [ jn:names($person)],</span></p><p class="c3"><span class="c2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot;values&quot; : [ jn:values($person)]</span></p><p class="c3"><span class="c2">&nbsp; &nbsp; &nbsp; &nbsp;}</span></p><p class="c3 c16"><span class="c5 c2">{</span></p><p class="c3 c16"><span class="c5 c2">&quot;names&quot; : [ &quot;name&quot;, &quot;age&quot;, &quot;gender&quot;, &quot;friends&quot; ],</span></p><p class="c3 c16"><span class="c5 c2">&quot;values&quot; : [ &quot;Sarah&quot;, 13, &quot;female&quot;, [ &quot;Jim&quot;, &quot;Mary&quot;, &quot;Jennifer&quot; ] ]</span></p><p class="c3 c16"><span class="c5 c2">}</span></p><p class="c3"><span>jn:values can also be used for an array:</span></p><p class="c9 c3"><span></span></p><p class="c3"><span class="c2">let $person := {</span></p><p class="c3"><span class="c2">&nbsp; &quot;name&quot; : &quot;Sarah&quot;,</span></p><p class="c3"><span class="c2">&nbsp; &quot;age&quot; : 13,</span></p><p class="c3"><span class="c2">&nbsp; &quot;gender&quot; : &quot;female&quot;,</span></p><p class="c3"><span class="c2">&nbsp; &quot;friends&quot; : [ &quot;Jim&quot;, &quot;Mary&quot;, &quot;Jennifer&quot;]</span></p><p class="c3"><span class="c2">}</span></p><p class="c3"><span class="c2">return jn:values($person(&quot;friends&quot;))</span></p><p class="c3 c4"><span class="c5">[ &quot;Jim&quot;, &quot;Mary&quot;, &quot;Jennifer&quot; ]</span></p><p class="c9 c3 c4"><span class="c5"></span></p><h1 class="c3"><a name="h.eb0bxle2oykl"></a><span>Relational Algebra</span></h1><p class="c3 c12"><span>Remember last century&#39;s SELECT FROM WHERE statements? Well, JSONiq didn&#39;t throw out the baby with the bathwater. It has selection, projection and join capability.</span></p><p class="c9 c3"><span></span></p><p class="c3"><span class="c2">let $stores :=</span></p><p class="c3"><span class="c2">[</span></p><p class="c3"><span class="c2">&nbsp; { &quot;store number&quot; : 1, &quot;state&quot; : &quot;MA&quot; },</span></p><p class="c3"><span class="c2">&nbsp; { &quot;store number&quot; : 2, &quot;state&quot; : &quot;MA&quot; },</span></p><p class="c3"><span class="c2">&nbsp; { &quot;store number&quot; : 3, &quot;state&quot; : &quot;CA&quot; },</span></p><p class="c3"><span class="c2">&nbsp; { &quot;store number&quot; : 4, &quot;state&quot; : &quot;CA&quot; }</span></p><p class="c3"><span class="c2">]</span></p><p class="c3"><span class="c2">let $sales := [</span></p><p class="c3"><span class="c2">&nbsp; &nbsp;{ &quot;product&quot; : &quot;broiler&quot;, &quot;store number&quot; : 1, &quot;quantity&quot; : 20 &nbsp;},</span></p><p class="c3"><span class="c2">&nbsp; &nbsp;{ &quot;product&quot; : &quot;toaster&quot;, &quot;store number&quot; : 2, &quot;quantity&quot; : 100 },</span></p><p class="c3"><span class="c2">&nbsp; &nbsp;{ &quot;product&quot; : &quot;toaster&quot;, &quot;store number&quot; : 2, &quot;quantity&quot; : 50 },</span></p><p class="c3"><span class="c2">&nbsp; &nbsp;{ &quot;product&quot; : &quot;toaster&quot;, &quot;store number&quot; : 3, &quot;quantity&quot; : 50 },</span></p><p class="c3"><span class="c2">&nbsp; &nbsp;{ &quot;product&quot; : &quot;blender&quot;, &quot;store number&quot; : 3, &quot;quantity&quot; : 100 },</span></p><p class="c3"><span class="c2">&nbsp; &nbsp;{ &quot;product&quot; : &quot;blender&quot;, &quot;store number&quot; : 3, &quot;quantity&quot; : 150 },</span></p><p class="c3"><span class="c2">&nbsp; &nbsp;{ &quot;product&quot; : &quot;socks&quot;, &quot;store number&quot; : 1, &quot;quantity&quot; : 500 },</span></p><p class="c3"><span class="c2">&nbsp; &nbsp;{ &quot;product&quot; : &quot;socks&quot;, &quot;store number&quot; : 2, &quot;quantity&quot; : 10 },</span></p><p class="c3"><span class="c2">&nbsp; &nbsp;{ &quot;product&quot; : &quot;shirt&quot;, &quot;store number&quot; : 3, &quot;quantity&quot; : 10 }</span></p><p class="c3"><span class="c2">]</span></p><p class="c3"><span class="c2">let $join :=</span></p><p class="c3"><span class="c2">&nbsp; for $store in jn:values($stores), $sale in jn:values($sales)</span></p><p class="c3"><span class="c2">&nbsp; where $store(&quot;store number&quot;) = $sale(&quot;store number&quot;)</span></p><p class="c3"><span class="c2">&nbsp; return {</span></p><p class="c3"><span class="c2">&nbsp; &nbsp; &quot;nb&quot; : $store(&quot;store number&quot;),</span></p><p class="c3"><span class="c2">&nbsp; &nbsp; &quot;state&quot; : $store(&quot;state&quot;),</span></p><p class="c3"><span class="c2">&nbsp; &nbsp; &quot;sold&quot; : $sale(&quot;product&quot;)</span></p><p class="c3"><span class="c2">&nbsp; }</span></p><p class="c3"><span class="c2">return [$join]</span></p><p class="c1"><span class="c5 c2">[ </span></p><p class="c1"><span class="c5 c2">{ &quot;nb&quot; : 1, &quot;state&quot; : &quot;MA&quot;, &quot;sold&quot; : &quot;broiler&quot; },</span></p><p class="c1"><span class="c5 c2">{ &quot;nb&quot; : 1, &quot;state&quot; : &quot;MA&quot;, &quot;sold&quot; : &quot;socks&quot; },</span></p><p class="c1"><span class="c5 c2">{ &quot;nb&quot; : 2, &quot;state&quot; : &quot;MA&quot;, &quot;sold&quot; : &quot;toaster&quot; },</span></p><p class="c1"><span class="c5 c2">{ &quot;nb&quot; : 2, &quot;state&quot; : &quot;MA&quot;, &quot;sold&quot; : &quot;toaster&quot; },</span></p><p class="c1"><span class="c5 c2">{ &quot;nb&quot; : 2, &quot;state&quot; : &quot;MA&quot;, &quot;sold&quot; : &quot;socks&quot; },</span></p><p class="c1"><span class="c5 c2">{ &quot;nb&quot; : 3, &quot;state&quot; : &quot;CA&quot;, &quot;sold&quot; : &quot;toaster&quot; },</span></p><p class="c1"><span class="c5 c2">{ &quot;nb&quot; : 3, &quot;state&quot; : &quot;CA&quot;, &quot;sold&quot; : &quot;blender&quot; },</span></p><p class="c1"><span class="c5 c2">{ &quot;nb&quot; : 3, &quot;state&quot; : &quot;CA&quot;, &quot;sold&quot; : &quot;blender&quot; },</span></p><p class="c1"><span class="c5 c2">{ &quot;nb&quot; : 3, &quot;state&quot; : &quot;CA&quot;, &quot;sold&quot; : &quot;shirt&quot; }</span></p><p class="c1"><span class="c5 c2">&nbsp;]</span></p><h1 class="c3"><a name="h.oii6pvliilhi"></a><span>Access external data</span></h1><p class="c3"><span>You can access a JSON file on your local disk with</span></p><p class="c9 c3"><span></span></p><p class="c3"><span class="c2">jn:json(&quot;file.json&quot;)</span></p><p class="c3 c4"><span class="c5 c2">[ &quot;The&quot;, &quot;contents&quot;, &quot;of&quot;, &quot;your&quot;, &quot;file&quot; ]</span></p><p class="c9 c3"><span></span></p><p class="c3"><span>Our implementation even supports collections of JSON objects or arrays:</span></p><p class="c9 c3"><span></span></p><p class="c3"><span class="c2">dml:collection(&quot;my:data&quot;)</span></p><p class="c3 c4"><span class="c5 c2">{ &quot;foo&quot; : &quot;Your&quot; }</span></p><p class="c3 c4"><span class="c5 c2">{ &quot;foo&quot; : &quot;Collection&quot; }</span></p><p class="c3 c4"><span class="c5 c2">{ &quot;foo&quot; : &quot;of&quot; }</span></p><p class="c3 c4"><span class="c5 c2">{ &quot;foo&quot; : &quot;JSON&quot; }</span></p><p class="c3 c4"><span class="c5 c2">{ &quot;foo&quot; : &quot;objects&quot; }</span></p><h1 class="c3"><a name="h.fopcxnkoydgt"></a><span>JSON and XML</span></h1><p class="c3 c12"><span>You can readily use XML and JSON in the same program. If you put a JSON array in an XML constructor, it will be flattened (its member values are recursively taken, even in arrays of arrays). If you put a JSON pair in an XML constructor, it will be unboxed (its value is taken).</span></p><p class="c9 c3"><span></span></p><p class="c3"><span class="c2">let $data := {</span></p><p class="c3"><span class="c2">&nbsp; &nbsp;&quot;color&quot; : &quot;blue&quot;,</span></p><p class="c3"><span class="c2">&nbsp; &nbsp;&quot;closed&quot; : true,</span></p><p class="c3"><span class="c2">&nbsp; &nbsp;&quot;points&quot; : [[10,10], [20,10], [20,20], [10,20]]</span></p><p class="c3"><span class="c2">&nbsp; &nbsp;}</span></p><p class="c9 c3"><span class="c2"></span></p><p class="c3"><span class="c2">let $stroke := attribute stroke { $data(&quot;color&quot;) }</span></p><p class="c3"><span class="c2">let $points := attribute points { $data(&quot;points&quot;) }</span></p><p class="c3"><span class="c2">return</span></p><p class="c3"><span class="c2">&nbsp; if ($data(&quot;closed&quot;)) then</span></p><p class="c3"><span class="c2">&nbsp; &nbsp; &lt;svg&gt;&lt;polygon&gt;{ $stroke, $points }&lt;/polygon&gt;&lt;/svg&gt;</span></p><p class="c3"><span class="c2">&nbsp; else</span></p><p class="c3"><span class="c2">&nbsp; &nbsp; &lt;svg&gt;&lt;polyline&gt;{ $stroke, $points }&lt;/polyline&gt;&lt;/svg&gt;</span></p><p class="c9 c3"><span class="c2"></span></p><p class="c3 c21"><span class="c5 c2">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span></p><p class="c3 c21"><span class="c5 c2">&lt;svg&gt;&lt;polygon stroke=&quot;blue&quot; points=&quot;10 10 20 10 20 20 10 20&quot;/&gt;&lt;/svg&gt;</span></p><p class="c9 c3"><span></span></p><h1 class="c3"><a name="h.bm3buqmzhtko"></a><span>I want more</span></h1><p class="c3 c12"><span>JSONiq supports JSON updates. You can declaratively update your JSON data. JSONiq provides functions that produce a list of updates. The list of updates that is eventually output by your program is then applied to your JSON data.</span></p><p class="c9 c3"><span></span></p><p class="c3"><span class="c2">let $my-data := jn:json(&quot;persons.json&quot;)</span></p><p class="c3"><span class="c2">let $john := jn:value($my-data(&quot;John&quot;))</span></p><p class="c3"><span class="c2">let $mary := jn:value($my-data(&quot;Mary&quot;))</span></p><p class="c3"><span class="c2">return (jn:replace-value($john, &quot;status&quot;, &quot;married&quot;),</span></p><p class="c3"><span class="c2">&nbsp; &nbsp; &nbsp; &nbsp; j:replace-value($mary, &quot;status&quot;, &quot;married&quot;))</span></p><p class="c9 c3"><span></span></p><p class="c3"><span>JSONiq works with the XQuery 3.0 standard (switch, typeswitch and try-catch expressions, universal/existential quantifiers, path expressions, filtering expressions, functors, mappings, grouping, windowing will work). The Zorba implementation is also compatible with the proprietary Zorba scripting.</span></p></body></html>
1970\ No newline at end of file
1971
1972=== added file 'doc/zorba/XQueryforJSON.html'
1973--- doc/zorba/XQueryforJSON.html 1970-01-01 00:00:00 +0000
1974+++ doc/zorba/XQueryforJSON.html 2012-02-08 21:22:19 +0000
1975@@ -0,0 +1,1 @@
1976+<html><head><title>XQuery for JSON</title><style type="text/css">@import url('https://themes.googleusercontent.com/fonts/css?kit=lhDjYqiy3mZ0x6ROQEUoUw');ol{margin:0;padding:0}p{margin:0}.c10{list-style-type:disc;margin:0;padding:0}.c21{max-width:468pt;background-color:#ffffff;padding:72pt 72pt 72pt 72pt}.c1{height:11pt;direction:ltr}.c9{color:#ff0000;font-style:italic}.c13{text-indent:-13.5pt;margin-left:76.5pt}.c2{color:#1155cc;text-decoration:underline}.c15{color:inherit;text-decoration:inherit}.c3{direction:ltr}.c6{text-align:justify}.c5{text-align:right}.c4{margin-left:144pt}.c11{font-style:italic}.c18{color:#ff9900}.c20{height:18pt}.c8{margin-left:36pt}.c19{text-align:center}.c17{color:#4a86e8}.c0{font-family:Consolas}.c7{color:#38761d}.c12{font-weight:bold}.c14{padding-left:0pt}.c16{margin-left:18pt}.title{padding-top:24pt;line-height:1.15;text-align:center;color:#4a86e8;font-size:36pt;font-family:Arial;font-weight:bold;padding-bottom:6pt}.subtitle{padding-top:18pt;line-height:1.15;text-align:left;color:#666666;font-style:italic;font-size:24pt;font-family:Georgia;padding-bottom:4pt}body{color:#000000;font-size:11pt;font-family:Arial}h1{padding-top:24pt;line-height:1.15;text-align:left;color:#4a86e8;font-size:24pt;font-family:Arial;font-weight:bold;padding-bottom:6pt}h2{padding-top:18pt;line-height:1.15;text-align:left;color:#ff9900;font-size:18pt;font-family:Arial;font-weight:bold;padding-bottom:4pt}h3{padding-top:14pt;line-height:1.15;text-align:left;color:#000000;font-size:14pt;font-family:Arial;font-weight:bold;padding-bottom:4pt}h4{padding-top:12pt;line-height:1.15;text-align:left;color:#000000;font-size:12pt;font-family:Arial;font-weight:bold;padding-bottom:2pt}h5{padding-top:11pt;line-height:1.15;text-align:left;color:#000000;font-size:11pt;font-family:Arial;font-weight:bold;padding-bottom:2pt}h6{padding-top:10pt;line-height:1.15;text-align:left;color:#000000;font-size:10pt;font-family:Arial;font-weight:bold;padding-bottom:2pt}</style></head><body class="c21"><p class="c3 title"><a name="h.li2wdq8unbq"></a><span>JSONiq for JSON users</span></p><p class="c3 title"><a name="h.5ipqqclfxk4n"></a><span class="c7">XQuery for JSON</span></p><hr><p class="c3 c19"><span>This tutorial introduces the JSONiq language, which declaratively manipulates JSON data.</span></p><p class="c3 c19"><span>Why don&#39;t you go ahead can try the queries of this document on our online demo interface?</span></p><p class="c3 c19"><span>&nbsp;</span><span class="c2 c12"><a class="c15" href="http://jsoniq.zorba-xquery.com/">http://jsoniq.zorba-xquery.com/</a></span></p><hr><p class="c1"><span></span></p><h2 class="c3 c20"><a name="h.8gra0ylxutrv"></a></h2><p class="c3 c16"><span class="c2"><a class="c15" href="#h.f453h84m2u1a">JSON</a></span></p><p class="c3 c16"><span class="c2"><a class="c15" href="#h.qtfakecy3fr7">Elevator Pitch</a></span></p><p class="c3 c16"><span class="c2"><a class="c15" href="#h.yugk1mszt0re">And here you go</a></span></p><p class="c3 c8"><span class="c2"><a class="c15" href="#h.4uvhbej4btrt">Like Monsieur Jourdain, you already knew some JSONiq</a></span></p><p class="c3 c16"><span class="c2"><a class="c15" href="#h.1gal1zhyffu4">JSONiq basics</a></span></p><p class="c3 c8"><span class="c2"><a class="c15" href="#h.ncbxtez2z3rn">The real JSONiq Hello, World!</a></span></p><p class="c3 c8"><span class="c2"><a class="c15" href="#h.ifcjheuaxoqc">Numbers and arithmetic operations</a></span></p><p class="c3 c8"><span class="c2"><a class="c15" href="#h.jmbc6c1fqqwx">Logical operations</a></span></p><p class="c3 c8"><span class="c2"><a class="c15" href="#h.iq1ixg5ywx0r">Strings</a></span></p><p class="c3 c8"><span class="c2"><a class="c15" href="#h.rv6w8p4wenfa">Sequences</a></span></p><p class="c3 c16"><span class="c2"><a class="c15" href="#h.7x2r8sj1zjwe">A bit more in depth</a></span></p><p class="c3 c8"><span class="c2"><a class="c15" href="#h.b6c9zq9um8cu">Variables</a></span></p><p class="c3 c8"><span class="c2"><a class="c15" href="#h.92ak2udyfghp">Iteration</a></span></p><p class="c3 c8"><span class="c2"><a class="c15" href="#h.zdhx60a5duyu">Conditions</a></span></p><p class="c3 c8"><span class="c2"><a class="c15" href="#h.ccs6lkxiixw4">Composability of Expressions</a></span></p><p class="c3 c16"><span class="c2"><a class="c15" href="#h.mjv7kyjurri2">JSON Navigation</a></span></p><p class="c3 c8"><span class="c2"><a class="c15" href="#h.xosiyb17dh24">Objects</a></span></p><p class="c3 c8"><span class="c2"><a class="c15" href="#h.mrf42gizl3y6">Arrays</a></span></p><p class="c3 c8"><span class="c2"><a class="c15" href="#h.hdc3dgohtdut">Pairs</a></span></p><p class="c3 c16"><span class="c2"><a class="c15" href="#h.eb0bxle2oykl">Relational Algebra</a></span></p><p class="c3 c16"><span class="c2"><a class="c15" href="#h.oii6pvliilhi">Access external data</a></span></p><p class="c3 c16"><span class="c2"><a class="c15" href="#h.bm3buqmzhtko">I want more</a></span></p><p class="c3 c8"><span class="c2"><a class="c15" href="#h.5itcphr8262b">Even more</a></span></p><p class="c3 c8"><span class="c2"><a class="c15" href="#h.j7oh3cyhem38">More is not enough</a></span></p><p><span></span></p><p class="c1"><span></span></p><h1 class="c3"><a name="h.f453h84m2u1a"></a><span>JSON</span></h1><p class="c3 c6"><span>As explained on </span><span class="c2"><a class="c15" href="http://www.json.org/">http://www.json.org/</a></span><span>, JSON is a lightweight data-interchange format designed for humans as well as for computers. It supports as values:</span></p><ol class="c10" start="1"><li class="c3 c6 c8 c14"><span>objects (string-to-value map)</span></li><li class="c3 c6 c8 c14"><span>arrays (ordered sequence of values)</span></li><li class="c3 c6 c8 c14"><span>strings</span></li><li class="c3 c6 c8 c14"><span>numbers</span></li><li class="c3 c6 c8 c14"><span>booleans (true, false)</span></li><li class="c3 c6 c8 c14"><span>null</span></li></ol><p class="c1"><span></span></p><p class="c3"><span>JSONiq provides declarative querying and updating capabilities on JSON data.</span></p><h1 class="c3"><a name="h.qtfakecy3fr7"></a><span>Elevator Pitch</span></h1><p class="c3 c6"><span>JSONiq is based on XQuery, which is a W3C standard (like XML and HTML). XQuery is a very powerful declarative language that manipulates XML data, but that is also a very good fit for JSON. Here is an appetizer before we start the tutorial from scratch.</span></p><p class="c1"><span></span></p><p class="c3"><span class="c0">let $stores :=</span></p><p class="c3"><span class="c0">[</span></p><p class="c3"><span class="c0">&nbsp; { &quot;store number&quot; : 1, &quot;state&quot; : &quot;MA&quot; },</span></p><p class="c3"><span class="c0">&nbsp; { &quot;store number&quot; : 2, &quot;state&quot; : &quot;MA&quot; },</span></p><p class="c3"><span class="c0">&nbsp; { &quot;store number&quot; : 3, &quot;state&quot; : &quot;CA&quot; },</span></p><p class="c3"><span class="c0">&nbsp; { &quot;store number&quot; : 4, &quot;state&quot; : &quot;CA&quot; }</span></p><p class="c3"><span class="c0">]</span></p><p class="c3"><span class="c0">let $sales := [</span></p><p class="c3"><span class="c0">&nbsp; &nbsp;{ &quot;product&quot; : &quot;broiler&quot;, &quot;store number&quot; : 1, &quot;quantity&quot; : 20 &nbsp;},</span></p><p class="c3"><span class="c0">&nbsp; &nbsp;{ &quot;product&quot; : &quot;toaster&quot;, &quot;store number&quot; : 2, &quot;quantity&quot; : 100 },</span></p><p class="c3"><span class="c0">&nbsp; &nbsp;{ &quot;product&quot; : &quot;toaster&quot;, &quot;store number&quot; : 2, &quot;quantity&quot; : 50 },</span></p><p class="c3"><span class="c0">&nbsp; &nbsp;{ &quot;product&quot; : &quot;toaster&quot;, &quot;store number&quot; : 3, &quot;quantity&quot; : 50 },</span></p><p class="c3"><span class="c0">&nbsp; &nbsp;{ &quot;product&quot; : &quot;blender&quot;, &quot;store number&quot; : 3, &quot;quantity&quot; : 100 },</span></p><p class="c3"><span class="c0">&nbsp; &nbsp;{ &quot;product&quot; : &quot;blender&quot;, &quot;store number&quot; : 3, &quot;quantity&quot; : 150 },</span></p><p class="c3"><span class="c0">&nbsp; &nbsp;{ &quot;product&quot; : &quot;socks&quot;, &quot;store number&quot; : 1, &quot;quantity&quot; : 500 },</span></p><p class="c3"><span class="c0">&nbsp; &nbsp;{ &quot;product&quot; : &quot;socks&quot;, &quot;store number&quot; : 2, &quot;quantity&quot; : 10 },</span></p><p class="c3"><span class="c0">&nbsp; &nbsp;{ &quot;product&quot; : &quot;shirt&quot;, &quot;store number&quot; : 3, &quot;quantity&quot; : 10 }</span></p><p class="c3"><span class="c0">]</span></p><p class="c3"><span class="c0">let $join :=</span></p><p class="c3"><span class="c0">&nbsp; for $store in jn:values($stores), $sale in jn:values($sales)</span></p><p class="c3"><span class="c0">&nbsp; where $store(&quot;store number&quot;) = $sale(&quot;store number&quot;)</span></p><p class="c3"><span class="c0">&nbsp; return {</span></p><p class="c3"><span class="c0">&nbsp; &nbsp; &quot;nb&quot; : $store(&quot;store number&quot;),</span></p><p class="c3"><span class="c0">&nbsp; &nbsp; &quot;state&quot; : $store(&quot;state&quot;),</span></p><p class="c3"><span class="c0">&nbsp; &nbsp; &quot;sold&quot; : $sale(&quot;product&quot;)</span></p><p class="c3"><span class="c0">&nbsp; }</span></p><p class="c3"><span class="c0">return [$join]</span></p><p class="c3 c4"><span class="c0 c7">[ </span></p><p class="c3 c4"><span class="c0 c7">&nbsp; { &quot;nb&quot; : 1, &quot;state&quot; : &quot;MA&quot;, &quot;sold&quot; : &quot;broiler&quot; },</span></p><p class="c3 c4"><span class="c0 c7">&nbsp; { &quot;nb&quot; : 1, &quot;state&quot; : &quot;MA&quot;, &quot;sold&quot; : &quot;socks&quot; },</span></p><p class="c3 c4"><span class="c0 c7">&nbsp; { &quot;nb&quot; : 2, &quot;state&quot; : &quot;MA&quot;, &quot;sold&quot; : &quot;toaster&quot; },</span></p><p class="c3 c4"><span class="c0 c7">&nbsp; { &quot;nb&quot; : 2, &quot;state&quot; : &quot;MA&quot;, &quot;sold&quot; : &quot;toaster&quot; },</span></p><p class="c3 c4"><span class="c0 c7">&nbsp; { &quot;nb&quot; : 2, &quot;state&quot; : &quot;MA&quot;, &quot;sold&quot; : &quot;socks&quot; },</span></p><p class="c3 c4"><span class="c0 c7">&nbsp; { &quot;nb&quot; : 3, &quot;state&quot; : &quot;CA&quot;, &quot;sold&quot; : &quot;toaster&quot; },</span></p><p class="c3 c4"><span class="c0 c7">&nbsp; { &quot;nb&quot; : 3, &quot;state&quot; : &quot;CA&quot;, &quot;sold&quot; : &quot;blender&quot; },</span></p><p class="c3 c4"><span class="c0 c7">&nbsp; { &quot;nb&quot; : 3, &quot;state&quot; : &quot;CA&quot;, &quot;sold&quot; : &quot;blender&quot; },</span></p><p class="c3 c4"><span class="c0 c7">&nbsp; { &quot;nb&quot; : 3, &quot;state&quot; : &quot;CA&quot;, &quot;sold&quot; : &quot;shirt&quot; }</span></p><p class="c3 c4"><span class="c0 c7">&nbsp;]</span></p><p class="c1"><span></span></p><h1 class="c3"><a name="h.yugk1mszt0re"></a><span>And here you go</span></h1><h2 class="c3"><a name="h.4uvhbej4btrt"></a><span>Like Monsieur Jourdain, you already knew some JSONiq</span></h2><p class="c3 c6"><span>The first thing you need to know is that every well-formed JSON document is a JSONiq query as well.</span></p><p class="c1"><span></span></p><p class="c3 c6"><span>This means that you can copy-and-paste a JSON document into a query. The following are JSONiq queries that are &quot;idempotent&quot; (they just output themselves):</span></p><p class="c1"><span></span></p><p class="c3"><span class="c0">{ &quot;pi&quot; : 3.14, &quot;sq2&quot; : 1.4 }</span></p><p class="c3 c5"><span class="c0 c7">{ &quot;pi&quot; : 3.14, &quot;sq2&quot; : 1.4 }</span></p><p class="c1"><span class="c0 c7"></span></p><p class="c3"><span class="c0">[ 2, 3, 5, 7, 11, 13 ]</span></p><p class="c3 c5"><span class="c0 c7">[ 2, 3, 5, 7, 11, 13 ]</span></p><p class="c1"><span class="c0"></span></p><p class="c3"><span class="c0">{</span></p><p class="c3"><span class="c0">&nbsp; &quot;operations&quot; : [</span></p><p class="c3"><span class="c0">&nbsp; &nbsp; { &quot;binary&quot; : [ &quot;and&quot;, &quot;or&quot;] },</span></p><p class="c3"><span class="c0">&nbsp; &nbsp; { &quot;unary&quot; : [&quot;not&quot;] }</span></p><p class="c3"><span class="c0">&nbsp; ],</span></p><p class="c3"><span class="c0">&nbsp; &quot;bits&quot; : [</span></p><p class="c3"><span class="c0">&nbsp; &nbsp; 0, 1</span></p><p class="c3"><span class="c0">&nbsp; ]</span></p><p class="c3"><span class="c0">}</span></p><p class="c3 c4"><span class="c0 c7">{</span></p><p class="c3 c4"><span class="c0 c7">&nbsp; &quot;operations&quot; : [</span></p><p class="c3 c4"><span class="c0 c7">&nbsp; &nbsp; { &quot;binary&quot; : [ &quot;and&quot;, &quot;or&quot; ] },</span></p><p class="c3 c4"><span class="c0 c7">&nbsp; &nbsp; { &quot;unary&quot; : [ &quot;not&quot; ] }</span></p><p class="c3 c4"><span class="c0 c7">&nbsp; ],</span></p><p class="c3 c4"><span class="c0 c7">&nbsp; &quot;bits&quot; : [</span></p><p class="c3 c4"><span class="c0 c7">&nbsp; &nbsp; 0, 1</span></p><p class="c3 c4"><span class="c0 c7">&nbsp; ]</span></p><p class="c3 c4"><span class="c0 c7">}</span></p><p class="c1 c5"><span class="c0 c7"></span></p><p class="c3"><span>This works with objects, arrays (even nested), strings, numbers, booleans, null. </span><span class="c11">The exceptions to this rule (but we are working on it!) are that:</span></p><p class="c3 c6"><span class="c11">(i) if a pair has a true, false or null value, there must be a space on at least one side of the colon (this will be fixed).</span></p><p class="c3 c6"><span class="c11">(ii) empty objects are not recognized</span></p><p class="c3 c6"><span class="c11">(iii) characters escaped with the \ in JSON strings are not recognized</span></p><p class="c1"><span class="c9 c0"></span></p><p class="c3 c6"><span>It also works the other way round: if your query outputs an object or an array, you can readily use it as a JSON document.</span></p><p class="c1"><span></span></p><p class="c3 c6"><span>JSONiq is a declarative language. This means that you only need to say </span><span class="c11">what</span><span>&nbsp;you want - the compiler will take care of the </span><span class="c11">how</span><span>. In the above queries, you are basically saying: I want to output this JSON content, and here it is.</span></p><h1 class="c3"><a name="h.1gal1zhyffu4"></a><span>JSONiq basics</span></h1><h2 class="c3"><a name="h.ncbxtez2z3rn"></a><span>The real JSONiq Hello, World!</span></h2><p class="c3"><span>Wondering what a hello world program looks like in JSONiq? Here it is:</span></p><p class="c1"><span></span></p><p class="c3"><span class="c0">&quot;Hello, World!&quot;</span></p><p class="c3 c5"><span class="c0 c7">Hello, World!</span></p><p class="c1"><span class="c0 c7"></span></p><p class="c3"><span>Not surprisingly, it outputs the string &quot;Hello, World!&quot;. Again, just say what you want and you will get it.</span></p><h2 class="c3"><a name="h.ifcjheuaxoqc"></a><span>Numbers and arithmetic operations</span></h2><p class="c3 c6"><span>Okay, so, now, you might be thinking: &quot;What is the use of this language if it just outputs what I put in?&quot; Of course, JSONiq can more than that. And still in a declarative way. Here is how it works with numbers:</span></p><p class="c1"><span></span></p><p class="c3"><span class="c0">2 + 2</span></p><p class="c1"><span class="c0"></span></p><p class="c3"><span>will surprisingly output:</span></p><p class="c3 c5"><span class="c0 c7">4</span></p><p class="c1"><span></span></p><p class="c3"><span>whereas</span></p><p class="c1"><span></span></p><p class="c3"><span class="c0">(38 + 2) div 2 + 11 * 2</span></p><p class="c1"><span class="c0"></span></p><p class="c3"><span>will output</span></p><p class="c3 c5"><span class="c0 c7">42</span></p><p class="c1"><span class="c0 c7"></span></p><p class="c3 c6"><span>(mind the division operator which is the &quot;div&quot; keyword. The slash has other semantics).</span></p><p class="c1"><span></span></p><p class="c3"><span>Like JSON, JSONiq works with decimals, too:</span></p><p class="c1"><span></span></p><p class="c3"><span class="c0">6.022e23 * 42</span></p><p class="c3 c5"><span class="c0 c7">2.52924E25</span></p><h2 class="c3"><a name="h.jmbc6c1fqqwx"></a><span>Logical operations</span></h2><p class="c3 c6"><span>JSONiq supports boolean operations.</span></p><p class="c1 c6"><span></span></p><p class="c3"><span class="c0">true and false</span></p><p class="c3 c5"><span class="c0 c7">false</span></p><p class="c1 c5"><span class="c0 c7"></span></p><p class="c3"><span class="c0">(true or false) and (false or true)</span></p><p class="c3 c5"><span class="c0 c7">true</span></p><p class="c1 c5"><span class="c0 c7"></span></p><p class="c3"><span>The unary not is a function (yes, JSONiq has functions, and they are in the same way as in many languages):</span></p><p class="c1"><span class="c0"></span></p><p class="c3"><span class="c0">not(true)</span></p><p class="c3 c5"><span class="c0 c7">false</span></p><h2 class="c3"><a name="h.iq1ixg5ywx0r"></a><span>Strings</span></h2><p class="c3"><span>JSONiq is capable of manipulating strings as well, using functions:</span></p><p class="c1"><span></span></p><p class="c3"><span class="c0">concat(&quot;Hello &quot;, &quot;Captain Kirk&quot;)</span></p><p class="c3 c5"><span class="c0 c7">Hello Captain Kirk</span></p><p class="c1 c5"><span class="c0 c7"></span></p><p class="c3"><span class="c0">substring(&quot;Mister Spock&quot;, 8, 5)</span></p><p class="c3 c5"><span class="c0 c7">Spock</span></p><h2 class="c3"><a name="h.rv6w8p4wenfa"></a><span>Sequences</span></h2><p class="c3"><span>Until now, we only handled single values (an object, an array, a number, a string, a boolean). JSONiq supports sequences of values. You can build a sequence using commas:</span></p><p class="c1"><span></span></p><p class="c3"><span>1, 2, 3, 4, 5, 6, 7, 8, 9, 10</span></p><p class="c3 c5"><span class="c7">1 2 3 4 5 6 7 8 9 10</span></p><p class="c1"><span class="c7"></span></p><p class="c3"><span class="c0">1, </span><span class="c0">true</span><span class="c0">, 4.2e1, &quot;Life&quot;</span></p><p class="c3 c5"><span class="c0 c7">1 true 42 Life</span></p><p class="c1"><span class="c0"></span></p><p class="c3"><span class="c0">{ &quot;Question&quot; : &quot;Ultimate&quot; }, [&quot;Life&quot;, &quot;The universe&quot;, &quot;and everything&quot;]</span></p><p class="c1 c5"><span class="c0"></span></p><p class="c3 c5"><span class="c0 c7">{ &quot;Question&quot; : &quot;Ultimate&quot; }[ &quot;Life&quot;, &quot;The universe&quot;, &quot;and everything&quot; ]</span></p><p class="c1 c5"><span class="c0"></span></p><p class="c3"><span>The &quot;to&quot; operator is very convenient, too:</span></p><p class="c1"><span class="c0"></span></p><p class="c3"><span class="c0">1 to 100</span></p><p class="c3 c5"><span class="c7">1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20</span></p><p class="c3 c5"><span class="c7">21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40</span></p><p class="c3 c5"><span class="c7">41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60</span></p><p class="c3 c5"><span class="c7">61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80</span></p><p class="c3 c5"><span class="c7">81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100</span></p><p class="c1"><span></span></p><p class="c3"><span>Some functions even work on sequences:</span></p><p class="c1"><span class="c0"></span></p><p class="c3"><span class="c0">sum(1 to 100)</span></p><p class="c3 c5"><span class="c0 c7">5050</span></p><p class="c1 c5"><span class="c0 c7"></span></p><p class="c3"><span class="c0">string-join((&quot;These&quot;, &quot;are&quot;, &quot;some&quot;, &quot;words&quot;), &quot;-&quot;)</span></p><p class="c3 c5"><span class="c0 c7">These-are-some-words</span></p><p class="c1 c5"><span class="c0 c7"></span></p><p class="c3"><span class="c0">count(10 to 20)</span></p><p class="c3 c5"><span class="c0 c7">11</span></p><p class="c1"><span class="c0 c7"></span></p><p class="c3"><span class="c0">avg(1 to 100)</span></p><p class="c3 c5"><span class="c0 c7">50.5</span></p><h1 class="c3"><a name="h.7x2r8sj1zjwe"></a><span>A bit more in depth</span></h1><h2 class="c3"><a name="h.b6c9zq9um8cu"></a><span>Variables</span></h2><p class="c3"><span>You can bind a sequence of values to a (dollar-prefixed) variable, like so:</span></p><p class="c1"><span></span></p><p class="c3"><span class="c0">let $x := &quot;Bearing 3 1 4 Mark 5. &quot;</span></p><p class="c3"><span class="c0">return concat($x, &quot;Engage!&quot;)</span></p><p class="c3 c5"><span class="c0 c7">Bearing 3 1 4 Mark 5. Engage!</span></p><p class="c1 c5"><span class="c0 c7"></span></p><p class="c1 c5"><span class="c0"></span></p><p class="c3"><span class="c0">let $x := (&quot;Kirk&quot;, &quot;Picard&quot;, &quot;Sisko&quot;)</span></p><p class="c3"><span class="c0">return string-join($x, &quot; and &quot;)</span></p><p class="c3 c5"><span class="c0 c7">Kirk and Picard and Sisko</span></p><p class="c1"><span class="c0 c7"></span></p><p class="c3"><span>You can bind as many variables as you want:</span></p><p class="c1"><span></span></p><p class="c3"><span class="c0">let $x := 1</span></p><p class="c3"><span class="c0">let $y := $x * 2</span></p><p class="c3"><span class="c0">let $z := $y + $x</span></p><p class="c3"><span class="c0">return [$x, $y, $z]</span></p><p class="c3 c5"><span class="c0 c7">[ 1, 2, 3 ]</span></p><p class="c1 c5"><span class="c0 c7"></span></p><p class="c3"><span>and even reuse the same name:</span></p><p class="c3"><span class="c0">let $x := 1</span></p><p class="c3"><span class="c0">let $x := $x + 2</span></p><p class="c3"><span class="c0">let $x := $x + 3</span></p><p class="c3"><span class="c0">return $x</span></p><p class="c3 c5"><span class="c0 c7">6</span></p><h2 class="c3"><a name="h.92ak2udyfghp"></a><span>Iteration</span></h2><p class="c3 c6"><span>In a way very similar to let, you can iterate over a sequence of values with the &quot;for&quot; keyword. Instead of binding the entire sequence of the variable, it will bind each value of the sequence in turn to this variable.</span></p><p class="c1 c6"><span></span></p><p class="c3 c6"><span class="c0">for $i in 1 to 10</span></p><p class="c3 c6"><span class="c0">return $i * 2</span></p><p class="c3 c5"><span class="c0 c7">2 4 6 8 10 12 14 16 18 20</span></p><p class="c1 c5"><span class="c0 c7"></span></p><p class="c3"><span>More interestingly, you can combine fors and lets like so:</span></p><p class="c1"><span class="c0"></span></p><p class="c3"><span class="c0">let $sequence := 1 to 10</span></p><p class="c3"><span class="c0">for $value in $sequence</span></p><p class="c3"><span class="c0">let $square := $value * 2</span></p><p class="c3"><span class="c0">return $square</span></p><p class="c3 c5"><span class="c0 c7">2 4 6 8 10 12 14 16 18 20</span></p><p class="c1 c5"><span class="c0 c7"></span></p><p class="c3"><span>and even filter out some values:</span></p><p class="c1"><span class="c0"></span></p><p class="c3"><span class="c0">let $sequence := 1 to 10</span></p><p class="c3"><span class="c0">for $value in $sequence</span></p><p class="c3"><span class="c0">let $square := $value * 2</span></p><p class="c3"><span class="c0">where $square &lt; 10</span></p><p class="c3"><span class="c0">return $square</span></p><p class="c3 c5"><span class="c0 c7">2 4 6 8</span></p><h2 class="c3"><a name="h.zdhx60a5duyu"></a><span>Conditions</span></h2><p class="c3"><span>You can make the output depend on a condition with an if-then-else construct:</span></p><p class="c1"><span></span></p><p class="c3"><span class="c0">for $x in 1 to 10</span></p><p class="c3"><span class="c0">return if ($x &lt; 5) then $x</span></p><p class="c3"><span class="c0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else -$x</span></p><p class="c3 c5"><span class="c0 c7">1 2 3 4 -5 -6 -7 -8 -9 -10</span></p><h2 class="c3"><a name="h.ccs6lkxiixw4"></a><span>Composability of Expressions</span></h2><p class="c3"><span>Now that you know of a couple of elementary JSONiq expressions, you can combine then in more elaborate expressions. For example, you can put any sequence of values in an array:</span></p><p class="c1"><span></span></p><p class="c3"><span class="c0">[ 1 to 10 ]</span></p><p class="c3 c5"><span class="c0 c7">[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]</span></p><p class="c1 c5"><span class="c0 c7"></span></p><p class="c3"><span>Or you can dynamically compute the value of object pairs:</span></p><p class="c1"><span></span></p><p class="c3"><span class="c0">{</span></p><p class="c3"><span class="c0">&nbsp; &quot;Greeting&quot; : let $d := &quot;Mister Spock&quot;</span></p><p class="c3"><span class="c0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return concat(&quot;Hello, &quot;, $d),</span></p><p class="c3"><span class="c0">&nbsp; &quot;Farewell&quot; : string-join((&quot;Live&quot;, &quot;long&quot;, &quot;and&quot;, &quot;prosper&quot;),</span></p><p class="c3"><span class="c0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot; &quot;)</span></p><p class="c3"><span class="c0">}</span></p><p class="c1"><span class="c0 c7"></span></p><p class="c3 c5"><span class="c0 c7">{ &quot;Greeting&quot; : &quot;Hello, Mister Spock&quot;, &quot;Farewell&quot; : &quot;Live long and prosper&quot; }</span></p><p class="c1"><span class="c7"></span></p><p class="c3"><span>You can also dynamically generate pairs:</span></p><p class="c1"><span class="c0"></span></p><p class="c3"><span class="c0">concat(&quot;Integer &quot;, 2) : 2 * 2</span></p><p class="c3 c5"><span class="c0 c7">&quot;Integer 2&quot; : 4</span></p><p class="c1 c5"><span class="c0 c7"></span></p><p class="c3"><span>and then wrap lots of them in an object:</span></p><p class="c1"><span class="c0"></span></p><p class="c3"><span class="c0">{</span></p><p class="c3"><span class="c0">&nbsp; for $i in 1 to 10</span></p><p class="c3"><span class="c0">&nbsp; return concat(&quot;Square of &quot;, $i) : $i * $i</span></p><p class="c3"><span class="c0">}</span></p><p class="c3 c4"><span class="c0 c7">{</span></p><p class="c3 c4"><span class="c0 c7">&quot;Square of 1&quot; : 1,</span></p><p class="c3 c4"><span class="c0 c7">&quot;Square of 2&quot; : 4,</span></p><p class="c3 c4"><span class="c0 c7">&quot;Square of 3&quot; : 9,</span></p><p class="c3 c4"><span class="c0 c7">&quot;Square of 4&quot; : 16,</span></p><p class="c3 c4"><span class="c0 c7">&quot;Square of 5&quot; : 25,</span></p><p class="c3 c4"><span class="c0 c7">&quot;Square of 6&quot; : 36,</span></p><p class="c3 c4"><span class="c0 c7">&quot;Square of 7&quot; : 49,</span></p><p class="c3 c4"><span class="c0 c7">&quot;Square of 8&quot; : 64,</span></p><p class="c3 c4"><span class="c0 c7">&quot;Square of 9&quot; : 81,</span></p><p class="c3 c4"><span class="c0 c7">&quot;Square of 10&quot; : 100</span></p><p class="c3 c4"><span class="c0 c7">}</span></p><h1 class="c3"><a name="h.mjv7kyjurri2"></a><span>JSON Navigation</span></h1><p class="c3 c6"><span>Up to now, you learnt how to compose expressions so as to do some computations and to build pairs, objects and arrays. It also works the other way round: if you have some JSON data, you can access it and navigate.</span></p><p class="c1 c6"><span></span></p><p class="c3 c6"><span>All you need to know is: JSONiq views</span></p><ol class="c10" start="1"><li class="c3 c6 c8 c14"><span>an array as a sequence of values,</span></li><li class="c3 c6 c8 c14"><span>an object as a set of name/value pairs (we call them just: pairs)</span></li><li class="c3 c6 c8 c14"><span>a pair as a (name, value) tuple.</span></li></ol><h2 class="c3 c6"><a name="h.xosiyb17dh24"></a><span>Objects</span></h2><p class="c3 c6"><span>If you use an object as a functor and provide it with a string, it will return the pair named after its parameter:</span></p><p class="c1"><span class="c0"></span></p><p class="c3"><span class="c0">let $person := {</span></p><p class="c3"><span class="c0">&nbsp; &quot;first name&quot; : &quot;Sarah&quot;,</span></p><p class="c3"><span class="c0">&nbsp; &quot;age&quot; : 13,</span></p><p class="c3"><span class="c0">&nbsp; &quot;gender&quot; : &quot;female&quot;,</span></p><p class="c3"><span class="c0">&nbsp; &quot;friends&quot; : [ &quot;Jim&quot;, &quot;Mary&quot;, &quot;Jennifer&quot;]</span></p><p class="c3"><span class="c0">}</span></p><p class="c3"><span class="c0">return $person(&quot;first name&quot;)</span></p><p class="c3 c5"><span class="c0 c7">&quot;first name&quot; : &quot;Sarah&quot;</span></p><p class="c1 c5"><span class="c0 c7"></span></p><h2 class="c3"><a name="h.mrf42gizl3y6"></a><span>Arrays</span></h2><p class="c3 c6"><span>If you use an array as a functor and provide it with an integer, it will return the corresponding entry:</span></p><p class="c1"><span class="c0"></span></p><p class="c3"><span class="c0">let $friends := [ &quot;Jim&quot;, &quot;Mary&quot;, &quot;Jennifer&quot;]</span></p><p class="c3"><span class="c0">return $friends(2)</span></p><p class="c3 c5"><span class="c0 c7">Mary</span></p><h2 class="c3"><a name="h.hdc3dgohtdut"></a><span>Pairs</span></h2><p class="c3"><span>Given a pair, you can get its name and value using the functions jn:name and jn:value:</span></p><p class="c1"><span></span></p><p class="c3"><span class="c0">let $pair := &quot;name of the pair&quot; : &quot;value of the pair&quot;</span></p><p class="c3"><span class="c0">return { &nbsp;&quot;name&quot; : jn:name($pair), &quot;value&quot; : jn:value($pair) }</span></p><p class="c1"><span class="c0"></span></p><p class="c3 c5"><span class="c0 c7">{ &quot;name&quot; : &quot;name of the pair&quot;, &quot;value&quot; : &quot;value of the pair&quot; }</span></p><p class="c1"><span class="c7"></span></p><p class="c3"><span>This functions also exist in plural form for objects:</span></p><p class="c1"><span></span></p><p class="c3"><span class="c0">let $person := {</span></p><p class="c3"><span class="c0">&nbsp; &quot;name&quot; : &quot;Sarah&quot;,</span></p><p class="c3"><span class="c0">&nbsp; &quot;age&quot; : 13,</span></p><p class="c3"><span class="c0">&nbsp; &quot;gender&quot; : &quot;female&quot;,</span></p><p class="c3"><span class="c0">&nbsp; &quot;friends&quot; : [ &quot;Jim&quot;, &quot;Mary&quot;, &quot;Jennifer&quot;]</span></p><p class="c3"><span class="c0">}</span></p><p class="c3"><span class="c0">return { &quot;names&quot; : [ jn:names($person)],</span></p><p class="c3"><span class="c0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot;values&quot; : [ jn:values($person)]</span></p><p class="c3"><span class="c0">&nbsp; &nbsp; &nbsp; &nbsp;}</span></p><p class="c3 c13"><span class="c0 c7">{</span></p><p class="c13 c3"><span class="c0 c7">&quot;names&quot; : [ &quot;name&quot;, &quot;age&quot;, &quot;gender&quot;, &quot;friends&quot; ],</span></p><p class="c13 c3"><span class="c0 c7">&quot;values&quot; : [ &quot;Sarah&quot;, 13, &quot;female&quot;, [ &quot;Jim&quot;, &quot;Mary&quot;, &quot;Jennifer&quot; ] ]</span></p><p class="c13 c3"><span class="c0 c7">}</span></p><p class="c3"><span>jn:values can also be used for an array:</span></p><p class="c1"><span></span></p><p class="c3"><span class="c0">let $person := {</span></p><p class="c3"><span class="c0">&nbsp; &quot;name&quot; : &quot;Sarah&quot;,</span></p><p class="c3"><span class="c0">&nbsp; &quot;age&quot; : 13,</span></p><p class="c3"><span class="c0">&nbsp; &quot;gender&quot; : &quot;female&quot;,</span></p><p class="c3"><span class="c0">&nbsp; &quot;friends&quot; : [ &quot;Jim&quot;, &quot;Mary&quot;, &quot;Jennifer&quot;]</span></p><p class="c3"><span class="c0">}</span></p><p class="c3"><span class="c0">return jn:values($person(&quot;friends&quot;))</span></p><p class="c3 c5"><span class="c7">[ &quot;Jim&quot;, &quot;Mary&quot;, &quot;Jennifer&quot; ]</span></p><p class="c1 c5"><span class="c7"></span></p><h1 class="c3"><a name="h.eb0bxle2oykl"></a><span>Relational Algebra</span></h1><p class="c3 c6"><span>Remember last century&#39;s SELECT FROM WHERE statements? Well, JSONiq didn&#39;t throw out the baby with the bathwater. It has selection, projection and join capability.</span></p><p class="c1"><span></span></p><p class="c3"><span class="c0">let $stores :=</span></p><p class="c3"><span class="c0">[</span></p><p class="c3"><span class="c0">&nbsp; { &quot;store number&quot; : 1, &quot;state&quot; : &quot;MA&quot; },</span></p><p class="c3"><span class="c0">&nbsp; { &quot;store number&quot; : 2, &quot;state&quot; : &quot;MA&quot; },</span></p><p class="c3"><span class="c0">&nbsp; { &quot;store number&quot; : 3, &quot;state&quot; : &quot;CA&quot; },</span></p><p class="c3"><span class="c0">&nbsp; { &quot;store number&quot; : 4, &quot;state&quot; : &quot;CA&quot; }</span></p><p class="c3"><span class="c0">]</span></p><p class="c3"><span class="c0">let $sales := [</span></p><p class="c3"><span class="c0">&nbsp; &nbsp;{ &quot;product&quot; : &quot;broiler&quot;, &quot;store number&quot; : 1, &quot;quantity&quot; : 20 &nbsp;},</span></p><p class="c3"><span class="c0">&nbsp; &nbsp;{ &quot;product&quot; : &quot;toaster&quot;, &quot;store number&quot; : 2, &quot;quantity&quot; : 100 },</span></p><p class="c3"><span class="c0">&nbsp; &nbsp;{ &quot;product&quot; : &quot;toaster&quot;, &quot;store number&quot; : 2, &quot;quantity&quot; : 50 },</span></p><p class="c3"><span class="c0">&nbsp; &nbsp;{ &quot;product&quot; : &quot;toaster&quot;, &quot;store number&quot; : 3, &quot;quantity&quot; : 50 },</span></p><p class="c3"><span class="c0">&nbsp; &nbsp;{ &quot;product&quot; : &quot;blender&quot;, &quot;store number&quot; : 3, &quot;quantity&quot; : 100 },</span></p><p class="c3"><span class="c0">&nbsp; &nbsp;{ &quot;product&quot; : &quot;blender&quot;, &quot;store number&quot; : 3, &quot;quantity&quot; : 150 },</span></p><p class="c3"><span class="c0">&nbsp; &nbsp;{ &quot;product&quot; : &quot;socks&quot;, &quot;store number&quot; : 1, &quot;quantity&quot; : 500 },</span></p><p class="c3"><span class="c0">&nbsp; &nbsp;{ &quot;product&quot; : &quot;socks&quot;, &quot;store number&quot; : 2, &quot;quantity&quot; : 10 },</span></p><p class="c3"><span class="c0">&nbsp; &nbsp;{ &quot;product&quot; : &quot;shirt&quot;, &quot;store number&quot; : 3, &quot;quantity&quot; : 10 }</span></p><p class="c3"><span class="c0">]</span></p><p class="c3"><span class="c0">let $join :=</span></p><p class="c3"><span class="c0">&nbsp; for $store in jn:values($stores), $sale in jn:values($sales)</span></p><p class="c3"><span class="c0">&nbsp; where $store(&quot;store number&quot;) = $sale(&quot;store number&quot;)</span></p><p class="c3"><span class="c0">&nbsp; return {</span></p><p class="c3"><span class="c0">&nbsp; &nbsp; &quot;nb&quot; : $store(&quot;store number&quot;),</span></p><p class="c3"><span class="c0">&nbsp; &nbsp; &quot;state&quot; : $store(&quot;state&quot;),</span></p><p class="c3"><span class="c0">&nbsp; &nbsp; &quot;sold&quot; : $sale(&quot;product&quot;)</span></p><p class="c3"><span class="c0">&nbsp; }</span></p><p class="c3"><span class="c0">return [$join]</span></p><p class="c3 c4"><span class="c0 c7">[ </span></p><p class="c3 c4"><span class="c0 c7">{ &quot;nb&quot; : 1, &quot;state&quot; : &quot;MA&quot;, &quot;sold&quot; : &quot;broiler&quot; },</span></p><p class="c3 c4"><span class="c0 c7">{ &quot;nb&quot; : 1, &quot;state&quot; : &quot;MA&quot;, &quot;sold&quot; : &quot;socks&quot; },</span></p><p class="c3 c4"><span class="c0 c7">{ &quot;nb&quot; : 2, &quot;state&quot; : &quot;MA&quot;, &quot;sold&quot; : &quot;toaster&quot; },</span></p><p class="c3 c4"><span class="c0 c7">{ &quot;nb&quot; : 2, &quot;state&quot; : &quot;MA&quot;, &quot;sold&quot; : &quot;toaster&quot; },</span></p><p class="c3 c4"><span class="c0 c7">{ &quot;nb&quot; : 2, &quot;state&quot; : &quot;MA&quot;, &quot;sold&quot; : &quot;socks&quot; },</span></p><p class="c3 c4"><span class="c0 c7">{ &quot;nb&quot; : 3, &quot;state&quot; : &quot;CA&quot;, &quot;sold&quot; : &quot;toaster&quot; },</span></p><p class="c3 c4"><span class="c0 c7">{ &quot;nb&quot; : 3, &quot;state&quot; : &quot;CA&quot;, &quot;sold&quot; : &quot;blender&quot; },</span></p><p class="c3 c4"><span class="c0 c7">{ &quot;nb&quot; : 3, &quot;state&quot; : &quot;CA&quot;, &quot;sold&quot; : &quot;blender&quot; },</span></p><p class="c3 c4"><span class="c0 c7">{ &quot;nb&quot; : 3, &quot;state&quot; : &quot;CA&quot;, &quot;sold&quot; : &quot;shirt&quot; }</span></p><p class="c3 c4"><span class="c0 c7">&nbsp;]</span></p><h1 class="c3"><a name="h.oii6pvliilhi"></a><span>Access external data</span></h1><p class="c3"><span>You can access a JSON file on your local disk with</span></p><p class="c1"><span></span></p><p class="c3"><span class="c0">jn:json(&quot;file.json&quot;)</span></p><p class="c3 c5"><span class="c0 c7">[ &quot;The&quot;, &quot;contents&quot;, &quot;of&quot;, &quot;your&quot;, &quot;file&quot; ]</span></p><p class="c1"><span></span></p><p class="c3"><span>Our implementation even supports collections of JSON objects or arrays:</span></p><p class="c1"><span></span></p><p class="c3"><span class="c0">dml:collection(&quot;my:data&quot;)</span></p><p class="c3 c5"><span class="c0 c7">{ &quot;foo&quot; : &quot;Your&quot; }</span></p><p class="c3 c5"><span class="c0 c7">{ &quot;foo&quot; : &quot;Collection&quot; }</span></p><p class="c3 c5"><span class="c0 c7">{ &quot;foo&quot; : &quot;of&quot; }</span></p><p class="c3 c5"><span class="c0 c7">{ &quot;foo&quot; : &quot;JSON&quot; }</span></p><p class="c3 c5"><span class="c0 c7">{ &quot;foo&quot; : &quot;objects&quot; }</span></p><h1 class="c3"><a name="h.bm3buqmzhtko"></a><span>I want more</span></h1><p class="c3 c6"><span>JSONiq supports JSON updates. You can declaratively update your JSON data. JSONiq provides functions that produce a list of updates. The list of updates that is eventually output by your program is then applied to your JSON data.</span></p><p class="c1"><span></span></p><p class="c3"><span>let $my-data := jn:json(&quot;persons.json&quot;)</span></p><p class="c3"><span>let $john := jn:value($my-data(&quot;John&quot;))</span></p><p class="c3"><span>let $mary := jn:value($my-data(&quot;Mary&quot;))</span></p><p class="c3"><span>return (jn:replace-value($john, &quot;status&quot;, &quot;married&quot;), j:replace-value($mary, &quot;status&quot;, &quot;married&quot;))</span></p><h2 class="c3"><a name="h.5itcphr8262b"></a><span>Even more</span></h2><p class="c3"><span>JSONiq can do way more that what is presented here. Here are a couple of highlights:</span></p><p class="c3 c6"><span>- JSONiq is a strongly typed language, but is smart enough to not bother you with types when unnecessary. It potentially supports static typing as well to detect errors before you even execute your program.</span></p><p class="c3"><span>- You can define your own functions and modules.</span></p><p class="c3"><span>- JSONiq provides you with loads of available modules.</span></p><p class="c3 c6"><span>- JSONiq has tons of further features such as switch, typeswitch and try-catch expressions, universal/existential quantifiers, path expressions, filtering expressions, functors, mappings, grouping, windowing.</span></p><h2 class="c3"><a name="h.j7oh3cyhem38"></a><span>More is not enough</span></h2><p class="c3 c6"><span>- JSONiq supports XML. Yes: you can manipulate JSON and XML with the same language! JSONiq is actually a superset of XQuery, a W3C standard, and extends its data model to support JSON.</span></p><p class="c3 c6"><span>- JSONiq supports scripting. If you need to write a full-fledged, side-effecting Web application, scripting is for you.</span></p></body></html>
1977\ No newline at end of file
1978
1979=== modified file 'doc/zorba/indexpage.dox.in'
1980--- doc/zorba/indexpage.dox.in 2011-10-07 08:28:43 +0000
1981+++ doc/zorba/indexpage.dox.in 2012-02-08 21:22:19 +0000
1982@@ -124,7 +124,15 @@
1983
1984 \ref options_and_annotations
1985
1986- <!--li>\ref extensions_update</li-->
1987+</td></tr>
1988+<tr><td class="tdDocIndexTable">
1989+
1990+ <h2>JSONiq</h2>
1991+
1992+
1993+ <a href="XQueryforJSON.html">JSONiq for JSON users</a>
1994+
1995+ <a href="JSONforXQuery.html">JSONiq for XQuery users</a>
1996
1997
1998 </td></tr>
1999
2000=== modified file 'include/zorba/config.h.cmake'
2001--- include/zorba/config.h.cmake 2012-02-05 12:31:20 +0000
2002+++ include/zorba/config.h.cmake 2012-02-08 21:22:19 +0000
2003@@ -155,6 +155,7 @@
2004 #cmakedefine ZORBA_WITH_BIG_INTEGER
2005 #cmakedefine ZORBA_WITH_DEBUGGER
2006 #cmakedefine ZORBA_WITH_FILE_ACCESS
2007+#cmakedefine ZORBA_WITH_JSON
2008 #cmakedefine ZORBA_WITH_LIBXML2_SAX
2009
2010 // Zorba parser configuration
2011
2012=== modified file 'include/zorba/diagnostic.h'
2013--- include/zorba/diagnostic.h 2011-07-01 16:07:54 +0000
2014+++ include/zorba/diagnostic.h 2012-02-08 21:22:19 +0000
2015@@ -239,7 +239,15 @@
2016 ZORBA_DEBUGGER, // Zorba Debugger
2017 ZORBA_OS, // Operating System
2018 ZORBA_SERIALIZATION,
2019- ZORBA_STORE
2020+ ZORBA_STORE,
2021+
2022+ JSON_PARSER,
2023+ JSON_SERIALIZATION,
2024+
2025+# ifdef ZORBA_WITH_JSON
2026+ JSONIQ_CORE,
2027+ JSONIQ_UPDATE
2028+# endif
2029 };
2030
2031 /**
2032
2033=== modified file 'include/zorba/error.h'
2034--- include/zorba/error.h 2011-07-04 21:23:55 +0000
2035+++ include/zorba/error.h 2012-02-08 21:22:19 +0000
2036@@ -42,6 +42,13 @@
2037 */
2038 typedef internal::SystemDiagnostic<internal::ZorbaErrQName> ZorbaErrorCode;
2039
2040+#ifdef ZORBA_WITH_JSON
2041+/**
2042+ * An %JSONiqErrorCode is a diagnostic for all JSONiq-specific errors.
2043+ */
2044+typedef internal::SystemDiagnostic<internal::JSONiqErrQName> JSONiqErrorCode;
2045+#endif
2046+
2047 ///////////////////////////////////////////////////////////////////////////////
2048
2049 /**
2050
2051=== modified file 'include/zorba/identtypes.h'
2052--- include/zorba/identtypes.h 2011-09-21 14:49:55 +0000
2053+++ include/zorba/identtypes.h 2012-02-08 21:22:19 +0000
2054@@ -18,10 +18,14 @@
2055
2056 #include <zorba/config.h>
2057
2058-namespace zorba {
2059-class ZORBA_DLL_PUBLIC IdentTypes {
2060+namespace zorba
2061+{
2062+
2063+class ZORBA_DLL_PUBLIC IdentTypes
2064+{
2065 public:
2066- typedef enum {
2067+ typedef enum
2068+ {
2069 NAMED_TYPE, // builtin atomic type
2070 ELEMENT_TYPE,
2071 ATTRIBUTE_TYPE,
2072@@ -30,12 +34,20 @@
2073 TEXT_TYPE,
2074 COMMENT_TYPE,
2075 ANY_NODE_TYPE, // node()
2076+#ifdef ZORBA_WITH_JSON
2077+ STRUCTURED_ITEM_TYPE,
2078+ JSON_ITEM_TYPE,
2079+ JSON_OBJECT_TYPE,
2080+ JSON_ARRAY_TYPE,
2081+ JSON_PAIR_TYPE,
2082+#endif
2083 ITEM_TYPE, // item()
2084 EMPTY_TYPE, // empty-sequence()
2085 INVALID_TYPE,
2086 } kind_t;
2087
2088- typedef enum {
2089+ typedef enum
2090+ {
2091 QUANT_ONE,
2092 QUANT_QUESTION,
2093 QUANT_PLUS,
2094
2095=== modified file 'include/zorba/internal/qname.h'
2096--- include/zorba/internal/qname.h 2011-06-30 16:42:30 +0000
2097+++ include/zorba/internal/qname.h 2012-02-08 21:22:19 +0000
2098@@ -182,6 +182,46 @@
2099
2100 ///////////////////////////////////////////////////////////////////////////////
2101
2102+#ifdef ZORBA_WITH_JSON
2103+
2104+/**
2105+ * An %JSONiqErrQName is-a FixedQName for standard JSONiq errors.
2106+ */
2107+class ZORBA_DLL_PUBLIC JSONiqErrQName :
2108+ public FixedQName<JSONiqErrQName,char const*>
2109+{
2110+ typedef FixedQName<JSONiqErrQName,char const*> base_type;
2111+public:
2112+ static char const NAMESPACE[];
2113+ static char const PREFIX[];
2114+
2115+ /**
2116+ * Constructs an %JSONiqErrQName.
2117+ *
2118+ * @param localname The local-name of the error.
2119+ */
2120+ JSONiqErrQName( char const *localname ) : base_type( localname ) { }
2121+
2122+ /**
2123+ * Gets the category of error this QName represents.
2124+ *
2125+ * @return Returns UNKNOWN_CATEGORY as there currently
2126+ * are no categories for JSONiq errors
2127+ */
2128+ zorba::diagnostic::category category() const;
2129+
2130+ /**
2131+ * Gets the kind of error this QName represents.
2132+ *
2133+ * @return Returns said kind.
2134+ */
2135+ zorba::diagnostic::kind kind() const;
2136+};
2137+
2138+#endif
2139+
2140+///////////////////////////////////////////////////////////////////////////////
2141+
2142 /**
2143 * An %ZorbaWarningQName is-a FixedQName for Zorba warnings.
2144 */
2145
2146=== modified file 'include/zorba/item.h'
2147--- include/zorba/item.h 2012-01-11 17:30:25 +0000
2148+++ include/zorba/item.h 2012-02-08 21:22:19 +0000
2149@@ -142,6 +142,21 @@
2150 Item
2151 getType() const;
2152
2153+#ifdef ZORBA_WITH_JSON
2154+
2155+ /**
2156+ * \brief Check if the Item is a JSON Item, that is, part of the JSONiq
2157+ * data model.
2158+ *
2159+ * Note that this function is available for all types of Items.
2160+ *
2161+ * @return true if the Item is a JSON Item, false otherwise.
2162+ */
2163+ bool
2164+ isJSONItem() const;
2165+
2166+#endif /* ZORBA_WITH_JSON */
2167+
2168 /** \brief Get the atomization value of the Item.
2169 *
2170 * The atomization value is the value that is returned by atomization
2171@@ -346,6 +361,83 @@
2172 int
2173 getNodeKind() const;
2174
2175+#ifdef ZORBA_WITH_JSON
2176+
2177+ /** \brief Get the kind of this (JSON) Item.
2178+ *
2179+ * Note that this function is only available for JSON Items, that is, Items
2180+ * which return true from isJSONItem().
2181+ *
2182+ * @return the kind of this JSON item
2183+ * @throw ZorbaException if an error occured (e.g. the Item is not of type JSON).
2184+ */
2185+ store::StoreConsts::JSONItemKind
2186+ getJSONItemKind() const;
2187+
2188+ /** \brief Get the pairs from a JSON Object.
2189+ *
2190+ * Note that this function is only available for JSON Objects.
2191+ *
2192+ * @return Iterator over the pairs in this object.
2193+ * @throw ZorbaException if an error occured (e.g. the Item is not of type JSON Object).
2194+ */
2195+ Iterator_t
2196+ getObjectPairs() const;
2197+
2198+ /** \brief Get the members of a JSON Array.
2199+ *
2200+ * Note that this function is only available for JSON Arrays.
2201+ *
2202+ * @return Iterator over the members of this array.
2203+ * @throw ZorbaException if an error occure (e.g. the Item is not of type JSON Array).
2204+ */
2205+ Iterator_t
2206+ getArrayMembers() const;
2207+
2208+ /** \brief Returns the value of a JSON Pair with the given name from a JSON Object.
2209+ *
2210+ * Note that this function is only available for JSON Objects.
2211+ *
2212+ * @param aName the name of the pair to return.
2213+ * @return Item the named Pair.
2214+ * @throw ZorbaException if an error occured (e.g. the Item is not of type JSON Object).
2215+ */
2216+ Item
2217+ getObjectValue(String aName) const;
2218+
2219+ /** \brief Returns the item in the JSON array at the specified index.
2220+ *
2221+ * Note that this function is only available for JSON Arrays.
2222+ *
2223+ * @param aIndex the index in the array.
2224+ * @return Item the indexed Item.
2225+ * @throw ZorbaException if an error occured (e.g. the Item is not of type JSON Array).
2226+ */
2227+ Item
2228+ getArrayMember(uint32_t aIndex) const;
2229+
2230+ /** \brief Returns the name of a JSON Pair.
2231+ *
2232+ * Note that this function is only available for JSON Pairs.
2233+ *
2234+ * @return Item the name of the Pair.
2235+ * @throw ZorbaException if an error occured (e.g. the Item is not of type JSON Pair).
2236+ */
2237+ Item
2238+ getPairName() const;
2239+
2240+ /** \brief Returns the value of a JSON Pair.
2241+ *
2242+ * Note that this function is only available for JSON Pairs.
2243+ *
2244+ * @return Item the value of the Pair.
2245+ * @throw ZorbaException if an error occured (e.g. the Item is not of type JSON Pair).
2246+ */
2247+ Item
2248+ getPairValue() const;
2249+
2250+#endif /* ZORBA_WITH_JSON */
2251+
2252 /**
2253 * Checks whether the item's content is streamable.
2254 *
2255
2256=== modified file 'include/zorba/item_factory.h'
2257--- include/zorba/item_factory.h 2012-01-11 17:30:25 +0000
2258+++ include/zorba/item_factory.h 2012-02-08 21:22:19 +0000
2259@@ -123,7 +123,7 @@
2260 /** \brief Creates a Base64Binary Item
2261 * see [http://www.w3.org/TR/xmlschema-2/#base64Binary]
2262 *
2263- * @param aBinData a pointer to the base64 binary data.
2264+ * @param aBinData a pointer to the base6c4 binary data.
2265 * @param aLength the length of the base64 binary data.
2266 * @return The Base64Binary Item.
2267 */
2268@@ -679,6 +679,51 @@
2269 virtual Item createTextNode(
2270 Item parent,
2271 String content) = 0;
2272+
2273+#ifdef ZORBA_WITH_JSON
2274+
2275+ /**
2276+ * Create a JSON null item.
2277+ */
2278+ virtual Item createJSONNull() = 0;
2279+
2280+ /**
2281+ * Create a JSON Number item from a string. This will actually be
2282+ * an xs:integer, xs:double, or xs:decimal, depending on the content
2283+ * of the string.
2284+ *
2285+ * @param aString The input string.
2286+ */
2287+ virtual Item createJSONNumber(String aString) = 0;
2288+
2289+ /**
2290+ * Create a JSON Object containing the specified JSON Pairs.
2291+ *
2292+ * @param aPairs A std::vector<Item> containing JSON Pair items.
2293+ */
2294+ virtual Item createJSONObject(std::vector<Item>& aPairs) = 0;
2295+
2296+ /**
2297+ * Create a JSON Array containing the specified items.
2298+ *
2299+ * @param aItems A std::vector<Item> containing Items which may
2300+ * be stored in a JSON Array (namely JSON Arrays, JSON Objects,
2301+ * JSON nulls, valid JSON numeric types, or xs:strings).
2302+ */
2303+ virtual Item createJSONArray(std::vector<Item>& aItems) = 0;
2304+
2305+ /**
2306+ * Create a JSON Pair, suitable for putting into a JSON Object.
2307+ *
2308+ * @param aName The name for the pair.
2309+ * @param aValue The value for the pair. This must be of a type
2310+ * which may be the value of a JSON pair (namely JSON Arrays, JSON Objects,
2311+ * JSON nulls, valid JSON numeric types, or xs:strings).
2312+ */
2313+ virtual Item createJSONPair(String aName, Item aValue) = 0;
2314+
2315+#endif /* ZORBA_WITH_JSON */
2316+
2317 }; // class ItemFactory
2318
2319 } // namespace zorba
2320
2321=== modified file 'include/zorba/options.h'
2322--- include/zorba/options.h 2012-01-11 17:30:25 +0000
2323+++ include/zorba/options.h 2012-02-08 21:22:19 +0000
2324@@ -83,7 +83,11 @@
2325 ZORBA_SERIALIZATION_METHOD_HTML,
2326 ZORBA_SERIALIZATION_METHOD_XHTML,
2327 ZORBA_SERIALIZATION_METHOD_TEXT,
2328- ZORBA_SERIALIZATION_METHOD_BINARY
2329+ ZORBA_SERIALIZATION_METHOD_BINARY,
2330+#ifdef ZORBA_WITH_JSON
2331+ ZORBA_SERIALIZATION_METHOD_JSON,
2332+ ZORBA_SERIALIZATION_METHOD_JSONIQ
2333+#endif
2334 } Zorba_serialization_method_t;
2335
2336
2337
2338=== modified file 'include/zorba/pregenerated/diagnostic_list.h'
2339--- include/zorba/pregenerated/diagnostic_list.h 2011-12-21 14:40:33 +0000
2340+++ include/zorba/pregenerated/diagnostic_list.h 2012-02-08 21:22:19 +0000
2341@@ -504,6 +504,12 @@
2342
2343 extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZAPI0042_ITERATOR_CLOSED;
2344
2345+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZAPI0043_CANNOT_SERIALIZE_JSON_ITEM;
2346+
2347+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZAPI0044_CANNOT_SERIALIZE_XML_ITEM;
2348+
2349+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZAPI0045_CANNOT_SERIALIZE_MIXED_XDM_JDM;
2350+
2351 extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZAPI0070_INVALID_SERIALIZATION_METHOD_FOR_SAX;
2352
2353 extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZAPI0080_CANNOT_RETRIEVE_NODE_REFERENCE;
2354@@ -704,6 +710,8 @@
2355
2356 extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZSTR0012_COLLECTION_ITEM_MUST_BE_A_NODE;
2357
2358+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZSTR0013_COLLECTION_ITEM_MUST_BE_STRUCTURED;
2359+
2360 extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZSTR0015_IC_ALREADY_EXISTS;
2361
2362 extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZSTR0016_IC_DOES_NOT_EXIST;
2363@@ -746,8 +754,70 @@
2364
2365 extern ZORBA_DLL_PUBLIC ZorbaErrorCode XSST0010;
2366
2367+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJPE0001_ILLEGAL_CHARACTER;
2368+
2369+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJPE0002_ILLEGAL_CODEPOINT;
2370+
2371+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJPE0003_ILLEGAL_ESCAPE;
2372+
2373+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJPE0004_ILLEGAL_LITERAL;
2374+
2375+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJPE0005_ILLEGAL_NUMBER;
2376+
2377+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJPE0006_UNEXPECTED_TOKEN;
2378+
2379+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJPE0007_UNTERMINATED_STRING;
2380+
2381+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJSE0001_NOT_DOCUMENT_OR_ELEMENT_NODE;
2382+
2383+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJSE0002_ELEMENT_MISSING_ATTRIBUTE;
2384+
2385+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJSE0003_BAD_ATTRIBUTE_VALUE;
2386+
2387+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJSE0004_BAD_ELEMENT;
2388+
2389+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJSE0005_BAD_CHILD_ELEMENT;
2390+
2391+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJSE0006_NO_ELEMENT_CHILD;
2392+
2393+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJSE0007_NO_TEXT_CHILD;
2394+
2395 } // namespace zerr
2396
2397+namespace jerr {
2398+
2399+#if defined(ZORBA_WITH_JSON)
2400+extern ZORBA_DLL_PUBLIC JSONiqErrorCode JSDY0001;
2401+
2402+extern ZORBA_DLL_PUBLIC JSONiqErrorCode JSDY0002;
2403+
2404+extern ZORBA_DLL_PUBLIC JSONiqErrorCode JSDY0003;
2405+
2406+extern ZORBA_DLL_PUBLIC JSONiqErrorCode JSDY0020;
2407+
2408+extern ZORBA_DLL_PUBLIC JSONiqErrorCode JSDY0040;
2409+
2410+extern ZORBA_DLL_PUBLIC JSONiqErrorCode JSDY0041;
2411+
2412+extern ZORBA_DLL_PUBLIC JSONiqErrorCode JUDY0060;
2413+
2414+extern ZORBA_DLL_PUBLIC JSONiqErrorCode JUDY0061;
2415+
2416+extern ZORBA_DLL_PUBLIC JSONiqErrorCode JSTY0001;
2417+
2418+extern ZORBA_DLL_PUBLIC JSONiqErrorCode JSTY0002;
2419+
2420+extern ZORBA_DLL_PUBLIC JSONiqErrorCode JUDY0062;
2421+
2422+extern ZORBA_DLL_PUBLIC JSONiqErrorCode JUDY0063;
2423+
2424+extern ZORBA_DLL_PUBLIC JSONiqErrorCode JUDY0064;
2425+
2426+extern ZORBA_DLL_PUBLIC JSONiqErrorCode JUDY0065;
2427+#endif
2428+
2429+} // namespace jerr
2430+
2431 namespace zwarn {
2432
2433 extern ZORBA_DLL_PUBLIC ZorbaWarningCode ZWST0002_UNKNOWN_ANNOTATION;
2434
2435=== modified file 'include/zorba/store_consts.h'
2436--- include/zorba/store_consts.h 2011-06-14 17:26:33 +0000
2437+++ include/zorba/store_consts.h 2012-02-08 21:22:19 +0000
2438@@ -25,6 +25,13 @@
2439 {
2440 public:
2441
2442+ enum NsScoping
2443+ {
2444+ ALL_NAMESPACES,
2445+ ONLY_LOCAL_NAMESPACES,
2446+ ONLY_PARENT_NAMESPACES
2447+ };
2448+
2449 enum NodeKind
2450 {
2451 anyNode = 0,
2452@@ -36,16 +43,10 @@
2453 commentNode = 6
2454 };
2455
2456- enum NsScoping
2457- {
2458- ALL_NAMESPACES,
2459- ONLY_LOCAL_NAMESPACES,
2460- ONLY_PARENT_NAMESPACES
2461- };
2462-
2463 static std::string toString(NodeKind k)
2464 {
2465- switch(k) {
2466+ switch(k)
2467+ {
2468 case anyNode:
2469 return "anyNode";
2470
2471@@ -71,6 +72,39 @@
2472 return "<unknown NodeKind>";
2473 }
2474 }
2475+
2476+
2477+ /* ATTENTION: the ordering of the enum values is important. Do NOT change it! */
2478+ enum JSONItemKind
2479+ {
2480+ jsonItem = 0,
2481+ jsonObject = 1,
2482+ jsonArray = 2,
2483+ jsonPair = 3
2484+ };
2485+
2486+
2487+ static std::string toString(JSONItemKind k)
2488+ {
2489+ switch(k)
2490+ {
2491+ case jsonItem:
2492+ return "json-item";
2493+
2494+ case jsonObject:
2495+ return "object";
2496+
2497+ case jsonArray:
2498+ return "array";
2499+
2500+ case jsonPair:
2501+ return "pair";
2502+
2503+ default:
2504+ return "<unknown JSONItemKind>";
2505+ }
2506+ }
2507+
2508 };
2509
2510 } // namespace store
2511
2512=== modified file 'include/zorba/typeident.h'
2513--- include/zorba/typeident.h 2011-06-14 17:26:33 +0000
2514+++ include/zorba/typeident.h 2012-02-08 21:22:19 +0000
2515@@ -64,45 +64,55 @@
2516 const String& localNameName,
2517 bool localNameWildcard,
2518 TypeIdentifier_t contentType,
2519- IdentTypes::quantifier_t quantifier = IdentTypes::QUANT_ONE
2520- );
2521+ IdentTypes::quantifier_t q = IdentTypes::QUANT_ONE);
2522
2523 static
2524 TypeIdentifier_t
2525 createDocumentType(
2526 TypeIdentifier_t contentType,
2527- IdentTypes::quantifier_t quantifier = IdentTypes::QUANT_ONE
2528- );
2529-
2530- static
2531- TypeIdentifier_t
2532- createPIType(
2533- IdentTypes::quantifier_t quantifier = IdentTypes::QUANT_ONE
2534- );
2535-
2536- static
2537- TypeIdentifier_t
2538- createTextType(
2539- IdentTypes::quantifier_t quantifier = IdentTypes::QUANT_ONE
2540- );
2541-
2542- static
2543- TypeIdentifier_t
2544- createCommentType(
2545- IdentTypes::quantifier_t quantifier = IdentTypes::QUANT_ONE
2546- );
2547-
2548- static
2549- TypeIdentifier_t
2550- createAnyNodeType(
2551- IdentTypes::quantifier_t quantifier = IdentTypes::QUANT_ONE
2552- );
2553-
2554- static
2555- TypeIdentifier_t
2556- createItemType(
2557- IdentTypes::quantifier_t quantifier = IdentTypes::QUANT_ONE
2558- );
2559+ IdentTypes::quantifier_t q = IdentTypes::QUANT_ONE);
2560+
2561+ static
2562+ TypeIdentifier_t
2563+ createPIType(IdentTypes::quantifier_t q = IdentTypes::QUANT_ONE);
2564+
2565+ static
2566+ TypeIdentifier_t
2567+ createTextType(IdentTypes::quantifier_t q = IdentTypes::QUANT_ONE);
2568+
2569+ static
2570+ TypeIdentifier_t
2571+ createCommentType(IdentTypes::quantifier_t q = IdentTypes::QUANT_ONE);
2572+
2573+ static
2574+ TypeIdentifier_t
2575+ createAnyNodeType(IdentTypes::quantifier_t q = IdentTypes::QUANT_ONE);
2576+
2577+#ifdef ZORBA_WITH_JSON
2578+ static
2579+ TypeIdentifier_t
2580+ createStructuredItemType(IdentTypes::quantifier_t q = IdentTypes::QUANT_ONE);
2581+
2582+ static
2583+ TypeIdentifier_t
2584+ createJSONItemType(IdentTypes::quantifier_t q = IdentTypes::QUANT_ONE);
2585+
2586+ static
2587+ TypeIdentifier_t
2588+ createJSONObjectType(IdentTypes::quantifier_t q = IdentTypes::QUANT_ONE);
2589+
2590+ static
2591+ TypeIdentifier_t
2592+ createJSONArrayType(IdentTypes::quantifier_t q = IdentTypes::QUANT_ONE);
2593+
2594+ static
2595+ TypeIdentifier_t
2596+ createJSONPairType(IdentTypes::quantifier_t q = IdentTypes::QUANT_ONE);
2597+#endif
2598+
2599+ static
2600+ TypeIdentifier_t
2601+ createItemType(IdentTypes::quantifier_t q = IdentTypes::QUANT_ONE);
2602
2603 static
2604 TypeIdentifier_t
2605
2606=== modified file 'modules/ExternalModules.conf'
2607--- modules/ExternalModules.conf 2012-02-08 05:52:51 +0000
2608+++ modules/ExternalModules.conf 2012-02-08 21:22:19 +0000
2609@@ -27,7 +27,7 @@
2610 # currently only works for bzr, since svn tags are just different URLS)
2611
2612 data-cleaning bzr lp:zorba/data-cleaning-module zorba-2.1
2613-data-converters bzr lp:zorba/data-converters-module zorba-2.1
2614+data-converters bzr lp:zorba/data-converters-module
2615 data-formatting bzr lp:zorba/data-formatting-module zorba-2.1
2616 email bzr lp:zorba/email-module zorba-2.1
2617 excel bzr lp:zorba/excel-module zorba-2.1
2618
2619=== modified file 'modules/com/zorba-xquery/www/modules/CMakeLists.txt'
2620--- modules/com/zorba-xquery/www/modules/CMakeLists.txt 2012-02-05 12:31:20 +0000
2621+++ modules/com/zorba-xquery/www/modules/CMakeLists.txt 2012-02-08 21:22:19 +0000
2622@@ -103,6 +103,11 @@
2623 DECLARE_ZORBA_MODULE(FILE store/static/integrity_constraints/dml.xq VERSION 2.0
2624 URI "http://www.zorba-xquery.com/modules/store/static/integrity_constraints/dml")
2625
2626+DECLARE_ZORBA_MODULE(FILE store/jsoniq/dynamic/collections/ddl.xq VERSION 1.0
2627+ URI "http://www.zorba-xquery.com/modules/store/jsoniq/dynamic/collections/ddl")
2628+DECLARE_ZORBA_MODULE(FILE store/jsoniq/dynamic/collections/dml.xq VERSION 1.0
2629+ URI "http://www.zorba-xquery.com/modules/store/jsoniq/dynamic/collections/dml")
2630+
2631 # debugger client DBGP message handler module
2632 IF (ZORBA_WITH_DEBUGGER)
2633 DECLARE_ZORBA_MODULE (FILE debugger/dbgp-message-handler.xq VERSION 1.0
2634
2635=== added file 'modules/com/zorba-xquery/www/modules/converters/json-options.xsd'
2636--- modules/com/zorba-xquery/www/modules/converters/json-options.xsd 1970-01-01 00:00:00 +0000
2637+++ modules/com/zorba-xquery/www/modules/converters/json-options.xsd 2012-02-08 21:22:19 +0000
2638@@ -0,0 +1,47 @@
2639+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
2640+ xmlns:json="http://www.zorba-xquery.com/modules/converters/json-options"
2641+ targetNamespace="http://www.zorba-xquery.com/modules/converters/json-options"
2642+ elementFormDefault="qualified" attributeFormDefault="unqualified">
2643+<!--
2644+:: Copyright 2006-2008 The FLWOR Foundation.
2645+::
2646+:: Licensed under the Apache License, Version 2.0 (the "License");
2647+:: you may not use this file except in compliance with the License.
2648+:: You may obtain a copy of the License at
2649+::
2650+:: http://www.apache.org/licenses/LICENSE-2.0
2651+::
2652+:: Unless required by applicable law or agreed to in writing, software
2653+:: distributed under the License is distributed on an "AS IS" BASIS,
2654+:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2655+:: See the License for the specific language governing permissions and
2656+:: limitations under the License.
2657+::
2658+-->
2659+
2660+
2661+ <xs:element name="options">
2662+ <xs:complexType>
2663+ <xs:sequence>
2664+ <xs:element name="json-param" minOccurs="1" maxOccurs="1">
2665+ <xs:complexType>
2666+ <xs:simpleContent>
2667+ <xs:extension base="xs:string">
2668+ <xs:attribute name="name" type="xs:string" use="required"/>
2669+ <xs:attribute name="value" use="required">
2670+ <xs:simpleType>
2671+ <xs:restriction base="xs:string">
2672+ <xs:enumeration value="simple-json"/>
2673+ <xs:enumeration value="json-ml"/>
2674+ </xs:restriction>
2675+ </xs:simpleType>
2676+ </xs:attribute>
2677+ <xs:attribute name="type" type="xs:string" use="optional"/>
2678+ </xs:extension>
2679+ </xs:simpleContent>
2680+ </xs:complexType>
2681+ </xs:element>
2682+ </xs:sequence>
2683+ </xs:complexType>
2684+ </xs:element>
2685+</xs:schema>
2686
2687=== added file 'modules/com/zorba-xquery/www/modules/converters/json.xq'
2688--- modules/com/zorba-xquery/www/modules/converters/json.xq 1970-01-01 00:00:00 +0000
2689+++ modules/com/zorba-xquery/www/modules/converters/json.xq 2012-02-08 21:22:19 +0000
2690@@ -0,0 +1,231 @@
2691+xquery version "3.0";
2692+
2693+ (:
2694+ : Copyright 2006-2009 The FLWOR Foundation.
2695+ :
2696+ : Licensed under the Apache License, Version 2.0 (the "License");
2697+ : you may not use this file except in compliance with the License.
2698+ : You may obtain a copy of the License at
2699+ :
2700+ : http://www.apache.org/licenses/LICENSE-2.0
2701+ :
2702+ : Unless required by applicable law or agreed to in writing, software
2703+ : distributed under the License is distributed on an "AS IS" BASIS,
2704+ : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2705+ : See the License for the specific language governing permissions and
2706+ : limitations under the License.
2707+ :)
2708+
2709+ (:~
2710+ :
2711+ : <p>In order to enable JSON processing with XQuery, Zorba implements a set
2712+ : of functions that open XQuery developers the door to process JSON
2713+ : data. Specifically, this module provides two types of functions. Functions
2714+ : to:
2715+ : <ul>
2716+ : <li>parse JSON and convert it to XDM and</li>
2717+ : <li>serialize XDM in order to output JSON.</li>
2718+ : </ul>
2719+ : </p>
2720+ :
2721+ : <p>Both types of functions are available to parse and serialize two
2722+ : types of XDM-JSON mappings:<ul><li>the first mapping called in this document
2723+ : <strong>simple XDM-JSON</strong> has been
2724+ : <a href="http://john.snelson.org.uk/parsing-json-into-xquery">
2725+ : proposed by John Snelson</a></li><li>the second mapping is called
2726+ : <a href="http://jsonml.org/">JsonML</a></li></ul>In the following, we
2727+ : briefly describe both mappings.</p>
2728+ :
2729+ : <h2>Simple XDM-JSON Mapping</h2>
2730+ : <ul><li>In order to process JSON with XQuery, Zorba implements a mapping between
2731+ : JSON and XML that was initially proposed by John Snelson in his article
2732+ : <a href="http://snelson.org.uk/archives/2008/02/parsing_json_in.php#more"
2733+ : target="_blank">Parsing JSON into XQuery</a></li></ul>
2734+ :
2735+ : <h2>JsonML Mapping</h2>
2736+ : <ul>
2737+ : <li><a href="http://jsonml.org" target="_blank">JSonML</a> (JSON Markup Language)
2738+ : is an application of the JSON format.</li>
2739+ : <li>The purpose of JSonML is to provide a compact format for transporting
2740+ : XML-based markup as JSon. In contrast to the <strong>simple XDM-JSON</strong> mapping described above
2741+ : <strong>JsonML</strong> allows a lossless conversion back and forth.</li></ul>
2742+ :
2743+ : @author Sorin Nasoi
2744+ :
2745+ : @see <a href="http://john.snelson.org.uk/parsing-json-into-xquery">Mapping proposed by John Snelson</a>
2746+ : @see <a href="http://jsonml.org" target="_blank">JSonML</a>
2747+ : @project data processing/data converters
2748+ :
2749+ :)
2750+module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
2751+
2752+import module namespace schema = "http://www.zorba-xquery.com/modules/schema";
2753+
2754+import schema namespace json-options = "http://www.zorba-xquery.com/modules/converters/json-options";
2755+
2756+declare namespace err = "http://www.w3.org/2005/xqt-errors";
2757+
2758+declare namespace ver = "http://www.zorba-xquery.com/options/versioning";
2759+declare option ver:module-version "2.0";
2760+
2761+(:~
2762+ : This function parses a JSON string and returns an XDM instance according
2763+ : to either one of the mappings described above.
2764+ :
2765+ : @param $arg a sequence of valid JSON strings.
2766+ : @param $options a set of name and value pairs that provide options
2767+ : to configure the JSON mapping process that have to be validated against the
2768+ : "http://www.zorba-xquery.com/modules/converters/json-options" schema.
2769+ : @return a sequence of nodes according to either one of the mappings described above.
2770+ : @error err:XQDY0027 if $options can not be validated against the json-options schema
2771+ : @error json:ParseError if the JSON string passed as parameter is not
2772+ : valid JSON.
2773+ : @example test_json/Queries/converters/jansson/parse_json_02.xq
2774+ : @example test_json/Queries/converters/jansson/parse_json_ml_01.xq
2775+ :)
2776+declare function json:parse(
2777+ $arg as xs:string?,
2778+ $options as element(json-options:options)
2779+) as element(*, xs:untyped)*
2780+{
2781+ let $validated-options := if(schema:is-validated($options)) then
2782+ $options
2783+ else
2784+ validate{$options}
2785+ return
2786+ json:parse-internal($arg, $validated-options)
2787+};
2788+
2789+(:~
2790+ : This function parses a JSON string and returns an XDM instance according
2791+ : to simple XDM-JSON mapping described above.
2792+ :
2793+ : @param $arg a sequence of valid JSON strings.
2794+ : @return a sequence of nodes according to Simple XDM-JSON mapping described above.
2795+ : @error json:ParseError if the JSON string passed as parameter is not
2796+ : valid JSON.
2797+ : @example test_json/Queries/converters/jansson/parse_json_11.xq
2798+ :)
2799+declare function json:parse(
2800+ $arg as xs:string?
2801+) as element(*, xs:untyped)*
2802+{
2803+ json:parse-internal($arg,
2804+ validate {
2805+ <options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
2806+ <json-param name="mapping" value="simple-json" />
2807+ </options>
2808+ }
2809+ )
2810+};
2811+
2812+(:~
2813+ : This function parses a JSON string and returns an XDM instance according
2814+ : to JsonML mapping described above.
2815+ :
2816+ : @param $arg a sequence of valid JSON strings.
2817+ : @return a sequence of nodes according the JSON-ML mapping described above.
2818+ : @error json:ParseError if the JSON string passed as parameter is not
2819+ : valid JSON.
2820+ : @example test_json/Queries/converters/jansson/parse_json_ml_05.xq
2821+ :)
2822+declare function json:parse-ml(
2823+ $arg as xs:string?
2824+) as element(*, xs:untyped)*
2825+{
2826+ json:parse-internal($arg,
2827+ validate {
2828+ <options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
2829+ <json-param name="mapping" value="json-ml" type="array"/>
2830+ </options>
2831+ }
2832+ )
2833+};
2834+
2835+declare %private function json:parse-internal(
2836+ $html as xs:string,
2837+ $options as item()?
2838+) as element()* external;
2839+
2840+
2841+(:~
2842+ : The serialize function takes a sequence of nodes as parameter and
2843+ : transforms each element into a valid JSON string according to one of the
2844+ : mappings described above.
2845+ :
2846+ : @param $xml a sequence of nodes.
2847+ : @param $options a set of name and value pairs that provide options
2848+ : to configure the JSON mapping process that have to be validated against the
2849+ : "http://www.zorba-xquery.com/modules/converters/json-options" schema.
2850+ : @return a JSON string.
2851+ : @error err:XQDY0027 if $options can not be validated against the json-options schema
2852+ : @error json:InvalidXDM if the input $xml is not a valid XDM
2853+ : representation of JSON or JSON ML.
2854+ : @example test_json/Queries/converters/jansson/serialize_json_01.xq
2855+ : @example test_json/Queries/converters/jansson/serialize_json_ml_01.xq
2856+ :)
2857+declare function json:serialize(
2858+ $xml as item()*,
2859+ $options as element(json-options:options)
2860+) as xs:string
2861+{
2862+ let $validated-options := if(schema:is-validated($options)) then
2863+ $options
2864+ else
2865+ validate{$options}
2866+ return
2867+ json:serialize-internal($xml, $validated-options)
2868+};
2869+
2870+(:~
2871+ : The serialize function takes a sequence of nodes as parameter and
2872+ : transforms each element into a valid JSON string according to the
2873+ : Simple XDM-JSON mapping described above
2874+ :
2875+ : @param $xml a sequence of nodes.
2876+ : @return a JSON string.
2877+ : @error json:InvalidXDM if the input $xml is not a valid XDM
2878+ : representation of JSON or JSON ML.
2879+ : @example test_json/Queries/converters/jansson/serialize_json_18.xq
2880+ :)
2881+declare function json:serialize(
2882+ $xml as item()*
2883+) as xs:string
2884+{
2885+ json:serialize-internal($xml,
2886+ validate {
2887+ <options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
2888+ <json-param name="mapping" value="simple-json" />
2889+ </options>
2890+ }
2891+ )
2892+};
2893+
2894+(:~
2895+ : The serialize function takes a sequence of nodes as parameter and
2896+ : transforms each element into a valid JSON string according to the
2897+ : JsonML mapping described above.
2898+ :
2899+ : @param $xml a sequence of nodes.
2900+ : @return a JSON string.
2901+ : @error json:InvalidXDM if the input $xml is not a valid XDM
2902+ : representation of JSON or JSON ML.
2903+ : @example test_json/Queries/converters/jansson/serialize_json_ml_04.xq
2904+ :)
2905+declare function json:serialize-ml(
2906+ $xml as item()*
2907+) as xs:string
2908+{
2909+ json:serialize-internal($xml,
2910+ validate {
2911+ <options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
2912+ <json-param name="mapping" value="json-ml" type="array"/>
2913+ </options>
2914+ }
2915+ )
2916+};
2917+
2918+declare %private function json:serialize-internal(
2919+ $xml as item()*,
2920+ $options as item()?
2921+ ) as xs:string external;
2922
2923=== modified file 'modules/com/zorba-xquery/www/modules/pregenerated/errors.xq'
2924--- modules/com/zorba-xquery/www/modules/pregenerated/errors.xq 2011-12-21 14:40:33 +0000
2925+++ modules/com/zorba-xquery/www/modules/pregenerated/errors.xq 2012-02-08 21:22:19 +0000
2926@@ -309,6 +309,18 @@
2927
2928 (:~
2929 :)
2930+declare variable $zerr:ZAPI0043 as xs:QName := fn:QName($zerr:NS, "zerr:ZAPI0043");
2931+
2932+(:~
2933+:)
2934+declare variable $zerr:ZAPI0044 as xs:QName := fn:QName($zerr:NS, "zerr:ZAPI0044");
2935+
2936+(:~
2937+:)
2938+declare variable $zerr:ZAPI0045 as xs:QName := fn:QName($zerr:NS, "zerr:ZAPI0045");
2939+
2940+(:~
2941+:)
2942 declare variable $zerr:ZAPI0070 as xs:QName := fn:QName($zerr:NS, "zerr:ZAPI0070");
2943
2944 (:~
2945@@ -704,6 +716,10 @@
2946
2947 (:~
2948 :)
2949+declare variable $zerr:ZSTR0013 as xs:QName := fn:QName($zerr:NS, "zerr:ZSTR0013");
2950+
2951+(:~
2952+:)
2953 declare variable $zerr:ZSTR0015 as xs:QName := fn:QName($zerr:NS, "zerr:ZSTR0015");
2954
2955 (:~
2956@@ -784,4 +800,60 @@
2957
2958 (:~
2959 :)
2960-declare variable $zerr:XSST0010 as xs:QName := fn:QName($zerr:NS, "zerr:XSST0010");
2961\ No newline at end of file
2962+declare variable $zerr:XSST0010 as xs:QName := fn:QName($zerr:NS, "zerr:XSST0010");
2963+
2964+(:~
2965+:)
2966+declare variable $zerr:ZJPE0001 as xs:QName := fn:QName($zerr:NS, "zerr:ZJPE0001");
2967+
2968+(:~
2969+:)
2970+declare variable $zerr:ZJPE0002 as xs:QName := fn:QName($zerr:NS, "zerr:ZJPE0002");
2971+
2972+(:~
2973+:)
2974+declare variable $zerr:ZJPE0003 as xs:QName := fn:QName($zerr:NS, "zerr:ZJPE0003");
2975+
2976+(:~
2977+:)
2978+declare variable $zerr:ZJPE0004 as xs:QName := fn:QName($zerr:NS, "zerr:ZJPE0004");
2979+
2980+(:~
2981+:)
2982+declare variable $zerr:ZJPE0005 as xs:QName := fn:QName($zerr:NS, "zerr:ZJPE0005");
2983+
2984+(:~
2985+:)
2986+declare variable $zerr:ZJPE0006 as xs:QName := fn:QName($zerr:NS, "zerr:ZJPE0006");
2987+
2988+(:~
2989+:)
2990+declare variable $zerr:ZJPE0007 as xs:QName := fn:QName($zerr:NS, "zerr:ZJPE0007");
2991+
2992+(:~
2993+:)
2994+declare variable $zerr:ZJSE0001 as xs:QName := fn:QName($zerr:NS, "zerr:ZJSE0001");
2995+
2996+(:~
2997+:)
2998+declare variable $zerr:ZJSE0002 as xs:QName := fn:QName($zerr:NS, "zerr:ZJSE0002");
2999+
3000+(:~
3001+:)
3002+declare variable $zerr:ZJSE0003 as xs:QName := fn:QName($zerr:NS, "zerr:ZJSE0003");
3003+
3004+(:~
3005+:)
3006+declare variable $zerr:ZJSE0004 as xs:QName := fn:QName($zerr:NS, "zerr:ZJSE0004");
3007+
3008+(:~
3009+:)
3010+declare variable $zerr:ZJSE0005 as xs:QName := fn:QName($zerr:NS, "zerr:ZJSE0005");
3011+
3012+(:~
3013+:)
3014+declare variable $zerr:ZJSE0006 as xs:QName := fn:QName($zerr:NS, "zerr:ZJSE0006");
3015+
3016+(:~
3017+:)
3018+declare variable $zerr:ZJSE0007 as xs:QName := fn:QName($zerr:NS, "zerr:ZJSE0007");
3019\ No newline at end of file
3020
3021=== added directory 'modules/com/zorba-xquery/www/modules/store/jsoniq'
3022=== added directory 'modules/com/zorba-xquery/www/modules/store/jsoniq/dynamic'
3023=== added directory 'modules/com/zorba-xquery/www/modules/store/jsoniq/dynamic/collections'
3024=== added file 'modules/com/zorba-xquery/www/modules/store/jsoniq/dynamic/collections/ddl.xq'
3025--- modules/com/zorba-xquery/www/modules/store/jsoniq/dynamic/collections/ddl.xq 1970-01-01 00:00:00 +0000
3026+++ modules/com/zorba-xquery/www/modules/store/jsoniq/dynamic/collections/ddl.xq 2012-02-08 21:22:19 +0000
3027@@ -0,0 +1,122 @@
3028+xquery version "3.0";
3029+
3030+(:
3031+ : Copyright 2006-2009 The FLWOR Foundation.
3032+ :
3033+ : Licensed under the Apache License, Version 2.0 (the "License");
3034+ : you may not use this file except in compliance with the License.
3035+ : You may obtain a copy of the License at
3036+ :
3037+ : http://www.apache.org/licenses/LICENSE-2.0
3038+ :
3039+ : Unless required by applicable law or agreed to in writing, software
3040+ : distributed under the License is distributed on an "AS IS" BASIS,
3041+ : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3042+ : See the License for the specific language governing permissions and
3043+ : limitations under the License.
3044+:)
3045+
3046+(:~
3047+ : This modules defines a set of functions for managing persistent, ordered, and
3048+ : updatable collections that can contain both XML nodes and JSON objects and arrays.
3049+ :
3050+ : <p>Please refer to our documentation for <a href="../../html/data_lifecycle.html">
3051+ : more information</a> about the lifecycle management and the manipulation of such
3052+ : collections.</p>
3053+ :
3054+ : @see <a href="../../html/data_lifecycle.html">Data Lifecycle</a>
3055+ : @see http://www.zorba-xquery.com/modules/store/dynamic/collections/dml
3056+ : @see <a href="www.zorba-xquery.com_errors.html">http://www.zorba-xquery.com/errors</a>
3057+ :
3058+ : @author Matthias Brantner, David Graf, Till Westmann, Markos Zaharioudakis
3059+ :
3060+ : @project store/jsoniq/collections/dynamic
3061+ :
3062+ :)
3063+module namespace ddl = "http://www.zorba-xquery.com/modules/store/jsoniq/dynamic/collections/ddl";
3064+
3065+declare namespace zerr = "http://www.zorba-xquery.com/errors";
3066+declare namespace ver = "http://www.zorba-xquery.com/options/versioning";
3067+
3068+declare option ver:module-version "1.0";
3069+declare option ver:zorba-version "2.1";
3070+
3071+(:~
3072+ : The function returns true if a collection with the given QName is available.
3073+ :
3074+ : @param $name The QName of the collection that is being checked.
3075+ :
3076+ : @return true if the collection is available and false otherwise.
3077+ :
3078+ :)
3079+declare function ddl:is-available-collection($name as xs:QName) as xs:boolean external;
3080+
3081+
3082+(:~
3083+ : The function returns a sequence of QNames of the collections that are
3084+ : available. The sequence will be empty if there are no collections.
3085+ :
3086+ : @return A sequence of QNames, one for each available collection, or an emtpy sequence.
3087+ :
3088+ :)
3089+declare function ddl:available-collections() as xs:QName* external;
3090+
3091+
3092+(:~
3093+ : The create function is an updating function which creates
3094+ : the collection with the given expanded QName.
3095+ :
3096+ : @param $name The QName of the collection to create.
3097+ :
3098+ : @return The result of the function is an empty XDM instance and a
3099+ : pending update list which, once applied, creates a collection
3100+ : with the given name.
3101+ :
3102+ : @error zerr:ZDDY0002 if a collection with the given expanded QName already
3103+ : exists.
3104+ :
3105+ :)
3106+declare updating function ddl:create($name as xs:QName) external;
3107+
3108+
3109+(:~
3110+ : The create function is an updating function which creates
3111+ : the collection with the given expanded QName. Moreover, it adds copies
3112+ : of the sequence $content to the new collection.
3113+ :
3114+ : @param $name The QName of the collection to create.
3115+ : @param $content The sequence of items that should be added to the new collection.
3116+ : The sequence may contain any mix of XML nodes, JSON objects, or
3117+ : JSON arrays.
3118+ : @return The result of the function is an empty XDM instance and a
3119+ : pending update list which, once applied, creates a collection
3120+ : with the given name and inserts the given nodes into it.
3121+ :
3122+ : @error zerr:ZDDY0002 if a collection with the given expanded QName already
3123+ : exists.
3124+ :
3125+ : @see ddl:create
3126+ : @see ddl:insert-nodes-last
3127+ :
3128+ :)
3129+declare updating function ddl:create(
3130+ $name as xs:QName,
3131+ $content as structured-item()*) external;
3132+
3133+
3134+(:~
3135+ : The delete function is an updating function that removes
3136+ : the collection with the given expanded QName.
3137+ :
3138+ : @param $name The QName of the collection to delete.
3139+ :
3140+ : @return The result of the function is an empty XDM instance and a pending
3141+ : update list which, once applied, deletes the collection with the given
3142+ : name.
3143+ :
3144+ : @error zerr:ZDDY0003 if the collection with the given name does not exist.
3145+ : @error zerr:ZDDY0015 if any of the in-scope variables references a node that
3146+ : belongs to the collection with QName $name.
3147+ :
3148+ :)
3149+declare updating function ddl:delete($coll as xs:QName) external;
3150
3151=== added file 'modules/com/zorba-xquery/www/modules/store/jsoniq/dynamic/collections/dml.xq'
3152--- modules/com/zorba-xquery/www/modules/store/jsoniq/dynamic/collections/dml.xq 1970-01-01 00:00:00 +0000
3153+++ modules/com/zorba-xquery/www/modules/store/jsoniq/dynamic/collections/dml.xq 2012-02-08 21:22:19 +0000
3154@@ -0,0 +1,354 @@
3155+xquery version "3.0";
3156+
3157+(:
3158+ : Copyright 2006-2009 The FLWOR Foundation.
3159+ :
3160+ : Licensed under the Apache License, Version 2.0 (the "License");
3161+ : you may not use this file except in compliance with the License.
3162+ : You may obtain a copy of the License at
3163+ :
3164+ : http://www.apache.org/licenses/LICENSE-2.0
3165+ :
3166+ : Unless required by applicable law or agreed to in writing, software
3167+ : distributed under the License is distributed on an "AS IS" BASIS,
3168+ : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3169+ : See the License for the specific language governing permissions and
3170+ : limitations under the License.
3171+:)
3172+
3173+(:~
3174+ : This modules provides a set of functions to modify a collection and retrieve the
3175+ : items contained in a particular collection. Collections that are accessed by the
3176+ : functions of this module may contain any mix of XML nodes, JSON objects, or
3177+ : JSON arrays. The term "structured item" is used in this module to refer to an
3178+ : XML node, JSON object, or JSON array.
3179+ :
3180+ : <p>Please refer to our documentation for <a href="../../html/data_lifecycle.html">
3181+ : more information</a> about the lifecycle management and the manipulation of such
3182+ : collections.</p>
3183+ :
3184+ : @see <a href="../../html/data_lifecycle.html">Data Lifecycle</a>
3185+ : @see http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl
3186+ : @see <a href="www.zorba-xquery.com_errors.html">http://www.zorba-xquery.com/errors</a>
3187+ :
3188+ : @author Matthias Brantner, David Graf, Till Westmann, Markos Zaharioudakis
3189+ :
3190+ : @project store/jsoniq/collections/dynamic
3191+ :)
3192+module namespace dml = "http://www.zorba-xquery.com/modules/store/jsoniq/dynamic/collections/dml";
3193+
3194+declare namespace zerr = "http://www.zorba-xquery.com/errors";
3195+declare namespace ann = "http://www.zorba-xquery.com/annotations";
3196+
3197+declare namespace ver = "http://www.zorba-xquery.com/options/versioning";
3198+
3199+declare option ver:module-version "1.0";
3200+declare option ver:zorba-version "2.1";
3201+
3202+(:~
3203+ : The insert-nodes-first function is an updating function that inserts copies of the
3204+ : given structured items at the beginning of the collection.
3205+ :
3206+ : @param $name The name of the collection to which the items should be added.
3207+ : @param $content The sequences of structured items whose copies should be added
3208+ : to the collection.
3209+ :
3210+ : @return The result of the function is an empty XDM instance and a pending update
3211+ : list which, once applied, inserts the items into the collection.
3212+ :
3213+ : @error zerr:ZDDY0003 if the collection identified by $name is not available.
3214+ :
3215+ :)
3216+declare updating function dml:insert-nodes-first(
3217+ $name as xs:QName,
3218+ $content as structured-item()*) external;
3219+
3220+(:~
3221+ : The insert-nodes-last function is an updating function that inserts copies of the
3222+ : given structured items at the end of the collection.
3223+ :
3224+ : @param $name The name of the collection to which the items should be added.
3225+ : @param $content The sequences of structured items whose copies should be added
3226+ : to the collection.
3227+ :
3228+ : @return The result of the function is an empty XDM instance and a pending update list
3229+ : which, once applied, inserts the items into the collection.
3230+ :
3231+ : @error zerr:ZDDY0003 if the collection identified by $name is not available.
3232+ :
3233+ :)
3234+declare updating function dml:insert-nodes-last(
3235+ $name as xs:QName,
3236+ $content as structured-item()*) external;
3237+
3238+
3239+(:~
3240+ : The insert-nodes-before function is an updating function that inserts copies
3241+ : of the given structured items into a collection at the position directly
3242+ : preceding the given target item.
3243+ :
3244+ : @param $name The name of the collection to which the items should be added.
3245+ : @param $target The item in the collection before which the $content
3246+ : sequence should be inserted.
3247+ : @param $content The sequences of structured items whose copies should be
3248+ : added to the collection.
3249+ :
3250+ : @return The result of the function is an empty XDM instance and a pending update list
3251+ : which, once applied, inserts the items into the collection.
3252+ :
3253+ : @error zerr:ZDDY0003 if the collection identified by $name is not available.
3254+ : @error zerr:ZDDY0011 if the target item is not contained in the collection.
3255+ :
3256+ :)
3257+declare updating function dml:insert-nodes-before(
3258+ $name as xs:QName,
3259+ $target as structured-item(),
3260+ $content as structured-item()*) external;
3261+
3262+
3263+(:~
3264+ : The insert-nodes-after function is an updating function that inserts copies
3265+ : of the given structured items into a collection at the position directly
3266+ : following the given target item.
3267+ :
3268+ : @param $name The name of the collection to which the items should be added.
3269+ : @param $target The structured item in the collection after which the $content
3270+ : sequence should be inserted.
3271+ : @param $content The sequences of structured items whose copies should be added
3272+ : to the collection.
3273+ :
3274+ : @return The result of the function is an empty XDM instance and a pending update list
3275+ : which, once applied, inserts the items into the collection.
3276+ :
3277+ : @error zerr:ZDDY0003 if the collection identified by $name is not available.
3278+ : @error zerr:ZDDY0011 if the target item is not contained in the collection.
3279+ :
3280+ :)
3281+declare updating function dml:insert-nodes-after(
3282+ $name as xs:QName,
3283+ $pos as structured-item(),
3284+ $content as structured-item()*) external;
3285+
3286+
3287+(:~
3288+ : This function does the same as the insert-nodes function except
3289+ : it immediately applies the resulting pending updates and returns the
3290+ : structured items that have been inserted.
3291+ :
3292+ : @param $name The name of the collection to which the items should be added.
3293+ : @param $content The sequences of structured items whose copies should be added
3294+ : to the collection.
3295+ :
3296+ : @return The result of the function is the sequence of items that have been
3297+ : inserted into the collection.
3298+ :
3299+ : @error zerr:ZDDY0003 if the collection identified by $name is not available.
3300+ :
3301+ : @see dml:insert-nodes-first
3302+ :
3303+ :)
3304+declare %ann:sequential function dml:apply-insert-nodes-first(
3305+ $name as xs:QName,
3306+ $content as structured-item()*) as structured-item()* external;
3307+
3308+
3309+(:~
3310+ : This function does the same as the insert-nodes-last function except
3311+ : it immediately applies the resulting pending updates and returns the
3312+ : structured items that have been inserted.
3313+ :
3314+ : @param $name The name of the collection to which the items should be added.
3315+ : @param $content The sequences of structured items whose copies should be added
3316+ : to the collection.
3317+ :
3318+ : @return The result of the function is the sequence of items that have been
3319+ : inserted into the collection.
3320+ :
3321+ : @error zerr:ZDDY0003 if the collection identified by $name is not available.
3322+ :
3323+ : @see dml:insert-nodes-last
3324+ :
3325+ :)
3326+declare %ann:sequential function dml:apply-insert-nodes-last(
3327+ $name as xs:QName,
3328+ $content as structured-item()*) as structured-item()* external;
3329+
3330+
3331+(:~
3332+ : This function does the same as the insert-nodes-before function except
3333+ : it immediately applies the resulting pending updates and returns the
3334+ : structured items that have been inserted.
3335+ :
3336+ : @param $name The name of the collection to which the items should be added.
3337+ : @param $target The structured item in the collection before which the $content
3338+ : sequence should be inserted.
3339+ : @param $content The sequences of structured items whose copies should be added
3340+ : to the collection.
3341+ :
3342+ : @return The result of the function is the sequence of items that have been
3343+ : inserted into the collection.
3344+ :
3345+ : @error zerr:ZDDY0003 if the collection identified by $name is not available.
3346+ :
3347+ : @see dml:insert-nodes-before
3348+ :
3349+ :)
3350+declare %ann:sequential function dml:apply-insert-nodes-before(
3351+ $name as xs:QName,
3352+ $target as structured-item(),
3353+ $content as structured-item()*) as structured-item()* external;
3354+
3355+
3356+(:~
3357+ : This function does the same as the insert-nodes-after function except
3358+ : it immediately applies the resulting pending updates and returns the
3359+ : structured items that have been inserted.
3360+ :
3361+ : @param $name The name of the collection to which the items should be added.
3362+ : @param $target The structured item in the collection after which the $content
3363+ : sequence should be inserted.
3364+ : @param $content The sequences of structured items whose copies should be added
3365+ : to the collection.
3366+ :
3367+ : @return The result of the function is the sequence of items that have been
3368+ : inserted into the collection.
3369+ :
3370+ : @error zerr:ZDDY0003 if the collection identified by $name is not available.
3371+ :
3372+ : @see dml:insert-nodes-after
3373+ :
3374+ :)
3375+declare %ann:sequential function dml:apply-insert-nodes-after(
3376+ $name as xs:QName,
3377+ $pos as structured-item(),
3378+ $content as structured-item()*) as structured-item()* external;
3379+
3380+
3381+(:~
3382+ : The delete-nodes function is an updating function that deletes zero of more
3383+ : structured items from a collection.
3384+ :
3385+ : @param $target the structured items in the collection that should be deleted.
3386+ :
3387+ : @return The result of this function is an empty XDM instance and a pending update
3388+ : list which, once applied, deletes the items from their collections.
3389+ :
3390+ : @error zerr:ZDDY0011 if any items in the $target sequence is not a member of
3391+ : a collection or not all items of the $target sequence belong to the
3392+ : same collection.
3393+ :)
3394+declare updating function dml:delete-nodes($target as structured-item()*) external;
3395+
3396+
3397+(:~
3398+ : The delete-node-first function is an updating function that deletes the
3399+ : first item from a collection.
3400+ :
3401+ : @param $name The name of the collection from which the first item should be deleted.
3402+ :
3403+ : @return The result of this function is an empty XDM instance and a pending update
3404+ : list which, once applied, deletes the first item from the collection.
3405+ :
3406+ : @error zerr:ZDDY0011 if the collection doesn't contain any item.
3407+ :
3408+ :)
3409+declare updating function dml:delete-node-first($name as xs:QName) external;
3410+
3411+
3412+(:~
3413+ : The delete-nodes-first function is an updating function that deletes the
3414+ : first n items from a collection.
3415+ :
3416+ : @param $name The name of the collection from which the first items should be deleted.
3417+ : @param $number The number of items that should be removed from the beginning of
3418+ : the collection.
3419+ :
3420+ : @return The result of this function is an empty XDM instance and a pending update
3421+ : list which, once applied, deletes the items from the collection.
3422+ :
3423+ : @error zerr:ZDDY0011 if the collection doesn't contain the given number of items.
3424+ :
3425+ :)
3426+declare updating function dml:delete-nodes-first(
3427+ $name as xs:QName,
3428+ $number as xs:integer) external;
3429+
3430+
3431+(:~
3432+ : The delete-node-last function is an updating function that deletes the
3433+ : last item from a collection.
3434+ :
3435+ : @param $name The name of the collection from which the last item should be deleted.
3436+ :
3437+ : @return The result of this function is an empty XDM instance and a pending update
3438+ : list which, once applied, deletes the last item from the collection.
3439+ :
3440+ : @error zerr:ZDDY0009 If available collections does not provide a mapping
3441+ : for the expanded QName $name.
3442+ : @error zerr:ZDDY0011 if the collection doesn't contain any item.
3443+ :
3444+ :)
3445+declare updating function dml:delete-node-last($name as xs:QName) external;
3446+
3447+
3448+(:~
3449+ : The delete-nodes-last function is an updating function that deletes the
3450+ : last n items from an ordered collection.
3451+ :
3452+ : @param $name The name of the collection from which the last items should be deleted.
3453+ : @param $number The number of items to delete.
3454+ :
3455+ : @return The result of this function is an empty XDM instance and a pending update
3456+ : list which, once applied, deletes the last n items.
3457+ :
3458+ : @error zerr:ZDDY0009 If available collections does not provide a mapping
3459+ : for the expanded QName $name.
3460+ : @error zerr:ZDDY0011 if the collection doesn't contain the given number of items.
3461+ :
3462+ :)
3463+declare updating function dml:delete-nodes-last(
3464+ $name as xs:QName,
3465+ $number as xs:integer) external;
3466+
3467+
3468+(:~
3469+ : The index-of function returns the index of the given structured item in
3470+ : the collection.
3471+ :
3472+ : @param $item The structured item to retrieve the index of.
3473+ :
3474+ : @return Returns the position as xs:integer of the given item in the collection.
3475+ :
3476+ : @error zerr:ZDDY0011 if item is not contained in any collection.
3477+ :
3478+ :)
3479+declare function dml:index-of($item as structured-item()) as xs:integer external;
3480+
3481+
3482+(:~
3483+ : The collection function returns the sequence of structured items of the
3484+ : collection identified by the given name.
3485+ :
3486+ : @param $name The name of the collection.
3487+ :
3488+ : @return The sequence contained in the given collection.
3489+ :
3490+ : @error zerr:ZDDY0009 If available collections does not provide a mapping
3491+ : for the expanded QName $name.
3492+ :
3493+ :)
3494+declare function dml:collection($name as xs:QName) as structured-item()* external;
3495+
3496+
3497+(:~
3498+ : This function returns the name of the collection the given structured item
3499+ : belongs to.
3500+ :
3501+ : @param $item The item for which to get the name of the collection
3502+ : @return The result of this function is a QName which identifies the collection
3503+ : to which the given item belongs to.
3504+ :
3505+ : @error zerr:ZDDY0011 if the given item does not belong to a collection.
3506+ :
3507+ :)
3508+declare function dml:collection-name($item as structured-item()) as xs:QName external;
3509
3510=== added directory 'modules/com/zorba-xquery/www/modules/store/jsoniq/static'
3511=== modified file 'modules/org/CMakeLists.txt'
3512--- modules/org/CMakeLists.txt 2011-01-19 14:45:10 +0000
3513+++ modules/org/CMakeLists.txt 2012-02-08 21:22:19 +0000
3514@@ -12,3 +12,5 @@
3515 # See the License for the specific language governing permissions and
3516 # limitations under the License.
3517 ADD_SUBDIRECTORY(expath)
3518+ADD_SUBDIRECTORY(jsoniq)
3519+
3520
3521=== added directory 'modules/org/jsoniq'
3522=== added file 'modules/org/jsoniq/CMakeLists.txt'
3523--- modules/org/jsoniq/CMakeLists.txt 1970-01-01 00:00:00 +0000
3524+++ modules/org/jsoniq/CMakeLists.txt 2012-02-08 21:22:19 +0000
3525@@ -0,0 +1,15 @@
3526+# Copyright 2011 The FLWOR Foundation.
3527+#
3528+# Licensed under the Apache License, Version 2.0 (the "License");
3529+# you may not use this file except in compliance with the License.
3530+# You may obtain a copy of the License at
3531+#
3532+# http://www.apache.org/licenses/LICENSE-2.0
3533+#
3534+# Unless required by applicable law or agreed to in writing, software
3535+# distributed under the License is distributed on an "AS IS" BASIS,
3536+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3537+# See the License for the specific language governing permissions and
3538+# limitations under the License.
3539+
3540+ADD_SUBDIRECTORY(www)
3541
3542=== added directory 'modules/org/jsoniq/www'
3543=== added file 'modules/org/jsoniq/www/CMakeLists.txt'
3544--- modules/org/jsoniq/www/CMakeLists.txt 1970-01-01 00:00:00 +0000
3545+++ modules/org/jsoniq/www/CMakeLists.txt 2012-02-08 21:22:19 +0000
3546@@ -0,0 +1,21 @@
3547+# Copyright 2006-2008 The FLWOR Foundation.
3548+#
3549+# Licensed under the Apache License, Version 2.0 (the "License");
3550+# you may not use this file except in compliance with the License.
3551+# You may obtain a copy of the License at
3552+#
3553+# http://www.apache.org/licenses/LICENSE-2.0
3554+#
3555+# Unless required by applicable law or agreed to in writing, software
3556+# distributed under the License is distributed on an "AS IS" BASIS,
3557+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3558+# See the License for the specific language governing permissions and
3559+# limitations under the License.
3560+
3561+IF(ZORBA_WITH_JSON)
3562+ DECLARE_ZORBA_MODULE(FILE functions.xq VERSION 1.0
3563+ URI "http://www.jsoniq.org/functions")
3564+ DECLARE_ZORBA_MODULE (FILE pregenerated/errors.xq
3565+ URI "http://www.jsoniq.org/errors")
3566+ENDIF(ZORBA_WITH_JSON)
3567+
3568
3569=== added file 'modules/org/jsoniq/www/functions.xq'
3570--- modules/org/jsoniq/www/functions.xq 1970-01-01 00:00:00 +0000
3571+++ modules/org/jsoniq/www/functions.xq 2012-02-08 21:22:19 +0000
3572@@ -0,0 +1,389 @@
3573+(:~
3574+ : This module provides the functions defined by the JSONiq specification,
3575+ : sections 1.7 (Functions) and 1.10 (Update Primitives). JSONiq extends
3576+ : the XQuery specification to also deal with JSON data natively. See
3577+ :
3578+ : http://www.jsoniq.org/
3579+ :
3580+ : for details.
3581+ :
3582+ : This module depends on having the JSONiq feature enabled in Zorba,
3583+ : ie, Zorba must be compiled with ZORBA_WITH_JSON.
3584+ :)
3585+module namespace j = "http://www.jsoniq.org/functions";
3586+
3587+import module namespace schema = "http://www.zorba-xquery.com/modules/schema";
3588+
3589+declare namespace jdm = "http://www.jsoniq.org/";
3590+
3591+declare namespace err = "http://www.w3.org/2005/xqt-errors";
3592+
3593+declare namespace ver = "http://www.zorba-xquery.com/options/versioning";
3594+declare option ver:module-version "1.0";
3595+
3596+(:~
3597+ : Recursively "flatten" a JSON Array, by replacing any arrays with their
3598+ : members. Equivalent to
3599+ :
3600+ : define function j:flatten($arg as array()) {
3601+ : for $value in j:values($arg)
3602+ : return
3603+ : if ($value instance of array())
3604+ : then j:flatten($value)
3605+ : else $value
3606+ : };
3607+ :
3608+ : @param $a A JSON Array.
3609+ : @return The flattened version of $a.
3610+ :)
3611+declare function j:flatten($a as array()) as item()* external;
3612+
3613+(:~
3614+ : This function has the same semantics as fn:parse-xml(), except that
3615+ : it parses the string as JSON (not XML), and returns an Object or
3616+ : Array rather than an XML document.
3617+ :
3618+ : @param $j A string containing a valid JSON text.
3619+ : @return a JSON Object or Array item.
3620+ :)
3621+declare function j:parse-json($j as xs:string) as json-item()? external;
3622+
3623+(:~
3624+ : Returns the names used in the Pairs of the object. This function is
3625+ : equivalent to
3626+ :
3627+ : for $p in j:pairs($arg) return j:name($p)
3628+ :
3629+ : The names will be returned in an implementation-defined order
3630+ :
3631+ : @param $o A JSON Object.
3632+ : @return The names of pairs in the object.
3633+ :)
3634+declare function j:names($o as object()) as xs:string* external;
3635+
3636+(:~
3637+ : Returns the name of the Pair.
3638+ :
3639+ : @param $p A JSON Pair.
3640+ : @return The name of the Pair.
3641+ :)
3642+declare function j:name($p as pair()) as xs:string external;
3643+
3644+(:~
3645+ : Returns the Pairs of the Object. The pairs will be returned in an
3646+ : implementation-defined order.
3647+ :
3648+ : @param $o A JSON Object.
3649+ : @return A sequence of JSON Pair items.
3650+ :)
3651+declare function j:pairs($o as object()) as pair()* external;
3652+
3653+(:~
3654+ : Returns the Pair of an Object with the specified name. If no such
3655+ : Pair exists in the Object, returns the empty sequence.
3656+ :
3657+ : @param $o A JSON Object.
3658+ : @param $n A name.
3659+ : @return The Pair with the given name, or empty sequence.
3660+ :)
3661+declare function j:pair($o as object(), $n as xs:string) as pair()? external;
3662+
3663+(:~
3664+ : Returns the member of an Array at the specified position (starting from 1).
3665+ : If the position is out of bounds of the array, returns the empty sequence.
3666+ :
3667+ : @param $a A JSON Array.
3668+ : @param $p The position in the array.
3669+ : @return The member at the specified position, or empty sequence.
3670+ :)
3671+declare function j:member($o as array(), $p as xs:integer) as item()? external;
3672+
3673+(:~
3674+ : Returns the size of a JSON Object or JSON Array. The size of an Object
3675+ : is the number of Pairs contained within it; the size of an Array is
3676+ : the number of members contained within it.
3677+ :
3678+ : @param $j A JSON Object or JSON Array.
3679+ : @return The number of items in $j.
3680+ : @error j:JUDY0060 if $j is a JSON Pair.
3681+ :)
3682+declare function j:size($j as json-item()) as xs:integer external;
3683+
3684+(:~
3685+ : Returns all Pairs in an Object, or all members of an Array. When
3686+ : passed an Object, the Pairs will be returned in an implementation-
3687+ : defined order.
3688+ :
3689+ : @param $j A JSON Object or JSON Array.
3690+ : @return All Pairs/members of $j.
3691+ : @error j:JUDY0060 if $j is a JSON Pair.
3692+ :)
3693+declare function j:values($j as json-item()) as item()* external;
3694+
3695+(:~
3696+ : Returns the value of a JSON Pair.
3697+ :
3698+ : @param $p A JSON Pair.
3699+ : @return the value of $p.
3700+ :)
3701+declare function j:value($p as pair()) as item() external;
3702+
3703+(:~
3704+ : Returns the jdm:null value null.
3705+ :
3706+ : @return the said value
3707+ :)
3708+declare function j:null() as jdm:null external;
3709+
3710+(:~
3711+ : Insert one or more pairs into an object. Recall that a JSON Object
3712+ : may not contain two pairs with the same name. This function will not
3713+ : replace a pair in an object.
3714+ :
3715+ : @param $o A JSON Object.
3716+ : @param $p A sequence of Pairs to insert.
3717+ : @return An empty XDM instance and a pending update list which, once
3718+ : applied, inserts the pairs into the object.
3719+ : @error j:JUDY0060 if pair with the given name already exists.
3720+ :)
3721+declare updating function j:insert-into(
3722+ $o as object(),
3723+ $p as pair()*) external;
3724+
3725+(:~
3726+ : Insert one or more items into a JSON Array. The items will be inserted
3727+ : at the beginning of the array.
3728+ :
3729+ : @param $a A JSON Array.
3730+ : @param $i A sequence of items to insert.
3731+ : @return An empty XDM instance and a pending update list which, once
3732+ : applied, inserts the items into the array.
3733+ :)
3734+declare updating function j:insert-as-first(
3735+ $a as array(),
3736+ $i as item()*) external;
3737+
3738+(:~
3739+ : Insert one or more items into a JSON Array. The items will be inserted
3740+ : after the specified position in the array.
3741+ :
3742+ : The position must exist in the array. You cannot specify an position of 0
3743+ : to insert at the beginning of the array (use j:insert-as-first($a, ...) or
3744+ : j:insert-before($a, 1, ...)).
3745+ :
3746+ : @param $a A JSON Array.
3747+ : @param $pos The position.
3748+ : @param $i A sequence of items to insert.
3749+ : @return An empty XDM instance and a pending update list which, once
3750+ : applied, inserts the items into the array.
3751+ : @error j:JUDY0061 if the position doesn't select an existing array member
3752+ :)
3753+declare updating function j:insert-after(
3754+ $a as array(),
3755+ $pos as xs:integer,
3756+ $i as item()*) external;
3757+
3758+(:~
3759+ : Insert one or more items into a JSON Array. The items will be inserted
3760+ : before the specified position in the array.
3761+ :
3762+ : The position must exist in the array.
3763+ :
3764+ : @param $a A JSON Array.
3765+ : @param $pos The position.
3766+ : @param $i A sequence of items to insert.
3767+ : @return An empty XDM instance and a pending update list which, once
3768+ : applied, inserts the items into the array.
3769+ : @error j:JUDY0061 if the position doesn't select an existing array member
3770+ :)
3771+declare updating function j:insert-before(
3772+ $a as array(),
3773+ $pos as xs:integer,
3774+ $i as item()*) external;
3775+
3776+(:~
3777+ : Insert one or more items into a JSON Array. The items will be inserted
3778+ : at the end of the array.
3779+ :
3780+ : @param $a A JSON Array.
3781+ : @param $i A sequence of items to insert.
3782+ : @return An empty XDM instance and a pending update list which, once
3783+ : applied, inserts the items into the array.
3784+ :)
3785+declare updating function j:insert-as-last(
3786+ $a as array(),
3787+ $i as item()*) external;
3788+
3789+(:~
3790+ : Delete an item from a JSON Array or a Pair from a JSON Object.
3791+ :
3792+ : If $j is an Object and $selector is an xs:string, deletes the Pair
3793+ : $i($selector) if it exists, raising an error if it does not exist.
3794+ :
3795+ : If $j is an Array and $selector is an xs:integer, deletes the member
3796+ : $i($selector) if it exists, raising an error if it does not exist.
3797+ :
3798+ : In any other case, a type error is raised.
3799+ : @param $j A JSON Array or JSON Object.
3800+ : @param $select An xs:string (if $j is an Object) or xs:integer
3801+ : (if $j is an array).
3802+ : @return An empty XDM instance and a pending update list which, once
3803+ : applied, deletes the item from the array or object.
3804+ : @error j:JUDY0061 if the selector doesn't select an existing pair or
3805+ : array member
3806+ : @error j:JUDY0062 if the first argument is a pair
3807+ : @error j:JUDY0063 invalid type for second argument (must be xs:integer
3808+ : if first argument is an array or xs:string if first argument is an object)
3809+ :)
3810+declare updating function j:delete(
3811+ $j as json-item(),
3812+ $selector as xs:anyAtomicType)
3813+{
3814+ try {
3815+ typeswitch ($j)
3816+ case $o as object()
3817+ return j:delete-pair($o, $selector treat as xs:string)
3818+ case $a as array()
3819+ return j:delete-member($a, $selector treat as xs:integer)
3820+ default return
3821+ fn:error(
3822+ fn:QName("http://www.jsoniq.org/errors", "JUDY0062"),
3823+ "first argument to delete function is pair() but must be array() or object()",
3824+ $j)
3825+ } catch err:XPDY0050 {
3826+ fn:error(
3827+ fn:QName("http://www.jsoniq.org/errors", "JUDY0063"),
3828+ concat(
3829+ schema:schema-type($selector),
3830+ ": invalid type for second argument; should be ",
3831+ typeswitch ($j)
3832+ case object() return "xs:string"
3833+ default return "xs:integer"
3834+ ),
3835+ $selector
3836+ )
3837+ }
3838+};
3839+
3840+(:~
3841+ : Delete a pair from a JSON Object by name.
3842+ :
3843+ : @param $o A JSON Object.
3844+ : @param $n The name of the Pair to delete.
3845+ : @return An empty XDM instance and a pending update list which, once
3846+ : applied, deletes the pair from the object.
3847+ : @error j:JUDY0061 if the key doesn't select an existing pair.
3848+ :)
3849+declare updating function j:delete-pair(
3850+ $o as object(),
3851+ $key as xs:string) external;
3852+
3853+(:~
3854+ : Delete an item from a JSON Array.
3855+ :
3856+ : @param $a A JSON Array.
3857+ : @param $pos The position in the array to delete.
3858+ : @return An empty XDM instance and a pending update list which, once
3859+ : applied, deletes the item from the array.
3860+ : @error j:JUDY0061 if the position doesn't select an existing member
3861+ :)
3862+declare updating function j:delete-member(
3863+ $a as array(),
3864+ $pos as xs:integer) external;
3865+
3866+(:~
3867+ : Assigns a new name to a JSON Pair in an Object.
3868+ :
3869+ : @param $o A JSON Object.
3870+ : @param $old-name The current name of a Pair in the Object.
3871+ : @param $new-name The new name for the Pair.
3872+ : @return An empty XDM instance and a pending update list which, once
3873+ : applied, renames the pair.
3874+ : @error j:JUDY0061 if $old-name doesn't select an existing pair.
3875+ :)
3876+declare updating function j:rename(
3877+ $o as object(),
3878+ $old-name as xs:string,
3879+ $new-name as xs:string) external;
3880+
3881+(:~
3882+ : Replace an item in an Array, or the value of a Pair in an Object.
3883+ :
3884+ : If $j is an Object and $selector is an xs:string, replaces the value
3885+ : of the Pair $i($selector) if it exists, raising an error if it does
3886+ : not exist.
3887+ :
3888+ : If $j is an Array and $selector is an xs:integer, replaces the member
3889+ : $i($selector) if it exists, raising an error if it does not exist.
3890+ :
3891+ : In any other case, a type error is raised.
3892+ :
3893+ : @param $j A JSON Object or Array.
3894+ : @param $select An xs:string (if $j is an Object) or xs:integer
3895+ : (if $j is an array).
3896+ : @param $new-val The new item to insert into the Object or Array in
3897+ : place of the old value.
3898+ : @return An empty XDM instance and a pending update list which, once
3899+ : applied, replaces the selected item in the object or array.
3900+ : @error j:JUDY0061 if $selector is wrong. (QQQ needs testing)
3901+ :)
3902+declare updating function j:replace-value(
3903+ $j as json-item(),
3904+ $selector as xs:anyAtomicType,
3905+ $new-val as item())
3906+{
3907+ try {
3908+ typeswitch ($j)
3909+ case $o as object()
3910+ return j:replace-value-in-object($o, $selector treat as xs:string, $new-val)
3911+ case $a as array()
3912+ return j:replace-value-in-array($a, $selector treat as xs:integer, $new-val)
3913+ default return
3914+ fn:error(
3915+ fn:QName("http://www.jsoniq.org/errors", "JUDY0062"),
3916+ "first argument to replace-value function is pair() but must be array() or object()",
3917+ $j)
3918+ } catch err:XPDY0050 {
3919+ fn:error(
3920+ fn:QName("http://www.jsoniq.org/errors", "JUDY0063"),
3921+ concat(
3922+ schema:schema-type($selector),
3923+ ": invalid type for second argument; should be ",
3924+ typeswitch ($j)
3925+ case object() return "xs:string"
3926+ default return "xs:integer"
3927+ ),
3928+ $selector
3929+ )
3930+ }
3931+};
3932+
3933+(:~
3934+ : Replace the value of a Pair in an Object.
3935+ :
3936+ : @param $o A JSON Object.
3937+ : @param $n The name of a Pair in $o.
3938+ : @param $new-val The new value for the Pair.
3939+ : @return An empty XDM instance and a pending update list which, once
3940+ : applied, replaces the value of the selected pair in the object.
3941+ : @error j:JUDY0061 if the position doesn't select an existing member
3942+ :)
3943+declare updating function j:replace-value-in-object(
3944+ $o as object(),
3945+ $n as xs:string,
3946+ $new-val as item()) external;
3947+
3948+(:~
3949+ : Replace an item in a JSON Array.
3950+ : @param $a A JSON Array.
3951+ : @param $pos The position in the array to replace.
3952+ : @param $new-valu The new item to put in the array in place of the
3953+ : existing item.
3954+ : @return An empty XDM instance and a pending update list which, once
3955+ : applied, replaces the selected item in the array.
3956+ : @error j:JUDY0061 if the position doesn't select an existing member
3957+ :)
3958+declare updating function j:replace-value-in-array(
3959+ $a as array(),
3960+ $pos as xs:integer,
3961+ $new-val as item()) external;
3962
3963=== added directory 'modules/org/jsoniq/www/pregenerated'
3964=== added file 'modules/org/jsoniq/www/pregenerated/errors.xq'
3965--- modules/org/jsoniq/www/pregenerated/errors.xq 1970-01-01 00:00:00 +0000
3966+++ modules/org/jsoniq/www/pregenerated/errors.xq 2012-02-08 21:22:19 +0000
3967@@ -0,0 +1,109 @@
3968+(:
3969+ : Copyright 2006-2011 The FLWOR Foundation.
3970+ :
3971+ : Licensed under the Apache License, Version 2.0 (the "License");
3972+ : you may not use this file except in compliance with the License.
3973+ : You may obtain a copy of the License at
3974+ :
3975+ : http://www.apache.org/licenses/LICENSE-2.0
3976+ :
3977+ : Unless required by applicable law or agreed to in writing, software
3978+ : distributed under the License is distributed on an "AS IS" BASIS,
3979+ : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3980+ : See the License for the specific language governing permissions and
3981+ : limitations under the License.
3982+ :)
3983+
3984+ (:
3985+ : THIS FILE IS GENERATED.
3986+ : PLEASE DO NOT EDIT.
3987+ :)
3988+ (:~
3989+ : This module contains one declaration of a variable for each
3990+ : error of the http://www.jsoniq.org/errors namespace.
3991+ : The variables serves as documentation for the errors but can also
3992+ : be used in the code. For example, one useful scenario is to compare
3993+ : an error caught in the catch clause of a try-catch expression with one of
3994+ : the variables.
3995+ :
3996+ : @author Carlos Lopez
3997+ :
3998+ : @project error
3999+ :)
4000+
4001+xquery version '1.0';
4002+
4003+module namespace jerr = 'http://www.jsoniq.org/errors';
4004+
4005+declare variable $jerr:NS := 'http://www.jsoniq.org/errors';
4006+
4007+(:~
4008+:)
4009+declare variable $jerr:JSDY0001 as xs:QName := fn:QName($jerr:NS, "jerr:JSDY0001");
4010+
4011+(:~
4012+:)
4013+declare variable $jerr:JSDY0002 as xs:QName := fn:QName($jerr:NS, "jerr:JSDY0002");
4014+
4015+(:~
4016+ :error raised by object constructor
4017+:)
4018+declare variable $jerr:JSDY0003 as xs:QName := fn:QName($jerr:NS, "jerr:JSDY0003");
4019+
4020+
4021+declare variable $jerr:JSDY0020 as xs:QName := fn:QName($jerr:NS, "jerr:JSDY0020");
4022+
4023+(:~
4024+ :parser errors raised by the JSONIQLoader
4025+:)
4026+declare variable $jerr:JSDY0040 as xs:QName := fn:QName($jerr:NS, "jerr:JSDY0040");
4027+
4028+(:~
4029+ :error raised by block expression
4030+:)
4031+declare variable $jerr:JSDY0041 as xs:QName := fn:QName($jerr:NS, "jerr:JSDY0041");
4032+
4033+(:~
4034+ :error raised by insert-into
4035+:)
4036+declare variable $jerr:JUDY0060 as xs:QName := fn:QName($jerr:NS, "jerr:JUDY0060");
4037+
4038+(:~
4039+ :error raised by upd:delete, upd:insert-before/after
4040+:)
4041+declare variable $jerr:JUDY0061 as xs:QName := fn:QName($jerr:NS, "jerr:JUDY0061");
4042+
4043+(:~
4044+ :objects or arrays don't have a typed value
4045+:)
4046+declare variable $jerr:JSTY0001 as xs:QName := fn:QName($jerr:NS, "jerr:JSTY0001");
4047+
4048+(:~
4049+ :objects or arrays don't have a string value
4050+:)
4051+declare variable $jerr:JSTY0002 as xs:QName := fn:QName($jerr:NS, "jerr:JSTY0002");
4052+
4053+(:~
4054+ :error raised by upd:delete if the argument is not an object or array
4055+:)
4056+declare variable $jerr:JUDY0062 as xs:QName := fn:QName($jerr:NS, "jerr:JUDY0062");
4057+
4058+(:~
4059+ :error raised by upd:delete if the first argument is an
4060+ : object/array but second argument is not of type xs:string/xs:integer,
4061+ : respectively
4062+ :
4063+:)
4064+declare variable $jerr:JUDY0063 as xs:QName := fn:QName($jerr:NS, "jerr:JUDY0063");
4065+
4066+(:~
4067+ :error raised by mergeUpdates. An insert-before or insert-last
4068+ : UP must not have the same target as any other insert-before, -last, -as-first, or -as-last UP
4069+ :
4070+:)
4071+declare variable $jerr:JUDY0064 as xs:QName := fn:QName($jerr:NS, "jerr:JUDY0064");
4072+
4073+(:~
4074+ :error raised by upd:rename
4075+:)
4076+declare variable $jerr:JUDY0065 as xs:QName := fn:QName($jerr:NS, "jerr:JUDY0065");
4077\ No newline at end of file
4078
4079=== modified file 'src/annotations/annotations.h'
4080--- src/annotations/annotations.h 2012-01-11 17:30:25 +0000
4081+++ src/annotations/annotations.h 2012-02-08 21:22:19 +0000
4082@@ -22,7 +22,7 @@
4083
4084 #include "common/shared_types.h"
4085
4086-#include "compiler/parsetree/parsenodes.h"
4087+//#include "compiler/parsetree/parsenodes.h"
4088
4089 #include "zorbautils/hashmap_itemh.h"
4090
4091
4092=== modified file 'src/api/collectionimpl.cpp'
4093--- src/api/collectionimpl.cpp 2011-11-02 06:14:25 +0000
4094+++ src/api/collectionimpl.cpp 2012-02-08 21:22:19 +0000
4095@@ -429,12 +429,17 @@
4096
4097 store::Store* lStore = & GENV_STORE;
4098
4099- store::Collection_t lColl = lStore->getCollection(lQName);
4100-
4101- if (!lColl)
4102- {
4103- lColl = lStore->getCollection(lQName, true);
4104- }
4105+ store::Collection_t lColl = lStore->getCollection(lQName, false, false);
4106+
4107+ if (!lColl)
4108+ lColl = lStore->getCollection(lQName, true, false);
4109+
4110+ if (!lColl)
4111+ lColl = lStore->getCollection(lQName, false, true);
4112+
4113+ if (!lColl)
4114+ lColl = lStore->getCollection(lQName, true, true);
4115+
4116 // must exist because otherwise we wouldn't have an instance of this class
4117 ZORBA_ASSERT(lColl);
4118
4119
4120=== modified file 'src/api/dynamiccontextimpl.cpp'
4121--- src/api/dynamiccontextimpl.cpp 2012-01-11 17:30:25 +0000
4122+++ src/api/dynamiccontextimpl.cpp 2012-02-08 21:22:19 +0000
4123@@ -429,7 +429,8 @@
4124 TypeManager* tm = theStaticContext->get_typemanager();
4125
4126 xqtref_t lItemType = tm->create_named_type(lItem->getType(),
4127- TypeConstants::QUANT_ONE);
4128+ TypeConstants::QUANT_ONE,
4129+ QueryLoc::null);
4130
4131 if (!TypeOps::is_subtype(tm,
4132 *lItemType,
4133
4134=== modified file 'src/api/item.cpp'
4135--- src/api/item.cpp 2012-02-02 09:56:52 +0000
4136+++ src/api/item.cpp 2012-02-08 21:22:19 +0000
4137@@ -170,6 +170,18 @@
4138 return Item();
4139 }
4140
4141+#ifdef ZORBA_WITH_JSON
4142+
4143+bool
4144+Item::isJSONItem() const
4145+{
4146+ ITEM_TRY
4147+ return m_item->isJSONItem();
4148+ ITEM_CATCH
4149+ return false;
4150+}
4151+
4152+#endif /* ZORBA_WITH_JSON */
4153
4154 Iterator_t Item::getAtomizationValue() const
4155 {
4156@@ -448,6 +460,102 @@
4157 return -1;
4158 }
4159
4160+#ifdef ZORBA_WITH_JSON
4161+
4162+store::StoreConsts::JSONItemKind
4163+Item::getJSONItemKind() const
4164+{
4165+ ITEM_TRY
4166+ SYNC_CODE(AutoLock lock(GENV_STORE.getGlobalLock(), Lock::READ);)
4167+
4168+ return m_item->getJSONItemKind();
4169+ ITEM_CATCH
4170+ return store::StoreConsts::jsonItem;
4171+}
4172+
4173+Iterator_t
4174+Item::getObjectPairs() const
4175+{
4176+ ITEM_TRY
4177+ SYNC_CODE(AutoLock lock(GENV_STORE.getGlobalLock(), Lock::READ);)
4178+
4179+ // TODO, we should have an error handler here
4180+ return new StoreIteratorImpl(m_item->getPairs(), nullptr);
4181+
4182+ ITEM_CATCH
4183+ return NULL;
4184+}
4185+
4186+Iterator_t
4187+Item::getArrayMembers() const
4188+{
4189+ ITEM_TRY
4190+ SYNC_CODE(AutoLock lock(GENV_STORE.getGlobalLock(), Lock::READ);)
4191+
4192+ // TODO, we should have an error handler here
4193+ return new StoreIteratorImpl(m_item->getMembers(), nullptr);
4194+
4195+ ITEM_CATCH
4196+ return NULL;
4197+}
4198+
4199+Item
4200+Item::getObjectValue(String aName) const
4201+{
4202+ zstring& lName = Unmarshaller::getInternalString(aName);
4203+ store::Item_t lIndex;
4204+ if (!GENV_ITEMFACTORY->createString(lIndex, lName)) {
4205+ // QQQ probably should throw exception here
4206+ return Item();
4207+ }
4208+ ITEM_TRY
4209+ SYNC_CODE(AutoLock lock(GENV_STORE.getGlobalLock(), Lock::READ););
4210+ store::Item_t lPair = m_item->getPair(lIndex);
4211+ if (lPair.isNull()) {
4212+ return Item();
4213+ }
4214+ return &*lPair->getValue();
4215+ ITEM_CATCH
4216+ return Item();
4217+}
4218+
4219+Item
4220+Item::getArrayMember(uint32_t aIndex) const
4221+{
4222+ store::Item_t lIndex;
4223+ if (!GENV_ITEMFACTORY->createInteger(lIndex, Integer(aIndex))) {
4224+ // QQQ probably should throw exception here
4225+ return Item();
4226+ }
4227+ ITEM_TRY
4228+ SYNC_CODE(AutoLock lock(GENV_STORE.getGlobalLock(), Lock::READ);)
4229+ return &*m_item->getMember(lIndex);
4230+ ITEM_CATCH
4231+ return Item();
4232+}
4233+
4234+Item
4235+Item::getPairName() const
4236+{
4237+ ITEM_TRY
4238+ SYNC_CODE(AutoLock lock(GENV_STORE.getGlobalLock(), Lock::READ);)
4239+ return &*m_item->getName();
4240+ ITEM_CATCH
4241+ return Item();
4242+}
4243+
4244+Item
4245+Item::getPairValue() const
4246+{
4247+ ITEM_TRY
4248+ SYNC_CODE(AutoLock lock(GENV_STORE.getGlobalLock(), Lock::READ);)
4249+ return &*m_item->getValue();
4250+ ITEM_CATCH
4251+ return Item();
4252+}
4253+
4254+#endif /* ZORBA_WITH_JSON */
4255+
4256 bool
4257 Item::isStreamable() const
4258 {
4259
4260=== modified file 'src/api/itemfactoryimpl.cpp'
4261--- src/api/itemfactoryimpl.cpp 2012-01-11 17:30:25 +0000
4262+++ src/api/itemfactoryimpl.cpp 2012-02-08 21:22:19 +0000
4263@@ -24,6 +24,7 @@
4264 #include "zorbatypes/duration.h"
4265 #include "system/globalenv.h"
4266 #include "store/api/item_factory.h"
4267+#include "store/api/copymode.h"
4268 #include "api/unmarshaller.h"
4269 #include "types/casting.h"
4270
4271@@ -805,6 +806,66 @@
4272 return &*lItem;
4273 }
4274
4275+#ifdef ZORBA_WITH_JSON
4276+
4277+zorba::Item ItemFactoryImpl::createJSONNull()
4278+{
4279+ store::Item_t lItem;
4280+ theItemFactory->createJSONNull(lItem);
4281+ return &*lItem;
4282+}
4283+
4284+zorba::Item ItemFactoryImpl::createJSONNumber(String aString)
4285+{
4286+ store::Item_t lItem;
4287+ zstring &lString = Unmarshaller::getInternalString(aString);
4288+ theItemFactory->createJSONNumber(lItem, lString);
4289+ return &*lItem;
4290+}
4291+
4292+static void addItems(store::Item* parent, std::vector<Item> &items)
4293+{
4294+ // "Copy" the items into the parent
4295+ store::CopyMode noCopy;
4296+ noCopy.theDoCopy = false;
4297+ std::vector<Item>::iterator i = items.begin();
4298+ std::vector<Item>::iterator end = items.end();
4299+ for (; i != end; i++) {
4300+ Unmarshaller::getInternalItem(*i)->copy(parent, noCopy);
4301+ }
4302+}
4303+
4304+zorba::Item ItemFactoryImpl::createJSONObject(std::vector<Item> &aPairs)
4305+{
4306+ store::Item_t lItem;
4307+ theItemFactory->createJSONObject(lItem);
4308+ addItems(lItem.getp(), aPairs);
4309+ return &*lItem;
4310+}
4311+
4312+zorba::Item ItemFactoryImpl::createJSONArray(std::vector<Item> &aItems)
4313+{
4314+ store::Item_t lItem;
4315+ theItemFactory->createJSONArray(lItem);
4316+ addItems(lItem.getp(), aItems);
4317+ return &*lItem;
4318+}
4319+
4320+zorba::Item ItemFactoryImpl::createJSONPair(String aName, Item aValue)
4321+{
4322+ store::Item_t lNameItem;
4323+ theItemFactory->createString(lNameItem, Unmarshaller::getInternalString(aName));
4324+
4325+ store::Item_t lValueItem = Unmarshaller::getInternalItem(aValue);
4326+ store::Item_t lItem;
4327+ theItemFactory->createJSONObjectPair(lItem, lNameItem, lValueItem);
4328+ return &*lItem;
4329+}
4330+
4331+
4332+
4333+#endif /* ZORBA_WITH_JSON */
4334+
4335
4336 } // namespace zorba
4337 /* vim:set et sw=2 ts=2: */
4338
4339=== modified file 'src/api/itemfactoryimpl.h'
4340--- src/api/itemfactoryimpl.h 2012-01-11 17:30:25 +0000
4341+++ src/api/itemfactoryimpl.h 2012-02-08 21:22:19 +0000
4342@@ -244,6 +244,24 @@
4343 Item parent,
4344 String content);
4345
4346+#ifdef ZORBA_WITH_JSON
4347+ virtual Item
4348+ createJSONNull();
4349+
4350+ virtual Item
4351+ createJSONNumber(String aString);
4352+
4353+ virtual Item
4354+ createJSONObject(std::vector<Item>& aPairs);
4355+
4356+ virtual Item
4357+ createJSONArray(std::vector<Item>& aItems);
4358+
4359+ virtual Item
4360+ createJSONPair(String aName, Item aValue);
4361+
4362+#endif /* ZORBA_WITH_JSON */
4363+
4364 protected:
4365 store::ItemFactory* theItemFactory;
4366
4367
4368=== modified file 'src/api/options.cpp'
4369--- src/api/options.cpp 2012-01-11 17:30:25 +0000
4370+++ src/api/options.cpp 2012-02-08 21:22:19 +0000
4371@@ -17,6 +17,7 @@
4372
4373 #include <string.h>
4374 #include <zorba/options.h>
4375+#include "diagnostics/xquery_diagnostics.h"
4376
4377 Zorba_CompilerHints::Zorba_CompilerHints()
4378 :
4379@@ -36,7 +37,11 @@
4380
4381 Zorba_SerializerOptions::Zorba_SerializerOptions()
4382 :
4383+#ifdef ZORBA_WITH_JSON
4384+ ser_method(ZORBA_SERIALIZATION_METHOD_JSONIQ),
4385+#else
4386 ser_method(ZORBA_SERIALIZATION_METHOD_XML),
4387+#endif
4388 byte_order_mark(ZORBA_BYTE_ORDER_MARK_NO),
4389 escape_uri_attributes(ZORBA_ESCAPE_URI_ATTRIBUTES_NO),
4390 include_content_type(ZORBA_INCLUDE_CONTENT_TYPE_NO),
4391@@ -63,9 +68,15 @@
4392 else if (strcmp(value, "html") == 0) ser_method = ZORBA_SERIALIZATION_METHOD_HTML;
4393 else if (strcmp(value, "xhtml") == 0) ser_method = ZORBA_SERIALIZATION_METHOD_XHTML;
4394 else if (strcmp(value, "text") == 0) ser_method = ZORBA_SERIALIZATION_METHOD_TEXT;
4395+ else if (strcmp(value, "binary") == 0) ser_method = ZORBA_SERIALIZATION_METHOD_BINARY;
4396+#ifdef ZORBA_WITH_JSON
4397+ else if (strcmp(value, "json") == 0) ser_method = ZORBA_SERIALIZATION_METHOD_JSON;
4398+ else if (strcmp(value, "jsoniq") == 0) ser_method = ZORBA_SERIALIZATION_METHOD_JSONIQ;
4399+#endif
4400 else
4401 {
4402- ; // TODO signal errors for incorrect values?
4403+ throw XQUERY_EXCEPTION
4404+ (err::SEPM0016, ERROR_PARAMS( value, "method", ZED( GoodValuesAreXMLEtc ) ));
4405 }
4406 }
4407 else if (strcmp(parameter, "byte-order-mark") == 0)
4408
4409=== modified file 'src/api/serialization/serializer.cpp'
4410--- src/api/serialization/serializer.cpp 2012-01-11 17:30:25 +0000
4411+++ src/api/serialization/serializer.cpp 2012-02-08 21:22:19 +0000
4412@@ -16,9 +16,10 @@
4413 #include "stdafx.h"
4414
4415 #include <sstream>
4416+#include <iomanip>
4417
4418 #include <zorba/zorba_string.h>
4419-
4420+#include <zorbamisc/ns_consts.h>
4421 #include "zorbatypes/numconversions.h"
4422 #include "diagnostics/xquery_diagnostics.h"
4423 #include "diagnostics/assert.h"
4424@@ -39,7 +40,8 @@
4425 #include "store/api/iterator.h"
4426 #include "store/api/iterator_factory.h"
4427 #include "store/api/item.h"
4428-
4429+#include <store/api/item_factory.h>
4430+#include <store/api/copymode.h>
4431
4432 namespace zorba {
4433
4434@@ -194,9 +196,15 @@
4435 const unsigned char* temp = chars;
4436 unicode::code_point cp = utf8::next_char(temp);
4437
4438- // raise an error iff (1) the serialization format is XML 1.0 and (2) the given character is an invalid XML 1.0 character
4439- if (ser && ser->method == PARAMETER_VALUE_XML && ser->version == "1.0" && !xml::is_valid(cp))
4440+ // raise an error iff (1) the serialization format is XML 1.0 and
4441+ // (2) the given character is an invalid XML 1.0 character
4442+ if (ser &&
4443+ ser->method == PARAMETER_VALUE_XML &&
4444+ ser->version == "1.0" &&
4445+ !xml::is_valid(cp))
4446+ {
4447 throw XQUERY_EXCEPTION( err::FOCH0001, ERROR_PARAMS( cp ) );
4448+ }
4449
4450 if (cp >= 0x10000 && cp <= 0x10FFFF)
4451 {
4452@@ -347,7 +355,7 @@
4453 /*******************************************************************************
4454
4455 ********************************************************************************/
4456-void serializer::emitter::emit_declaration_end()
4457+void serializer::emitter::emit_end()
4458 {
4459 // Do nothing in the default emitter
4460 }
4461@@ -393,6 +401,12 @@
4462 ********************************************************************************/
4463 void serializer::emitter::emit_item(store::Item* item)
4464 {
4465+#ifdef ZORBA_WITH_JSON
4466+ if (item->isJSONItem())
4467+ {
4468+ throw XQUERY_EXCEPTION(zerr::ZAPI0043_CANNOT_SERIALIZE_JSON_ITEM);
4469+ }
4470+#endif
4471 if (item->isAtomic())
4472 {
4473 if (previous_item == PREVIOUS_ITEM_WAS_TEXT)
4474@@ -764,7 +778,6 @@
4475 return false;
4476 }
4477
4478-
4479 /*******************************************************************************
4480
4481 ********************************************************************************/
4482@@ -809,7 +822,7 @@
4483
4484 ////////////////////////////////////////////////////////////////////////////////
4485 // //
4486-// XML Emitter //
4487+// XML emitter //
4488 // //
4489 ////////////////////////////////////////////////////////////////////////////////
4490
4491@@ -889,6 +902,335 @@
4492 }
4493
4494
4495+#ifdef ZORBA_WITH_JSON
4496+
4497+////////////////////////////////////////////////////////////////////////////////
4498+// //
4499+// JSON emitter //
4500+// //
4501+////////////////////////////////////////////////////////////////////////////////
4502+
4503+serializer::json_emitter::json_emitter(
4504+ serializer* the_serializer,
4505+ transcoder& the_transcoder)
4506+ : emitter(the_serializer, the_transcoder),
4507+ theXMLStringStream(nullptr)
4508+{
4509+}
4510+
4511+serializer::json_emitter::~json_emitter()
4512+{
4513+ delete theXMLStringStream;
4514+}
4515+
4516+void serializer::json_emitter::emit_item(store::Item *item)
4517+{
4518+ if (!item->isJSONItem())
4519+ {
4520+ throw XQUERY_EXCEPTION(zerr::ZAPI0044_CANNOT_SERIALIZE_XML_ITEM);
4521+ }
4522+ emit_json_item(item, 0);
4523+}
4524+
4525+void serializer::json_emitter::emit_declaration()
4526+{
4527+}
4528+
4529+void serializer::json_emitter::emit_end()
4530+{
4531+}
4532+
4533+void serializer::json_emitter::emit_json_item(store::Item* item, int depth)
4534+{
4535+ // This is called for any item within a JSON array or object, or for a
4536+ // top-level JSON array or object. So JSON rules for simple types may
4537+ // apply here.
4538+ if (item->isJSONObject()) {
4539+ emit_json_object(item, depth);
4540+ }
4541+ else if (item->isJSONArray()) {
4542+ emit_json_array(item, depth);
4543+ }
4544+ else if (item->isJSONPair()) {
4545+ emit_json_pair(item, depth);
4546+ }
4547+ else if (item->isAtomic()) {
4548+ store::SchemaTypeCode type = item->getTypeCode();
4549+ switch (type) {
4550+ case store::XS_STRING:
4551+ emit_json_string(item->getStringValue());
4552+ break;
4553+
4554+ case store::XS_DOUBLE:
4555+ case store::XS_FLOAT:
4556+ if (item->isNaN()) {
4557+ emit_jsoniq_value("number", "NaN", depth);
4558+ break;
4559+ }
4560+ else if (item->isPosOrNegInf()) {
4561+ emit_jsoniq_value("number", "Infinity", depth);
4562+ break;
4563+ }
4564+ // else fall through
4565+ case store::XS_INTEGER:
4566+ case store::XS_DECIMAL:
4567+ case store::XS_NON_POSITIVE_INTEGER:
4568+ case store::XS_NEGATIVE_INTEGER:
4569+ case store::XS_LONG:
4570+ case store::XS_INT:
4571+ case store::XS_SHORT:
4572+ case store::XS_BYTE:
4573+ case store::XS_NON_NEGATIVE_INTEGER:
4574+ case store::XS_UNSIGNED_LONG:
4575+ case store::XS_UNSIGNED_INT:
4576+ case store::XS_UNSIGNED_SHORT:
4577+ case store::XS_UNSIGNED_BYTE:
4578+ case store::XS_POSITIVE_INTEGER:
4579+ // All numerics get serialized the same way
4580+ tr << item->getStringValue();
4581+ break;
4582+
4583+ case store::XS_BOOLEAN:
4584+ tr << (item->getBooleanValue() ? "true" : "false");
4585+ break;
4586+
4587+ case store::JDM_NULL:
4588+ tr << "null";
4589+ break;
4590+
4591+ default: {
4592+ emit_jsoniq_value(item->getType()->getStringValue(),
4593+ item->getStringValue(), depth);
4594+ break;
4595+ }
4596+ }
4597+ }
4598+ else {
4599+ // OK, we've got a non-atomic non-JDM Item here, so serialize it as XML
4600+ // and output it as a "JSONiq value".
4601+ if (!theXMLEmitter) {
4602+ theXMLStringStream = new std::stringstream();
4603+ theXMLTranscoder = ser->create_transcoder(*theXMLStringStream);
4604+ theXMLEmitter = new serializer::xml_emitter(ser, *theXMLTranscoder);
4605+ }
4606+ theXMLEmitter->emit_item(item);
4607+ std::string xml = theXMLStringStream->str();
4608+ emit_jsoniq_value("XML", xml, depth);
4609+ theXMLStringStream->str("");
4610+ }
4611+}
4612+
4613+/*******************************************************************************
4614+
4615+********************************************************************************/
4616+void serializer::json_emitter::emit_json_object(store::Item* obj, int depth)
4617+{
4618+ store::Item_t pair;
4619+ store::Iterator_t it = obj->getPairs();
4620+ it->open();
4621+ bool first = true;
4622+ if (ser->indent) {
4623+ tr << "{" <<ser->END_OF_LINE;
4624+ }
4625+ else {
4626+ tr << "{ ";
4627+ }
4628+ depth++;
4629+ while (it->next(pair)) {
4630+ if (first) {
4631+ first = false;
4632+ }
4633+ else {
4634+ tr << ", ";
4635+ if (ser->indent) {
4636+ tr << ser->END_OF_LINE;
4637+ }
4638+ }
4639+ if (ser->indent) {
4640+ emit_indentation(depth);
4641+ }
4642+ emit_json_pair(pair, depth);
4643+ }
4644+ if (ser->indent) {
4645+ tr << ser->END_OF_LINE;
4646+ emit_indentation(depth-1);
4647+ tr << "}";
4648+ }
4649+ else {
4650+ tr << " }";
4651+ }
4652+}
4653+
4654+/*******************************************************************************
4655+
4656+********************************************************************************/
4657+void serializer::json_emitter::emit_json_array(store::Item* array, int depth)
4658+{
4659+ store::Item_t member;
4660+ store::Iterator_t it = array->getMembers();
4661+ it->open();
4662+ bool first = true;
4663+ tr << "[ ";
4664+ while (it->next(member)) {
4665+ if (first) {
4666+ first = false;
4667+ }
4668+ else {
4669+ tr << ", ";
4670+ }
4671+ emit_json_item(member, depth);
4672+ }
4673+ tr << " ]";
4674+}
4675+
4676+/*******************************************************************************
4677+
4678+********************************************************************************/
4679+void serializer::json_emitter::emit_json_pair(store::Item* pair, int depth)
4680+{
4681+ emit_json_item(pair->getName(), depth);
4682+ tr << " : ";
4683+ emit_json_item(pair->getValue(), depth);
4684+}
4685+
4686+/*******************************************************************************
4687+
4688+********************************************************************************/
4689+void serializer::json_emitter::emit_jsoniq_value
4690+ (zstring type, zstring value, int depth)
4691+{
4692+ // Create items for constant strings, if not already done
4693+ if (!theJsoniqValueName) {
4694+ zstring jsoniqvaluestring("JSONiq value");
4695+ zstring typestring("type");
4696+ zstring valuestring("value");
4697+ GENV_ITEMFACTORY->createString(theJsoniqValueName, jsoniqvaluestring);
4698+ GENV_ITEMFACTORY->createString(theTypeName, typestring);
4699+ GENV_ITEMFACTORY->createString(theValueName, valuestring);
4700+ }
4701+
4702+ // Create the inner JSON object
4703+ store::Item_t inner;
4704+ GENV_ITEMFACTORY->createJSONObject(inner);
4705+ // Inner object contains two pairs
4706+ store::Item_t typeitem, valueitem;
4707+ store::Item_t typepair, valuepair;
4708+ GENV_ITEMFACTORY->createString(typeitem, type);
4709+ GENV_ITEMFACTORY->createString(valueitem, value);
4710+ GENV_ITEMFACTORY->createJSONObjectPair(typepair, theTypeName, typeitem);
4711+ GENV_ITEMFACTORY->createJSONObjectPair(valuepair, theValueName, valueitem);
4712+
4713+ // "Copy" pairs into object
4714+ store::CopyMode noCopy;
4715+ noCopy.theDoCopy = false;
4716+ typepair->copy(inner.getp(), noCopy);
4717+ valuepair->copy(inner.getp(), noCopy);
4718+
4719+ // Create the outer JSON object with one pair
4720+ store::Item_t outer;
4721+ GENV_ITEMFACTORY->createJSONObject(outer);
4722+ store::Item_t outerpair;
4723+ GENV_ITEMFACTORY->createJSONObjectPair(outerpair, theJsoniqValueName, inner);
4724+ outerpair->copy(outer, noCopy);
4725+
4726+ emit_json_object(outer, depth);
4727+}
4728+
4729+void serializer::json_emitter::emit_json_string(zstring string)
4730+{
4731+ tr << '"';
4732+ zstring::const_iterator i = string.begin();
4733+ zstring::const_iterator end = string.end();
4734+ for (; i < end; i++) {
4735+ if (*i < 0x20) {
4736+ // Escape control sequences
4737+ std::stringstream hex;
4738+ hex << "\\u" << std::setw(4) << std::setfill('0')
4739+ << std::hex << static_cast<int>(*i);
4740+ tr << hex.str();
4741+ continue;
4742+ }
4743+ if (*i == '\\' || *i == '"') {
4744+ // Output escape char for \ or "
4745+ tr << '\\';
4746+ // Fall through to output original character
4747+ }
4748+ tr << *i;
4749+ }
4750+ tr << '"';
4751+}
4752+
4753+
4754+////////////////////////////////////////////////////////////////////////////////
4755+// //
4756+// JSONiq emitter (auto-detects JSON or XML) //
4757+// //
4758+////////////////////////////////////////////////////////////////////////////////
4759+
4760+serializer::jsoniq_emitter::jsoniq_emitter(
4761+ serializer* the_serializer,
4762+ transcoder& the_transcoder)
4763+ :
4764+ emitter(the_serializer, the_transcoder),
4765+ theEmitterState(JESTATE_UNDETERMINED),
4766+ theEmitter(nullptr)
4767+{
4768+}
4769+
4770+serializer::jsoniq_emitter::~jsoniq_emitter()
4771+{
4772+ delete theEmitter;
4773+}
4774+
4775+void serializer::jsoniq_emitter::emit_declaration()
4776+{
4777+ // Probably I should set a flag here to note whether emit_declaration() has
4778+ // been called or not. However, I know that all serializer::serialize()
4779+ // methods DO call emit_declaration() and call it first, so there's no need.
4780+}
4781+
4782+void serializer::jsoniq_emitter::emit_item(store::Item *item)
4783+{
4784+ bool isJson = item->isJSONItem();
4785+
4786+ if (theEmitterState == JESTATE_UNDETERMINED) {
4787+ // Initialize theEmitter based on item type, passing through our serializer
4788+ // and transcoder.
4789+ if (isJson) {
4790+ theEmitterState = JESTATE_JDM;
4791+ theEmitter = new json_emitter(ser, tr);
4792+ }
4793+ else {
4794+ theEmitterState = JESTATE_XDM;
4795+ theEmitter = new xml_emitter(ser, tr);
4796+ }
4797+ // Since this was the first item, call emit_declaration().
4798+ theEmitter->emit_declaration();
4799+ }
4800+ else {
4801+ // Error checking
4802+ if ( (isJson && theEmitterState == JESTATE_XDM) ||
4803+ (!isJson && theEmitterState == JESTATE_JDM) ) {
4804+ throw XQUERY_EXCEPTION(zerr::ZAPI0045_CANNOT_SERIALIZE_MIXED_XDM_JDM);
4805+ }
4806+ }
4807+
4808+ // Pass through
4809+ theEmitter->emit_item(item);
4810+}
4811+
4812+void serializer::jsoniq_emitter::emit_end()
4813+{
4814+ // Not really clear what to do if we serialized no items and hence have
4815+ // no emitter yet, but doing nothing at all seems reasonable.
4816+ if (theEmitter) {
4817+ theEmitter->emit_end();
4818+ }
4819+}
4820+
4821+
4822+#endif /* ZORBA_WITH_JSON */
4823+
4824 ////////////////////////////////////////////////////////////////////////////////
4825 // //
4826 // HTML Emitter //
4827@@ -1043,7 +1385,7 @@
4828 /*******************************************************************************
4829
4830 ********************************************************************************/
4831-void serializer::html_emitter::emit_declaration_end()
4832+void serializer::html_emitter::emit_end()
4833 {
4834 }
4835
4836@@ -1439,7 +1781,7 @@
4837 /*******************************************************************************
4838
4839 ********************************************************************************/
4840-void serializer::sax2_emitter::emit_declaration_end()
4841+void serializer::sax2_emitter::emit_end()
4842 {
4843 theSAX2ContentHandler->endDocument();
4844 }
4845@@ -1893,7 +2235,6 @@
4846 }
4847 }
4848
4849-
4850 ////////////////////////////////////////////////////////////////////////////////
4851 // //
4852 // Serializer //
4853@@ -1940,7 +2281,12 @@
4854
4855 media_type.clear();
4856
4857+ // This default should match the default for ser_method in Zorba_SerializerOptions
4858+#ifdef ZORBA_WITH_JSON
4859+ method = PARAMETER_VALUE_JSONIQ;
4860+#else
4861 method = PARAMETER_VALUE_XML;
4862+#endif
4863
4864 normalization_form.clear();
4865
4866@@ -2032,6 +2378,12 @@
4867 method = PARAMETER_VALUE_TEXT;
4868 else if (!strcmp(aValue, "binary"))
4869 method = PARAMETER_VALUE_BINARY;
4870+#ifdef ZORBA_WITH_JSON
4871+ else if (!strcmp(aValue, "json"))
4872+ method = PARAMETER_VALUE_JSON;
4873+ else if (!strcmp(aValue, "jsoniq"))
4874+ method = PARAMETER_VALUE_JSONIQ;
4875+#endif
4876 else
4877 throw XQUERY_EXCEPTION(
4878 err::SEPM0016, ERROR_PARAMS( aValue, aName, ZED( GoodValuesAreXMLEtc ) )
4879@@ -2160,22 +2512,10 @@
4880 ********************************************************************************/
4881 bool serializer::setup(std::ostream& os)
4882 {
4883- if (encoding == PARAMETER_VALUE_UTF_8)
4884- {
4885- tr = new transcoder(os, false);
4886- }
4887-#ifndef ZORBA_NO_UNICODE
4888- else if (encoding == PARAMETER_VALUE_UTF_16)
4889- {
4890- tr = new transcoder(os, true);
4891- }
4892-#endif
4893- else
4894- {
4895- ZORBA_ASSERT(0);
4896+ tr = create_transcoder(os);
4897+ if (!tr) {
4898 return false;
4899 }
4900-
4901 if (method == PARAMETER_VALUE_XML)
4902 e = new xml_emitter(this, *tr);
4903 else if (method == PARAMETER_VALUE_HTML)
4904@@ -2186,6 +2526,12 @@
4905 e = new text_emitter(this, *tr);
4906 else if (method == PARAMETER_VALUE_BINARY)
4907 e = new binary_emitter(this, *tr);
4908+#ifdef ZORBA_WITH_JSON
4909+ else if (method == PARAMETER_VALUE_JSON)
4910+ e = new json_emitter(this, *tr);
4911+ else if (method == PARAMETER_VALUE_JSONIQ)
4912+ e = new jsoniq_emitter(this, *tr);
4913+#endif
4914 else
4915 {
4916 ZORBA_ASSERT(0);
4917@@ -2204,6 +2550,24 @@
4918 return true;
4919 }
4920
4921+transcoder* serializer::create_transcoder(std::ostream &os)
4922+{
4923+ if (encoding == PARAMETER_VALUE_UTF_8)
4924+ {
4925+ return new transcoder(os, false);
4926+ }
4927+#ifndef ZORBA_NO_UNICODE
4928+ else if (encoding == PARAMETER_VALUE_UTF_16)
4929+ {
4930+ return new transcoder(os, true);
4931+ }
4932+#endif
4933+ else
4934+ {
4935+ ZORBA_ASSERT(0);
4936+ return nullptr;
4937+ }
4938+}
4939
4940 /*******************************************************************************
4941
4942@@ -2265,7 +2629,7 @@
4943 e->emit_item(&*lItem);
4944 }
4945 //+ aObject->close();
4946- e->emit_declaration_end();
4947+ e->emit_end();
4948 }
4949
4950
4951@@ -2311,7 +2675,7 @@
4952 }
4953
4954 //object->close();
4955- e->emit_declaration_end();
4956+ e->emit_end();
4957 }
4958
4959 } // namespace zorba
4960
4961=== modified file 'src/api/serialization/serializer.h'
4962--- src/api/serialization/serializer.h 2011-11-11 07:44:01 +0000
4963+++ src/api/serialization/serializer.h 2012-02-08 21:22:19 +0000
4964@@ -69,6 +69,10 @@
4965 PARAMETER_VALUE_XHTML,
4966 PARAMETER_VALUE_TEXT,
4967 PARAMETER_VALUE_BINARY,
4968+#ifdef ZORBA_WITH_JSON
4969+ PARAMETER_VALUE_JSON,
4970+ PARAMETER_VALUE_JSONIQ,
4971+#endif
4972
4973 PARAMETER_VALUE_UTF_8
4974 #ifndef ZORBA_NO_UNICODE
4975@@ -168,6 +172,7 @@
4976
4977 bool setup(std::ostream& os);
4978
4979+ transcoder* create_transcoder(std::ostream& os);
4980
4981 ///////////////////////////////////////////////////////////
4982 // //
4983@@ -198,8 +203,20 @@
4984 /**
4985 * Outputs the end of the serialized document.
4986 */
4987- virtual void emit_declaration_end();
4988-
4989+ virtual void emit_end();
4990+
4991+ /**
4992+ * Serializes the given item, depending on its type, and its children. This
4993+ * will be called by serializer for each top-level item in the sequence.
4994+ *
4995+ * @param item the item to serialize
4996+ */
4997+ virtual void emit_item(store::Item* item);
4998+
4999+ // End of the "public" emitter API. All remaining methods are implementation
5000+ // details and will not be called from outside.
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches