Ghislain Fourny has proposed merging lp:~zorba-coders/zorba/bug-1041445 into 
lp:zorba.

Requested reviews:
  Till Westmann (tillw)
Related bugs:
  Bug #1041445 in Zorba: "Semantics of cast/comparison/arithmetics involving 
null"
  https://bugs.launchpad.net/zorba/+bug/1041445

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

Implementing semantics of arithmetics and comparison operators for JSON nulls.
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1041445/+merge/124191
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'include/zorba/store_consts.h'
--- include/zorba/store_consts.h	2012-09-11 22:55:05 +0000
+++ include/zorba/store_consts.h	2012-09-13 13:01:18 +0000
@@ -84,7 +84,7 @@
   XS_QNAME                 = 43,
   XS_NOTATION              = 44,
   
-  JDM_NULL                 = 45,
+  JS_NULL                  = 45,
 
   XS_LAST
 };

=== modified file 'modules/org/jsoniq/www/functions.xq'
--- modules/org/jsoniq/www/functions.xq	2012-09-11 22:55:05 +0000
+++ modules/org/jsoniq/www/functions.xq	2012-09-13 13:01:18 +0000
@@ -35,11 +35,9 @@
 
 import module namespace schema = "http://www.zorba-xquery.com/modules/schema";;
 
-declare namespace jdm = "http://www.jsoniq.org/";;
-
 declare namespace err = "http://www.w3.org/2005/xqt-errors";;
-
 declare namespace jerr = "http://www.jsoniq.org/errors";;
+declare namespace js = "http://www.jsoniq.org/data-model";;
 
 declare namespace ver = "http://www.zorba-xquery.com/options/versioning";;
 declare option ver:module-version "1.0";
@@ -180,3 +178,20 @@
  : @error jerr:JNDY0003 if there is a pair collision.
  :)
 declare function jn:object($o as object()*) as object() external;
+
+(:~
+ : Returns the JSON null.
+ :
+ : @return The JSON null.
+ :)
+declare function jn:null() as js:null external;
+
+(:~
+ : Tests whether the supplied atomic item is a JSON null.
+ :
+ : @return true if the item is of type js:null.
+ :)
+declare function jn:is-null($i as xs:anyAtomicType) as xs:boolean external;
+
+
+

=== modified file 'src/api/serialization/serializer.cpp'
--- src/api/serialization/serializer.cpp	2012-09-13 08:28:50 +0000
+++ src/api/serialization/serializer.cpp	2012-09-13 13:01:18 +0000
@@ -1040,7 +1040,7 @@
       tr << (item->getBooleanValue() ? "true" : "false");
       break;
 
-    case store::JDM_NULL:
+    case store::JS_NULL:
       tr << "null";
       break;
 

=== modified file 'src/context/static_context.cpp'
--- src/context/static_context.cpp	2012-09-11 22:55:05 +0000
+++ src/context/static_context.cpp	2012-09-13 13:01:18 +0000
@@ -397,8 +397,8 @@
 #ifdef ZORBA_WITH_JSON
 
 const char*
-static_context::JSONIQ_NS =
-"http://www.jsoniq.org/";;
+static_context::JSONIQ_DM_NS =
+"http://www.jsoniq.org/data-model";;
 
 const char*
 static_context::JSONIQ_FN_NS =

=== modified file 'src/context/static_context.h'
--- src/context/static_context.h	2012-09-11 22:55:05 +0000
+++ src/context/static_context.h	2012-09-13 13:01:18 +0000
@@ -527,7 +527,7 @@
   static const char* ZORBA_STORE_DYNAMIC_UNORDERED_MAP_FN_NS;
 
 #ifdef ZORBA_WITH_JSON
-  static const char* JSONIQ_NS;
+  static const char* JSONIQ_DM_NS;
   static const char* JSONIQ_FN_NS;
 #endif
 

=== modified file 'src/functions/func_jsoniq_functions_impl.cpp'
--- src/functions/func_jsoniq_functions_impl.cpp	2012-09-13 08:28:50 +0000
+++ src/functions/func_jsoniq_functions_impl.cpp	2012-09-13 13:01:18 +0000
@@ -145,7 +145,7 @@
     return type;
 
   if (type->max_card() == 0)
-    return GENV_TYPESYSTEM.JDM_NULL_TYPE_ONE;
+    return GENV_TYPESYSTEM.JS_NULL_TYPE_ONE;
 
   return theSignature.returnType();
 }

=== modified file 'src/functions/pregenerated/func_jsoniq_functions.cpp'
--- src/functions/pregenerated/func_jsoniq_functions.cpp	2012-09-11 22:55:05 +0000
+++ src/functions/pregenerated/func_jsoniq_functions.cpp	2012-09-13 13:01:18 +0000
@@ -142,6 +142,18 @@
 
 #endif
 #ifdef ZORBA_WITH_JSON
+PlanIter_t fn_jsoniq_is_null::codegen(
+  CompilerCB*,
+  static_context* sctx,
+  const QueryLoc& loc,
+  std::vector<PlanIter_t>& argv,
+  expr& ann) const
+{
+  return new JSONIsNullIterator(sctx, loc, argv[0]);
+}
+
+#endif
+#ifdef ZORBA_WITH_JSON
 PlanIter_t op_zorba_json_array_insert::codegen(
   CompilerCB*,
   static_context* sctx,
@@ -379,7 +391,7 @@
       {
     DECL_WITH_KIND(sctx, fn_jsoniq_null,
         (createQName("http://www.jsoniq.org/functions","","null";), 
-        GENV_TYPESYSTEM.JDM_NULL_TYPE_ONE),
+        GENV_TYPESYSTEM.JS_NULL_TYPE_ONE),
         FunctionConsts::FN_JSONIQ_NULL_0);
 
   }
@@ -392,6 +404,22 @@
 
 
       {
+    DECL_WITH_KIND(sctx, fn_jsoniq_is_null,
+        (createQName("http://www.jsoniq.org/functions","","is-null";), 
+        GENV_TYPESYSTEM.ANY_ATOMIC_TYPE_ONE, 
+        GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+        FunctionConsts::FN_JSONIQ_IS_NULL_1);
+
+  }
+
+
+#endif
+
+
+#ifdef ZORBA_WITH_JSON
+
+
+      {
     DECL_WITH_KIND(sctx, op_zorba_json_array_insert,
         (createQName("http://www.zorba-xquery.com/internal/zorba-ops","","json-array-insert";), 
         GENV_TYPESYSTEM.JSON_ARRAY_TYPE_ONE, 

=== modified file 'src/functions/pregenerated/func_jsoniq_functions.h'
--- src/functions/pregenerated/func_jsoniq_functions.h	2012-09-13 08:28:50 +0000
+++ src/functions/pregenerated/func_jsoniq_functions.h	2012-09-13 13:01:18 +0000
@@ -234,6 +234,22 @@
 #endif
 #ifdef ZORBA_WITH_JSON
 
+//fn-jsoniq:is-null
+class fn_jsoniq_is_null : public function
+{
+public:
+  fn_jsoniq_is_null(const signature& sig, FunctionConsts::FunctionKind kind)
+    : 
+    function(sig, kind)
+  {
+
+  }
+
+  CODEGEN_DECL();
+};
+#endif
+#ifdef ZORBA_WITH_JSON
+
 //op-zorba:json-array-insert
 class op_zorba_json_array_insert : public function
 {

=== modified file 'src/functions/pregenerated/function_enum.h'
--- src/functions/pregenerated/function_enum.h	2012-09-13 08:28:50 +0000
+++ src/functions/pregenerated/function_enum.h	2012-09-13 13:01:18 +0000
@@ -238,6 +238,7 @@
   FN_JSONIQ_FLATTEN_1,
   OP_ZORBA_JSON_ITEM_ACCESSOR_2,
   FN_JSONIQ_NULL_0,
+  FN_JSONIQ_IS_NULL_1,
   OP_ZORBA_JSON_ARRAY_INSERT_3,
   OP_ZORBA_JSON_DELETE_2,
   OP_ZORBA_JSON_REPLACE_VALUE_3,

=== modified file 'src/runtime/booleans/BooleanImpl.cpp'
--- src/runtime/booleans/BooleanImpl.cpp	2012-09-11 22:55:05 +0000
+++ src/runtime/booleans/BooleanImpl.cpp	2012-09-13 13:01:18 +0000
@@ -142,7 +142,7 @@
          TypeOps::is_subtype(type, store::XS_STRING) ||
          TypeOps::is_subtype(type, store::XS_ANY_URI) ||
          type == store::XS_UNTYPED_ATOMIC ||
-         type == store::JDM_NULL ||
+         type == store::JS_NULL ||
          TypeOps::is_numeric(type)))
     {
       // atomic type xs_boolean, xs_string, xs_anyURI, xs_untypedAtomic
@@ -488,19 +488,23 @@
     if (consumeNext(item0, theChild0.getp(), planState) &&
         consumeNext(item1, theChild1.getp(), planState))
     {
-      STACK_PUSH(GENV_ITEMFACTORY->
-                 createBoolean(result,
-                               CompareIterator::valueComparison(loc,
-                                                                item0,
-                                                                item1,
-                                                                theCompType,
-                                                                theTypeManager,
-                                                                theTimezone,
-                                                                theCollation)),
-                 state);
+      if (item0->getTypeCode() != store::JS_NULL &&
+          item1->getTypeCode() != store::JS_NULL)
+      {
+        STACK_PUSH(GENV_ITEMFACTORY->
+                   createBoolean(result,
+                                 CompareIterator::valueComparison(loc,
+                                                                  item0,
+                                                                  item1,
+                                                                  theCompType,
+                                                                  theTypeManager,
+                                                                  theTimezone,
+                                                                  theCollation)),
+                   state);
 
-      assert(!consumeNext(item0, theChild0.getp(), planState) &&
-             !consumeNext(item1, theChild1.getp(), planState));
+        assert(!consumeNext(item0, theChild0.getp(), planState) &&
+               !consumeNext(item1, theChild1.getp(), planState));
+      }
     }
   }
 
@@ -685,6 +689,11 @@
     long timezone,
     XQPCollator* aCollation)
 {
+  if (aItem0->getTypeCode() == store::JS_NULL ||
+      aItem1->getTypeCode() == store::JS_NULL)
+  {
+    return false;
+  }
   try
   {
     switch(aCompType)

=== modified file 'src/runtime/core/arithmetic_impl.cpp'
--- src/runtime/core/arithmetic_impl.cpp	2012-09-11 22:55:05 +0000
+++ src/runtime/core/arithmetic_impl.cpp	2012-09-13 13:01:18 +0000
@@ -115,24 +115,28 @@
   {
     if (this->consumeNext(n1, this->theChild1.getp(), planState))
     {
-      status = compute(result,
-                       planState.theLocalDynCtx,
-                       this->theSctx->get_typemanager(),
-                       this->loc,
-                       n0,
-                       n1);
-      /*
-      if (this->consumeNext(n0, this->theChild0.getp(), planState) ||
-          this->consumeNext(n1, this->theChild1.getp(), planState))
+      if (n0->getTypeCode() != store::JS_NULL &&
+          n1->getTypeCode() != store::JS_NULL)
       {
-        throw XQUERY_EXCEPTION(
-          err::XPTY0004,
-          ERROR_PARAMS( ZED( NoSeqAsArithOp ) ),
-          ERROR_LOC( this->loc )
-        );
+        status = compute(result,
+                         planState.theLocalDynCtx,
+                         this->theSctx->get_typemanager(),
+                         this->loc,
+                         n0,
+                         n1);
+        /*
+        if (this->consumeNext(n0, this->theChild0.getp(), planState) ||
+            this->consumeNext(n1, this->theChild1.getp(), planState))
+        {
+          throw XQUERY_EXCEPTION(
+            err::XPTY0004,
+            ERROR_PARAMS( ZED( NoSeqAsArithOp ) ),
+            ERROR_LOC( this->loc )
+          );
+        }
+        */
+        STACK_PUSH ( status, state );
       }
-      */
-      STACK_PUSH ( status, state );
     }
   }
 

=== modified file 'src/runtime/json/jsoniq_functions_impl.cpp'
--- src/runtime/json/jsoniq_functions_impl.cpp	2012-09-11 22:55:05 +0000
+++ src/runtime/json/jsoniq_functions_impl.cpp	2012-09-13 13:01:18 +0000
@@ -512,7 +512,7 @@
 
 
 /*******************************************************************************
-  j:null()) as jdm:null
+  jn:null() as jn:null
 ********************************************************************************/
 bool
 JSONNullIterator::nextImpl(
@@ -529,6 +529,30 @@
 
 
 /*******************************************************************************
+  jn:is-null(xs:anyAtomicType) as xs:boolean
+********************************************************************************/
+bool
+JSONIsNullIterator::nextImpl(
+  store::Item_t& result,
+  PlanState& planState) const
+{
+  PlanIteratorState* state;
+  store::Item_t lItem;
+  bool lIsNull;
+
+  DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+  consumeNext(lItem, theChild.getp(), planState);
+
+  lIsNull = (lItem->getTypeCode() == store::JS_NULL);
+
+  STACK_PUSH(GENV_ITEMFACTORY->createBoolean(result, lIsNull), state);
+
+  STACK_END(state);
+}
+
+
+/*******************************************************************************
   updating function op-zorba:object-insert(
       $o as object(),
       $name1 as xs:string, $value1 as item(), 

=== modified file 'src/runtime/json/pregenerated/jsoniq_functions.cpp'
--- src/runtime/json/pregenerated/jsoniq_functions.cpp	2012-09-11 22:55:05 +0000
+++ src/runtime/json/pregenerated/jsoniq_functions.cpp	2012-09-13 13:01:18 +0000
@@ -327,6 +327,31 @@
 
 #endif
 #ifdef ZORBA_WITH_JSON
+// <JSONIsNullIterator>
+SERIALIZABLE_CLASS_VERSIONS(JSONIsNullIterator)
+
+void JSONIsNullIterator::serialize(::zorba::serialization::Archiver& ar)
+{
+  serialize_baseclass(ar,
+  (UnaryBaseIterator<JSONIsNullIterator, PlanIteratorState>*)this);
+}
+
+
+void JSONIsNullIterator::accept(PlanIterVisitor& v) const
+{
+  v.beginVisit(*this);
+
+  theChild->accept(v);
+
+  v.endVisit(*this);
+}
+
+JSONIsNullIterator::~JSONIsNullIterator() {}
+
+// </JSONIsNullIterator>
+
+#endif
+#ifdef ZORBA_WITH_JSON
 // <JSONArrayInsertIterator>
 SERIALIZABLE_CLASS_VERSIONS(JSONArrayInsertIterator)
 

=== modified file 'src/runtime/json/pregenerated/jsoniq_functions.h'
--- src/runtime/json/pregenerated/jsoniq_functions.h	2012-09-11 22:55:05 +0000
+++ src/runtime/json/pregenerated/jsoniq_functions.h	2012-09-13 13:01:18 +0000
@@ -418,6 +418,38 @@
 #ifdef ZORBA_WITH_JSON
 /**
  * 
+ * Author: 
+ */
+class JSONIsNullIterator : public UnaryBaseIterator<JSONIsNullIterator, PlanIteratorState>
+{ 
+public:
+  SERIALIZABLE_CLASS(JSONIsNullIterator);
+
+  SERIALIZABLE_CLASS_CONSTRUCTOR2T(JSONIsNullIterator,
+    UnaryBaseIterator<JSONIsNullIterator, PlanIteratorState>);
+
+  void serialize( ::zorba::serialization::Archiver& ar);
+
+  JSONIsNullIterator(
+    static_context* sctx,
+    const QueryLoc& loc,
+    PlanIter_t& child)
+    : 
+    UnaryBaseIterator<JSONIsNullIterator, PlanIteratorState>(sctx, loc, child)
+  {}
+
+  virtual ~JSONIsNullIterator();
+
+  void accept(PlanIterVisitor& v) const;
+
+  bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+#endif
+
+#ifdef ZORBA_WITH_JSON
+/**
+ * 
  *      internal function 
  *    
  * Author: Zorba Team

=== modified file 'src/runtime/pregenerated/iterator_enum.h'
--- src/runtime/pregenerated/iterator_enum.h	2012-09-13 08:28:50 +0000
+++ src/runtime/pregenerated/iterator_enum.h	2012-09-13 13:01:18 +0000
@@ -161,6 +161,7 @@
   TYPE_JSONArrayFlattenIterator,
   TYPE_JSONItemAccessorIterator,
   TYPE_JSONNullIterator,
+  TYPE_JSONIsNullIterator,
   TYPE_JSONArrayInsertIterator,
   TYPE_JSONDeleteIterator,
   TYPE_JSONReplaceValueIterator,

=== modified file 'src/runtime/spec/json/jsoniq_functions.xml'
--- src/runtime/spec/json/jsoniq_functions.xml	2012-09-13 08:28:50 +0000
+++ src/runtime/spec/json/jsoniq_functions.xml	2012-09-13 13:01:18 +0000
@@ -267,24 +267,42 @@
 </zorba:iterator>
 
 
-<!--
-/*******************************************************************************
-********************************************************************************/
--->
-<zorba:iterator name="JSONNullIterator" arity="noary"
-  preprocessorGuard="#ifdef ZORBA_WITH_JSON">
-
-  <zorba:function isDeterministic="true">
-    <zorba:signature localname="null" prefix="fn-jsoniq">
-      <zorba:output>jdm:null</zorba:output>
-    </zorba:signature>
-
-  </zorba:function>
-
-</zorba:iterator>
-
-
-<!--
+  <!--
+/*******************************************************************************
+********************************************************************************/
+-->
+  <zorba:iterator name="JSONNullIterator" arity="noary"
+    preprocessorGuard="#ifdef ZORBA_WITH_JSON">
+    
+    <zorba:function isDeterministic="true">
+      <zorba:signature localname="null" prefix="fn-jsoniq">
+        <zorba:output>js:null</zorba:output>
+      </zorba:signature>
+      
+    </zorba:function>
+    
+  </zorba:iterator>
+  
+  
+  <!--
+/*******************************************************************************
+********************************************************************************/
+-->
+  <zorba:iterator name="JSONIsNullIterator" arity="unary"
+    preprocessorGuard="#ifdef ZORBA_WITH_JSON">
+    
+    <zorba:function isDeterministic="true">
+      <zorba:signature localname="is-null" prefix="fn-jsoniq">
+        <zorba:param>xs:anyAtomicType</zorba:param>
+        <zorba:output>xs:boolean</zorba:output>
+      </zorba:signature>
+      
+    </zorba:function>
+    
+  </zorba:iterator>
+  
+  
+  <!--
 /*******************************************************************************
 ********************************************************************************/
 <zorba:iterator name="JSONObjectInsertIterator" arity="nary"

=== modified file 'src/runtime/spec/mappings.xml'
--- src/runtime/spec/mappings.xml	2012-09-11 22:55:05 +0000
+++ src/runtime/spec/mappings.xml	2012-09-13 13:01:18 +0000
@@ -207,7 +207,7 @@
     <zorba:type zorbaType="JSON_ITEM">json-item()</zorba:type>
     <zorba:type zorbaType="JSON_ARRAY">array()</zorba:type>
     <zorba:type zorbaType="JSON_OBJECT">object()</zorba:type>
-    <zorba:type zorbaType="JDM_NULL">jdm:null</zorba:type>
+    <zorba:type zorbaType="JS_NULL">js:null</zorba:type>
   </zorba:types>
 
   <!-- XQuery Occurrence Indicators -->

=== modified file 'src/runtime/visitors/pregenerated/planiter_visitor.h'
--- src/runtime/visitors/pregenerated/planiter_visitor.h	2012-09-13 08:28:50 +0000
+++ src/runtime/visitors/pregenerated/planiter_visitor.h	2012-09-13 13:01:18 +0000
@@ -339,6 +339,9 @@
     class JSONNullIterator;
 #endif
 #ifdef ZORBA_WITH_JSON
+    class JSONIsNullIterator;
+#endif
+#ifdef ZORBA_WITH_JSON
     class JSONArrayInsertIterator;
 #endif
 #ifdef ZORBA_WITH_JSON
@@ -1179,6 +1182,10 @@
     virtual void endVisit   ( const JSONNullIterator& ) = 0;
 #endif
 #ifdef ZORBA_WITH_JSON
+    virtual void beginVisit ( const JSONIsNullIterator& ) = 0;
+    virtual void endVisit   ( const JSONIsNullIterator& ) = 0;
+#endif
+#ifdef ZORBA_WITH_JSON
     virtual void beginVisit ( const JSONArrayInsertIterator& ) = 0;
     virtual void endVisit   ( const JSONArrayInsertIterator& ) = 0;
 #endif

=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp'
--- src/runtime/visitors/pregenerated/printer_visitor.cpp	2012-09-13 08:28:50 +0000
+++ src/runtime/visitors/pregenerated/printer_visitor.cpp	2012-09-13 13:01:18 +0000
@@ -2114,6 +2114,21 @@
 
 #endif
 #ifdef ZORBA_WITH_JSON
+// <JSONIsNullIterator>
+void PrinterVisitor::beginVisit ( const JSONIsNullIterator& a) {
+  thePrinter.startBeginVisit("JSONIsNullIterator", ++theId);
+  printCommons( &a, theId );
+  thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const JSONIsNullIterator& ) {
+  thePrinter.startEndVisit();
+  thePrinter.endEndVisit();
+}
+// </JSONIsNullIterator>
+
+#endif
+#ifdef ZORBA_WITH_JSON
 // <JSONArrayInsertIterator>
 void PrinterVisitor::beginVisit ( const JSONArrayInsertIterator& a) {
   thePrinter.startBeginVisit("JSONArrayInsertIterator", ++theId);

=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.h'
--- src/runtime/visitors/pregenerated/printer_visitor.h	2012-09-13 08:28:50 +0000
+++ src/runtime/visitors/pregenerated/printer_visitor.h	2012-09-13 13:01:18 +0000
@@ -523,6 +523,11 @@
 #endif
 
 #ifdef ZORBA_WITH_JSON
+    void beginVisit( const JSONIsNullIterator& );
+    void endVisit  ( const JSONIsNullIterator& );
+#endif
+
+#ifdef ZORBA_WITH_JSON
     void beginVisit( const JSONArrayInsertIterator& );
     void endVisit  ( const JSONArrayInsertIterator& );
 #endif

=== modified file 'src/store/naive/json_items.cpp'
--- src/store/naive/json_items.cpp	2012-09-11 22:55:05 +0000
+++ src/store/naive/json_items.cpp	2012-09-13 13:01:18 +0000
@@ -38,7 +38,7 @@
 *******************************************************************************/
 store::Item* JSONNull::getType() const
 {
-  return GET_STORE().JDM_NULL_QNAME;
+  return GET_STORE().JS_NULL_QNAME;
 }
 
 
@@ -50,7 +50,7 @@
     long /* timezone */,
     const XQPCollator* /* collation */) const
 {
-  return other->getTypeCode() == store::JDM_NULL;
+  return other->getTypeCode() == store::JS_NULL;
 }
 
 
@@ -204,7 +204,7 @@
 *******************************************************************************/
 store::Item* JSONObject::getType() const
 {
-  return GET_STORE().JDM_OBJECT_QNAME;
+  return GET_STORE().JS_OBJECT_QNAME;
 }
 
 
@@ -732,7 +732,7 @@
 *******************************************************************************/
 store::Item* JSONArray::getType() const
 {
-  return GET_STORE().JDM_ARRAY_QNAME;
+  return GET_STORE().JS_ARRAY_QNAME;
 }
 
 

=== modified file 'src/store/naive/json_items.h'
--- src/store/naive/json_items.h	2012-09-11 22:55:05 +0000
+++ src/store/naive/json_items.h	2012-09-13 13:01:18 +0000
@@ -68,7 +68,7 @@
 
   void getTypedValue(store::Item_t& val, store::Iterator_t& iter) const;
 
-  store::SchemaTypeCode getTypeCode() const { return store::JDM_NULL; }
+  store::SchemaTypeCode getTypeCode() const { return store::JS_NULL; }
 
   store::Item* getType() const; 
 

=== modified file 'src/store/naive/store.cpp'
--- src/store/naive/store.cpp	2012-09-11 22:55:05 +0000
+++ src/store/naive/store.cpp	2012-09-13 13:01:18 +0000
@@ -86,7 +86,7 @@
 const char* Store::XS_URI = "http://www.w3.org/2001/XMLSchema";;
 const char* Store::XML_URI = "http://www.w3.org/2001/XML/1998/namespace";;
 const char* Store::ZXSE_URI = "http://www.zorba-xquery.com/zorba/schema-extensions";;
-const char* Store::JDM_URI = "http://www.jsoniq.org/";;
+const char* Store::JS_URI = "http://www.jsoniq.org/data-model";;
 
 const ulong Store::XML_URI_LEN = sizeof(Store::XML_URI);
 
@@ -185,9 +185,9 @@
   theSchemaTypeNames.resize(store::XS_LAST);
 
 #ifdef ZORBA_WITH_JSON
-  JDM_NULL_QNAME = theQNamePool->insert(JDM_URI, "jdm", "null");
-  JDM_OBJECT_QNAME = theQNamePool->insert(JDM_URI, "jdm", "object");
-  JDM_ARRAY_QNAME = theQNamePool->insert(JDM_URI, "jdm", "array");
+  JS_NULL_QNAME = theQNamePool->insert(JS_URI, "js", "null");
+  JS_OBJECT_QNAME = theQNamePool->insert(JS_URI, "js", "object");
+  JS_ARRAY_QNAME = theQNamePool->insert(JS_URI, "js", "array");
 #endif
 
   XS_UNTYPED_QNAME = theQNamePool->insert(ns, "xs", "untyped");
@@ -323,9 +323,9 @@
       XS_ANY_SIMPLE_QNAME = NULL;
 
 #ifdef ZORBA_WITH_JSON
-      JDM_OBJECT_QNAME = NULL;
-      JDM_ARRAY_QNAME = NULL;
-      JDM_NULL_QNAME = NULL;
+      JS_OBJECT_QNAME = NULL;
+      JS_ARRAY_QNAME = NULL;
+      JS_NULL_QNAME = NULL;
 #endif
 
       delete theQNamePool;

=== modified file 'src/store/naive/store.h'
--- src/store/naive/store.h	2012-09-13 08:28:50 +0000
+++ src/store/naive/store.h	2012-09-13 13:01:18 +0000
@@ -136,7 +136,7 @@
   static const char* XS_URI;
   static const char* XML_URI;
   static const char* ZXSE_URI;
-  static const char* JDM_URI;
+  static const char* JS_URI;
 
   static const ulong XML_URI_LEN;
 
@@ -159,9 +159,9 @@
   store::Item_t                 XS_ANY_SIMPLE_QNAME;
 
 #ifdef ZORBA_WITH_JSON
-  store::Item_t                 JDM_OBJECT_QNAME;
-  store::Item_t                 JDM_ARRAY_QNAME;
-  store::Item_t                 JDM_NULL_QNAME;
+  store::Item_t                 JS_OBJECT_QNAME;
+  store::Item_t                 JS_ARRAY_QNAME;
+  store::Item_t                 JS_NULL_QNAME;
 #endif
 
 protected:

=== modified file 'src/types/casting.cpp'
--- src/types/casting.cpp	2012-09-11 22:55:05 +0000
+++ src/types/casting.cpp	2012-09-13 13:01:18 +0000
@@ -1818,7 +1818,7 @@
   20,  // 42 XS_ANY_URI
   21,  // 43 XS_QNAME
   22,  // 44 XS_NOTATION
-  23   // 45 JDM_NULL
+  23   // 45 JS_NULL
 };
 
 
@@ -2159,7 +2159,7 @@
       sourceTypeCode != store::XS_UNTYPED_ATOMIC)
     throwTypeException(err::XPTY0004, errorInfo);
 
-  if (targetTypeCode == store::JDM_NULL)
+  if (targetTypeCode == store::JS_NULL)
     throwTypeException(err::XPTY0004, errorInfo);
 
   CastFunc castFunc = theCastMatrix[theMapping[sourceTypeCode]]

=== modified file 'src/types/root_typemanager.cpp'
--- src/types/root_typemanager.cpp	2012-09-11 22:55:05 +0000
+++ src/types/root_typemanager.cpp	2012-09-13 13:01:18 +0000
@@ -281,9 +281,9 @@
   XSQNDECL(XS_UNTYPED_QNAME, "untyped");
 
 #ifdef ZORBA_WITH_JSON
-  GENV_STORE.getItemFactory()->createQName(JDM_NULL_QNAME,
-                                           static_context::JSONIQ_NS,
-                                           "",
+  GENV_STORE.getItemFactory()->createQName(JS_NULL_QNAME,
+                                           static_context::JSONIQ_DM_NS,
+                                           "jn",
                                            "null");
 #endif
 
@@ -389,43 +389,43 @@
   new StructuredItemXQType(this, TypeConstants::QUANT_PLUS, true);
 
 #ifdef ZORBA_WITH_JSON
-  JDM_NULL_TYPE_ONE = new AtomicXQType(this,
-                                      store::JDM_NULL,
+  JS_NULL_TYPE_ONE = new AtomicXQType(this,
+                                      store::JS_NULL,
                                       TypeConstants::QUANT_ONE,
                                       true);                   
                                                                
-  JDM_NULL_TYPE_QUESTION = new AtomicXQType(this,              
-                                           store::JDM_NULL,  
+  JS_NULL_TYPE_QUESTION = new AtomicXQType(this,              
+                                           store::JS_NULL,  
                                            TypeConstants::QUANT_QUESTION,
                                            true);              
                                                                
-  JDM_NULL_TYPE_STAR = new AtomicXQType(this,              
-                                       store::JDM_NULL,  
+  JS_NULL_TYPE_STAR = new AtomicXQType(this,              
+                                       store::JS_NULL,  
                                        TypeConstants::QUANT_STAR,
                                        true);                    
                                                                  
-  JDM_NULL_TYPE_PLUS = new AtomicXQType(this,                    
-                                       store::JDM_NULL,        
+  JS_NULL_TYPE_PLUS = new AtomicXQType(this,                    
+                                       store::JS_NULL,        
                                        TypeConstants::QUANT_PLUS,
                                        true);                    
                                                                  
-  m_atomic_typecode_qname_map[store::JDM_NULL] = JDM_NULL_QNAME;
+  m_atomic_typecode_qname_map[store::JS_NULL] = JS_NULL_QNAME;
                                                                       
-  tempQN = JDM_NULL_QNAME.getp();                                 
-  tempCode = store::JDM_NULL;                                       
+  tempQN = JS_NULL_QNAME.getp();                                 
+  tempCode = store::JS_NULL;                                       
   m_atomic_qnametype_map.insert(tempQN, tempCode);                    
                                                                       
-  m_atomic_typecode_map[store::JDM_NULL][TypeConstants::QUANT_ONE] =
-    &JDM_NULL_TYPE_ONE;                                                
+  m_atomic_typecode_map[store::JS_NULL][TypeConstants::QUANT_ONE] =
+    &JS_NULL_TYPE_ONE;                                                
                                                                       
-  m_atomic_typecode_map[store::JDM_NULL][TypeConstants::QUANT_QUESTION] =
-    &JDM_NULL_TYPE_QUESTION;                                                
-                                                                           
-  m_atomic_typecode_map[store::JDM_NULL][TypeConstants::QUANT_STAR] =    
-    &JDM_NULL_TYPE_STAR;                                                    
-                                                                           
-  m_atomic_typecode_map[store::JDM_NULL][TypeConstants::QUANT_PLUS] =    
-    &JDM_NULL_TYPE_PLUS;
+  m_atomic_typecode_map[store::JS_NULL][TypeConstants::QUANT_QUESTION] =
+    &JS_NULL_TYPE_QUESTION;                                                
+                                                                           
+  m_atomic_typecode_map[store::JS_NULL][TypeConstants::QUANT_STAR] =    
+    &JS_NULL_TYPE_STAR;                                                    
+                                                                           
+  m_atomic_typecode_map[store::JS_NULL][TypeConstants::QUANT_PLUS] =    
+    &JS_NULL_TYPE_PLUS;
 
 #define JSON_TYPE_DEFN(basename, kind)                                  \
   basename##_TYPE_ONE = new JSONXQType(this,                            \
@@ -558,7 +558,7 @@
   DELETE_TYPE(STRUCTURED_ITEM)
 
 #ifdef ZORBA_WITH_JSON
-  DELETE_TYPE(JDM_NULL)
+  DELETE_TYPE(JS_NULL)
 
   DELETE_TYPE(JSON_ITEM)
   DELETE_TYPE(JSON_OBJECT)

=== modified file 'src/types/root_typemanager.h'
--- src/types/root_typemanager.h	2012-09-11 22:55:05 +0000
+++ src/types/root_typemanager.h	2012-09-13 13:01:18 +0000
@@ -132,11 +132,11 @@
    *
    * N, N?, N+, N*, where N is the jdm::null atomic type
    */
-  store::Item_t JDM_NULL_QNAME;
-  xqtref_t JDM_NULL_TYPE_ONE;
-  xqtref_t JDM_NULL_TYPE_QUESTION;
-  xqtref_t JDM_NULL_TYPE_STAR;
-  xqtref_t JDM_NULL_TYPE_PLUS;
+  store::Item_t JS_NULL_QNAME;
+  xqtref_t JS_NULL_TYPE_ONE;
+  xqtref_t JS_NULL_TYPE_QUESTION;
+  xqtref_t JS_NULL_TYPE_STAR;
+  xqtref_t JS_NULL_TYPE_PLUS;
 #endif
 
   /**

=== modified file 'src/zorbaserialization/serialize_zorba_types.cpp'
--- src/zorbaserialization/serialize_zorba_types.cpp	2012-09-11 22:55:05 +0000
+++ src/zorbaserialization/serialize_zorba_types.cpp	2012-09-13 13:01:18 +0000
@@ -770,7 +770,7 @@
   }
  
  #ifdef ZORBA_WITH_JSON
-  case store::JDM_NULL:
+  case store::JS_NULL:
   {
     break;
   }
@@ -1076,7 +1076,7 @@
   }
 
  #ifdef ZORBA_WITH_JSON
-  case store::JDM_NULL:
+  case store::JS_NULL:
   {
     store::Item_t lRes;
     GENV_ITEMFACTORY->createJSONNull(lRes);

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/null04.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/null04.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/null04.xml.res	2012-09-13 13:01:18 +0000
@@ -0,0 +1,1 @@
+true

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/null05.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/null05.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/null05.xml.res	2012-09-13 13:01:18 +0000
@@ -0,0 +1,1 @@
+false

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/null06.xml.res'
=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/null07.xml.res'
=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/null08.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/null08.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/null08.xml.res	2012-09-13 13:01:18 +0000
@@ -0,0 +1,1 @@
+true true true true true false false false false false

=== modified file 'test/rbkt/ExpQueryResults/zorba/jsoniq/serializer-JNSE0022.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/serializer-JNSE0022.xml.res	2012-09-10 17:47:37 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/serializer-JNSE0022.xml.res	2012-09-13 13:01:18 +0000
@@ -1,1 +1,1 @@
-html: invalid serialization method for item type (jdm:object) text: invalid serialization method for item type (jdm:object) xml: invalid serialization method for item type (jdm:object) xhtml: invalid serialization method for item type (jdm:object)
+html: invalid serialization method for item type (js:object) text: invalid serialization method for item type (js:object) xml: invalid serialization method for item type (js:object) xhtml: invalid serialization method for item type (js:object)

=== modified file 'test/rbkt/Queries/zorba/jsoniq/null01.xq'
--- test/rbkt/Queries/zorba/jsoniq/null01.xq	2012-01-27 23:00:49 +0000
+++ test/rbkt/Queries/zorba/jsoniq/null01.xq	2012-09-13 13:01:18 +0000
@@ -1,3 +1,1 @@
-import module namespace j = "http://www.jsoniq.org/functions";;
-
-j:null()
+jn:null()

=== modified file 'test/rbkt/Queries/zorba/jsoniq/null02.xq'
--- test/rbkt/Queries/zorba/jsoniq/null02.xq	2012-01-30 18:37:03 +0000
+++ test/rbkt/Queries/zorba/jsoniq/null02.xq	2012-09-13 13:01:18 +0000
@@ -1,3 +1,1 @@
-import module namespace j = "http://www.jsoniq.org/functions";;
-
-j:null() = j:null()
+jn:null() = jn:null()

=== modified file 'test/rbkt/Queries/zorba/jsoniq/null03.xq'
--- test/rbkt/Queries/zorba/jsoniq/null03.xq	2012-01-31 04:17:50 +0000
+++ test/rbkt/Queries/zorba/jsoniq/null03.xq	2012-09-13 13:01:18 +0000
@@ -1,4 +1,2 @@
-import module namespace j = "http://www.jsoniq.org/functions";;
-
-fn:data(j:null())
+fn:data(jn:null())
 

=== added file 'test/rbkt/Queries/zorba/jsoniq/null04.xq'
--- test/rbkt/Queries/zorba/jsoniq/null04.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/null04.xq	2012-09-13 13:01:18 +0000
@@ -0,0 +1,2 @@
+jn:is-null(jn:null())
+

=== added file 'test/rbkt/Queries/zorba/jsoniq/null05.xq'
--- test/rbkt/Queries/zorba/jsoniq/null05.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/null05.xq	2012-09-13 13:01:18 +0000
@@ -0,0 +1,2 @@
+jn:is-null("null")
+

=== added file 'test/rbkt/Queries/zorba/jsoniq/null06.xq'
--- test/rbkt/Queries/zorba/jsoniq/null06.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/null06.xq	2012-09-13 13:01:18 +0000
@@ -0,0 +1,3 @@
+null + 1, null - 1, null * 1, null div 1, null mod 1
+
+

=== added file 'test/rbkt/Queries/zorba/jsoniq/null07.xq'
--- test/rbkt/Queries/zorba/jsoniq/null07.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/null07.xq	2012-09-13 13:01:18 +0000
@@ -0,0 +1,1 @@
+null eq 1, 1 ne null, null le 1, 1 ge null, 1 lt null, null gt 1

=== added file 'test/rbkt/Queries/zorba/jsoniq/null08.xq'
--- test/rbkt/Queries/zorba/jsoniq/null08.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/null08.xq	2012-09-13 13:01:18 +0000
@@ -0,0 +1,10 @@
+(null, 1, 2, null) = (4, null, 1, 6),
+(null, 1, 2, null) < (4, null, 1, 6),
+(null, 1, 2, null) > (4, null, 1, 6),
+(null, 1, 2, null) <= (4, null, 1, 6),
+(null, 1, 2, null) >= (4, null, 1, 6),
+(null, 1, 2) = (3, 4, null),
+(null, 3, 4) < (1, 2, null),
+(null, 1, 2) > (3, 4, null),
+(null, 3, 4) <= (1, 2, null),
+(null, 1, 2) >= (3, 4, null)

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

Reply via email to