← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/markos-scratch into lp:zorba

 

Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/markos-scratch into lp:zorba.

Requested reviews:
  Markos Zaharioudakis (markos-za)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/88057

moved atomic type codes enum to the store api
-- 
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/88057
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/functions/func_accessors_impl.cpp'
--- src/functions/func_accessors_impl.cpp	2012-01-03 12:10:06 +0000
+++ src/functions/func_accessors_impl.cpp	2012-01-10 13:58:38 +0000
@@ -95,13 +95,13 @@
     if (nodeKind == store::StoreConsts::piNode ||
         nodeKind == store::StoreConsts::commentNode)
     {
-      return tm->create_builtin_atomic_type(TypeConstants::XS_STRING, q);
+      return tm->create_builtin_atomic_type(store::XS_STRING, q);
     }
 
     if (nodeKind == store::StoreConsts::documentNode ||
         nodeKind == store::StoreConsts::textNode)
     {
-      return tm->create_builtin_atomic_type(TypeConstants::XS_UNTYPED_ATOMIC, q);
+      return tm->create_builtin_atomic_type(store::XS_UNTYPED_ATOMIC, q);
     }
 
     xqtref_t cType = nType.get_content_type();
@@ -115,7 +115,7 @@
       }
       else if (TypeOps::is_equal(tm, *cType, *RTM.UNTYPED_TYPE))
       {
-        return tm->create_builtin_atomic_type(TypeConstants::XS_UNTYPED_ATOMIC, q);
+        return tm->create_builtin_atomic_type(store::XS_UNTYPED_ATOMIC, q);
       }
       else if (TypeOps::is_subtype(tm, *cType, *RTM.ANY_ATOMIC_TYPE_STAR, loc))
       {

=== modified file 'src/functions/func_booleans_impl.cpp'
--- src/functions/func_booleans_impl.cpp	2012-01-03 12:10:06 +0000
+++ src/functions/func_booleans_impl.cpp	2012-01-10 13:58:38 +0000
@@ -101,13 +101,13 @@
   if (! (TypeOps::is_builtin_atomic(tm, *t0) && TypeOps::is_builtin_atomic(tm, *t1)))
     return NULL;
 
-  TypeConstants::atomic_type_code_t tc0 = TypeOps::get_atomic_type_code(*t0);
-  TypeConstants::atomic_type_code_t tc1 = TypeOps::get_atomic_type_code(*t1);
+  store::SchemaTypeCode tc0 = TypeOps::get_atomic_type_code(*t0);
+  store::SchemaTypeCode tc1 = TypeOps::get_atomic_type_code(*t1);
 
-  if (tc0 == TypeConstants::XS_UNTYPED_ATOMIC ||
-      tc1 == TypeConstants::XS_UNTYPED_ATOMIC ||
-      tc0 == TypeConstants::XS_ANY_ATOMIC ||
-      tc1 == TypeConstants::XS_ANY_ATOMIC)
+  if (tc0 == store::XS_UNTYPED_ATOMIC ||
+      tc1 == store::XS_UNTYPED_ATOMIC ||
+      tc0 == store::XS_ANY_ATOMIC ||
+      tc1 == store::XS_ANY_ATOMIC)
     return NULL;
 
   return toValueComp(sctx);
@@ -200,26 +200,26 @@
 
   if (TypeOps::is_builtin_simple(tm, *t0) && TypeOps::is_builtin_simple(tm, *t1))
   {
-    TypeConstants::atomic_type_code_t tc0 = TypeOps::get_atomic_type_code(*t0);
-    TypeConstants::atomic_type_code_t tc1 = TypeOps::get_atomic_type_code(*t1);
+    store::SchemaTypeCode tc0 = TypeOps::get_atomic_type_code(*t0);
+    store::SchemaTypeCode tc1 = TypeOps::get_atomic_type_code(*t1);
 
     if (tc0 == tc1)
     {
       switch(tc0)
       {
-      case TypeConstants::XS_DOUBLE:
+      case store::XS_DOUBLE:
         SPECIALIZE_VALUE_COMP_FUNCTION(theKind, DOUBLE);
 
-      case TypeConstants::XS_DECIMAL:
+      case store::XS_DECIMAL:
         SPECIALIZE_VALUE_COMP_FUNCTION(theKind, DECIMAL);
 
-      case TypeConstants::XS_FLOAT:
+      case store::XS_FLOAT:
         SPECIALIZE_VALUE_COMP_FUNCTION(theKind, FLOAT);
 
-      case TypeConstants::XS_INTEGER:
+      case store::XS_INTEGER:
         SPECIALIZE_VALUE_COMP_FUNCTION(theKind, INTEGER);
 
-      case TypeConstants::XS_STRING:
+      case store::XS_STRING:
         SPECIALIZE_VALUE_COMP_FUNCTION(theKind, STRING);
 
       default:
@@ -241,7 +241,7 @@
   class op_value_greater : SpecificValueComparison<CompareConsts::GREATER>
 
   class op_value_greater_double : TypedValueComparison<CompareConsts::GREATER,
-                                                       TypeConstants::XS_DOUBLE>
+                                                       store::XS_DOUBLE>
 
 
 ********************************************************************************/
@@ -266,7 +266,7 @@
 };
 
 
-template<enum CompareConsts::CompareType CC, TypeConstants::atomic_type_code_t t>
+template<enum CompareConsts::CompareType CC, store::SchemaTypeCode t>
 class TypedValueComparison : public SpecificValueComparison<CC>
 {
 public:
@@ -291,13 +291,13 @@
 #define DECL_SPECIFIC_TYPED_OP( cc, op, t, xqt )                        \
 class op_value_##op##_##t :                                             \
 public TypedValueComparison<CompareConsts::VALUE_##cc,                  \
-                            TypeConstants::XS_##xqt>                    \
+                            store::XS_##xqt>                            \
 {                                                                       \
 public:                                                                 \
   op_value_##op##_##t(const signature& sig)                             \
     :                                                                   \
     TypedValueComparison<CompareConsts::VALUE_##cc,                     \
-                         TypeConstants::XS_##xqt>                       \
+                         store::XS_##xqt>                               \
     (sig, FunctionConsts::OP_VALUE_##cc##_##xqt##_2)                    \
   {                                                                     \
   }                                                                     \

=== modified file 'src/functions/func_numerics_impl.cpp'
--- src/functions/func_numerics_impl.cpp	2011-12-21 14:40:33 +0000
+++ src/functions/func_numerics_impl.cpp	2012-01-10 13:58:38 +0000
@@ -119,23 +119,23 @@
   if (t0->type_kind() == XQType::ATOMIC_TYPE_KIND &&
       t1->type_kind() == XQType::ATOMIC_TYPE_KIND)
   {
-    TypeConstants::atomic_type_code_t tc0 = TypeOps::get_atomic_type_code(*t0);
-    TypeConstants::atomic_type_code_t tc1 = TypeOps::get_atomic_type_code(*t1);
+    store::SchemaTypeCode tc0 = TypeOps::get_atomic_type_code(*t0);
+    store::SchemaTypeCode tc1 = TypeOps::get_atomic_type_code(*t1);
 
     if (tc0 == tc1)
     {
       switch(tc0)
       {
-      case TypeConstants::XS_DOUBLE:
+      case store::XS_DOUBLE:
         SPECIALIZE_NUMERIC_ARITH_FUNCTION(theKind, DOUBLE);
         break;
-      case TypeConstants::XS_DECIMAL:
+      case store::XS_DECIMAL:
         SPECIALIZE_NUMERIC_ARITH_FUNCTION(theKind, DECIMAL);
         break;
-      case TypeConstants::XS_FLOAT:
+      case store::XS_FLOAT:
         SPECIALIZE_NUMERIC_ARITH_FUNCTION(theKind, FLOAT);
         break;
-      case TypeConstants::XS_INTEGER:
+      case store::XS_INTEGER:
         SPECIALIZE_NUMERIC_ARITH_FUNCTION(theKind, INTEGER);
         break;
       default:
@@ -180,7 +180,7 @@
 };
 
 
-template<TypeConstants::atomic_type_code_t t, FunctionConsts::FunctionKind k>
+template<store::SchemaTypeCode t, FunctionConsts::FunctionKind k>
 class op_numeric_add_specific : public bin_num_arith_func
 {
 public:
@@ -198,25 +198,25 @@
 
 
 typedef
-op_numeric_add_specific<TypeConstants::XS_DOUBLE,
+op_numeric_add_specific<store::XS_DOUBLE,
                         FunctionConsts::OP_NUMERIC_ADD_DOUBLE_2>
 op_numeric_add_double;
 
 
 typedef
-op_numeric_add_specific<TypeConstants::XS_FLOAT,
+op_numeric_add_specific<store::XS_FLOAT,
                         FunctionConsts::OP_NUMERIC_ADD_FLOAT_2>
 op_numeric_add_float;
 
 
 typedef
-op_numeric_add_specific<TypeConstants::XS_DECIMAL,
+op_numeric_add_specific<store::XS_DECIMAL,
                         FunctionConsts::OP_NUMERIC_ADD_DECIMAL_2>
 op_numeric_add_decimal;
 
 
 typedef
-op_numeric_add_specific<TypeConstants::XS_INTEGER,
+op_numeric_add_specific<store::XS_INTEGER,
                         FunctionConsts::OP_NUMERIC_ADD_INTEGER_2>
 op_numeric_add_integer;
 
@@ -254,7 +254,7 @@
 };
 
 
-template<TypeConstants::atomic_type_code_t t, FunctionConsts::FunctionKind k>
+template<store::SchemaTypeCode t, FunctionConsts::FunctionKind k>
 class op_numeric_subtract_specific : public bin_num_arith_func
 {
 public:
@@ -272,25 +272,25 @@
 
 
 typedef
-op_numeric_subtract_specific<TypeConstants::XS_DOUBLE,
+op_numeric_subtract_specific<store::XS_DOUBLE,
                              FunctionConsts::OP_NUMERIC_SUBTRACT_DOUBLE_2>
 op_numeric_subtract_double;
 
 
 typedef
-op_numeric_subtract_specific<TypeConstants::XS_FLOAT,
+op_numeric_subtract_specific<store::XS_FLOAT,
                              FunctionConsts::OP_NUMERIC_SUBTRACT_FLOAT_2>
 op_numeric_subtract_float;
 
 
 typedef
-op_numeric_subtract_specific<TypeConstants::XS_DECIMAL,
+op_numeric_subtract_specific<store::XS_DECIMAL,
                              FunctionConsts::OP_NUMERIC_SUBTRACT_DECIMAL_2>
 op_numeric_subtract_decimal;
 
 
 typedef
-op_numeric_subtract_specific<TypeConstants::XS_INTEGER,
+op_numeric_subtract_specific<store::XS_INTEGER,
                              FunctionConsts::OP_NUMERIC_SUBTRACT_INTEGER_2>
 op_numeric_subtract_integer;
 
@@ -327,7 +327,7 @@
 };
 
 
-template<TypeConstants::atomic_type_code_t t, FunctionConsts::FunctionKind k>
+template<store::SchemaTypeCode t, FunctionConsts::FunctionKind k>
 class op_numeric_multiply_specific : public bin_num_arith_func
 {
 public:
@@ -345,25 +345,25 @@
 
 
 typedef
-op_numeric_multiply_specific<TypeConstants::XS_DOUBLE,
+op_numeric_multiply_specific<store::XS_DOUBLE,
                              FunctionConsts::OP_NUMERIC_MULTIPLY_DOUBLE_2>
 op_numeric_multiply_double;
 
 
 typedef
-op_numeric_multiply_specific<TypeConstants::XS_FLOAT,
+op_numeric_multiply_specific<store::XS_FLOAT,
                              FunctionConsts::OP_NUMERIC_MULTIPLY_FLOAT_2>
 op_numeric_multiply_float;
 
 
 typedef
-op_numeric_multiply_specific<TypeConstants::XS_DECIMAL,
+op_numeric_multiply_specific<store::XS_DECIMAL,
                              FunctionConsts::OP_NUMERIC_MULTIPLY_DECIMAL_2>
 op_numeric_multiply_decimal;
 
 
 typedef
-op_numeric_multiply_specific<TypeConstants::XS_INTEGER,
+op_numeric_multiply_specific<store::XS_INTEGER,
                              FunctionConsts::OP_NUMERIC_MULTIPLY_INTEGER_2>
 op_numeric_multiply_integer;
 
@@ -409,7 +409,7 @@
 };
 
 
-template<TypeConstants::atomic_type_code_t t, FunctionConsts::FunctionKind k>
+template<store::SchemaTypeCode t, FunctionConsts::FunctionKind k>
 class op_numeric_divide_specific : public bin_num_arith_func
 {
 public:
@@ -427,25 +427,25 @@
 
 
 typedef
-op_numeric_divide_specific<TypeConstants::XS_DOUBLE,
+op_numeric_divide_specific<store::XS_DOUBLE,
                            FunctionConsts::OP_NUMERIC_DIVIDE_DOUBLE_2>
 op_numeric_divide_double;
 
 
 typedef
-op_numeric_divide_specific<TypeConstants::XS_FLOAT,
+op_numeric_divide_specific<store::XS_FLOAT,
                            FunctionConsts::OP_NUMERIC_DIVIDE_FLOAT_2>
 op_numeric_divide_float;
 
 
 typedef
-op_numeric_divide_specific<TypeConstants::XS_DECIMAL,
+op_numeric_divide_specific<store::XS_DECIMAL,
                            FunctionConsts::OP_NUMERIC_DIVIDE_DECIMAL_2>
 op_numeric_divide_decimal;
 
 
 typedef
-op_numeric_divide_specific<TypeConstants::XS_INTEGER,
+op_numeric_divide_specific<store::XS_INTEGER,
                            FunctionConsts::OP_NUMERIC_DIVIDE_INTEGER_2>
 op_numeric_divide_integer;
 

=== modified file 'src/runtime/booleans/BooleanImpl.cpp'
--- src/runtime/booleans/BooleanImpl.cpp	2011-12-30 17:55:53 +0000
+++ src/runtime/booleans/BooleanImpl.cpp	2012-01-10 13:58:38 +0000
@@ -58,11 +58,11 @@
 SERIALIZABLE_TEMPLATE_VERSIONS(TypedValueCompareIterator)
 END_SERIALIZABLE_TEMPLATE_VERSIONS(TypedValueCompareIterator)
 
-SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS(TypedValueCompareIterator, TypedValueCompareIterator<TypeConstants::XS_DOUBLE>, 1)
-SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS(TypedValueCompareIterator, TypedValueCompareIterator<TypeConstants::XS_FLOAT>, 2)
-SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS(TypedValueCompareIterator, TypedValueCompareIterator<TypeConstants::XS_DECIMAL>, 3)
-SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS(TypedValueCompareIterator, TypedValueCompareIterator<TypeConstants::XS_INTEGER>, 4)
-SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS(TypedValueCompareIterator, TypedValueCompareIterator<TypeConstants::XS_STRING>, 5)
+SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS(TypedValueCompareIterator, TypedValueCompareIterator<store::XS_DOUBLE>, 1)
+SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS(TypedValueCompareIterator, TypedValueCompareIterator<store::XS_FLOAT>, 2)
+SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS(TypedValueCompareIterator, TypedValueCompareIterator<store::XS_DECIMAL>, 3)
+SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS(TypedValueCompareIterator, TypedValueCompareIterator<store::XS_INTEGER>, 4)
+SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS(TypedValueCompareIterator, TypedValueCompareIterator<store::XS_STRING>, 5)
 
 SERIALIZABLE_CLASS_VERSIONS(AtomicValuesEquivalenceIterator)
 END_SERIALIZABLE_CLASS_VERSIONS(AtomicValuesEquivalenceIterator)
@@ -872,14 +872,8 @@
     }
     else
     {
-      throw XQUERY_EXCEPTION(
-        err::XPTY0004,
-        ERROR_PARAMS(
-          ZED( BadType_23o ), *type0,
-          ZED( NoCompareWithType_4 ), *type1
-        ),
-        ERROR_LOC( loc )
-      );
+      RAISE_ERROR(err::XPTY0004, loc,
+      ERROR_PARAMS(ZED(BadType_23o), *type0, ZED(NoCompareWithType_4), *type1));
     }
   }
 }
@@ -925,14 +919,8 @@
       }
       else
       {
-        throw XQUERY_EXCEPTION(
-          err::XPTY0004,
-          ERROR_PARAMS(
-            ZED( BadType_23o ), *type0,
-            ZED( NoCompareWithType_4 ), *type1
-          ),
-          ERROR_LOC( loc )
-        );
+        RAISE_ERROR(err::XPTY0004, loc,
+        ERROR_PARAMS(ZED(BadType_23o), *type0, ZED(NoCompareWithType_4), *type1));
       }
     }
     else if (TypeOps::is_subtype(tm, *type1, *type0))
@@ -955,14 +943,8 @@
       }
       else
       {
-        throw XQUERY_EXCEPTION(
-          err::XPTY0004,
-          ERROR_PARAMS(
-            ZED( BadType_23o ), *type0,
-            ZED( NoCompareWithType_4 ), *type1
-          ),
-          ERROR_LOC( loc )
-        );
+        RAISE_ERROR(err::XPTY0004, loc,
+        ERROR_PARAMS(ZED(BadType_23o), *type0, ZED(NoCompareWithType_4), *type1));
       }
     }
   }
@@ -971,14 +953,8 @@
     // For example, two QName items do not have an order relationship.
     if (e.diagnostic() == zerr::ZSTR0040_TYPE_ERROR)
     {
-      throw XQUERY_EXCEPTION(
-        err::XPTY0004,
-        ERROR_PARAMS(
-          ZED( BadType_23o ), *type0,
-          ZED( NoCompareWithType_4 ), *type1
-        ),
-        ERROR_LOC( loc )
-      );
+      RAISE_ERROR(err::XPTY0004, loc,
+      ERROR_PARAMS(ZED(BadType_23o), *type0, ZED(NoCompareWithType_4), *type1));
     }
     throw;
   }
@@ -992,7 +968,7 @@
 /////////////////////////////////////////////////////////////////////////////////
 
 
-template <TypeConstants::atomic_type_code_t ATC>
+template <store::SchemaTypeCode ATC>
 void TypedValueCompareIterator<ATC>::accept(PlanIterVisitor& v) const
 {
   v.beginVisit(*this);
@@ -1008,7 +984,7 @@
 }
 
 
-template<TypeConstants::atomic_type_code_t ATC>
+template<store::SchemaTypeCode ATC>
 void TypedValueCompareIterator<ATC>::openImpl(PlanState& planState, uint32_t& offset)
 {
   NaryBaseIterator<TypedValueCompareIterator, PlanIteratorState>
@@ -1019,7 +995,7 @@
 }
 
 
-template<TypeConstants::atomic_type_code_t ATC>
+template<store::SchemaTypeCode ATC>
 bool TypedValueCompareIterator<ATC>::nextImpl(
     store::Item_t& result,
     PlanState& planState) const
@@ -1092,11 +1068,11 @@
 }
 
 
-template class TypedValueCompareIterator<TypeConstants::XS_DOUBLE>;
-template class TypedValueCompareIterator<TypeConstants::XS_FLOAT>;
-template class TypedValueCompareIterator<TypeConstants::XS_DECIMAL>;
-template class TypedValueCompareIterator<TypeConstants::XS_INTEGER>;
-template class TypedValueCompareIterator<TypeConstants::XS_STRING>;
+template class TypedValueCompareIterator<store::XS_DOUBLE>;
+template class TypedValueCompareIterator<store::XS_FLOAT>;
+template class TypedValueCompareIterator<store::XS_DECIMAL>;
+template class TypedValueCompareIterator<store::XS_INTEGER>;
+template class TypedValueCompareIterator<store::XS_STRING>;
 
 
 

=== modified file 'src/runtime/booleans/BooleanImpl.h'
--- src/runtime/booleans/BooleanImpl.h	2011-06-14 17:26:33 +0000
+++ src/runtime/booleans/BooleanImpl.h	2012-01-10 13:58:38 +0000
@@ -284,7 +284,7 @@
 /*******************************************************************************
 
 ********************************************************************************/
-template <TypeConstants::atomic_type_code_t ATC>
+template <store::SchemaTypeCode ATC>
 class TypedValueCompareIterator : public NaryBaseIterator<TypedValueCompareIterator<ATC>,
                                                           PlanIteratorState>
 {

=== modified file 'src/runtime/core/arithmetic_impl.cpp'
--- src/runtime/core/arithmetic_impl.cpp	2011-06-14 17:26:33 +0000
+++ src/runtime/core/arithmetic_impl.cpp	2012-01-10 13:58:38 +0000
@@ -55,8 +55,8 @@
     const TypeManager* tm,
     const char* aOp, 
     const QueryLoc* aLoc, 
-    TypeConstants::atomic_type_code_t aType0,
-    TypeConstants::atomic_type_code_t aType1)
+    store::SchemaTypeCode aType0,
+    store::SchemaTypeCode aType1)
 {
   xqtref_t t0 = tm->create_builtin_atomic_type(aType0,TypeConstants::QUANT_ONE);
   xqtref_t t1 = tm->create_builtin_atomic_type(aType1,TypeConstants::QUANT_ONE);
@@ -164,13 +164,13 @@
     if (TypeOps::is_subtype(tm, *type1, *rtm.YM_DURATION_TYPE_ONE))
     {
       return Operation::template
-             compute<TypeConstants::XS_DOUBLE, TypeConstants::XS_YM_DURATION>
+             compute<store::XS_DOUBLE, store::XS_YM_DURATION>
              (result, dctx, tm, &aLoc, n0, n1);
     }
     else
     {
       return Operation::template
-             compute<TypeConstants::XS_DOUBLE,TypeConstants::XS_DT_DURATION>
+             compute<store::XS_DOUBLE,store::XS_DT_DURATION>
              (result, dctx, tm, &aLoc, n0, n1);
     }
   }
@@ -178,7 +178,7 @@
            TypeOps::is_subtype(tm, *type1, *rtm.TIME_TYPE_ONE))
   {
     return Operation::template
-           compute<TypeConstants::XS_DURATION,TypeConstants::XS_TIME>
+           compute<store::XS_DURATION,store::XS_TIME>
            (result, dctx, tm, &aLoc, n0, n1);
   }
   else if (TypeOps::is_subtype(tm, *type0, *rtm.YM_DURATION_TYPE_ONE))
@@ -187,25 +187,25 @@
     {
       GenericCast::castToAtomic(n1, n1, &*rtm.DOUBLE_TYPE_ONE, tm, NULL, aLoc);
       return Operation::template
-             compute<TypeConstants::XS_YM_DURATION,TypeConstants::XS_DOUBLE>
+             compute<store::XS_YM_DURATION,store::XS_DOUBLE>
              (result, dctx, tm, &aLoc, n0, n1);
     }
     else if (TypeOps::is_subtype(tm, *type1, *rtm.DATETIME_TYPE_ONE))
     {
       return Operation::template
-             compute<TypeConstants::XS_DURATION,TypeConstants::XS_DATETIME>
+             compute<store::XS_DURATION,store::XS_DATETIME>
              (result, dctx, tm, &aLoc, n0, n1);
     }
     else if (TypeOps::is_subtype(tm, *type1, *rtm.DATE_TYPE_ONE))
     {
       return Operation::template
-             compute<TypeConstants::XS_DURATION,TypeConstants::XS_DATE>
+             compute<store::XS_DURATION,store::XS_DATE>
              (result, dctx, tm, &aLoc, n0, n1);
     }
     else if (TypeOps::is_equal(tm, *type0, *type1))
     {
       return Operation::template
-      computeSingleType<TypeConstants::XS_YM_DURATION>
+      computeSingleType<store::XS_YM_DURATION>
       (result, dctx, tm, &aLoc, n0, n1);
     }
   }
@@ -216,25 +216,25 @@
       GenericCast::castToAtomic(n1, n1, &*rtm.DOUBLE_TYPE_ONE, tm, NULL, aLoc);
 
       return Operation::template
-             compute<TypeConstants::XS_DT_DURATION,TypeConstants::XS_DOUBLE>
+             compute<store::XS_DT_DURATION,store::XS_DOUBLE>
              (result, dctx, tm, &aLoc, n0, n1);
     }
     else if (TypeOps::is_subtype(tm, *type1, *rtm.DATETIME_TYPE_ONE))
     {
       return Operation::template 
-             compute<TypeConstants::XS_DURATION,TypeConstants::XS_DATETIME>
+             compute<store::XS_DURATION,store::XS_DATETIME>
              (result, dctx, tm, &aLoc, n0, n1);
     }
     else if (TypeOps::is_subtype(tm, *type1, *rtm.DATE_TYPE_ONE))
     {
       return Operation::template
-             compute<TypeConstants::XS_DURATION,TypeConstants::XS_DATE>
+             compute<store::XS_DURATION,store::XS_DATE>
              (result, dctx, tm, &aLoc, n0, n1);
     }
     else if (TypeOps::is_equal(tm, *type0, *type1))
     {
       return Operation::template
-             computeSingleType<TypeConstants::XS_DT_DURATION>
+             computeSingleType<store::XS_DT_DURATION>
              (result, dctx, tm, &aLoc, n0, n1);
     }
   }
@@ -243,13 +243,13 @@
     if(TypeOps::is_subtype(tm, *type1, *rtm.DATETIME_TYPE_ONE))
     {
       return Operation::template
-             compute<TypeConstants::XS_DATETIME,TypeConstants::XS_DATETIME>
+             compute<store::XS_DATETIME,store::XS_DATETIME>
              (result, dctx, tm, &aLoc, n0, n1);
     }
     else if (TypeOps::is_subtype(tm, *type1, *rtm.DURATION_TYPE_ONE ))
     {
       return Operation::template
-             compute<TypeConstants::XS_DATETIME,TypeConstants::XS_DURATION>
+             compute<store::XS_DATETIME,store::XS_DURATION>
             (result, dctx, tm, &aLoc, n0, n1);
     }
   }
@@ -258,13 +258,13 @@
     if (TypeOps::is_subtype(tm, *type1, *rtm.DATE_TYPE_ONE))
     {
       return Operation::template
-             compute<TypeConstants::XS_DATE,TypeConstants::XS_DATE>
+             compute<store::XS_DATE,store::XS_DATE>
              (result, dctx, tm, &aLoc, n0, n1);
     }
     else if (TypeOps::is_subtype(tm, *type1, *rtm.DURATION_TYPE_ONE))
     {
       return Operation::template
-             compute<TypeConstants::XS_DATE,TypeConstants::XS_DURATION>
+             compute<store::XS_DATE,store::XS_DURATION>
              (result, dctx, tm, &aLoc, n0, n1);
     }
   }
@@ -273,13 +273,13 @@
     if(TypeOps::is_subtype(tm, *type1, *rtm.TIME_TYPE_ONE))
     {
       return Operation::template
-             compute<TypeConstants::XS_TIME,TypeConstants::XS_TIME>
+             compute<store::XS_TIME,store::XS_TIME>
              (result, dctx, tm, &aLoc, n0, n1);
     }
     else if (TypeOps::is_subtype(tm, *type1, *rtm.DT_DURATION_TYPE_ONE))
     {
       return Operation::template 
-             compute<TypeConstants::XS_TIME,TypeConstants::XS_DURATION>
+             compute<store::XS_TIME,store::XS_DURATION>
              (result, dctx, tm, &aLoc, n0, n1);
     }
   }
@@ -308,7 +308,7 @@
 ********************************************************************************/
 
 template<>
-bool AddOperation::compute<TypeConstants::XS_YM_DURATION,TypeConstants::XS_YM_DURATION>
+bool AddOperation::compute<store::XS_YM_DURATION,store::XS_YM_DURATION>
  ( store::Item_t& result,
    dynamic_context* dctx,
    const TypeManager* tm,
@@ -322,7 +322,7 @@
 
 
 template<>
-bool AddOperation::compute<TypeConstants::XS_DT_DURATION,TypeConstants::XS_DT_DURATION>
+bool AddOperation::compute<store::XS_DT_DURATION,store::XS_DT_DURATION>
 ( store::Item_t& result,
   dynamic_context* dctx,
   const TypeManager* tm,
@@ -336,7 +336,7 @@
 
 
 template<>
-bool AddOperation::compute<TypeConstants::XS_DATETIME,TypeConstants::XS_DURATION>(
+bool AddOperation::compute<store::XS_DATETIME,store::XS_DURATION>(
     store::Item_t& result,
     dynamic_context* dctx,
     const TypeManager* tm,
@@ -350,7 +350,7 @@
 
 
 template<>
-bool AddOperation::compute<TypeConstants::XS_DURATION,TypeConstants::XS_DATETIME>(
+bool AddOperation::compute<store::XS_DURATION,store::XS_DATETIME>(
     store::Item_t& result,
     dynamic_context* dctx,
     const TypeManager* tm,
@@ -364,7 +364,7 @@
 
 
 template<>
-bool AddOperation::compute<TypeConstants::XS_DATE,TypeConstants::XS_DURATION>
+bool AddOperation::compute<store::XS_DATE,store::XS_DURATION>
 ( store::Item_t& result,
   dynamic_context* dctx,
   const TypeManager* tm,
@@ -378,7 +378,7 @@
 
 
 template<>
-bool AddOperation::compute<TypeConstants::XS_DURATION,TypeConstants::XS_DATE>
+bool AddOperation::compute<store::XS_DURATION,store::XS_DATE>
 ( store::Item_t& result,
   dynamic_context* dctx,
   const TypeManager* tm,
@@ -392,7 +392,7 @@
 
 
 template<>
-bool AddOperation::compute<TypeConstants::XS_TIME,TypeConstants::XS_DURATION>
+bool AddOperation::compute<store::XS_TIME,store::XS_DURATION>
 ( store::Item_t& result,
   dynamic_context* dctx,
   const TypeManager* tm,
@@ -406,7 +406,7 @@
 
 
 template<>
-bool AddOperation::compute<TypeConstants::XS_DURATION,TypeConstants::XS_TIME>
+bool AddOperation::compute<store::XS_DURATION,store::XS_TIME>
 ( store::Item_t& result,
   dynamic_context* dctx,
   const TypeManager* tm,
@@ -424,7 +424,7 @@
 ********************************************************************************/
 
 template<>
-bool SubtractOperation::compute<TypeConstants::XS_YM_DURATION,TypeConstants::XS_YM_DURATION>(
+bool SubtractOperation::compute<store::XS_YM_DURATION,store::XS_YM_DURATION>(
     store::Item_t& result,
     dynamic_context* dctx,
     const TypeManager* tm,
@@ -440,7 +440,7 @@
 
 
 template<>
-bool SubtractOperation::compute<TypeConstants::XS_DT_DURATION,TypeConstants::XS_DT_DURATION>(
+bool SubtractOperation::compute<store::XS_DT_DURATION,store::XS_DT_DURATION>(
     store::Item_t& result,
     dynamic_context* dctx,
     const TypeManager* tm,
@@ -456,7 +456,7 @@
 
 
 template<>
-bool SubtractOperation::compute<TypeConstants::XS_DATETIME,TypeConstants::XS_DURATION>(
+bool SubtractOperation::compute<store::XS_DATETIME,store::XS_DURATION>(
     store::Item_t& result,
     dynamic_context* dctx,
     const TypeManager* tm,
@@ -470,7 +470,7 @@
 
 
 template<>
-bool SubtractOperation::compute<TypeConstants::XS_DATE,TypeConstants::XS_DURATION>(
+bool SubtractOperation::compute<store::XS_DATE,store::XS_DURATION>(
     store::Item_t& result,
     dynamic_context* dctx,
     const TypeManager* tm,
@@ -484,7 +484,7 @@
 
 
 template<>
-bool SubtractOperation::compute<TypeConstants::XS_TIME,TypeConstants::XS_DURATION>(
+bool SubtractOperation::compute<store::XS_TIME,store::XS_DURATION>(
     store::Item_t& result,
     dynamic_context* dctx,
     const TypeManager* tm,
@@ -498,7 +498,7 @@
 
 
 template<>
-bool SubtractOperation::compute<TypeConstants::XS_DATETIME,TypeConstants::XS_DATETIME>(
+bool SubtractOperation::compute<store::XS_DATETIME,store::XS_DATETIME>(
     store::Item_t& result,
     dynamic_context* dctx,
     const TypeManager* tm,
@@ -521,7 +521,7 @@
 
 
 template<>
-bool SubtractOperation::compute<TypeConstants::XS_DATE,TypeConstants::XS_DATE>(
+bool SubtractOperation::compute<store::XS_DATE,store::XS_DATE>(
     store::Item_t& result,
     dynamic_context* dctx,
     const TypeManager* tm,
@@ -544,7 +544,7 @@
 
 
 template<>
-bool SubtractOperation::compute<TypeConstants::XS_TIME,TypeConstants::XS_TIME>(
+bool SubtractOperation::compute<store::XS_TIME,store::XS_TIME>(
     store::Item_t& result,
     dynamic_context* dctx,
     const TypeManager* tm,
@@ -571,7 +571,7 @@
 ********************************************************************************/
 
 template<>
-bool MultiplyOperation::compute<TypeConstants::XS_YM_DURATION,TypeConstants::XS_DOUBLE>(
+bool MultiplyOperation::compute<store::XS_YM_DURATION,store::XS_DOUBLE>(
     store::Item_t& result,
     dynamic_context* dctx,
     const TypeManager* tm,
@@ -593,7 +593,7 @@
 
 
 template<>
-bool MultiplyOperation::compute<TypeConstants::XS_DT_DURATION,TypeConstants::XS_DOUBLE>(
+bool MultiplyOperation::compute<store::XS_DT_DURATION,store::XS_DOUBLE>(
     store::Item_t& result,
     dynamic_context* dctx,
     const TypeManager* tm,
@@ -615,7 +615,7 @@
 
 
 template<>
-bool MultiplyOperation::compute<TypeConstants::XS_DOUBLE,TypeConstants::XS_YM_DURATION>(
+bool MultiplyOperation::compute<store::XS_DOUBLE,store::XS_YM_DURATION>(
     store::Item_t& result,
     dynamic_context* dctx,
     const TypeManager* tm,
@@ -623,12 +623,12 @@
     const store::Item* i0,
     const store::Item* i1)
 {
-  return MultiplyOperation::compute<TypeConstants::XS_YM_DURATION,TypeConstants::XS_DOUBLE>(result, dctx, tm, loc, i1, i0);
+  return MultiplyOperation::compute<store::XS_YM_DURATION,store::XS_DOUBLE>(result, dctx, tm, loc, i1, i0);
 }
 
 
 template<>
-bool MultiplyOperation::compute<TypeConstants::XS_DOUBLE,TypeConstants::XS_DT_DURATION>
+bool MultiplyOperation::compute<store::XS_DOUBLE,store::XS_DT_DURATION>
 ( store::Item_t& result,
   dynamic_context* dctx,
   const TypeManager* tm,
@@ -636,7 +636,7 @@
   const store::Item* i0,
   const store::Item* i1 )
 {
-  return MultiplyOperation::compute<TypeConstants::XS_DT_DURATION,TypeConstants::XS_DOUBLE>(result, dctx, tm, loc, i1, i0);
+  return MultiplyOperation::compute<store::XS_DT_DURATION,store::XS_DOUBLE>(result, dctx, tm, loc, i1, i0);
 }
 
 
@@ -645,7 +645,7 @@
 ********************************************************************************/
 
 template<>
-bool DivideOperation::compute<TypeConstants::XS_YM_DURATION,TypeConstants::XS_DOUBLE>(
+bool DivideOperation::compute<store::XS_YM_DURATION,store::XS_DOUBLE>(
     store::Item_t& result,
     dynamic_context* dctx,
     const TypeManager* tm,
@@ -671,7 +671,7 @@
 
 
 template<>
-bool DivideOperation::compute<TypeConstants::XS_DT_DURATION,TypeConstants::XS_DOUBLE>
+bool DivideOperation::compute<store::XS_DT_DURATION,store::XS_DOUBLE>
 ( store::Item_t& result,
   dynamic_context* dctx,
   const TypeManager* tm,
@@ -697,7 +697,7 @@
 
 
 template<>
-bool DivideOperation::compute<TypeConstants::XS_YM_DURATION,TypeConstants::XS_YM_DURATION>
+bool DivideOperation::compute<store::XS_YM_DURATION, store::XS_YM_DURATION>
 ( store::Item_t& result,
   dynamic_context* dctx,
   const TypeManager* tm,
@@ -711,7 +711,7 @@
 
 
 template<>
-bool DivideOperation::compute<TypeConstants::XS_DT_DURATION,TypeConstants::XS_DT_DURATION>(
+bool DivideOperation::compute<store::XS_DT_DURATION, store::XS_DT_DURATION>(
     store::Item_t& result,
     dynamic_context* dctx,
     const TypeManager* tm,

=== modified file 'src/runtime/core/arithmetic_impl.h'
--- src/runtime/core/arithmetic_impl.h	2011-06-14 17:26:33 +0000
+++ src/runtime/core/arithmetic_impl.h	2012-01-10 13:58:38 +0000
@@ -19,12 +19,15 @@
 
 #include "common/shared_types.h"
 
-#include "types/typeconstants.h"
+//#include "types/typeconstants.h"
 
 #include "compiler/expression/expr_consts.h"
 
 #include "runtime/base/binarybase.h" 
 
+#include "store/api/xs_type_codes.h"
+
+
 namespace zorba {
 
 /**
@@ -37,8 +40,8 @@
       const TypeManager* tm,
       const char* aOp, 
       const QueryLoc*, 
-      TypeConstants::atomic_type_code_t aType0,
-      TypeConstants::atomic_type_code_t aType1
+      store::SchemaTypeCode aType0,
+      store::SchemaTypeCode aType1
   );
 };
 
@@ -56,7 +59,7 @@
     return ArithmeticConsts::ADDITION;
   }
 
-  template<TypeConstants::atomic_type_code_t ATC0, TypeConstants::atomic_type_code_t ATC1>
+  template<store::SchemaTypeCode ATC0, store::SchemaTypeCode ATC1>
   static bool compute(
         store::Item_t& result,
         dynamic_context* dctx,
@@ -69,7 +72,7 @@
     return 0;
   }
 
-  template<TypeConstants::atomic_type_code_t ATC>
+  template<store::SchemaTypeCode ATC>
   static bool computeSingleType(
         store::Item_t& result,
         dynamic_context* dctx,
@@ -97,7 +100,7 @@
   }
 
 public:
-  template<TypeConstants::atomic_type_code_t ATC0, TypeConstants::atomic_type_code_t ATC1>
+  template<store::SchemaTypeCode ATC0, store::SchemaTypeCode ATC1>
   static bool compute(
         store::Item_t& result,
         dynamic_context* dctx,
@@ -110,7 +113,7 @@
     return 0;
   }
 
-  template<TypeConstants::atomic_type_code_t ATC>
+  template<store::SchemaTypeCode ATC>
   static bool computeSingleType(
         store::Item_t& result,
         dynamic_context* dctx,
@@ -138,7 +141,7 @@
   }
 
 public:
-  template<TypeConstants::atomic_type_code_t ATC0, TypeConstants::atomic_type_code_t ATC1>
+  template<store::SchemaTypeCode ATC0, store::SchemaTypeCode ATC1>
   static bool compute(
         store::Item_t& result,
         dynamic_context* dctx,
@@ -151,7 +154,7 @@
     return 0;
   }
 
-  template<TypeConstants::atomic_type_code_t ATC>
+  template<store::SchemaTypeCode ATC>
   static bool computeSingleType(
         store::Item_t& result,
         dynamic_context* dctx,
@@ -179,7 +182,7 @@
   }
 
 public:
-  template<TypeConstants::atomic_type_code_t ATC0, TypeConstants::atomic_type_code_t ATC1>
+  template<store::SchemaTypeCode ATC0, store::SchemaTypeCode ATC1>
   static bool compute(
         store::Item_t& result,
         dynamic_context* dctx,
@@ -192,7 +195,7 @@
     return 0;
   }
 
-  template<TypeConstants::atomic_type_code_t ATC>
+  template<store::SchemaTypeCode ATC>
   static bool computeSingleType(
         store::Item_t& result,
         dynamic_context* dctx,
@@ -219,7 +222,7 @@
   }
 
 public:
-  template<TypeConstants::atomic_type_code_t ATC0, TypeConstants::atomic_type_code_t ATC1>
+  template<store::SchemaTypeCode ATC0, store::SchemaTypeCode ATC1>
   static bool compute(
         store::Item_t& result,
         dynamic_context* dctx,
@@ -232,7 +235,7 @@
     return 0;
   }
 
-  template<TypeConstants::atomic_type_code_t ATC>
+  template<store::SchemaTypeCode ATC>
   static bool computeSingleType(
         store::Item_t& result,
         dynamic_context* dctx,
@@ -259,7 +262,7 @@
   }
 
 public:
-  template<TypeConstants::atomic_type_code_t ATC0, TypeConstants::atomic_type_code_t ATC1>
+  template<store::SchemaTypeCode ATC0, store::SchemaTypeCode ATC1>
   static bool compute(
         store::Item_t& result,
         dynamic_context* dctx,
@@ -272,7 +275,7 @@
     return 0;
   }
 
-  template<TypeConstants::atomic_type_code_t ATC>
+  template<store::SchemaTypeCode ATC>
   static bool computeSingleType(
         store::Item_t& result,
         dynamic_context* dctx,

=== modified file 'src/runtime/numerics/NumericsImpl.cpp'
--- src/runtime/numerics/NumericsImpl.cpp	2011-07-10 14:04:53 +0000
+++ src/runtime/numerics/NumericsImpl.cpp	2012-01-10 13:58:38 +0000
@@ -53,26 +53,26 @@
 
 SERIALIZABLE_TEMPLATE_VERSIONS(SpecificNumArithIterator)
 END_SERIALIZABLE_TEMPLATE_VERSIONS(SpecificNumArithIterator)
-SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<AddOperation, TypeConstants::XS_DOUBLE>, 1);
-SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<AddOperation, TypeConstants::XS_FLOAT>, 2);
-SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<AddOperation, TypeConstants::XS_DECIMAL>, 3);
-SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<AddOperation, TypeConstants::XS_INTEGER>, 4);
-SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<SubtractOperation, TypeConstants::XS_DOUBLE>, 5);
-SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<SubtractOperation, TypeConstants::XS_FLOAT>, 6);
-SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<SubtractOperation, TypeConstants::XS_DECIMAL>, 7);
-SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<SubtractOperation, TypeConstants::XS_INTEGER>, 8);
-SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<MultiplyOperation, TypeConstants::XS_DOUBLE>, 9);
-SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<MultiplyOperation, TypeConstants::XS_FLOAT>, 10);
-SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<MultiplyOperation, TypeConstants::XS_DECIMAL>, 11);
-SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<MultiplyOperation, TypeConstants::XS_INTEGER>, 12);
-SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<DivideOperation, TypeConstants::XS_DOUBLE>, 13);
-SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<DivideOperation, TypeConstants::XS_FLOAT>, 14);
-SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<DivideOperation, TypeConstants::XS_DECIMAL>, 15);
-SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<DivideOperation, TypeConstants::XS_INTEGER>, 16);
-SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<ModOperation, TypeConstants::XS_DOUBLE>, 17);
-SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<ModOperation, TypeConstants::XS_FLOAT>, 18);
-SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<ModOperation, TypeConstants::XS_DECIMAL>, 19);
-SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<ModOperation, TypeConstants::XS_INTEGER>, 20);
+SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<AddOperation, store::XS_DOUBLE>, 1);
+SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<AddOperation, store::XS_FLOAT>, 2);
+SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<AddOperation, store::XS_DECIMAL>, 3);
+SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<AddOperation, store::XS_INTEGER>, 4);
+SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<SubtractOperation, store::XS_DOUBLE>, 5);
+SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<SubtractOperation, store::XS_FLOAT>, 6);
+SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<SubtractOperation, store::XS_DECIMAL>, 7);
+SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<SubtractOperation, store::XS_INTEGER>, 8);
+SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<MultiplyOperation, store::XS_DOUBLE>, 9);
+SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<MultiplyOperation, store::XS_FLOAT>, 10);
+SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<MultiplyOperation, store::XS_DECIMAL>, 11);
+SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<MultiplyOperation, store::XS_INTEGER>, 12);
+SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<DivideOperation, store::XS_DOUBLE>, 13);
+SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<DivideOperation, store::XS_FLOAT>, 14);
+SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<DivideOperation, store::XS_DECIMAL>, 15);
+SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<DivideOperation, store::XS_INTEGER>, 16);
+SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<ModOperation, store::XS_DOUBLE>, 17);
+SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<ModOperation, store::XS_FLOAT>, 18);
+SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<ModOperation, store::XS_DECIMAL>, 19);
+SERIALIZABLE_TEMPLATE_INSTANCE_VERSIONS2(SpecificNumArithIterator, SpecificNumArithIterator<ModOperation, store::XS_INTEGER>, 20);
 
 
 SERIALIZABLE_CLASS_VERSIONS(OpNumericUnaryIterator)
@@ -85,7 +85,7 @@
   AddOperation (see runtime/core/arithmetic_impl.h/cpp)
 ********************************************************************************/
 template<>
-bool AddOperation::compute<TypeConstants::XS_DOUBLE, TypeConstants::XS_DOUBLE>(
+bool AddOperation::compute<store::XS_DOUBLE, store::XS_DOUBLE>(
     store::Item_t& result,
     dynamic_context* /* dctx */,
     const TypeManager* /* tm */,
@@ -99,7 +99,7 @@
 
 
 template<>
-bool AddOperation::compute<TypeConstants::XS_FLOAT,TypeConstants::XS_FLOAT>(
+bool AddOperation::compute<store::XS_FLOAT,store::XS_FLOAT>(
     store::Item_t& result,
     dynamic_context* /* dctx */,
     const TypeManager* /* tm */,
@@ -113,7 +113,7 @@
 
 
 template<>
-bool AddOperation::compute<TypeConstants::XS_DECIMAL,TypeConstants::XS_DECIMAL>(
+bool AddOperation::compute<store::XS_DECIMAL,store::XS_DECIMAL>(
     store::Item_t& result,
     dynamic_context* /* dctx */,
     const TypeManager* /* tm */,
@@ -127,7 +127,7 @@
 
 
 template<>
-bool AddOperation::compute<TypeConstants::XS_INTEGER,TypeConstants::XS_INTEGER>(
+bool AddOperation::compute<store::XS_INTEGER,store::XS_INTEGER>(
     store::Item_t& result,
     dynamic_context* /* dctx */,
     const TypeManager* /* tm */,
@@ -144,7 +144,7 @@
   SubtractOperation (see runtime/core/arithmetic_impl.h/cpp)
 ********************************************************************************/
 template<>
-bool SubtractOperation::compute<TypeConstants::XS_DOUBLE,TypeConstants::XS_DOUBLE>(
+bool SubtractOperation::compute<store::XS_DOUBLE,store::XS_DOUBLE>(
     store::Item_t& result,
     dynamic_context* /* dctx */,
     const TypeManager* /* tm */,
@@ -158,7 +158,7 @@
 
 
 template<>
-bool SubtractOperation::compute<TypeConstants::XS_FLOAT,TypeConstants::XS_FLOAT>(
+bool SubtractOperation::compute<store::XS_FLOAT,store::XS_FLOAT>(
     store::Item_t& result,
     dynamic_context* /* dctx */,
     const TypeManager* /* tm */,
@@ -172,7 +172,7 @@
 
 
 template<>
-bool SubtractOperation::compute<TypeConstants::XS_DECIMAL,TypeConstants::XS_DECIMAL>(
+bool SubtractOperation::compute<store::XS_DECIMAL,store::XS_DECIMAL>(
     store::Item_t& result,
     dynamic_context* /* dctx */,
     const TypeManager* /* tm */,
@@ -186,7 +186,7 @@
 
 
 template<>
-bool SubtractOperation::compute<TypeConstants::XS_INTEGER,TypeConstants::XS_INTEGER>(
+bool SubtractOperation::compute<store::XS_INTEGER,store::XS_INTEGER>(
     store::Item_t& result,
     dynamic_context* /* dctx */,
     const TypeManager* /* tm */,
@@ -203,7 +203,7 @@
   MultiplyOperation (see runtime/core/arithmetic_impl.h/cpp)
 ********************************************************************************/
 template<>
-bool MultiplyOperation::compute<TypeConstants::XS_DOUBLE,TypeConstants::XS_DOUBLE>(
+bool MultiplyOperation::compute<store::XS_DOUBLE,store::XS_DOUBLE>(
     store::Item_t& result,
     dynamic_context* /* dctx */,
     const TypeManager* /* tm */,
@@ -217,7 +217,7 @@
 
 
 template<>
-bool MultiplyOperation::compute<TypeConstants::XS_FLOAT,TypeConstants::XS_FLOAT>(
+bool MultiplyOperation::compute<store::XS_FLOAT,store::XS_FLOAT>(
     store::Item_t& result,
     dynamic_context* /* dctx */,
     const TypeManager* /* tm */,
@@ -231,7 +231,7 @@
 
 
 template<>
-bool MultiplyOperation::compute<TypeConstants::XS_DECIMAL,TypeConstants::XS_DECIMAL>(
+bool MultiplyOperation::compute<store::XS_DECIMAL,store::XS_DECIMAL>(
     store::Item_t& result,
     dynamic_context* /* dctx */,
     const TypeManager* /* tm */,
@@ -245,7 +245,7 @@
 
 
 template<>
-bool MultiplyOperation::compute<TypeConstants::XS_INTEGER,TypeConstants::XS_INTEGER>(
+bool MultiplyOperation::compute<store::XS_INTEGER,store::XS_INTEGER>(
     store::Item_t& result,
     dynamic_context* /* dctx */,
     const TypeManager* /* tm */,
@@ -262,7 +262,7 @@
   DivideOperation (see runtime/core/arithmetic_impl.h/cpp)
 ********************************************************************************/
 template<>
-bool DivideOperation::compute<TypeConstants::XS_DOUBLE,TypeConstants::XS_DOUBLE>(
+bool DivideOperation::compute<store::XS_DOUBLE,store::XS_DOUBLE>(
     store::Item_t& result,
     dynamic_context* /* dctx */,
     const TypeManager* /* tm */,
@@ -276,7 +276,7 @@
 
 
 template<>
-bool DivideOperation::compute<TypeConstants::XS_FLOAT,TypeConstants::XS_FLOAT>(
+bool DivideOperation::compute<store::XS_FLOAT,store::XS_FLOAT>(
     store::Item_t& result,
     dynamic_context* /* dctx */,
     const TypeManager* /* tm */,
@@ -290,7 +290,7 @@
 
 
 template<>
-bool DivideOperation::compute<TypeConstants::XS_DECIMAL,TypeConstants::XS_DECIMAL>(
+bool DivideOperation::compute<store::XS_DECIMAL,store::XS_DECIMAL>(
     store::Item_t& result,
     dynamic_context* /*dctx*/,
     const TypeManager* /* tm */,
@@ -309,7 +309,7 @@
 
 
 template<>
-bool DivideOperation::compute<TypeConstants::XS_INTEGER,TypeConstants::XS_INTEGER>(
+bool DivideOperation::compute<store::XS_INTEGER,store::XS_INTEGER>(
     store::Item_t& result,
     dynamic_context* /* dctx */,
     const TypeManager* /* tm */,
@@ -331,7 +331,7 @@
   IntegerDivideOperation (see runtime/core/arithmetic_impl.h/cpp)
 ********************************************************************************/
 template<>
-bool IntegerDivideOperation::compute<TypeConstants::XS_DOUBLE,TypeConstants::XS_DOUBLE>(
+bool IntegerDivideOperation::compute<store::XS_DOUBLE,store::XS_DOUBLE>(
     store::Item_t& result,
     dynamic_context* /* dctx */,
     const TypeManager* /* tm */,
@@ -371,7 +371,7 @@
 
 
 template<>
-bool IntegerDivideOperation::compute<TypeConstants::XS_FLOAT,TypeConstants::XS_FLOAT>(
+bool IntegerDivideOperation::compute<store::XS_FLOAT,store::XS_FLOAT>(
     store::Item_t& result,
     dynamic_context* /* dctx */,
     const TypeManager* /* tm */,
@@ -410,7 +410,7 @@
 
 
 template<>
-bool IntegerDivideOperation::compute<TypeConstants::XS_DECIMAL,TypeConstants::XS_DECIMAL>(
+bool IntegerDivideOperation::compute<store::XS_DECIMAL,store::XS_DECIMAL>(
     store::Item_t& result,
     dynamic_context* /* dctx */,
     const TypeManager* /* tm */,
@@ -430,7 +430,7 @@
 
 
 template<>
-bool IntegerDivideOperation::compute<TypeConstants::XS_INTEGER,TypeConstants::XS_INTEGER>(
+bool IntegerDivideOperation::compute<store::XS_INTEGER,store::XS_INTEGER>(
     store::Item_t& result,
     dynamic_context* /* dctx */,
     const TypeManager* /* tm */,
@@ -453,7 +453,7 @@
   ModOperation (see runtime/core/arithmetic_impl.h/cpp)
 ********************************************************************************/
 template<>
-bool ModOperation::compute<TypeConstants::XS_DOUBLE, TypeConstants::XS_DOUBLE>(
+bool ModOperation::compute<store::XS_DOUBLE, store::XS_DOUBLE>(
     store::Item_t& result,
     dynamic_context* /* dctx */,
     const TypeManager* /* tm */,
@@ -467,7 +467,7 @@
 
 
 template<>
-bool ModOperation::compute<TypeConstants::XS_FLOAT, TypeConstants::XS_FLOAT>(
+bool ModOperation::compute<store::XS_FLOAT, store::XS_FLOAT>(
     store::Item_t& result,
     dynamic_context* /* dctx */,
     const TypeManager* /* tm */,
@@ -481,7 +481,7 @@
 
 
 template<>
-bool ModOperation::compute<TypeConstants::XS_DECIMAL, TypeConstants::XS_DECIMAL>(
+bool ModOperation::compute<store::XS_DECIMAL, store::XS_DECIMAL>(
     store::Item_t& result,
     dynamic_context* /* dctx */,
     const TypeManager* /* tm */,
@@ -501,7 +501,7 @@
 
 
 template<>
-bool ModOperation::compute<TypeConstants::XS_INTEGER, TypeConstants::XS_INTEGER>(
+bool ModOperation::compute<store::XS_INTEGER, store::XS_INTEGER>(
     store::Item_t& result,
     dynamic_context* /* dctx */,
     const TypeManager* /* tm */,
@@ -625,43 +625,43 @@
 
   switch (TypeOps::get_atomic_type_code(*resultType))
   {
-  case TypeConstants::XS_DOUBLE:
+  case store::XS_DOUBLE:
   {
     GenericCast::castToAtomic(n0, item0, &*resultType, tm, NULL, aLoc);
     GenericCast::castToAtomic(n1, item1, &*resultType, tm, NULL, aLoc);
     
     res = Operation::template
-          computeSingleType<TypeConstants::XS_DOUBLE>
+          computeSingleType<store::XS_DOUBLE>
           (result, dctx, tm, &aLoc, n0, n1 );
     break;
   }
-  case TypeConstants::XS_FLOAT:
+  case store::XS_FLOAT:
   {
     GenericCast::castToAtomic(n0, item0, &*resultType, tm, NULL, aLoc);
     GenericCast::castToAtomic(n1, item1, &*resultType, tm, NULL, aLoc);
 
     res = Operation::template 
-          computeSingleType<TypeConstants::XS_FLOAT>
+          computeSingleType<store::XS_FLOAT>
           (result, dctx, tm, &aLoc, n0, n1);
     break;
   }
-  case TypeConstants::XS_DECIMAL:
+  case store::XS_DECIMAL:
   {
     GenericCast::castToAtomic(n0, item0, &*resultType, tm, NULL, aLoc);
     GenericCast::castToAtomic(n1, item1, &*resultType, tm, NULL, aLoc);
 
     res = Operation::template
-          computeSingleType<TypeConstants::XS_DECIMAL>
+          computeSingleType<store::XS_DECIMAL>
           (result, dctx, tm, &aLoc,n0, n1);
     break;
   }
-  case TypeConstants::XS_INTEGER:
+  case store::XS_INTEGER:
   {
     GenericCast::castToAtomic(n0, item0, &*resultType, tm, NULL, aLoc);
     GenericCast::castToAtomic(n1, item1, &*resultType, tm, NULL, aLoc);
 
     res = Operation::template 
-          computeSingleType<TypeConstants::XS_INTEGER>
+          computeSingleType<store::XS_INTEGER>
           (result, dctx, tm, &aLoc, n0, n1 );
     break;
   }
@@ -692,7 +692,7 @@
 
 ********************************************************************************/
 
-template< class Operations, TypeConstants::atomic_type_code_t Type >
+template< class Operations, store::SchemaTypeCode Type >
 SpecificNumArithIterator<Operations, Type>::SpecificNumArithIterator(
     static_context* sctx,
     const QueryLoc& loc,
@@ -704,7 +704,7 @@
 }
 
 
-template < class Operation, TypeConstants::atomic_type_code_t Type >
+template < class Operation, store::SchemaTypeCode Type >
 void SpecificNumArithIterator<Operation, Type>::accept(PlanIterVisitor& v) const 
 {
   v.beginVisit(*this);
@@ -716,7 +716,7 @@
 }
 
 
-template < class Operation, TypeConstants::atomic_type_code_t Type >
+template < class Operation, store::SchemaTypeCode Type >
 bool SpecificNumArithIterator<Operation, Type>::nextImpl(
     store::Item_t& result,
     PlanState& planState) const
@@ -751,7 +751,7 @@
 }
 
 
-template < class Operation, TypeConstants::atomic_type_code_t Type >
+template < class Operation, store::SchemaTypeCode Type >
 bool SpecificNumArithIterator<Operation, Type>::compute(
     store::Item_t& result,
     dynamic_context* dctx,
@@ -767,26 +767,26 @@
 }
 
   
-template class SpecificNumArithIterator<AddOperation, TypeConstants::XS_DOUBLE>;
-template class SpecificNumArithIterator<AddOperation, TypeConstants::XS_FLOAT>;
-template class SpecificNumArithIterator<AddOperation, TypeConstants::XS_DECIMAL>;
-template class SpecificNumArithIterator<AddOperation, TypeConstants::XS_INTEGER>;
-template class SpecificNumArithIterator<SubtractOperation, TypeConstants::XS_DOUBLE>;
-template class SpecificNumArithIterator<SubtractOperation, TypeConstants::XS_FLOAT>;
-template class SpecificNumArithIterator<SubtractOperation, TypeConstants::XS_DECIMAL>;
-template class SpecificNumArithIterator<SubtractOperation, TypeConstants::XS_INTEGER>;
-template class SpecificNumArithIterator<MultiplyOperation, TypeConstants::XS_DOUBLE>;
-template class SpecificNumArithIterator<MultiplyOperation, TypeConstants::XS_FLOAT>;
-template class SpecificNumArithIterator<MultiplyOperation, TypeConstants::XS_DECIMAL>;
-template class SpecificNumArithIterator<MultiplyOperation, TypeConstants::XS_INTEGER>;
-template class SpecificNumArithIterator<DivideOperation, TypeConstants::XS_DOUBLE>;
-template class SpecificNumArithIterator<DivideOperation, TypeConstants::XS_FLOAT>;
-template class SpecificNumArithIterator<DivideOperation, TypeConstants::XS_DECIMAL>;
-template class SpecificNumArithIterator<DivideOperation, TypeConstants::XS_INTEGER>;
-template class SpecificNumArithIterator<ModOperation, TypeConstants::XS_DOUBLE>;
-template class SpecificNumArithIterator<ModOperation, TypeConstants::XS_FLOAT>;
-template class SpecificNumArithIterator<ModOperation, TypeConstants::XS_DECIMAL>;
-template class SpecificNumArithIterator<ModOperation, TypeConstants::XS_INTEGER>;
+template class SpecificNumArithIterator<AddOperation, store::XS_DOUBLE>;
+template class SpecificNumArithIterator<AddOperation, store::XS_FLOAT>;
+template class SpecificNumArithIterator<AddOperation, store::XS_DECIMAL>;
+template class SpecificNumArithIterator<AddOperation, store::XS_INTEGER>;
+template class SpecificNumArithIterator<SubtractOperation, store::XS_DOUBLE>;
+template class SpecificNumArithIterator<SubtractOperation, store::XS_FLOAT>;
+template class SpecificNumArithIterator<SubtractOperation, store::XS_DECIMAL>;
+template class SpecificNumArithIterator<SubtractOperation, store::XS_INTEGER>;
+template class SpecificNumArithIterator<MultiplyOperation, store::XS_DOUBLE>;
+template class SpecificNumArithIterator<MultiplyOperation, store::XS_FLOAT>;
+template class SpecificNumArithIterator<MultiplyOperation, store::XS_DECIMAL>;
+template class SpecificNumArithIterator<MultiplyOperation, store::XS_INTEGER>;
+template class SpecificNumArithIterator<DivideOperation, store::XS_DOUBLE>;
+template class SpecificNumArithIterator<DivideOperation, store::XS_FLOAT>;
+template class SpecificNumArithIterator<DivideOperation, store::XS_DECIMAL>;
+template class SpecificNumArithIterator<DivideOperation, store::XS_INTEGER>;
+template class SpecificNumArithIterator<ModOperation, store::XS_DOUBLE>;
+template class SpecificNumArithIterator<ModOperation, store::XS_FLOAT>;
+template class SpecificNumArithIterator<ModOperation, store::XS_DECIMAL>;
+template class SpecificNumArithIterator<ModOperation, store::XS_INTEGER>;
 
 
 /*******************************************************************************

=== modified file 'src/runtime/numerics/NumericsImpl.h'
--- src/runtime/numerics/NumericsImpl.h	2011-06-14 17:26:33 +0000
+++ src/runtime/numerics/NumericsImpl.h	2012-01-10 13:58:38 +0000
@@ -23,7 +23,7 @@
 #include "runtime/base/binarybase.h" // TODO remove after iterator refactoring
 #include "runtime/base/narybase.h"
 
-#include "types/typeconstants.h"
+#include "store/api/xs_type_codes.h"
 
 namespace zorba
 {
@@ -95,7 +95,7 @@
   specific operation is passed as the template class param, and the data type
   of the operands is passed as a template const param.
 ********************************************************************************/
-template < class Operation, TypeConstants::atomic_type_code_t Type >
+template < class Operation, store::SchemaTypeCode Type >
 class SpecificNumArithIterator : 
 public BinaryBaseIterator<SpecificNumArithIterator<Operation, Type>, PlanIteratorState>
 {

=== modified file 'src/runtime/spec/plan_iter_visitor_h.xq'
--- src/runtime/spec/plan_iter_visitor_h.xq	2012-01-03 12:10:06 +0000
+++ src/runtime/spec/plan_iter_visitor_h.xq	2012-01-10 13:58:38 +0000
@@ -27,7 +27,7 @@
   '#include <vector>',$gen:newline,
   '#include "common/common.h"',$gen:newline,
   '#include "zorbatypes/zorbatypes_decl.h"',$gen:newline,
-  '#include "types/typeconstants.h"',$gen:newline,
+  '#include "store/api/xs_type_codes.h"',$gen:newline,
   '#include "zorbatypes/rchandle.h"',$gen:newline,
   '#include "zorbatypes/zstring.h"',$gen:newline
   ),'')

=== modified file 'src/runtime/visitors/planiter_visitor_impl_code.h'
--- src/runtime/visitors/planiter_visitor_impl_code.h	2012-01-03 12:10:06 +0000
+++ src/runtime/visitors/planiter_visitor_impl_code.h	2012-01-10 13:58:38 +0000
@@ -123,57 +123,57 @@
   virtual void endVisit ( const GenericArithIterator<IntegerDivideOperation>& ) = 0;
   virtual void endVisit ( const GenericArithIterator<ModOperation>& ) = 0;
 
-  virtual void beginVisit ( const SpecificNumArithIterator<AddOperation, TypeConstants::XS_DECIMAL>& ) = 0;
-  virtual void beginVisit ( const SpecificNumArithIterator<AddOperation, TypeConstants::XS_INTEGER>& ) = 0;
-  virtual void beginVisit ( const SpecificNumArithIterator<AddOperation, TypeConstants::XS_FLOAT>& ) = 0;
-  virtual void beginVisit ( const SpecificNumArithIterator<AddOperation, TypeConstants::XS_DOUBLE>& ) = 0;
-  virtual void beginVisit ( const SpecificNumArithIterator<SubtractOperation, TypeConstants::XS_DECIMAL>& ) = 0;
-  virtual void beginVisit ( const SpecificNumArithIterator<SubtractOperation, TypeConstants::XS_INTEGER>& ) = 0;
-  virtual void beginVisit ( const SpecificNumArithIterator<SubtractOperation, TypeConstants::XS_FLOAT>& ) = 0;
-  virtual void beginVisit ( const SpecificNumArithIterator<SubtractOperation, TypeConstants::XS_DOUBLE>& ) = 0;
-  virtual void beginVisit ( const SpecificNumArithIterator<MultiplyOperation, TypeConstants::XS_DECIMAL>& ) = 0;
-  virtual void beginVisit ( const SpecificNumArithIterator<MultiplyOperation, TypeConstants::XS_INTEGER>& ) = 0;
-  virtual void beginVisit ( const SpecificNumArithIterator<MultiplyOperation, TypeConstants::XS_FLOAT>& ) = 0;
-  virtual void beginVisit ( const SpecificNumArithIterator<MultiplyOperation, TypeConstants::XS_DOUBLE>& ) = 0;
-  virtual void beginVisit ( const SpecificNumArithIterator<DivideOperation, TypeConstants::XS_DECIMAL>& ) = 0;
-  virtual void beginVisit ( const SpecificNumArithIterator<DivideOperation, TypeConstants::XS_INTEGER>& ) = 0;
-  virtual void beginVisit ( const SpecificNumArithIterator<DivideOperation, TypeConstants::XS_FLOAT>& ) = 0;
-  virtual void beginVisit ( const SpecificNumArithIterator<DivideOperation, TypeConstants::XS_DOUBLE>& ) = 0;
-  virtual void beginVisit ( const SpecificNumArithIterator<ModOperation, TypeConstants::XS_DECIMAL>& ) = 0;
-  virtual void beginVisit ( const SpecificNumArithIterator<ModOperation, TypeConstants::XS_INTEGER>& ) = 0;
-  virtual void beginVisit ( const SpecificNumArithIterator<ModOperation, TypeConstants::XS_FLOAT>& ) = 0;
-  virtual void beginVisit ( const SpecificNumArithIterator<ModOperation, TypeConstants::XS_DOUBLE>& ) = 0;
-  virtual void endVisit ( const SpecificNumArithIterator<AddOperation, TypeConstants::XS_DECIMAL>& ) = 0;
-  virtual void endVisit ( const SpecificNumArithIterator<AddOperation, TypeConstants::XS_INTEGER>& ) = 0;
-  virtual void endVisit ( const SpecificNumArithIterator<AddOperation, TypeConstants::XS_FLOAT>& ) = 0;
-  virtual void endVisit ( const SpecificNumArithIterator<AddOperation, TypeConstants::XS_DOUBLE>& ) = 0;
-  virtual void endVisit ( const SpecificNumArithIterator<SubtractOperation, TypeConstants::XS_DECIMAL>& ) = 0;
-  virtual void endVisit ( const SpecificNumArithIterator<SubtractOperation, TypeConstants::XS_INTEGER>& ) = 0;
-  virtual void endVisit ( const SpecificNumArithIterator<SubtractOperation, TypeConstants::XS_FLOAT>& ) = 0;
-  virtual void endVisit ( const SpecificNumArithIterator<SubtractOperation, TypeConstants::XS_DOUBLE>& ) = 0;
-  virtual void endVisit ( const SpecificNumArithIterator<MultiplyOperation, TypeConstants::XS_DECIMAL>& ) = 0;
-  virtual void endVisit ( const SpecificNumArithIterator<MultiplyOperation, TypeConstants::XS_INTEGER>& ) = 0;
-  virtual void endVisit ( const SpecificNumArithIterator<MultiplyOperation, TypeConstants::XS_FLOAT>& ) = 0;
-  virtual void endVisit ( const SpecificNumArithIterator<MultiplyOperation, TypeConstants::XS_DOUBLE>& ) = 0;
-  virtual void endVisit ( const SpecificNumArithIterator<DivideOperation, TypeConstants::XS_DECIMAL>& ) = 0;
-  virtual void endVisit ( const SpecificNumArithIterator<DivideOperation, TypeConstants::XS_INTEGER>& ) = 0;
-  virtual void endVisit ( const SpecificNumArithIterator<DivideOperation, TypeConstants::XS_FLOAT>& ) = 0;
-  virtual void endVisit ( const SpecificNumArithIterator<DivideOperation, TypeConstants::XS_DOUBLE>& ) = 0;
-  virtual void endVisit ( const SpecificNumArithIterator<ModOperation, TypeConstants::XS_DECIMAL>& ) = 0;
-  virtual void endVisit ( const SpecificNumArithIterator<ModOperation, TypeConstants::XS_INTEGER>& ) = 0;
-  virtual void endVisit ( const SpecificNumArithIterator<ModOperation, TypeConstants::XS_FLOAT>& ) = 0;
-  virtual void endVisit ( const SpecificNumArithIterator<ModOperation, TypeConstants::XS_DOUBLE>& ) = 0;
+  virtual void beginVisit ( const SpecificNumArithIterator<AddOperation, store::XS_DECIMAL>& ) = 0;
+  virtual void beginVisit ( const SpecificNumArithIterator<AddOperation, store::XS_INTEGER>& ) = 0;
+  virtual void beginVisit ( const SpecificNumArithIterator<AddOperation, store::XS_FLOAT>& ) = 0;
+  virtual void beginVisit ( const SpecificNumArithIterator<AddOperation, store::XS_DOUBLE>& ) = 0;
+  virtual void beginVisit ( const SpecificNumArithIterator<SubtractOperation, store::XS_DECIMAL>& ) = 0;
+  virtual void beginVisit ( const SpecificNumArithIterator<SubtractOperation, store::XS_INTEGER>& ) = 0;
+  virtual void beginVisit ( const SpecificNumArithIterator<SubtractOperation, store::XS_FLOAT>& ) = 0;
+  virtual void beginVisit ( const SpecificNumArithIterator<SubtractOperation, store::XS_DOUBLE>& ) = 0;
+  virtual void beginVisit ( const SpecificNumArithIterator<MultiplyOperation, store::XS_DECIMAL>& ) = 0;
+  virtual void beginVisit ( const SpecificNumArithIterator<MultiplyOperation, store::XS_INTEGER>& ) = 0;
+  virtual void beginVisit ( const SpecificNumArithIterator<MultiplyOperation, store::XS_FLOAT>& ) = 0;
+  virtual void beginVisit ( const SpecificNumArithIterator<MultiplyOperation, store::XS_DOUBLE>& ) = 0;
+  virtual void beginVisit ( const SpecificNumArithIterator<DivideOperation, store::XS_DECIMAL>& ) = 0;
+  virtual void beginVisit ( const SpecificNumArithIterator<DivideOperation, store::XS_INTEGER>& ) = 0;
+  virtual void beginVisit ( const SpecificNumArithIterator<DivideOperation, store::XS_FLOAT>& ) = 0;
+  virtual void beginVisit ( const SpecificNumArithIterator<DivideOperation, store::XS_DOUBLE>& ) = 0;
+  virtual void beginVisit ( const SpecificNumArithIterator<ModOperation, store::XS_DECIMAL>& ) = 0;
+  virtual void beginVisit ( const SpecificNumArithIterator<ModOperation, store::XS_INTEGER>& ) = 0;
+  virtual void beginVisit ( const SpecificNumArithIterator<ModOperation, store::XS_FLOAT>& ) = 0;
+  virtual void beginVisit ( const SpecificNumArithIterator<ModOperation, store::XS_DOUBLE>& ) = 0;
+  virtual void endVisit ( const SpecificNumArithIterator<AddOperation, store::XS_DECIMAL>& ) = 0;
+  virtual void endVisit ( const SpecificNumArithIterator<AddOperation, store::XS_INTEGER>& ) = 0;
+  virtual void endVisit ( const SpecificNumArithIterator<AddOperation, store::XS_FLOAT>& ) = 0;
+  virtual void endVisit ( const SpecificNumArithIterator<AddOperation, store::XS_DOUBLE>& ) = 0;
+  virtual void endVisit ( const SpecificNumArithIterator<SubtractOperation, store::XS_DECIMAL>& ) = 0;
+  virtual void endVisit ( const SpecificNumArithIterator<SubtractOperation, store::XS_INTEGER>& ) = 0;
+  virtual void endVisit ( const SpecificNumArithIterator<SubtractOperation, store::XS_FLOAT>& ) = 0;
+  virtual void endVisit ( const SpecificNumArithIterator<SubtractOperation, store::XS_DOUBLE>& ) = 0;
+  virtual void endVisit ( const SpecificNumArithIterator<MultiplyOperation, store::XS_DECIMAL>& ) = 0;
+  virtual void endVisit ( const SpecificNumArithIterator<MultiplyOperation, store::XS_INTEGER>& ) = 0;
+  virtual void endVisit ( const SpecificNumArithIterator<MultiplyOperation, store::XS_FLOAT>& ) = 0;
+  virtual void endVisit ( const SpecificNumArithIterator<MultiplyOperation, store::XS_DOUBLE>& ) = 0;
+  virtual void endVisit ( const SpecificNumArithIterator<DivideOperation, store::XS_DECIMAL>& ) = 0;
+  virtual void endVisit ( const SpecificNumArithIterator<DivideOperation, store::XS_INTEGER>& ) = 0;
+  virtual void endVisit ( const SpecificNumArithIterator<DivideOperation, store::XS_FLOAT>& ) = 0;
+  virtual void endVisit ( const SpecificNumArithIterator<DivideOperation, store::XS_DOUBLE>& ) = 0;
+  virtual void endVisit ( const SpecificNumArithIterator<ModOperation, store::XS_DECIMAL>& ) = 0;
+  virtual void endVisit ( const SpecificNumArithIterator<ModOperation, store::XS_INTEGER>& ) = 0;
+  virtual void endVisit ( const SpecificNumArithIterator<ModOperation, store::XS_FLOAT>& ) = 0;
+  virtual void endVisit ( const SpecificNumArithIterator<ModOperation, store::XS_DOUBLE>& ) = 0;
 
-  virtual void beginVisit ( const TypedValueCompareIterator<TypeConstants::XS_DOUBLE>& ) = 0;
-  virtual void endVisit ( const TypedValueCompareIterator<TypeConstants::XS_DOUBLE>& ) = 0;
-  virtual void beginVisit ( const TypedValueCompareIterator<TypeConstants::XS_FLOAT>& ) = 0;
-  virtual void endVisit ( const TypedValueCompareIterator<TypeConstants::XS_FLOAT>& ) = 0;
-  virtual void beginVisit ( const TypedValueCompareIterator<TypeConstants::XS_DECIMAL>& ) = 0;
-  virtual void endVisit ( const TypedValueCompareIterator<TypeConstants::XS_DECIMAL>& ) = 0;
-  virtual void beginVisit ( const TypedValueCompareIterator<TypeConstants::XS_INTEGER>& ) = 0;
-  virtual void endVisit ( const TypedValueCompareIterator<TypeConstants::XS_INTEGER>& ) = 0;
-  virtual void beginVisit ( const TypedValueCompareIterator<TypeConstants::XS_STRING>& ) = 0;
-  virtual void endVisit ( const TypedValueCompareIterator<TypeConstants::XS_STRING>& ) = 0;
+  virtual void beginVisit ( const TypedValueCompareIterator<store::XS_DOUBLE>& ) = 0;
+  virtual void endVisit ( const TypedValueCompareIterator<store::XS_DOUBLE>& ) = 0;
+  virtual void beginVisit ( const TypedValueCompareIterator<store::XS_FLOAT>& ) = 0;
+  virtual void endVisit ( const TypedValueCompareIterator<store::XS_FLOAT>& ) = 0;
+  virtual void beginVisit ( const TypedValueCompareIterator<store::XS_DECIMAL>& ) = 0;
+  virtual void endVisit ( const TypedValueCompareIterator<store::XS_DECIMAL>& ) = 0;
+  virtual void beginVisit ( const TypedValueCompareIterator<store::XS_INTEGER>& ) = 0;
+  virtual void endVisit ( const TypedValueCompareIterator<store::XS_INTEGER>& ) = 0;
+  virtual void beginVisit ( const TypedValueCompareIterator<store::XS_STRING>& ) = 0;
+  virtual void endVisit ( const TypedValueCompareIterator<store::XS_STRING>& ) = 0;
 
   PLAN_ITER_VISITOR (OpNumericUnaryIterator);
 

=== modified file 'src/runtime/visitors/planiter_visitor_impl_include.h'
--- src/runtime/visitors/planiter_visitor_impl_include.h	2012-01-03 12:10:06 +0000
+++ src/runtime/visitors/planiter_visitor_impl_include.h	2012-01-10 13:58:38 +0000
@@ -84,11 +84,11 @@
   template < class DivideOperation> class GenericArithIterator;
   template < class IntegerDivideOperation> class GenericArithIterator;
   template < class ModOperation> class GenericArithIterator;
-  template < class AddOperation, TypeConstants::atomic_type_code_t > class SpecificNumArithIterator;
-  template < class SubtractOperation, TypeConstants::atomic_type_code_t > class SpecificNumArithIterator;
-  template < class MultiplyOperation, TypeConstants::atomic_type_code_t > class SpecificNumArithIterator;
-  template < class DivideOperation, TypeConstants::atomic_type_code_t > class SpecificNumArithIterator;
-  template < TypeConstants::atomic_type_code_t > class TypedValueCompareIterator;
+  template < class AddOperation, store::SchemaTypeCode > class SpecificNumArithIterator;
+  template < class SubtractOperation, store::SchemaTypeCode > class SpecificNumArithIterator;
+  template < class MultiplyOperation, store::SchemaTypeCode > class SpecificNumArithIterator;
+  template < class DivideOperation, store::SchemaTypeCode > class SpecificNumArithIterator;
+  template < store::SchemaTypeCode > class TypedValueCompareIterator;
 
   class OpNumericUnaryIterator;
   class OpDoubleUnaryIterator;

=== modified file 'src/runtime/visitors/pregenerated/planiter_visitor.h'
--- src/runtime/visitors/pregenerated/planiter_visitor.h	2012-01-05 13:19:14 +0000
+++ src/runtime/visitors/pregenerated/planiter_visitor.h	2012-01-10 13:58:38 +0000
@@ -25,7 +25,7 @@
 #include <vector>
 #include "common/common.h"
 #include "zorbatypes/zorbatypes_decl.h"
-#include "types/typeconstants.h"
+#include "store/api/xs_type_codes.h"
 #include "zorbatypes/rchandle.h"
 #include "zorbatypes/zstring.h"
 

=== modified file 'src/runtime/visitors/printer_visitor_impl.cpp'
--- src/runtime/visitors/printer_visitor_impl.cpp	2012-01-03 12:10:06 +0000
+++ src/runtime/visitors/printer_visitor_impl.cpp	2012-01-10 13:58:38 +0000
@@ -337,7 +337,7 @@
 }
 
 void PrinterVisitor::beginVisit ( const SpecificNumArithIterator<AddOperation,
-                    TypeConstants::XS_DECIMAL>& a)
+                    store::XS_DECIMAL>& a)
 {
   thePrinter.startBeginVisit("SpecificNumArithIterator_AddOperation_DECIMAL",
                              ++theId);
@@ -345,7 +345,7 @@
   thePrinter.endBeginVisit(theId);
 }
 void PrinterVisitor::beginVisit ( const SpecificNumArithIterator<AddOperation,
-                    TypeConstants::XS_INTEGER>& a)
+                    store::XS_INTEGER>& a)
 {
   thePrinter.startBeginVisit("SpecificNumArithIterator_AddOperation_INTEGER",
                              ++theId);
@@ -353,7 +353,7 @@
   thePrinter.endBeginVisit(theId);
 }
 void PrinterVisitor::beginVisit ( const SpecificNumArithIterator<AddOperation,
-                    TypeConstants::XS_FLOAT>& a)
+                    store::XS_FLOAT>& a)
 {
   thePrinter.startBeginVisit("SpecificNumArithIterator_AddOperation_FLOAT",
                              ++theId);
@@ -361,7 +361,7 @@
   thePrinter.endBeginVisit(theId);
 }
 void PrinterVisitor::beginVisit ( const SpecificNumArithIterator<AddOperation,
-                    TypeConstants::XS_DOUBLE>& a)
+                    store::XS_DOUBLE>& a)
 {
   thePrinter.startBeginVisit("SpecificNumArithIterator_AddOperation_DOUBLE",
                              ++theId);
@@ -370,7 +370,7 @@
 }
 void PrinterVisitor::beginVisit ( const
 SpecificNumArithIterator<SubtractOperation,
-                    TypeConstants::XS_DECIMAL>& a)
+                    store::XS_DECIMAL>& a)
 {
 thePrinter.startBeginVisit("SpecificNumArithIterator_SubtractOperation_DECIMAL",
                              ++theId);
@@ -380,7 +380,7 @@
 
 void PrinterVisitor::beginVisit ( const
 SpecificNumArithIterator<SubtractOperation,
-                    TypeConstants::XS_INTEGER>& a)
+                    store::XS_INTEGER>& a)
 {
 thePrinter.startBeginVisit("SpecificNumArithIterator_SubtractOperation_INTEGER",
                              ++theId);
@@ -389,7 +389,7 @@
 }
 void PrinterVisitor::beginVisit ( const
 SpecificNumArithIterator<SubtractOperation,
-                    TypeConstants::XS_FLOAT>& a)
+                    store::XS_FLOAT>& a)
 {
   thePrinter.startBeginVisit("SpecificNumArithIterator_SubtractOperation_FLOAT",
                              ++theId);
@@ -398,7 +398,7 @@
 }
 void PrinterVisitor::beginVisit ( const
 SpecificNumArithIterator<SubtractOperation,
-                    TypeConstants::XS_DOUBLE>& a)
+                    store::XS_DOUBLE>& a)
 {
 thePrinter.startBeginVisit("SpecificNumArithIterator_SubtractOperation_DOUBLE",
                              ++theId);
@@ -407,7 +407,7 @@
 }
 void PrinterVisitor::beginVisit ( const
 SpecificNumArithIterator<MultiplyOperation,
-                    TypeConstants::XS_DECIMAL>& a)
+                    store::XS_DECIMAL>& a)
 {
 thePrinter.startBeginVisit("SpecificNumArithIterator_MultiplyOperation_DECIMAL",
                              ++theId);
@@ -416,7 +416,7 @@
 }
 void PrinterVisitor::beginVisit ( const
 SpecificNumArithIterator<MultiplyOperation,
-                    TypeConstants::XS_INTEGER>& a)
+                    store::XS_INTEGER>& a)
 {
 thePrinter.startBeginVisit("SpecificNumArithIterator_MultiplyOperation_INTEGER",
                              ++theId);
@@ -426,7 +426,7 @@
 
 void PrinterVisitor::beginVisit ( const
 SpecificNumArithIterator<MultiplyOperation,
-                    TypeConstants::XS_FLOAT>& a)
+                    store::XS_FLOAT>& a)
 {
   thePrinter.startBeginVisit("SpecificNumArithIterator_MultiplyOperation_FLOAT",
                              ++theId);
@@ -435,7 +435,7 @@
 }
 void PrinterVisitor::beginVisit ( const
 SpecificNumArithIterator<MultiplyOperation,
-                    TypeConstants::XS_DOUBLE>& a)
+                    store::XS_DOUBLE>& a)
 {
 thePrinter.startBeginVisit("SpecificNumArithIterator_MultiplyOperation_DOUBLE",
                              ++theId);
@@ -444,7 +444,7 @@
 }
 void PrinterVisitor::beginVisit ( const
 SpecificNumArithIterator<DivideOperation,
-                    TypeConstants::XS_DECIMAL>& a)
+                    store::XS_DECIMAL>& a)
 {
   thePrinter.startBeginVisit("SpecificNumArithIterator_DivideOperation_DECIMAL",
                              ++theId);
@@ -453,7 +453,7 @@
 }
 void PrinterVisitor::beginVisit ( const
 SpecificNumArithIterator<DivideOperation,
-                    TypeConstants::XS_INTEGER>& a)
+                    store::XS_INTEGER>& a)
 {
   thePrinter.startBeginVisit("SpecificNumArithIterator_DivideOperation_INTEGER",
                              ++theId);
@@ -462,7 +462,7 @@
 }
 void PrinterVisitor::beginVisit ( const
 SpecificNumArithIterator<DivideOperation,
-                    TypeConstants::XS_FLOAT>& a)
+                    store::XS_FLOAT>& a)
 {
   thePrinter.startBeginVisit("SpecificNumArithIterator_DivideOperation_FLOAT",
                              ++theId);
@@ -472,7 +472,7 @@
 
 void PrinterVisitor::beginVisit ( const
 SpecificNumArithIterator<DivideOperation,
-                    TypeConstants::XS_DOUBLE>& a)
+                    store::XS_DOUBLE>& a)
 {
 
   thePrinter.startBeginVisit("SpecificNumArithIterator_DivideOperation_DOUBLE",
@@ -481,7 +481,7 @@
   thePrinter.endBeginVisit(theId);
 }
 void PrinterVisitor::beginVisit ( const SpecificNumArithIterator<ModOperation,
-                    TypeConstants::XS_DECIMAL>& a)
+                    store::XS_DECIMAL>& a)
 {
   thePrinter.startBeginVisit("SpecificNumArithIterator_ModOperation_DECIMAL",
                              ++theId);
@@ -489,7 +489,7 @@
   thePrinter.endBeginVisit(theId);
 }
 void PrinterVisitor::beginVisit ( const SpecificNumArithIterator<ModOperation,
-                    TypeConstants::XS_INTEGER>& a)
+                    store::XS_INTEGER>& a)
 {
   thePrinter.startBeginVisit("SpecificNumArithIterator_ModOperation_INTEGER",
                              ++theId);
@@ -497,7 +497,7 @@
   thePrinter.endBeginVisit(theId);
 }
 void PrinterVisitor::beginVisit ( const SpecificNumArithIterator<ModOperation,
-                    TypeConstants::XS_FLOAT>& a)
+                    store::XS_FLOAT>& a)
 {
   thePrinter.startBeginVisit("SpecificNumArithIterator_ModOperation_FLOAT",
                              ++theId);
@@ -505,7 +505,7 @@
   thePrinter.endBeginVisit(theId);
 }
 void PrinterVisitor::beginVisit ( const SpecificNumArithIterator<ModOperation,
-                    TypeConstants::XS_DOUBLE>& a)
+                    store::XS_DOUBLE>& a)
 {
   thePrinter.startBeginVisit("SpecificNumArithIterator_ModOperation_DOUBLE",
                              ++theId);
@@ -514,132 +514,132 @@
 }
 
 void PrinterVisitor::endVisit ( const SpecificNumArithIterator<AddOperation,
-                  TypeConstants::XS_DECIMAL>& )
-{
-  thePrinter.startEndVisit();
-  thePrinter.endEndVisit();
-}
-void PrinterVisitor::endVisit ( const SpecificNumArithIterator<AddOperation,
-                  TypeConstants::XS_INTEGER>& )
-{
-  thePrinter.startEndVisit();
-  thePrinter.endEndVisit();
-}
-void PrinterVisitor::endVisit ( const SpecificNumArithIterator<AddOperation,
-                  TypeConstants::XS_FLOAT>& )
-{
-  thePrinter.startEndVisit();
-  thePrinter.endEndVisit();
-}
-void PrinterVisitor::endVisit ( const SpecificNumArithIterator<AddOperation,
-                  TypeConstants::XS_DOUBLE>& )
-{
-  thePrinter.startEndVisit();
-  thePrinter.endEndVisit();
-}
-void PrinterVisitor::endVisit ( const
-SpecificNumArithIterator<SubtractOperation,
-                    TypeConstants::XS_DECIMAL>& )
-{
-  thePrinter.startEndVisit();
-  thePrinter.endEndVisit();
-}
-
-void PrinterVisitor::endVisit ( const
-SpecificNumArithIterator<SubtractOperation,
-                  TypeConstants::XS_INTEGER>& )
-{
-  thePrinter.startEndVisit();
-  thePrinter.endEndVisit();
-}
-void PrinterVisitor::endVisit ( const
-SpecificNumArithIterator<SubtractOperation,
-                  TypeConstants::XS_FLOAT>& )
-{
-  thePrinter.startEndVisit();
-  thePrinter.endEndVisit();
-}
-void PrinterVisitor::endVisit ( const
-SpecificNumArithIterator<SubtractOperation,
-                  TypeConstants::XS_DOUBLE>& )
-{
-  thePrinter.startEndVisit();
-  thePrinter.endEndVisit();
-}
-void PrinterVisitor::endVisit ( const
-SpecificNumArithIterator<MultiplyOperation,
-                  TypeConstants::XS_DECIMAL>& )
-{
-  thePrinter.startEndVisit();
-  thePrinter.endEndVisit();
-}
-void PrinterVisitor::endVisit ( const
-SpecificNumArithIterator<MultiplyOperation,
-                  TypeConstants::XS_INTEGER>& )
-{
-  thePrinter.startEndVisit();
-  thePrinter.endEndVisit();
-}
-
-void PrinterVisitor::endVisit ( const
-SpecificNumArithIterator<MultiplyOperation,
-                  TypeConstants::XS_FLOAT>& )
-{
-  thePrinter.startEndVisit();
-  thePrinter.endEndVisit();
-}
-void PrinterVisitor::endVisit ( const
-SpecificNumArithIterator<MultiplyOperation,
-                  TypeConstants::XS_DOUBLE>& )
-{
-  thePrinter.startEndVisit();
-  thePrinter.endEndVisit();
-}
-void PrinterVisitor::endVisit ( const SpecificNumArithIterator<DivideOperation,
-                  TypeConstants::XS_DECIMAL>& )
-{
-  thePrinter.startEndVisit();
-  thePrinter.endEndVisit();
-}
-void PrinterVisitor::endVisit ( const SpecificNumArithIterator<DivideOperation,
-                  TypeConstants::XS_INTEGER>& )
-{
-  thePrinter.startEndVisit();
-  thePrinter.endEndVisit();
-}
-void PrinterVisitor::endVisit ( const SpecificNumArithIterator<DivideOperation,
-                  TypeConstants::XS_FLOAT>& )
-{
-  thePrinter.startEndVisit();
-  thePrinter.endEndVisit();
-}
-
-void PrinterVisitor::endVisit ( const SpecificNumArithIterator<DivideOperation,
-                  TypeConstants::XS_DOUBLE>& )
-{
-  thePrinter.startEndVisit();
-  thePrinter.endEndVisit();
-}
-void PrinterVisitor::endVisit ( const SpecificNumArithIterator<ModOperation,
-                  TypeConstants::XS_DECIMAL>& )
-{
-  thePrinter.startEndVisit();
-  thePrinter.endEndVisit();
-}
-void PrinterVisitor::endVisit ( const SpecificNumArithIterator<ModOperation,
-                  TypeConstants::XS_INTEGER>& )
-{
-  thePrinter.startEndVisit();
-  thePrinter.endEndVisit();
-}
-void PrinterVisitor::endVisit ( const SpecificNumArithIterator<ModOperation,
-                  TypeConstants::XS_FLOAT>& )
-{
-  thePrinter.startEndVisit();
-  thePrinter.endEndVisit();
-}
-void PrinterVisitor::endVisit ( const SpecificNumArithIterator<ModOperation,
-                  TypeConstants::XS_DOUBLE>& )
+                  store::XS_DECIMAL>& )
+{
+  thePrinter.startEndVisit();
+  thePrinter.endEndVisit();
+}
+void PrinterVisitor::endVisit ( const SpecificNumArithIterator<AddOperation,
+                  store::XS_INTEGER>& )
+{
+  thePrinter.startEndVisit();
+  thePrinter.endEndVisit();
+}
+void PrinterVisitor::endVisit ( const SpecificNumArithIterator<AddOperation,
+                  store::XS_FLOAT>& )
+{
+  thePrinter.startEndVisit();
+  thePrinter.endEndVisit();
+}
+void PrinterVisitor::endVisit ( const SpecificNumArithIterator<AddOperation,
+                  store::XS_DOUBLE>& )
+{
+  thePrinter.startEndVisit();
+  thePrinter.endEndVisit();
+}
+void PrinterVisitor::endVisit ( const
+SpecificNumArithIterator<SubtractOperation,
+                    store::XS_DECIMAL>& )
+{
+  thePrinter.startEndVisit();
+  thePrinter.endEndVisit();
+}
+
+void PrinterVisitor::endVisit ( const
+SpecificNumArithIterator<SubtractOperation,
+                  store::XS_INTEGER>& )
+{
+  thePrinter.startEndVisit();
+  thePrinter.endEndVisit();
+}
+void PrinterVisitor::endVisit ( const
+SpecificNumArithIterator<SubtractOperation,
+                  store::XS_FLOAT>& )
+{
+  thePrinter.startEndVisit();
+  thePrinter.endEndVisit();
+}
+void PrinterVisitor::endVisit ( const
+SpecificNumArithIterator<SubtractOperation,
+                  store::XS_DOUBLE>& )
+{
+  thePrinter.startEndVisit();
+  thePrinter.endEndVisit();
+}
+void PrinterVisitor::endVisit ( const
+SpecificNumArithIterator<MultiplyOperation,
+                  store::XS_DECIMAL>& )
+{
+  thePrinter.startEndVisit();
+  thePrinter.endEndVisit();
+}
+void PrinterVisitor::endVisit ( const
+SpecificNumArithIterator<MultiplyOperation,
+                  store::XS_INTEGER>& )
+{
+  thePrinter.startEndVisit();
+  thePrinter.endEndVisit();
+}
+
+void PrinterVisitor::endVisit ( const
+SpecificNumArithIterator<MultiplyOperation,
+                  store::XS_FLOAT>& )
+{
+  thePrinter.startEndVisit();
+  thePrinter.endEndVisit();
+}
+void PrinterVisitor::endVisit ( const
+SpecificNumArithIterator<MultiplyOperation,
+                  store::XS_DOUBLE>& )
+{
+  thePrinter.startEndVisit();
+  thePrinter.endEndVisit();
+}
+void PrinterVisitor::endVisit ( const SpecificNumArithIterator<DivideOperation,
+                  store::XS_DECIMAL>& )
+{
+  thePrinter.startEndVisit();
+  thePrinter.endEndVisit();
+}
+void PrinterVisitor::endVisit ( const SpecificNumArithIterator<DivideOperation,
+                  store::XS_INTEGER>& )
+{
+  thePrinter.startEndVisit();
+  thePrinter.endEndVisit();
+}
+void PrinterVisitor::endVisit ( const SpecificNumArithIterator<DivideOperation,
+                  store::XS_FLOAT>& )
+{
+  thePrinter.startEndVisit();
+  thePrinter.endEndVisit();
+}
+
+void PrinterVisitor::endVisit ( const SpecificNumArithIterator<DivideOperation,
+                  store::XS_DOUBLE>& )
+{
+  thePrinter.startEndVisit();
+  thePrinter.endEndVisit();
+}
+void PrinterVisitor::endVisit ( const SpecificNumArithIterator<ModOperation,
+                  store::XS_DECIMAL>& )
+{
+  thePrinter.startEndVisit();
+  thePrinter.endEndVisit();
+}
+void PrinterVisitor::endVisit ( const SpecificNumArithIterator<ModOperation,
+                  store::XS_INTEGER>& )
+{
+  thePrinter.startEndVisit();
+  thePrinter.endEndVisit();
+}
+void PrinterVisitor::endVisit ( const SpecificNumArithIterator<ModOperation,
+                  store::XS_FLOAT>& )
+{
+  thePrinter.startEndVisit();
+  thePrinter.endEndVisit();
+}
+void PrinterVisitor::endVisit ( const SpecificNumArithIterator<ModOperation,
+                  store::XS_DOUBLE>& )
 {
   thePrinter.startEndVisit();
   thePrinter.endEndVisit();
@@ -1205,13 +1205,13 @@
 
 
 #define TYPED_VAL_CMP( xqt )                                            \
-void PrinterVisitor::beginVisit(const TypedValueCompareIterator<TypeConstants::XS_##xqt>& a){\
+void PrinterVisitor::beginVisit(const TypedValueCompareIterator<store::XS_##xqt>& a){\
     thePrinter.startBeginVisit("TypedValueCompareIterator_" #xqt, ++theId); \
     printCommons( &a, theId );                                          \
     thePrinter.endBeginVisit(theId);                                    \
 }                                                                     \
                                                                         \
-void PrinterVisitor::endVisit(const TypedValueCompareIterator<TypeConstants::XS_##xqt>& a){\
+void PrinterVisitor::endVisit(const TypedValueCompareIterator<store::XS_##xqt>& a){\
     thePrinter.startEndVisit();                                         \
     thePrinter.endEndVisit();                                           \
 }

=== modified file 'src/runtime/visitors/printer_visitor_impl.h'
--- src/runtime/visitors/printer_visitor_impl.h	2012-01-03 12:10:06 +0000
+++ src/runtime/visitors/printer_visitor_impl.h	2012-01-10 13:58:38 +0000
@@ -72,46 +72,46 @@
 void endVisit  (const GenericArithIterator<IntegerDivideOperation>& );
 void endVisit  (const GenericArithIterator<ModOperation>& );
 
-void beginVisit( const SpecificNumArithIterator<AddOperation, TypeConstants::XS_DECIMAL>& a);
-void beginVisit( const SpecificNumArithIterator<AddOperation, TypeConstants::XS_INTEGER>& a);
-void beginVisit( const SpecificNumArithIterator<AddOperation, TypeConstants::XS_FLOAT>& a);
-void beginVisit( const SpecificNumArithIterator<AddOperation, TypeConstants::XS_DOUBLE>& a);
-void beginVisit( const SpecificNumArithIterator<SubtractOperation, TypeConstants::XS_DECIMAL>& a);
-void beginVisit( const SpecificNumArithIterator<SubtractOperation, TypeConstants::XS_INTEGER>& a);
-void beginVisit( const SpecificNumArithIterator<SubtractOperation, TypeConstants::XS_FLOAT>& a);
-void beginVisit( const SpecificNumArithIterator<SubtractOperation, TypeConstants::XS_DOUBLE>& a);
-void beginVisit( const SpecificNumArithIterator<MultiplyOperation, TypeConstants::XS_DECIMAL>& a);
-void beginVisit( const SpecificNumArithIterator<MultiplyOperation, TypeConstants::XS_INTEGER>& a);
-void beginVisit( const SpecificNumArithIterator<MultiplyOperation, TypeConstants::XS_FLOAT>& a);
-void beginVisit( const SpecificNumArithIterator<MultiplyOperation, TypeConstants::XS_DOUBLE>& a);
-void beginVisit( const SpecificNumArithIterator<DivideOperation, TypeConstants::XS_DECIMAL>& a);
-void beginVisit( const SpecificNumArithIterator<DivideOperation, TypeConstants::XS_INTEGER>& a);
-void beginVisit(const SpecificNumArithIterator<DivideOperation, TypeConstants::XS_FLOAT>& a);
-void beginVisit(const SpecificNumArithIterator<DivideOperation, TypeConstants::XS_DOUBLE>& a);
-void beginVisit(const SpecificNumArithIterator<ModOperation, TypeConstants::XS_DECIMAL>& a);
-void beginVisit(const SpecificNumArithIterator<ModOperation, TypeConstants::XS_INTEGER>& a);
-void beginVisit(const SpecificNumArithIterator<ModOperation, TypeConstants::XS_FLOAT>& a);
-void beginVisit(const SpecificNumArithIterator<ModOperation, TypeConstants::XS_DOUBLE>& a);
-void endVisit(const SpecificNumArithIterator<AddOperation, TypeConstants::XS_DECIMAL>& );
-void endVisit(const SpecificNumArithIterator<AddOperation, TypeConstants::XS_INTEGER>& );
-void endVisit(const SpecificNumArithIterator<AddOperation, TypeConstants::XS_FLOAT>& );
-void endVisit(const SpecificNumArithIterator<AddOperation, TypeConstants::XS_DOUBLE>& );
-void endVisit(const SpecificNumArithIterator<SubtractOperation, TypeConstants::XS_DECIMAL>& );
-void endVisit(const SpecificNumArithIterator<SubtractOperation, TypeConstants::XS_INTEGER>& );
-void endVisit(const SpecificNumArithIterator<SubtractOperation, TypeConstants::XS_FLOAT>& );
-void endVisit(const SpecificNumArithIterator<SubtractOperation, TypeConstants::XS_DOUBLE>& );
-void endVisit(const SpecificNumArithIterator<MultiplyOperation, TypeConstants::XS_DECIMAL>& );
-void endVisit(const SpecificNumArithIterator<MultiplyOperation, TypeConstants::XS_INTEGER>& );
-void endVisit(const SpecificNumArithIterator<MultiplyOperation, TypeConstants::XS_FLOAT>& );
-void endVisit(const SpecificNumArithIterator<MultiplyOperation, TypeConstants::XS_DOUBLE>& );
-void endVisit(const SpecificNumArithIterator<DivideOperation, TypeConstants::XS_DECIMAL>& );
-void endVisit(const SpecificNumArithIterator<DivideOperation, TypeConstants::XS_INTEGER>& );
-void endVisit(const SpecificNumArithIterator<DivideOperation, TypeConstants::XS_FLOAT>& );
-void endVisit(const SpecificNumArithIterator<DivideOperation, TypeConstants::XS_DOUBLE>& );
-void endVisit(const SpecificNumArithIterator<ModOperation, TypeConstants::XS_DECIMAL>& );
-void endVisit(const SpecificNumArithIterator<ModOperation, TypeConstants::XS_INTEGER>& );
-void endVisit(const SpecificNumArithIterator<ModOperation, TypeConstants::XS_FLOAT>& );
-void endVisit(const SpecificNumArithIterator<ModOperation, TypeConstants::XS_DOUBLE>& );
+void beginVisit( const SpecificNumArithIterator<AddOperation, store::XS_DECIMAL>& a);
+void beginVisit( const SpecificNumArithIterator<AddOperation, store::XS_INTEGER>& a);
+void beginVisit( const SpecificNumArithIterator<AddOperation, store::XS_FLOAT>& a);
+void beginVisit( const SpecificNumArithIterator<AddOperation, store::XS_DOUBLE>& a);
+void beginVisit( const SpecificNumArithIterator<SubtractOperation, store::XS_DECIMAL>& a);
+void beginVisit( const SpecificNumArithIterator<SubtractOperation, store::XS_INTEGER>& a);
+void beginVisit( const SpecificNumArithIterator<SubtractOperation, store::XS_FLOAT>& a);
+void beginVisit( const SpecificNumArithIterator<SubtractOperation, store::XS_DOUBLE>& a);
+void beginVisit( const SpecificNumArithIterator<MultiplyOperation, store::XS_DECIMAL>& a);
+void beginVisit( const SpecificNumArithIterator<MultiplyOperation, store::XS_INTEGER>& a);
+void beginVisit( const SpecificNumArithIterator<MultiplyOperation, store::XS_FLOAT>& a);
+void beginVisit( const SpecificNumArithIterator<MultiplyOperation, store::XS_DOUBLE>& a);
+void beginVisit( const SpecificNumArithIterator<DivideOperation, store::XS_DECIMAL>& a);
+void beginVisit( const SpecificNumArithIterator<DivideOperation, store::XS_INTEGER>& a);
+void beginVisit(const SpecificNumArithIterator<DivideOperation, store::XS_FLOAT>& a);
+void beginVisit(const SpecificNumArithIterator<DivideOperation, store::XS_DOUBLE>& a);
+void beginVisit(const SpecificNumArithIterator<ModOperation, store::XS_DECIMAL>& a);
+void beginVisit(const SpecificNumArithIterator<ModOperation, store::XS_INTEGER>& a);
+void beginVisit(const SpecificNumArithIterator<ModOperation, store::XS_FLOAT>& a);
+void beginVisit(const SpecificNumArithIterator<ModOperation, store::XS_DOUBLE>& a);
+void endVisit(const SpecificNumArithIterator<AddOperation, store::XS_DECIMAL>& );
+void endVisit(const SpecificNumArithIterator<AddOperation, store::XS_INTEGER>& );
+void endVisit(const SpecificNumArithIterator<AddOperation, store::XS_FLOAT>& );
+void endVisit(const SpecificNumArithIterator<AddOperation, store::XS_DOUBLE>& );
+void endVisit(const SpecificNumArithIterator<SubtractOperation, store::XS_DECIMAL>& );
+void endVisit(const SpecificNumArithIterator<SubtractOperation, store::XS_INTEGER>& );
+void endVisit(const SpecificNumArithIterator<SubtractOperation, store::XS_FLOAT>& );
+void endVisit(const SpecificNumArithIterator<SubtractOperation, store::XS_DOUBLE>& );
+void endVisit(const SpecificNumArithIterator<MultiplyOperation, store::XS_DECIMAL>& );
+void endVisit(const SpecificNumArithIterator<MultiplyOperation, store::XS_INTEGER>& );
+void endVisit(const SpecificNumArithIterator<MultiplyOperation, store::XS_FLOAT>& );
+void endVisit(const SpecificNumArithIterator<MultiplyOperation, store::XS_DOUBLE>& );
+void endVisit(const SpecificNumArithIterator<DivideOperation, store::XS_DECIMAL>& );
+void endVisit(const SpecificNumArithIterator<DivideOperation, store::XS_INTEGER>& );
+void endVisit(const SpecificNumArithIterator<DivideOperation, store::XS_FLOAT>& );
+void endVisit(const SpecificNumArithIterator<DivideOperation, store::XS_DOUBLE>& );
+void endVisit(const SpecificNumArithIterator<ModOperation, store::XS_DECIMAL>& );
+void endVisit(const SpecificNumArithIterator<ModOperation, store::XS_INTEGER>& );
+void endVisit(const SpecificNumArithIterator<ModOperation, store::XS_FLOAT>& );
+void endVisit(const SpecificNumArithIterator<ModOperation, store::XS_DOUBLE>& );
 
 void beginVisit ( const FnMinMaxIterator& a);
 void endVisit   ( const FnMinMaxIterator& );
@@ -210,16 +210,16 @@
     void endVisit  (const PromoteIterator& );
     void beginVisit(const CastableIterator& a);
     void endVisit  (const CastableIterator& );
-    void beginVisit ( const TypedValueCompareIterator<TypeConstants::XS_DECIMAL>& a);
-    void beginVisit ( const TypedValueCompareIterator<TypeConstants::XS_INTEGER>& a);
-    void beginVisit ( const TypedValueCompareIterator<TypeConstants::XS_DOUBLE>& a);
-    void beginVisit ( const TypedValueCompareIterator<TypeConstants::XS_FLOAT>& a);
-    void beginVisit ( const TypedValueCompareIterator<TypeConstants::XS_STRING>& a);
-    void endVisit ( const TypedValueCompareIterator<TypeConstants::XS_DECIMAL>& a);
-    void endVisit ( const TypedValueCompareIterator<TypeConstants::XS_INTEGER>& a);
-    void endVisit ( const TypedValueCompareIterator<TypeConstants::XS_DOUBLE>& a);
-    void endVisit ( const TypedValueCompareIterator<TypeConstants::XS_FLOAT>& a);
-    void endVisit ( const TypedValueCompareIterator<TypeConstants::XS_STRING>& a);
+    void beginVisit ( const TypedValueCompareIterator<store::XS_DECIMAL>& a);
+    void beginVisit ( const TypedValueCompareIterator<store::XS_INTEGER>& a);
+    void beginVisit ( const TypedValueCompareIterator<store::XS_DOUBLE>& a);
+    void beginVisit ( const TypedValueCompareIterator<store::XS_FLOAT>& a);
+    void beginVisit ( const TypedValueCompareIterator<store::XS_STRING>& a);
+    void endVisit ( const TypedValueCompareIterator<store::XS_DECIMAL>& a);
+    void endVisit ( const TypedValueCompareIterator<store::XS_INTEGER>& a);
+    void endVisit ( const TypedValueCompareIterator<store::XS_DOUBLE>& a);
+    void endVisit ( const TypedValueCompareIterator<store::XS_FLOAT>& a);
+    void endVisit ( const TypedValueCompareIterator<store::XS_STRING>& a);
 
   DECLARE_VISITOR (UDFunctionCallIterator)
   DECLARE_VISITOR (ExtFunctionCallIterator)

=== modified file 'src/store/api/item.h'
--- src/store/api/item.h	2012-01-03 12:10:06 +0000
+++ src/store/api/item.h	2012-01-10 13:58:38 +0000
@@ -26,6 +26,7 @@
 #include "zorbatypes/rclock.h"
 #include "zorbatypes/schema_types.h"
 
+#include "store/api/xs_type_codes.h"
 #include "store/api/shared_types.h"
 
 #ifndef ZORBA_NO_FULL_TEXT
@@ -239,6 +240,11 @@
   /* -------------------  Methods for AtomicValues ------------------------------ */
 
   /**
+   * @return The numeric code coresponding to the data type of this item.
+   */
+  virtual SchemaTypeCode getTypeCode() const;
+
+  /**
    * @return If this is an atomic item with a user-defined data type UT, return
    *         the underlying atomic item that stores the actual value and whose
    *         data type is a builtin atomic supertype of UT. Otherwise, return NULL.

=== added file 'src/store/api/xs_type_codes.h'
--- src/store/api/xs_type_codes.h	1970-01-01 00:00:00 +0000
+++ src/store/api/xs_type_codes.h	2012-01-10 13:58:38 +0000
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef ZORBA_STORE_XS_TYPES_ENUM
+#define ZORBA_STORE_XS_TYPES_ENUM
+
+
+namespace zorba 
+{ 
+
+namespace store
+{
+
+/*******************************************************************************
+  !!! ATTENTION: The order of thr enum values within SchemaTypeCode is important.
+  !!! DO NOT change this order!!!!
+********************************************************************************/
+enum SchemaTypeCode
+{
+  XS_ANY_ATOMIC            = 0,
+
+  XS_STRING                = 1,
+  XS_NORMALIZED_STRING     = 2,
+  XS_TOKEN                 = 3,
+  XS_LANGUAGE              = 4,
+  XS_NMTOKEN               = 5,
+  XS_NAME                  = 6,
+  XS_NCNAME                = 7,
+  XS_ID                    = 8,
+  XS_IDREF                 = 9,
+  XS_ENTITY                = 10,
+
+  XS_UNTYPED_ATOMIC        = 11,
+
+  XS_DATETIME              = 12,
+  XS_DATE                  = 13,
+  XS_TIME                  = 14,
+  XS_DURATION              = 15,
+  XS_DT_DURATION           = 16,
+  XS_YM_DURATION           = 17,
+
+  XS_FLOAT                 = 18,
+  XS_DOUBLE                = 19,
+
+  XS_DECIMAL               = 20,
+  XS_INTEGER               = 21,
+  XS_NON_POSITIVE_INTEGER  = 22,
+  XS_NEGATIVE_INTEGER      = 23,
+  XS_LONG                  = 24,
+  XS_INT                   = 25,
+  XS_SHORT                 = 26,
+  XS_BYTE                  = 27,
+  XS_NON_NEGATIVE_INTEGER  = 28,
+  XS_UNSIGNED_LONG         = 29,
+  XS_UNSIGNED_INT          = 30,
+  XS_UNSIGNED_SHORT        = 31,
+  XS_UNSIGNED_BYTE         = 32,
+  XS_POSITIVE_INTEGER      = 33,
+
+  XS_GYEAR_MONTH           = 34,
+  XS_GYEAR                 = 35,
+  XS_GMONTH_DAY            = 36,
+  XS_GDAY                  = 37,
+  XS_GMONTH                = 38,
+
+  XS_BOOLEAN               = 39,
+
+  XS_BASE64BINARY          = 40,
+  XS_HEXBINARY             = 41,
+
+  XS_ANY_URI               = 42,
+
+  XS_QNAME                 = 43,
+  XS_NOTATION              = 44,
+
+  XS_LAST
+};
+
+}
+}
+#endif
+/* vim:set et sw=2 ts=2: */

=== modified file 'src/store/naive/atomic_items.cpp'
--- src/store/naive/atomic_items.cpp	2011-12-30 17:55:53 +0000
+++ src/store/naive/atomic_items.cpp	2012-01-10 13:58:38 +0000
@@ -96,7 +96,7 @@
 
   switch (item1->getTypeCode())
   {
-  case XS_UNTYPED_ATOMIC:
+  case store::XS_UNTYPED_ATOMIC:
   {
     const UntypedAtomicItem* item = static_cast<const UntypedAtomicItem*>(item1);
     try
@@ -111,8 +111,8 @@
     break;
   }
 
-  case XS_DOUBLE:
-  case XS_FLOAT:
+  case store::XS_DOUBLE:
+  case store::XS_FLOAT:
   {
     double doubleValue = item1->getDoubleValue().getNumber();
     longValue = static_cast<xs_long>(doubleValue);
@@ -123,7 +123,7 @@
     break;
   }
 
-  case XS_DECIMAL:
+  case store::XS_DECIMAL:
   {
     const DecimalItem* item = static_cast<const DecimalItem*>(item1);
     try
@@ -138,11 +138,11 @@
     break;
   }
 
-  case XS_INTEGER:
-  case XS_NON_POSITIVE_INTEGER:
-  case XS_NEGATIVE_INTEGER:
-  case XS_NON_NEGATIVE_INTEGER:
-  case XS_POSITIVE_INTEGER:
+  case store::XS_INTEGER:
+  case store::XS_NON_POSITIVE_INTEGER:
+  case store::XS_NEGATIVE_INTEGER:
+  case store::XS_NON_NEGATIVE_INTEGER:
+  case store::XS_POSITIVE_INTEGER:
   {
     const IntegerItem* item = static_cast<const IntegerItem*>(item1);
     try
@@ -157,7 +157,7 @@
     break;
   }
 
-  case XS_UNSIGNED_LONG:
+  case store::XS_UNSIGNED_LONG:
   {
     const UnsignedLongItem* item = static_cast<const UnsignedLongItem*>(item1);
     if ((item->theValue >> 63) == 0)
@@ -197,7 +197,7 @@
 
   switch (item1->getTypeCode())
   {
-  case XS_DECIMAL:
+  case store::XS_DECIMAL:
   {
     const DecimalItem* item = static_cast<const DecimalItem*>(item1);
 
@@ -209,11 +209,11 @@
     break;
   }
 
-  case XS_INTEGER:
-  case XS_NON_POSITIVE_INTEGER:
-  case XS_NEGATIVE_INTEGER:
-  case XS_NON_NEGATIVE_INTEGER:
-  case XS_POSITIVE_INTEGER:
+  case store::XS_INTEGER:
+  case store::XS_NON_POSITIVE_INTEGER:
+  case store::XS_NEGATIVE_INTEGER:
+  case store::XS_NON_NEGATIVE_INTEGER:
+  case store::XS_POSITIVE_INTEGER:
   {
     const IntegerItem* item = static_cast<const IntegerItem*>(item1);
 
@@ -225,7 +225,7 @@
     break;
   }
 
-  case XS_UNSIGNED_LONG:
+  case store::XS_UNSIGNED_LONG:
   {
     const UnsignedLongItem* item = static_cast<const UnsignedLongItem*>(item1);
 
@@ -237,16 +237,16 @@
     break;
   }
 
-  case XS_UNSIGNED_INT:
-  case XS_UNSIGNED_SHORT:
-  case XS_UNSIGNED_BYTE:
+  case store::XS_UNSIGNED_INT:
+  case store::XS_UNSIGNED_SHORT:
+  case store::XS_UNSIGNED_BYTE:
   {
     doubleValue = getUnsignedIntValue();
     lossy = false;
     break;
   }
 
-  case XS_LONG:
+  case store::XS_LONG:
   {
     const LongItem* item = static_cast<const LongItem*>(item1);
 
@@ -258,9 +258,9 @@
     break;
   }
 
-  case XS_INT:
-  case XS_SHORT:
-  case XS_BYTE:
+  case store::XS_INT:
+  case store::XS_SHORT:
+  case store::XS_BYTE:
   {
     doubleValue = item1->getIntValue();
     lossy = false;
@@ -291,7 +291,7 @@
     bool& negINF,
     bool& posINF) const
 {
-  if (getTypeCode() != XS_DOUBLE && getTypeCode() != XS_FLOAT)
+  if (getTypeCode() != store::XS_DOUBLE && getTypeCode() != store::XS_FLOAT)
   {
     RAISE_ERROR_NO_LOC(zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
     ERROR_PARAMS(__FUNCTION__, typeid(*this).name()));
@@ -556,7 +556,7 @@
 
 store::Item* UntypedAtomicItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_UNTYPED_ATOMIC];
+  return GET_STORE().theSchemaTypeNames[store::XS_UNTYPED_ATOMIC];
 }
 
 
@@ -630,7 +630,7 @@
 
 store::Item* QNameItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_QNAME];
+  return GET_STORE().theSchemaTypeNames[store::XS_QNAME];
 }
 
 
@@ -765,7 +765,7 @@
 
 store::Item* NotationItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_NOTATION];
+  return GET_STORE().theSchemaTypeNames[store::XS_NOTATION];
 }
 
 
@@ -806,7 +806,7 @@
 ********************************************************************************/
 store::Item* AnyUriItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_ANY_URI];
+  return GET_STORE().theSchemaTypeNames[store::XS_ANY_URI];
 }
 
 
@@ -1556,7 +1556,7 @@
 ********************************************************************************/
 store::Item* StringItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_STRING];
+  return GET_STORE().theSchemaTypeNames[store::XS_STRING];
 }
 
 
@@ -1797,7 +1797,7 @@
 ********************************************************************************/
 store::Item* NormalizedStringItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_NORMALIZED_STRING];
+  return GET_STORE().theSchemaTypeNames[store::XS_NORMALIZED_STRING];
 }
 
 
@@ -1815,7 +1815,7 @@
 ********************************************************************************/
 store::Item* TokenItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_TOKEN];
+  return GET_STORE().theSchemaTypeNames[store::XS_TOKEN];
 }
 
 
@@ -1833,7 +1833,7 @@
 ********************************************************************************/
 store::Item* LanguageItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_LANGUAGE];
+  return GET_STORE().theSchemaTypeNames[store::XS_LANGUAGE];
 }
 
 
@@ -1851,7 +1851,7 @@
 ********************************************************************************/
 store::Item* NMTOKENItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_NMTOKEN];
+  return GET_STORE().theSchemaTypeNames[store::XS_NMTOKEN];
 }
 
 
@@ -1869,7 +1869,7 @@
 ********************************************************************************/
 store::Item* NameItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_NAME];
+  return GET_STORE().theSchemaTypeNames[store::XS_NAME];
 }
 
 
@@ -1887,7 +1887,7 @@
 ********************************************************************************/
 store::Item* NCNameItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_NCNAME];
+  return GET_STORE().theSchemaTypeNames[store::XS_NCNAME];
 }
 
 
@@ -1905,7 +1905,7 @@
 ********************************************************************************/
 store::Item* IDItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_ID];
+  return GET_STORE().theSchemaTypeNames[store::XS_ID];
 }
 
 
@@ -1923,7 +1923,7 @@
 ********************************************************************************/
 store::Item* IDREFItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_IDREF];
+  return GET_STORE().theSchemaTypeNames[store::XS_IDREF];
 }
 
 
@@ -1941,7 +1941,7 @@
 ********************************************************************************/
 store::Item* ENTITYItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_ENTITY];
+  return GET_STORE().theSchemaTypeNames[store::XS_ENTITY];
 }
 
 zstring ENTITYItem::show() const
@@ -1973,33 +1973,33 @@
 }
 
 
-SchemaTypeCode DateTimeItem::getTypeCode() const
+store::SchemaTypeCode DateTimeItem::getTypeCode() const
 {
   switch (theValue.getFacet())
   {
   case DateTime::GYEARMONTH_FACET:
-    return XS_GYEAR_MONTH;
+    return store::XS_GYEAR_MONTH;
 
   case DateTime::GYEAR_FACET:
-    return XS_GYEAR;
+    return store::XS_GYEAR;
 
   case DateTime::GMONTH_FACET:
-    return XS_GMONTH;
+    return store::XS_GMONTH;
 
   case DateTime::GMONTHDAY_FACET:
-    return XS_GMONTH_DAY;
+    return store::XS_GMONTH_DAY;
 
   case DateTime::GDAY_FACET:
-    return XS_GDAY;
+    return store::XS_GDAY;
 
   case DateTime::DATE_FACET:
-    return XS_DATE;
+    return store::XS_DATE;
 
   case DateTime::TIME_FACET:
-    return XS_TIME;
+    return store::XS_TIME;
 
   case DateTime::DATETIME_FACET:
-    return XS_DATETIME;
+    return store::XS_DATETIME;
 
   default:
     ZORBA_ASSERT(false);
@@ -2170,19 +2170,19 @@
 }
 
 
-SchemaTypeCode DurationItem::getTypeCode() const
+store::SchemaTypeCode DurationItem::getTypeCode() const
 {
   switch (theValue.getFacet())
   {
   case Duration::DURATION_FACET:
-    return XS_DURATION;
+    return store::XS_DURATION;
 
   case Duration::DAYTIMEDURATION_FACET:
-    return XS_DT_DURATION;
+    return store::XS_DT_DURATION;
 
   case Duration::YEARMONTHDURATION_FACET:
   default:
-    return XS_YM_DURATION;
+    return store::XS_YM_DURATION;
   }
 }
 
@@ -2212,7 +2212,7 @@
 ********************************************************************************/
 store::Item* DoubleItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_DOUBLE];
+  return GET_STORE().theSchemaTypeNames[store::XS_DOUBLE];
 }
 
 
@@ -2284,7 +2284,7 @@
 ********************************************************************************/
 store::Item* FloatItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_FLOAT];
+  return GET_STORE().theSchemaTypeNames[store::XS_FLOAT];
 }
 
 
@@ -2356,7 +2356,7 @@
 
 store::Item* DecimalItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_DECIMAL];
+  return GET_STORE().theSchemaTypeNames[store::XS_DECIMAL];
 }
 
 
@@ -2451,7 +2451,7 @@
 
 store::Item* IntegerItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_INTEGER];
+  return GET_STORE().theSchemaTypeNames[store::XS_INTEGER];
 }
 
 
@@ -2500,7 +2500,7 @@
 ********************************************************************************/
 store::Item* NonPositiveIntegerItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_NON_POSITIVE_INTEGER];
+  return GET_STORE().theSchemaTypeNames[store::XS_NON_POSITIVE_INTEGER];
 }
 
 zstring NonPositiveIntegerItem::show() const
@@ -2517,7 +2517,7 @@
 ********************************************************************************/
 store::Item* NegativeIntegerItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_NEGATIVE_INTEGER];
+  return GET_STORE().theSchemaTypeNames[store::XS_NEGATIVE_INTEGER];
 }
 
 
@@ -2535,7 +2535,7 @@
 ********************************************************************************/
 store::Item* NonNegativeIntegerItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_NON_NEGATIVE_INTEGER];
+  return GET_STORE().theSchemaTypeNames[store::XS_NON_NEGATIVE_INTEGER];
 }
 
 
@@ -2553,7 +2553,7 @@
 ********************************************************************************/
 store::Item* PositiveIntegerItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_POSITIVE_INTEGER];
+  return GET_STORE().theSchemaTypeNames[store::XS_POSITIVE_INTEGER];
 }
 
 
@@ -2583,7 +2583,7 @@
 
 store::Item* LongItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_LONG];
+  return GET_STORE().theSchemaTypeNames[store::XS_LONG];
 }
 
 
@@ -2644,7 +2644,7 @@
 
 store::Item* IntItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_INT];
+  return GET_STORE().theSchemaTypeNames[store::XS_INT];
 }
 
 
@@ -2704,7 +2704,7 @@
 
 store::Item* ShortItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_SHORT];
+  return GET_STORE().theSchemaTypeNames[store::XS_SHORT];
 }
 
 
@@ -2765,7 +2765,7 @@
 
 store::Item* ByteItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_BYTE];
+  return GET_STORE().theSchemaTypeNames[store::XS_BYTE];
 }
 
 
@@ -2832,7 +2832,7 @@
 
 store::Item* UnsignedLongItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_UNSIGNED_LONG];
+  return GET_STORE().theSchemaTypeNames[store::XS_UNSIGNED_LONG];
 }
 
 
@@ -2899,7 +2899,7 @@
 
 store::Item* UnsignedIntItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_UNSIGNED_INT];
+  return GET_STORE().theSchemaTypeNames[store::XS_UNSIGNED_INT];
 }
 
 
@@ -2966,7 +2966,7 @@
 
 store::Item* UnsignedShortItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_UNSIGNED_SHORT];
+  return GET_STORE().theSchemaTypeNames[store::XS_UNSIGNED_SHORT];
 }
 
 
@@ -3033,7 +3033,7 @@
 
 store::Item* UnsignedByteItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_UNSIGNED_BYTE];
+  return GET_STORE().theSchemaTypeNames[store::XS_UNSIGNED_BYTE];
 }
 
 
@@ -3082,7 +3082,7 @@
 ********************************************************************************/
 store::Item* BooleanItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_BOOLEAN];
+  return GET_STORE().theSchemaTypeNames[store::XS_BOOLEAN];
 }
 
 
@@ -3139,7 +3139,7 @@
 ********************************************************************************/
 store::Item* Base64BinaryItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_BASE64BINARY];
+  return GET_STORE().theSchemaTypeNames[store::XS_BASE64BINARY];
 }
 
 
@@ -3181,7 +3181,7 @@
 ********************************************************************************/
 store::Item* HexBinaryItem::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_HEXBINARY];
+  return GET_STORE().theSchemaTypeNames[store::XS_HEXBINARY];
 }
 
 

=== modified file 'src/store/naive/atomic_items.h'
--- src/store/naive/atomic_items.h	2011-12-21 14:40:33 +0000
+++ src/store/naive/atomic_items.h	2012-01-10 13:58:38 +0000
@@ -28,6 +28,7 @@
 
 #include "store/api/item.h"
 #include "store/api/item_handle.h"
+#include "store/api/xs_type_codes.h"
 #include "store/naive/store_defs.h"
 #include "store/naive/shared_types.h"
 
@@ -79,16 +80,11 @@
 
   store::Item_t getAtomizationValue() const;
 
-  virtual SchemaTypeCode getTypeCode() const = 0;
-
   void getTypedValue(store::Item_t& val, store::Iterator_t& iter) const;
 
   bool castToLong(store::Item_t& result) const;
 
-  void coerceToDouble(
-      store::Item_t& result,
-      bool force,
-      bool& lossy) const;
+  void coerceToDouble(store::Item_t& result, bool force, bool& lossy) const;
 };
 
 
@@ -118,7 +114,7 @@
 public:
   store::Item* getBaseItem() const;
 
-  SchemaTypeCode getTypeCode() const { return theBaseItem->getTypeCode(); }
+  store::SchemaTypeCode getTypeCode() const { return theBaseItem->getTypeCode(); }
 
   store::Item* getType() const { return theTypeName.getp(); }
 
@@ -305,7 +301,7 @@
 
   bool castToBoolean(store::Item_t& result) const;
 
-  SchemaTypeCode getTypeCode() const { return XS_UNTYPED_ATOMIC; }
+  store::SchemaTypeCode getTypeCode() const { return store::XS_UNTYPED_ATOMIC; }
 
   store::Item* getType() const;
 
@@ -367,7 +363,7 @@
 
   const zstring& getLocalName() const { return getNormalized()->theLocal; }
 
-  SchemaTypeCode getTypeCode() const { return XS_QNAME; }
+  store::SchemaTypeCode getTypeCode() const { return store::XS_QNAME; }
 
   store::Item* getType() const;
 
@@ -476,7 +472,7 @@
 
   zstring show() const;
 
-  virtual SchemaTypeCode getTypeCode() const { return XS_NOTATION; }
+  virtual store::SchemaTypeCode getTypeCode() const { return store::XS_NOTATION; }
 };
 
 
@@ -502,7 +498,7 @@
     return NON_SPECIALIZED_ANY_URI;
   }
 
-  SchemaTypeCode getTypeCode() const { return XS_ANY_URI; }
+  store::SchemaTypeCode getTypeCode() const { return store::XS_ANY_URI; }
 
   store::Item* getType( ) const;
 
@@ -729,7 +725,7 @@
 
 public:
 
-  virtual SchemaTypeCode getTypeCode() const { return XS_STRING; }
+  virtual store::SchemaTypeCode getTypeCode() const { return store::XS_STRING; }
 
   virtual store::Item* getType() const;
 
@@ -852,7 +848,7 @@
   NormalizedStringItem(zstring& value) : StringItem(value) {}
 
 public:
-  virtual SchemaTypeCode getTypeCode() const { return XS_NORMALIZED_STRING; }
+  virtual store::SchemaTypeCode getTypeCode() const { return store::XS_NORMALIZED_STRING; }
 
   virtual store::Item* getType() const;
 
@@ -870,7 +866,7 @@
 public:
   TokenItem(zstring& value) : NormalizedStringItem(value) {}
 
-  virtual SchemaTypeCode getTypeCode() const { return XS_TOKEN; }
+  virtual store::SchemaTypeCode getTypeCode() const { return store::XS_TOKEN; }
 
   virtual store::Item* getType() const;
 
@@ -889,7 +885,7 @@
   NMTOKENItem(zstring& value) : TokenItem(value) {}
 
 public:
-  virtual SchemaTypeCode getTypeCode() const { return XS_NMTOKEN; }
+  virtual store::SchemaTypeCode getTypeCode() const { return store::XS_NMTOKEN; }
 
   virtual store::Item* getType() const;
 
@@ -908,7 +904,7 @@
   LanguageItem(zstring& value) : TokenItem(value) {}
 
 public:
-  virtual SchemaTypeCode getTypeCode() const { return XS_LANGUAGE; }
+  virtual store::SchemaTypeCode getTypeCode() const { return store::XS_LANGUAGE; }
 
   virtual store::Item* getType() const;
 
@@ -927,7 +923,7 @@
   NameItem(zstring& value) : TokenItem(value) {}
 
 public:
-  virtual SchemaTypeCode getTypeCode() const { return XS_NAME; }
+  virtual store::SchemaTypeCode getTypeCode() const { return store::XS_NAME; }
 
   virtual store::Item* getType() const;
 
@@ -946,7 +942,7 @@
   NCNameItem(zstring& value) : NameItem(value) {}
 
 public:
-  virtual SchemaTypeCode getTypeCode() const { return XS_NCNAME; }
+  virtual store::SchemaTypeCode getTypeCode() const { return store::XS_NCNAME; }
 
   virtual store::Item* getType() const;
 
@@ -965,7 +961,7 @@
   IDItem(zstring& value) : NCNameItem(value) { }
 
 public:
-  SchemaTypeCode getTypeCode() const { return XS_ID; }
+  store::SchemaTypeCode getTypeCode() const { return store::XS_ID; }
 
   store::Item* getType() const;
 
@@ -983,7 +979,7 @@
   IDREFItem(zstring& value) : NCNameItem(value) { }
 
 public:
-  SchemaTypeCode getTypeCode() const { return XS_IDREF; }
+  store::SchemaTypeCode getTypeCode() const { return store::XS_IDREF; }
 
   store::Item* getType() const;
 
@@ -1001,7 +997,7 @@
   ENTITYItem(zstring& value) : NCNameItem(value) { }
 
 public:
-  SchemaTypeCode getTypeCode() const { return XS_ENTITY; }
+  store::SchemaTypeCode getTypeCode() const { return store::XS_ENTITY; }
 
   store::Item* getType() const;
 
@@ -1041,7 +1037,7 @@
 
   const xs_gDay& getGDayValue() const { return theValue; }
 
-  SchemaTypeCode getTypeCode() const;
+  store::SchemaTypeCode getTypeCode() const;
 
   store::Item* getType() const;
 
@@ -1091,7 +1087,7 @@
 
   const xs_yearMonthDuration& getYearMonthDurationValue() const;
 
-  SchemaTypeCode getTypeCode() const;
+  store::SchemaTypeCode getTypeCode() const;
 
   store::Item* getType() const;
 
@@ -1151,7 +1147,7 @@
 
   bool isPosOrNegInf() const;
 
-  SchemaTypeCode getTypeCode() const { return XS_DOUBLE; }
+  store::SchemaTypeCode getTypeCode() const { return store::XS_DOUBLE; }
 
 	store::Item* getType() const;
 
@@ -1212,7 +1208,7 @@
 
   bool isPosOrNegInf() const;
 
-  SchemaTypeCode getTypeCode() const { return XS_FLOAT; }
+  store::SchemaTypeCode getTypeCode() const { return store::XS_FLOAT; }
 
   store::Item* getType() const;
 
@@ -1289,7 +1285,7 @@
 public:
   xs_decimal getDecimalValue() const { return theValue; }
 
-  SchemaTypeCode getTypeCode() const { return XS_DECIMAL; }
+  store::SchemaTypeCode getTypeCode() const { return store::XS_DECIMAL; }
 
   store::Item* getType() const;
 
@@ -1351,7 +1347,7 @@
 
   xs_long getLongValue() const;
 
-  virtual SchemaTypeCode getTypeCode() const { return XS_INTEGER; }
+  virtual store::SchemaTypeCode getTypeCode() const { return store::XS_INTEGER; }
 
   virtual store::Item* getType() const;
 
@@ -1394,7 +1390,7 @@
   NonPositiveIntegerItem() {}
 
 public:
-  SchemaTypeCode getTypeCode() const { return XS_NON_POSITIVE_INTEGER; }
+  store::SchemaTypeCode getTypeCode() const { return store::XS_NON_POSITIVE_INTEGER; }
 
   store::Item* getType() const;
 
@@ -1415,7 +1411,7 @@
   NegativeIntegerItem() {}
 
 public:
-  SchemaTypeCode getTypeCode() const { return XS_NEGATIVE_INTEGER; }
+  store::SchemaTypeCode getTypeCode() const { return store::XS_NEGATIVE_INTEGER; }
 
   store::Item* getType() const;
 
@@ -1440,7 +1436,7 @@
 public:
   xs_uinteger getUnsignedIntegerValue() const { return theValue; }
 
-  SchemaTypeCode getTypeCode() const { return XS_NON_NEGATIVE_INTEGER; }
+  store::SchemaTypeCode getTypeCode() const { return store::XS_NON_NEGATIVE_INTEGER; }
 
   store::Item* getType() const;
 
@@ -1463,7 +1459,7 @@
 public:
   xs_uinteger getUnsignedIntegerValue() const { return theValue; }
 
-  SchemaTypeCode getTypeCode() const { return XS_POSITIVE_INTEGER; }
+  store::SchemaTypeCode getTypeCode() const { return store::XS_POSITIVE_INTEGER; }
 
   store::Item* getType() const;
 
@@ -1494,7 +1490,7 @@
 
   xs_long getLongValue() const { return theValue; }
 
-  SchemaTypeCode getTypeCode() const { return XS_LONG; }
+  store::SchemaTypeCode getTypeCode() const { return store::XS_LONG; }
 
   store::Item* getType() const;
 
@@ -1576,7 +1572,7 @@
 
   int32_t getIntValue() const { return theValue; }
 
-  SchemaTypeCode getTypeCode() const { return XS_INT; }
+  store::SchemaTypeCode getTypeCode() const { return store::XS_INT; }
 
   store::Item* getType( ) const;
 
@@ -1656,7 +1652,7 @@
 
   xs_short getShortValue() const { return theValue; }
 
-  SchemaTypeCode getTypeCode() const { return XS_SHORT; }
+  store::SchemaTypeCode getTypeCode() const { return store::XS_SHORT; }
 
   store::Item* getType() const;
 
@@ -1740,7 +1736,7 @@
 
   xs_byte getByteValue() const { return theValue; }
 
-  SchemaTypeCode getTypeCode() const { return XS_BYTE; }
+  store::SchemaTypeCode getTypeCode() const { return store::XS_BYTE; }
 
   store::Item* getType() const;
 
@@ -1822,7 +1818,7 @@
 
   xs_unsignedLong getUnsignedLongValue() const { return theValue; }
 
-  SchemaTypeCode getTypeCode() const { return XS_UNSIGNED_LONG; }
+  store::SchemaTypeCode getTypeCode() const { return store::XS_UNSIGNED_LONG; }
 
   store::Item* getType() const;
 
@@ -1906,7 +1902,7 @@
 
   xs_unsignedInt getUnsignedIntValue() const { return theValue; }
 
-  SchemaTypeCode getTypeCode() const { return XS_UNSIGNED_INT; }
+  store::SchemaTypeCode getTypeCode() const { return store::XS_UNSIGNED_INT; }
 
   store::Item* getType() const;
 
@@ -1999,7 +1995,7 @@
 
   bool isNaN() const { return false; }
 
-  SchemaTypeCode getTypeCode() const { return XS_UNSIGNED_SHORT; }
+  store::SchemaTypeCode getTypeCode() const { return store::XS_UNSIGNED_SHORT; }
 
   store::Item* getType() const;
 
@@ -2094,7 +2090,7 @@
 
   bool isNaN() const { return false; }
 
-  SchemaTypeCode getTypeCode() const { return XS_UNSIGNED_BYTE; }
+  store::SchemaTypeCode getTypeCode() const { return store::XS_UNSIGNED_BYTE; }
 
   store::Item* getType() const;
 
@@ -2172,7 +2168,7 @@
 public:
   xs_boolean getBooleanValue() const { return theValue; }
 
-  SchemaTypeCode getTypeCode() const { return XS_BOOLEAN; }
+  store::SchemaTypeCode getTypeCode() const { return store::XS_BOOLEAN; }
 
   store::Item* getType() const;
 
@@ -2226,7 +2222,7 @@
 public:
   xs_base64Binary getBase64BinaryValue() const { return theValue; }
 
-  SchemaTypeCode getTypeCode() const { return XS_BASE64BINARY; }
+  store::SchemaTypeCode getTypeCode() const { return store::XS_BASE64BINARY; }
 
   store::Item* getType() const;
 
@@ -2261,23 +2257,20 @@
   xs_hexBinary theValue;
 
 protected:
-  HexBinaryItem(xs_hexBinary aValue) : theValue(aValue) {}
+  HexBinaryItem(xs_hexBinary value) : theValue(value) {}
 
   HexBinaryItem() {}
 
 public:
   xs_hexBinary getHexBinaryValue() const { return theValue; }
 
-  SchemaTypeCode getTypeCode() const { return XS_HEXBINARY; }
+  store::SchemaTypeCode getTypeCode() const { return store::XS_HEXBINARY; }
 
   store::Item* getType() const;
 
-  uint32_t hash(long timezone = 0, const XQPCollator* aCollation = 0) const;
+  uint32_t hash(long timezone = 0, const XQPCollator* coll = 0) const;
 
-  bool equals(
-        const store::Item* other,
-        long timezone = 0,
-        const XQPCollator* aCollation = 0 ) const
+  bool equals(const store::Item* other, long tz = 0, const XQPCollator* coll = 0) const
   {
     return theValue.equal(other->getHexBinaryValue());
   }
@@ -2326,8 +2319,6 @@
 
   ZorbaException* getError() const { return theError; }
 
-  SchemaTypeCode getTypeCode() const { return ZXSE_ERROR; }
-
   zstring show() const;
 
 protected:

=== modified file 'src/store/naive/item.cpp'
--- src/store/naive/item.cpp	2011-12-21 14:40:33 +0000
+++ src/store/naive/item.cpp	2012-01-10 13:58:38 +0000
@@ -212,6 +212,15 @@
 }
 
 
+store::SchemaTypeCode Item::getTypeCode() const
+{
+  throw ZORBA_EXCEPTION(
+    zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
+    ERROR_PARAMS( __FUNCTION__, typeid(*this).name() )
+  );
+}
+
+
 Item* Item::getType() const
 {
   throw ZORBA_EXCEPTION(

=== modified file 'src/store/naive/loader_dtd.cpp'
--- src/store/naive/loader_dtd.cpp	2011-11-14 09:27:26 +0000
+++ src/store/naive/loader_dtd.cpp	2012-01-10 13:58:38 +0000
@@ -1137,15 +1137,15 @@
         case 0:                       // libxml2 bug
         case XML_ATTRIBUTE_CDATA:
           GET_STORE().getItemFactory()->createUntypedAtomic(typedValue, value);
-          typeName = GET_STORE().theSchemaTypeNames[XS_UNTYPED_ATOMIC];
+          typeName = GET_STORE().theSchemaTypeNames[store::XS_UNTYPED_ATOMIC];
           break;
         case XML_ATTRIBUTE_ID:
           GET_STORE().getItemFactory()->createID(typedValue, value);
-          typeName = GET_STORE().theSchemaTypeNames[XS_ID];
+          typeName = GET_STORE().theSchemaTypeNames[store::XS_ID];
           break;
         case XML_ATTRIBUTE_IDREF:
           GET_STORE().getItemFactory()->createIDREF(typedValue, value);
-          typeName = GET_STORE().theSchemaTypeNames[XS_IDREF];
+          typeName = GET_STORE().theSchemaTypeNames[store::XS_IDREF];
           break;
         case XML_ATTRIBUTE_IDREFS:
           GET_STORE().getItemFactory()->createIDREFS(typedValue, value);
@@ -1154,7 +1154,7 @@
           break;
         case XML_ATTRIBUTE_ENTITY:
           GET_STORE().getItemFactory()->createENTITY(typedValue, value);
-          typeName = GET_STORE().theSchemaTypeNames[XS_ENTITY];
+          typeName = GET_STORE().theSchemaTypeNames[store::XS_ENTITY];
           break;
         case XML_ATTRIBUTE_ENTITIES:
           GET_STORE().getItemFactory()->createENTITIES(typedValue, value);
@@ -1163,7 +1163,7 @@
           break;
         case XML_ATTRIBUTE_NMTOKEN:
           GET_STORE().getItemFactory()->createNMTOKEN(typedValue, value);
-          typeName = GET_STORE().theSchemaTypeNames[XS_NMTOKEN];
+          typeName = GET_STORE().theSchemaTypeNames[store::XS_NMTOKEN];
           break;
         case XML_ATTRIBUTE_NMTOKENS:
           GET_STORE().getItemFactory()->createNMTOKENS(typedValue, value);

=== modified file 'src/store/naive/node_items.cpp'
--- src/store/naive/node_items.cpp	2012-01-03 12:10:06 +0000
+++ src/store/naive/node_items.cpp	2012-01-10 13:58:38 +0000
@@ -1638,7 +1638,7 @@
 store::Item* DocumentNode::getType() const
 {
   // ???? should return NULL?
-  return GET_STORE().theSchemaTypeNames[XS_UNTYPED];
+  return GET_STORE().XS_UNTYPED_QNAME;
 }
 
 
@@ -2071,8 +2071,8 @@
         store::Item* typeName = getType();
 
         if (typeName != NULL &&
-            (typeName->equals(GET_STORE().theSchemaTypeNames[XS_QNAME]) ||
-             typeName->equals(GET_STORE().theSchemaTypeNames[XS_NOTATION])))
+            (typeName->equals(GET_STORE().theSchemaTypeNames[store::XS_QNAME]) ||
+             typeName->equals(GET_STORE().theSchemaTypeNames[store::XS_NOTATION])))
         {
           throw XQUERY_EXCEPTION(err::XQTY0086);
         }
@@ -2258,7 +2258,7 @@
 {
   return (theTypeName != NULL ?
           theTypeName.getp() :
-          GET_STORE().theSchemaTypeNames[XS_UNTYPED].getp());
+          GET_STORE().XS_UNTYPED_QNAME);
 }
 
 
@@ -2273,7 +2273,7 @@
 {
   return (haveType() ?
           getTree()->getType(this) :
-          GET_STORE().theSchemaTypeNames[XS_UNTYPED].getp());
+          GET_STORE().XS_UNTYPED_QNAME.getp());
 }
 
 
@@ -2282,7 +2282,7 @@
   if (haveType())
   {
     if (type == NULL ||
-        type == GET_STORE().theSchemaTypeNames[XS_UNTYPED])
+        type == GET_STORE().XS_UNTYPED_QNAME)
     {
       getTree()->removeType(this);
       resetHaveType();
@@ -2293,7 +2293,7 @@
     }
   }
   else if (type != NULL &&
-           type != GET_STORE().theSchemaTypeNames[XS_UNTYPED])
+           type != GET_STORE().XS_UNTYPED_QNAME)
   {
     getTree()->addType(this, type);
     setHaveType();
@@ -2525,7 +2525,7 @@
 {
   store::Item_t val;
 
-  if (getType()->equals(GET_STORE().theSchemaTypeNames[XS_UNTYPED]))
+  if (getType()->equals(GET_STORE().XS_UNTYPED_QNAME))
   {
     GET_STORE().getItemFactory()->createBoolean(val, false);
     return val;
@@ -3032,7 +3032,7 @@
   const SimpleStore& store = GET_STORE();
 
   store::Item_t qname = store.getQNamePool().insert(store.XML_URI, "xml", "base");
-  store::Item_t typeName = store.theSchemaTypeNames[XS_ANY_URI];
+  store::Item_t typeName = store.theSchemaTypeNames[store::XS_ANY_URI];
 
   store::Item_t typedValue;
 
@@ -3378,7 +3378,7 @@
     typeName = NULL;
 
     if (!haveListValue() &&
-        theTypedValue->getType()->equals(store.theSchemaTypeNames[XS_UNTYPED_ATOMIC]))
+        theTypedValue->getType()->equals(store.theSchemaTypeNames[store::XS_UNTYPED_ATOMIC]))
     {
       typedValue = theTypedValue;
     }
@@ -3432,7 +3432,7 @@
 {
   return (theTypeName != NULL ?
           theTypeName.getp() :
-          GET_STORE().theSchemaTypeNames[XS_UNTYPED_ATOMIC].getp());
+          GET_STORE().theSchemaTypeNames[store::XS_UNTYPED_ATOMIC].getp());
 }
 
 
@@ -3447,7 +3447,7 @@
 {
   return (haveType() ?
           getTree()->getType(this) :
-          GET_STORE().theSchemaTypeNames[XS_UNTYPED_ATOMIC].getp());
+          GET_STORE().theSchemaTypeNames[store::XS_UNTYPED_ATOMIC].getp());
 }
 
 
@@ -3456,7 +3456,7 @@
   if (haveType())
   {
     if (type == NULL ||
-        type == GET_STORE().theSchemaTypeNames[XS_UNTYPED_ATOMIC])
+        type == GET_STORE().theSchemaTypeNames[store::XS_UNTYPED_ATOMIC])
     {
       getTree()->removeType(this);
       resetHaveType();
@@ -3467,7 +3467,7 @@
     }
   }
   else if (type != NULL &&
-           type != GET_STORE().theSchemaTypeNames[XS_UNTYPED_ATOMIC])
+           type != GET_STORE().theSchemaTypeNames[store::XS_UNTYPED_ATOMIC])
   {
     getTree()->addType(this, type);
     setHaveType();
@@ -3540,9 +3540,10 @@
       else if (dynamic_cast<UserTypedAtomicItem*>(values.getItem(i)) != NULL)
       {
         UserTypedAtomicItem* utai = dynamic_cast<UserTypedAtomicItem*>(values.getItem(i));
-        if (utai->getTypeCode() == XS_IDREF)
+        if (utai->getTypeCode() == store::XS_IDREF)
           return true;
-        if ((dynamic_cast<AtomicItem*>(utai->getBaseItem()))->getTypeCode() == XS_IDREF)
+
+        if (utai->getBaseItem()->getTypeCode() == store::XS_IDREF)
           return true;
       }
     }
@@ -3554,9 +3555,11 @@
   else if (dynamic_cast<UserTypedAtomicItem*>(theTypedValue.getp()) != NULL)
   {
     UserTypedAtomicItem* utai = dynamic_cast<UserTypedAtomicItem*>(theTypedValue.getp());
-    if (utai->getTypeCode() == XS_IDREF)
+
+    if (utai->getTypeCode() == store::XS_IDREF)
       return true;
-    if ((dynamic_cast<AtomicItem*>(utai->getBaseItem()))->getTypeCode() == XS_IDREF)
+
+    if (utai->getBaseItem()->getTypeCode() == store::XS_IDREF)
       return true;
   }
 
@@ -4017,7 +4020,7 @@
 ********************************************************************************/
 store::Item* TextNode::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_UNTYPED_ATOMIC];
+  return GET_STORE().theSchemaTypeNames[store::XS_UNTYPED_ATOMIC];
 }
 
 
@@ -4049,7 +4052,7 @@
 {
   if (isTyped() &&
       getValue()->isAtomic() &&
-      static_cast<AtomicItem*>(getValue())->getTypeCode() == XS_ID)
+      getValue()->getTypeCode() == store::XS_ID)
     return true;
 
   return false;
@@ -4079,9 +4082,10 @@
         else if (dynamic_cast<UserTypedAtomicItem*>(values.getItem(i)) != NULL)
         {
           UserTypedAtomicItem* utai = dynamic_cast<UserTypedAtomicItem*>(values.getItem(i));
-          if ( utai->getTypeCode() == XS_IDREF )
+          if (utai->getTypeCode() == store::XS_IDREF)
             return true;
-          if ( (dynamic_cast<AtomicItem*>(utai->getBaseItem()))->getTypeCode() == XS_IDREF )
+
+          if (utai->getBaseItem()->getTypeCode() == store::XS_IDREF)
             return true;
         }
       }
@@ -4093,9 +4097,9 @@
     else if (dynamic_cast<UserTypedAtomicItem*>(value) != NULL)
     {
       UserTypedAtomicItem* utai = dynamic_cast<UserTypedAtomicItem*>(value);
-      if ( utai->getTypeCode() == XS_IDREF )
+      if ( utai->getTypeCode() == store::XS_IDREF )
         return true;
-      if ( (dynamic_cast<AtomicItem*>(utai->getBaseItem()))->getTypeCode() == XS_IDREF )
+      if (utai->getBaseItem()->getTypeCode() == store::XS_IDREF )
         return true;
     }
   }
@@ -4454,7 +4458,7 @@
 ********************************************************************************/
 store::Item* PiNode::getType() const
 {
-  return GET_STORE().theSchemaTypeNames[XS_UNTYPED_ATOMIC];
+  return GET_STORE().theSchemaTypeNames[store::XS_UNTYPED_ATOMIC];
 }
 
 
@@ -4785,8 +4789,8 @@
     {
       const AtomicItem* avalue = static_cast<const AtomicItem*>(value);
 
-      if (avalue->getTypeCode() < XS_STRING ||
-          avalue->getTypeCode() > XS_ENTITY)
+      if (avalue->getTypeCode() < store::XS_STRING ||
+          avalue->getTypeCode() > store::XS_ENTITY)
         return;
 
       text = &avalue->getString();
@@ -4803,8 +4807,8 @@
 
         const AtomicItem* avalue = static_cast<const AtomicItem*>(lvalue->getItem(i));
 
-        if (avalue->getTypeCode() < XS_STRING ||
-            avalue->getTypeCode() > XS_ENTITY)
+        if (avalue->getTypeCode() < store::XS_STRING ||
+            avalue->getTypeCode() > store::XS_ENTITY)
           continue;
 
         listText += avalue->getString();

=== modified file 'src/store/naive/node_updates.cpp'
--- src/store/naive/node_updates.cpp	2011-10-10 12:56:57 +0000
+++ src/store/naive/node_updates.cpp	2012-01-10 13:58:38 +0000
@@ -621,13 +621,13 @@
     {
       ElementNode* n = reinterpret_cast<ElementNode*>(currNode);
 
-      if (n->getType()->equals(GET_STORE().theSchemaTypeNames[XS_UNTYPED]))
+      if (n->getType()->equals(GET_STORE().XS_UNTYPED_QNAME))
       {
         revalidationNode = currNode;
         break;
       }
 
-      if (n->getType()->equals(GET_STORE().theSchemaTypeNames[XS_ANY]))
+      if (n->getType()->equals(GET_STORE().XS_ANY_QNAME))
       {
         revalidationNode = currNode;
         break;
@@ -635,11 +635,11 @@
 
 #ifdef EMBEDED_TYPE
       tinfo.theTypeName.transfer(n->theTypeName);
-      n->theTypeName = GET_STORE().theSchemaTypeNames[XS_ANY];
+      n->theTypeName = GET_STORE().XS_ANY_QNAME;
 #else
       assert(n->haveType());
       tinfo.theTypeName = n->getType();
-      n->setType(GET_STORE().theSchemaTypeNames[XS_ANY]);
+      n->setType(GET_STORE().XS_ANY_QNAME);
 #endif
       tinfo.theFlags = n->theFlags;
 
@@ -670,7 +670,7 @@
     {
       AttributeNode* n = reinterpret_cast<AttributeNode*>(currNode);
 
-      if (n->getType()->equals(GET_STORE().theSchemaTypeNames[XS_UNTYPED_ATOMIC]))
+      if (n->getType()->equals(GET_STORE().theSchemaTypeNames[store::XS_UNTYPED_ATOMIC]))
       {
         undoList.resize(++undoSize);
         undoList[undoSize - 1].transfer(tinfo);
@@ -679,11 +679,11 @@
       {
 #ifdef EMBEDED_TYPE
         tinfo.theTypeName.transfer(n->theTypeName);
-        n->theTypeName = GET_STORE().theSchemaTypeNames[XS_UNTYPED_ATOMIC];
+        n->theTypeName = GET_STORE().theSchemaTypeNames[store::XS_UNTYPED_ATOMIC];
 #else
         assert(n->haveType());
         tinfo.theTypeName = n->getType();
-        n->setType(GET_STORE().theSchemaTypeNames[XS_UNTYPED_ATOMIC]);
+        n->setType(GET_STORE().theSchemaTypeNames[store::XS_UNTYPED_ATOMIC]);
 #endif
 
         tinfo.theFlags = n->theFlags;
@@ -1349,8 +1349,8 @@
   store::Item* typeName = getType();
 
   if (theParent &&
-      (typeName->equals(GET_STORE().theSchemaTypeNames[XS_UNTYPED]) ||
-       typeName->equals(GET_STORE().theSchemaTypeNames[XS_ANY])))
+      (typeName->equals(GET_STORE().XS_UNTYPED_QNAME) ||
+       typeName->equals(GET_STORE().XS_ANY_QNAME)))
   {
     // Even if "this" is untyped, we must call removeType() on the parent
     // because renaming of an elelemt may require revalidation of the ancestors.
@@ -1469,7 +1469,7 @@
   upd.theOldName.transfer(theName);
   theName.transfer(upd.theNewName);
 
-  if (getType()->equals(GET_STORE().theSchemaTypeNames[XS_UNTYPED_ATOMIC]))
+  if (getType()->equals(GET_STORE().theSchemaTypeNames[store::XS_UNTYPED_ATOMIC]))
   {
     // We must call removeType() even if "this" is untyped, because renaming
     // of an attribute may require revalidation of the ancestors.

=== modified file 'src/store/naive/simple_index_general.cpp'
--- src/store/naive/simple_index_general.cpp	2011-12-21 14:40:33 +0000
+++ src/store/naive/simple_index_general.cpp	2012-01-10 13:58:38 +0000
@@ -189,7 +189,7 @@
     const store::IndexSpecification& spec)
   :
   IndexImpl(qname, spec),
-  theKeyTypeCode(XS_LAST),
+  theKeyTypeCode(store::XS_LAST),
   theCompFunction(spec.theTimezone, spec.theCollations[0]),
   theUntypedFlag(false),
   theMultiKeyFlag(false)
@@ -197,8 +197,8 @@
   store::Item* typeName = spec.theKeyTypes[0].getp();
 
   if (typeName != NULL &&
-      typeName != GET_STORE().theSchemaTypeNames[XS_UNTYPED_ATOMIC] &&
-      typeName != GET_STORE().theSchemaTypeNames[XS_ANY_ATOMIC])
+      typeName != GET_STORE().theSchemaTypeNames[store::XS_UNTYPED_ATOMIC] &&
+      typeName != GET_STORE().theSchemaTypeNames[store::XS_ANY_ATOMIC])
   {
     theKeyTypeCode = GET_STORE().theSchemaTypeCodes[spec.theKeyTypes[0].getp()];
   }
@@ -275,7 +275,7 @@
     key = keyItem;
   }
 
-  SchemaTypeCode keyType = keyItem->getTypeCode();
+  store::SchemaTypeCode keyType = keyItem->getTypeCode();
 
   if (isTyped())
   {
@@ -284,67 +284,67 @@
 
   switch (keyType)
   {
-  case XS_BASE64BINARY:
-  case XS_HEXBINARY:
-
-  case XS_QNAME:
-  case XS_NOTATION:
-
-  case XS_GYEAR_MONTH:
-  case XS_GYEAR:
-  case XS_GMONTH_DAY:
-  case XS_GDAY:
-  case XS_GMONTH:
+  case store::XS_BASE64BINARY:
+  case store::XS_HEXBINARY:
+
+  case store::XS_QNAME:
+  case store::XS_NOTATION:
+
+  case store::XS_GYEAR_MONTH:
+  case store::XS_GYEAR:
+  case store::XS_GMONTH_DAY:
+  case store::XS_GDAY:
+  case store::XS_GMONTH:
   {
     assert(!sorted);
     // falth through
   }
 
-  case XS_ANY_URI:
-
-  case XS_BOOLEAN:
-
-  case XS_DATETIME:
-  case XS_DATE:
-  case XS_TIME:
+  case store::XS_ANY_URI:
+
+  case store::XS_BOOLEAN:
+
+  case store::XS_DATETIME:
+  case store::XS_DATE:
+  case store::XS_TIME:
   {
     return insertInMap(key, node, keyType, false);
   }
 
-  case XS_DURATION:
-  case XS_YM_DURATION:
-  case XS_DT_DURATION:
-  {
-    return insertInMap(key, node, XS_DURATION, false);
-  }
-
-  case XS_STRING:
-  case XS_NORMALIZED_STRING:
-  case XS_TOKEN:
-  case XS_NMTOKEN:
-  case XS_LANGUAGE:
-  case XS_NAME:
-  case XS_NCNAME:
-  case XS_ID:
-  case XS_IDREF:
-  case XS_ENTITY:
-  {
-    return insertInMap(key, node, XS_STRING, false);
-  }
-
-  case XS_DOUBLE:
-  case XS_FLOAT:
-  {
-    return insertInMap(key, node, XS_DOUBLE, false);
-  }
-
-  case XS_DECIMAL:
-  case XS_INTEGER:
-  case XS_NON_POSITIVE_INTEGER:
-  case XS_NEGATIVE_INTEGER:
-  case XS_NON_NEGATIVE_INTEGER:
-  case XS_POSITIVE_INTEGER:
-  case XS_UNSIGNED_LONG:
+  case store::XS_DURATION:
+  case store::XS_YM_DURATION:
+  case store::XS_DT_DURATION:
+  {
+    return insertInMap(key, node, store::XS_DURATION, false);
+  }
+
+  case store::XS_STRING:
+  case store::XS_NORMALIZED_STRING:
+  case store::XS_TOKEN:
+  case store::XS_NMTOKEN:
+  case store::XS_LANGUAGE:
+  case store::XS_NAME:
+  case store::XS_NCNAME:
+  case store::XS_ID:
+  case store::XS_IDREF:
+  case store::XS_ENTITY:
+  {
+    return insertInMap(key, node, store::XS_STRING, false);
+  }
+
+  case store::XS_DOUBLE:
+  case store::XS_FLOAT:
+  {
+    return insertInMap(key, node, store::XS_DOUBLE, false);
+  }
+
+  case store::XS_DECIMAL:
+  case store::XS_INTEGER:
+  case store::XS_NON_POSITIVE_INTEGER:
+  case store::XS_NEGATIVE_INTEGER:
+  case store::XS_NON_NEGATIVE_INTEGER:
+  case store::XS_POSITIVE_INTEGER:
+  case store::XS_UNSIGNED_LONG:
   {
     // try lossless cast to xs:long
     keyItem->castToLong(castItem);
@@ -358,18 +358,18 @@
     // Coerce to xs:double 
     keyItem->coerceToDouble(castItem, true, lossy);
 
-    found = insertInMap(key, node, XS_DOUBLE, false);
+    found = insertInMap(key, node, store::XS_DOUBLE, false);
 
     if (lossy)
     {
       node2 = node;
-      found = found || insertInMap(castItem, node2, XS_DECIMAL, false);
+      found = found || insertInMap(castItem, node2, store::XS_DECIMAL, false);
     }
 
     return found;
   }
 
-  case XS_LONG:
+  case store::XS_LONG:
   {
 longmap:
     xs_long longValue = static_cast<LongItem*>(keyItem)->getLongValue();
@@ -390,34 +390,34 @@
       if (lossy)
       {
         node2 = node;
-        found = insertInMap(key, node2, XS_LONG, false);
+        found = insertInMap(key, node2, store::XS_LONG, false);
 
-        found = found || insertInMap(castItem, node, XS_DOUBLE, false);
+        found = found || insertInMap(castItem, node, store::XS_DOUBLE, false);
       }
       else
       {
-        found = insertInMap(key, node, XS_LONG, false);
+        found = insertInMap(key, node, store::XS_LONG, false);
       }
     }
     else
     {
-      found = insertInMap(key, node, XS_LONG, false);
+      found = insertInMap(key, node, store::XS_LONG, false);
     }
 
     return found;
   }
 
-  case XS_INT:
-  case XS_SHORT:
-  case XS_BYTE:
-  case XS_UNSIGNED_INT:
-  case XS_UNSIGNED_SHORT:
-  case XS_UNSIGNED_BYTE:
+  case store::XS_INT:
+  case store::XS_SHORT:
+  case store::XS_BYTE:
+  case store::XS_UNSIGNED_INT:
+  case store::XS_UNSIGNED_SHORT:
+  case store::XS_UNSIGNED_BYTE:
   {
-    return insertInMap(key, node, XS_LONG, false);
+    return insertInMap(key, node, store::XS_LONG, false);
   }
 
-  case XS_UNTYPED_ATOMIC:
+  case store::XS_UNTYPED_ATOMIC:
   {
     store::ItemHandle<UntypedAtomicItem> untypedItem = 
     static_cast<UntypedAtomicItem*>(key.getp());
@@ -426,7 +426,7 @@
     untypedItem->castToString(castItem);
 
     node2 = node;
-    found = insertInMap(castItem, node2, XS_STRING, false);
+    found = insertInMap(castItem, node2, store::XS_STRING, false);
 
     // No reason to cast to xs:anyUri, because when we probe with xs:string or
     // with xs:anyUri, or with xs:untypedAtomic, we unconditionally probe both
@@ -440,7 +440,7 @@
       xs_long longValue = longItem->getLongValue();
 
       node2 = node;
-      found = found || insertInMap(castItem, node2, XS_LONG, true);
+      found = found || insertInMap(castItem, node2, store::XS_LONG, true);
 
       if (longValue > theMaxLong || longValue < theMinLong)
       {
@@ -458,7 +458,7 @@
         if (lossy)
         {
           node2 = node;
-          found = found || insertInMap(castItem, node2, XS_DOUBLE, true);
+          found = found || insertInMap(castItem, node2, store::XS_DOUBLE, true);
         }
       }
 
@@ -468,19 +468,19 @@
         if (untypedItem->castToGYear(castItem))
         {
           node2 = node;
-          found = found || insertInMap(castItem, node2, XS_GYEAR, true);
+          found = found || insertInMap(castItem, node2, store::XS_GYEAR, true);
         }
 
         if (untypedItem->castToHexBinary(castItem))
         {
           node2 = node;
-          found = found || insertInMap(castItem, node2, XS_HEXBINARY, true);
+          found = found || insertInMap(castItem, node2, store::XS_HEXBINARY, true);
         }
 
         if (untypedItem->castToBase64Binary(castItem))
         {
           node2 = node;
-          found = found || insertInMap(castItem, node2, XS_BASE64BINARY, true);
+          found = found || insertInMap(castItem, node2, store::XS_BASE64BINARY, true);
         }
       }
     }
@@ -494,13 +494,13 @@
       decimalItem->coerceToDouble(castItem, true, lossy);
 
       node2 = node;
-      found = found || insertInMap(castItem, node2, XS_DOUBLE, true);
+      found = found || insertInMap(castItem, node2, store::XS_DOUBLE, true);
 
       if (lossy)
       {
         castItem.transfer(decimalItem);
         node2 = node;
-        found = found || insertInMap(castItem, node2, XS_DECIMAL, true);
+        found = found || insertInMap(castItem, node2, store::XS_DECIMAL, true);
       }
 
       // may also be hexBinary or base64Binary
@@ -509,13 +509,13 @@
         if (untypedItem->castToHexBinary(castItem))
         {
           node2 = node;
-          found = found || insertInMap(castItem, node2, XS_HEXBINARY, true);
+          found = found || insertInMap(castItem, node2, store::XS_HEXBINARY, true);
         }
 
         if (untypedItem->castToBase64Binary(castItem))
         {
           node2 = node;
-          found = found || insertInMap(castItem, node2, XS_BASE64BINARY, true);
+          found = found || insertInMap(castItem, node2, store::XS_BASE64BINARY, true);
         }
       }
     }
@@ -524,77 +524,77 @@
     else if (untypedItem->castToDouble(castItem))
     {
       node2 = node;
-      found = found || insertInMap(castItem, node2, XS_DOUBLE, true);
+      found = found || insertInMap(castItem, node2, store::XS_DOUBLE, true);
     }
 
     // try casting to xs:datetime
     else if (untypedItem->castToDateTime(castItem))
     {
       node2 = node;
-      found = found || insertInMap(castItem, node2, XS_DATETIME, true);
+      found = found || insertInMap(castItem, node2, store::XS_DATETIME, true);
     }
 
     // try casting to xs:date
     else if (untypedItem->castToDate(castItem))
     {
       node2 = node;
-      found = found || insertInMap(castItem, node2, XS_DATE, true);
+      found = found || insertInMap(castItem, node2, store::XS_DATE, true);
     }
 
     // try casting to xs:time
     else if (untypedItem->castToTime(castItem))
     {
       node2 = node;
-      found = found || insertInMap(castItem, node2, XS_TIME, true);
+      found = found || insertInMap(castItem, node2, store::XS_TIME, true);
     }
 
     // try casting to xs:gYearMonth
     if (!sorted && untypedItem->castToGYearMonth(castItem))
     {
       node2 = node;
-      found = found || insertInMap(castItem, node2, XS_GYEAR_MONTH, true);
+      found = found || insertInMap(castItem, node2, store::XS_GYEAR_MONTH, true);
     }
 
     // try casting to xs:gMonthDay
     else if (!sorted && untypedItem->castToGMonthDay(castItem))
     {
       node2 = node;
-      found = found || insertInMap(castItem, node2, XS_GMONTH_DAY, true);
+      found = found || insertInMap(castItem, node2, store::XS_GMONTH_DAY, true);
     }
 
     // try casting to xs:gDay
     else if (!sorted && untypedItem->castToGDay(castItem))
     {
       node2 = node;
-      found = found || insertInMap(castItem, node2, XS_GDAY, true);
+      found = found || insertInMap(castItem, node2, store::XS_GDAY, true);
     }
 
     // try casting to xs:gMonth
     else if (!sorted && untypedItem->castToGMonth(castItem))
     {
       node2 = node;
-      found = found || insertInMap(castItem, node2, XS_GMONTH, true);
+      found = found || insertInMap(castItem, node2, store::XS_GMONTH, true);
     }
 
     // try casting to xs:duration
     else if (untypedItem->castToDuration(castItem))
     {
       node2 = node;
-      found = found || insertInMap(castItem, node2, XS_DURATION, true);
+      found = found || insertInMap(castItem, node2, store::XS_DURATION, true);
     }
 
     // try casting to xs:hexBinary
     else if (!sorted && untypedItem->castToHexBinary(castItem))
     {
       node2 = node;
-      found = found || insertInMap(castItem, node2, XS_HEXBINARY, true);
+      found = found || insertInMap(castItem, node2, store::XS_HEXBINARY, true);
     }
 
     // try casting to xs:base64Binary
     else if (!sorted && untypedItem->castToBase64Binary(castItem))
     {
       node2 = node;
-      found = found || insertInMap(castItem, node2, XS_BASE64BINARY, true);
+      found = found || insertInMap(castItem, node2, store::XS_BASE64BINARY, true);
     }
 
     return found;
@@ -616,7 +616,7 @@
 bool GeneralIndex::insertInMap(
     store::Item_t& key,
     store::Item_t& node,
-    SchemaTypeCode targetMap,
+    store::SchemaTypeCode targetMap,
     bool untyped)
 {
   if (untyped)
@@ -654,7 +654,7 @@
 {
   assert(getNumColumns() == 1);
 
-  memset(reinterpret_cast<void*>(theMaps), 0, XS_LAST * sizeof(IndexMap*));
+  memset(reinterpret_cast<void*>(theMaps), 0, store::XS_LAST * sizeof(IndexMap*));
 
   if (isTyped())
   {
@@ -670,7 +670,7 @@
 *******************************************************************************/
 GeneralHashIndex::~GeneralHashIndex()
 {
-  for (ulong i = 0; i < XS_LAST; ++i)
+  for (ulong i = 0; i < store::XS_LAST; ++i)
   {
     if (theMaps[i] == NULL)
       continue;
@@ -817,7 +817,7 @@
 {
   assert(getNumColumns() == 1);
 
-  memset(reinterpret_cast<void*>(theMaps), 0, XS_LAST * sizeof(IndexMap*));
+  memset(reinterpret_cast<void*>(theMaps), 0, store::XS_LAST * sizeof(IndexMap*));
 
   if (isTyped())
   {
@@ -833,7 +833,7 @@
 *******************************************************************************/
 GeneralTreeIndex::~GeneralTreeIndex()
 {
-  for (ulong i = 0; i < XS_LAST; ++i)
+  for (ulong i = 0; i < store::XS_LAST; ++i)
   {
     if (theMaps[i] == NULL)
       continue;
@@ -982,20 +982,20 @@
   if (key == NULL)
     return;
 
-  SchemaTypeCode keyType = key->getTypeCode();
+  store::SchemaTypeCode keyType = key->getTypeCode();
 
-  if (keyType != XS_UNTYPED_ATOMIC &&
-      keyType != XS_ANY_URI &&
-      keyType != XS_STRING &&
-      keyType != XS_NORMALIZED_STRING &&
-      keyType != XS_TOKEN &&
-      keyType != XS_NMTOKEN &&
-      keyType != XS_LANGUAGE &&
-      keyType != XS_NAME &&
-      keyType != XS_NCNAME &&
-      keyType != XS_ID &&
-      keyType != XS_IDREF &&
-      keyType != XS_ENTITY)
+  if (keyType != store::XS_UNTYPED_ATOMIC &&
+      keyType != store::XS_ANY_URI &&
+      keyType != store::XS_STRING &&
+      keyType != store::XS_NORMALIZED_STRING &&
+      keyType != store::XS_TOKEN &&
+      keyType != store::XS_NMTOKEN &&
+      keyType != store::XS_LANGUAGE &&
+      keyType != store::XS_NAME &&
+      keyType != store::XS_NCNAME &&
+      keyType != store::XS_ID &&
+      keyType != store::XS_IDREF &&
+      keyType != store::XS_ENTITY)
   {
     RAISE_ERROR_NO_LOC(err::XPTY0004,
     ERROR_PARAMS(ZED(NoUntypedKeyNodeValue_2), theIndex->getName()->getStringValue()));
@@ -1132,134 +1132,134 @@
     bool lossy;
     store::Item_t castItem;
 
-    SchemaTypeCode keyType = key->getTypeCode();
+    store::SchemaTypeCode keyType = key->getTypeCode();
 
     switch (keyType)
     {
-    case XS_QNAME:
-    case XS_NOTATION:
-    case XS_BASE64BINARY:
-    case XS_HEXBINARY:
-    case XS_GYEAR_MONTH:
-    case XS_GYEAR:
-    case XS_GMONTH_DAY:
-    case XS_GDAY:
-    case XS_GMONTH:
+    case store::XS_QNAME:
+    case store::XS_NOTATION:
+    case store::XS_BASE64BINARY:
+    case store::XS_HEXBINARY:
+    case store::XS_GYEAR_MONTH:
+    case store::XS_GYEAR:
+    case store::XS_GMONTH_DAY:
+    case store::XS_GDAY:
+    case store::XS_GMONTH:
     {
       assert(!sorted);
     }
 
-    case XS_BOOLEAN:
-    case XS_DATETIME:
-    case XS_DATE:
-    case XS_TIME:
+    case store::XS_BOOLEAN:
+    case store::XS_DATETIME:
+    case store::XS_DATE:
+    case store::XS_TIME:
 
     {
       probeMap(keyType, key.getp());
       break;
     }
 
-    case XS_DURATION:
-    case XS_YM_DURATION:
-    case XS_DT_DURATION:
+    case store::XS_DURATION:
+    case store::XS_YM_DURATION:
+    case store::XS_DT_DURATION:
     {
-      probeMap(XS_DURATION, key.getp()); 
+      probeMap(store::XS_DURATION, key.getp()); 
       break;
     }
 
-    case XS_ANY_URI:
+    case store::XS_ANY_URI:
     {
-      probeMap(XS_ANY_URI, key.getp()); 
+      probeMap(store::XS_ANY_URI, key.getp()); 
 
-      if (haveMap(XS_STRING))
+      if (haveMap(store::XS_STRING))
       {
         zstring tmp;
         key->getStringValue2(tmp);
         GET_FACTORY().createString(castItem, tmp);
 
-        probeMap(XS_STRING, castItem.getp());
+        probeMap(store::XS_STRING, castItem.getp());
       }
 
       break;
     }
 
-    case XS_STRING:
-    case XS_NORMALIZED_STRING:
-    case XS_TOKEN:
-    case XS_NMTOKEN:
-    case XS_LANGUAGE:
-    case XS_NAME:
-    case XS_NCNAME:
-    case XS_ID:
-    case XS_IDREF:
-    case XS_ENTITY:
+    case store::XS_STRING:
+    case store::XS_NORMALIZED_STRING:
+    case store::XS_TOKEN:
+    case store::XS_NMTOKEN:
+    case store::XS_LANGUAGE:
+    case store::XS_NAME:
+    case store::XS_NCNAME:
+    case store::XS_ID:
+    case store::XS_IDREF:
+    case store::XS_ENTITY:
     {
-      probeMap(XS_STRING, key.getp());
+      probeMap(store::XS_STRING, key.getp());
 
-      if (haveMap(XS_ANY_URI))
+      if (haveMap(store::XS_ANY_URI))
       {
         zstring tmp;
         key->getStringValue2(tmp);
         GET_FACTORY().createAnyURI(castItem, tmp);
 
-        probeMap(XS_ANY_URI, castItem.getp());
+        probeMap(store::XS_ANY_URI, castItem.getp());
       }
 
       break;
     }
 
-    case XS_DOUBLE:
-    case XS_FLOAT:
+    case store::XS_DOUBLE:
+    case store::XS_FLOAT:
     {
-      probeMap(XS_DOUBLE, key.getp());
+      probeMap(store::XS_DOUBLE, key.getp());
 
-      if (haveMap(XS_LONG) && key->castToLong(castItem))
-        probeMap(XS_LONG, castItem.getp());
+      if (haveMap(store::XS_LONG) && key->castToLong(castItem))
+        probeMap(store::XS_LONG, castItem.getp());
 
       break;
     }
 
-    case XS_DECIMAL:
-    case XS_INTEGER:
-    case XS_NON_POSITIVE_INTEGER:
-    case XS_NEGATIVE_INTEGER:
-    case XS_NON_NEGATIVE_INTEGER:
-    case XS_POSITIVE_INTEGER:
-    case XS_UNSIGNED_LONG:
+    case store::XS_DECIMAL:
+    case store::XS_INTEGER:
+    case store::XS_NON_POSITIVE_INTEGER:
+    case store::XS_NEGATIVE_INTEGER:
+    case store::XS_NON_NEGATIVE_INTEGER:
+    case store::XS_POSITIVE_INTEGER:
+    case store::XS_UNSIGNED_LONG:
     {
       key->coerceToDouble(castItem, true, lossy);
 
       if (lossy)
-        probeMap(XS_DECIMAL, key.getp());
-
-      probeMap(XS_DOUBLE, castItem.getp());
-
-      if (haveMap(XS_LONG) && key->castToLong(castItem))
-        probeMap(XS_LONG, castItem.getp());
+        probeMap(store::XS_DECIMAL, key.getp());
+
+      probeMap(store::XS_DOUBLE, castItem.getp());
+
+      if (haveMap(store::XS_LONG) && key->castToLong(castItem))
+        probeMap(store::XS_LONG, castItem.getp());
 
       break;
     }
 
-    case XS_LONG:
-    case XS_INT:
-    case XS_SHORT:
-    case XS_BYTE:
-    case XS_UNSIGNED_INT:
-    case XS_UNSIGNED_SHORT:
-    case XS_UNSIGNED_BYTE:
+    case store::XS_LONG:
+    case store::XS_INT:
+    case store::XS_SHORT:
+    case store::XS_BYTE:
+    case store::XS_UNSIGNED_INT:
+    case store::XS_UNSIGNED_SHORT:
+    case store::XS_UNSIGNED_BYTE:
     {
-      probeMap(XS_LONG, key.getp());
+      probeMap(store::XS_LONG, key.getp());
 
-      if (haveMap(XS_DOUBLE))
+      if (haveMap(store::XS_DOUBLE))
       {
         key->coerceToDouble(castItem, true, lossy);
-        probeMap(XS_DOUBLE, castItem.getp());
+        probeMap(store::XS_DOUBLE, castItem.getp());
       }
 
       break;
     }
 
-    case XS_UNTYPED_ATOMIC:
+    case store::XS_UNTYPED_ATOMIC:
     {
       ZORBA_ASSERT(theProbeKind == store::IndexCondition::POINT_GENERAL);
 
@@ -1269,58 +1269,60 @@
       static_cast<UntypedAtomicItem*>(key.getp());
 
       // cast to xs:string
-      if (haveMap(XS_STRING))
+      if (haveMap(store::XS_STRING))
       {
         untypedItem->castToString(castItem); 
-        probeMap(XS_STRING, castItem.getp());
+        probeMap(store::XS_STRING, castItem.getp());
       }
 
       // cast to xs:anyURI
-      if (haveMap(XS_ANY_URI) && untypedItem->castToUri(castItem))
+      if (haveMap(store::XS_ANY_URI) && untypedItem->castToUri(castItem))
       {
-        probeMap(XS_ANY_URI, castItem.getp());
+        probeMap(store::XS_ANY_URI, castItem.getp());
       }
 
       // try casting to xs:long
-      if ((haveMap(XS_LONG) || haveMap(XS_DOUBLE)) &&
+      if ((haveMap(store::XS_LONG) || haveMap(store::XS_DOUBLE)) &&
           (untypedItem->castToLong(castItem), castItem != NULL))
       {
         store::ItemHandle<LongItem> longItem = 
         static_cast<LongItem*>(castItem.getp());
 
-        probeMap(XS_LONG, castItem.getp());
+        probeMap(store::XS_LONG, castItem.getp());
 
-        if (haveMap(XS_DOUBLE))
+        if (haveMap(store::XS_DOUBLE))
         {
           longItem->coerceToDouble(castItem, true, lossy);
-          probeMap(XS_DOUBLE, castItem.getp());
+          probeMap(store::XS_DOUBLE, castItem.getp());
         }
 
         // may also be gYear, hexBinary, base64Binary, or boolean
         if (!sorted)
         {
-          if (haveMap(XS_GYEAR))
+          if (haveMap(store::XS_GYEAR))
           {
             untypedItem->castToGYear(castItem);
-            probeMap(XS_GYEAR, castItem.getp());
+            probeMap(store::XS_GYEAR, castItem.getp());
           }
 
-          if (haveMap(XS_HEXBINARY))
+          if (haveMap(store::XS_HEXBINARY))
           {
             untypedItem->castToHexBinary(castItem); 
-            probeMap(XS_HEXBINARY, castItem.getp());
+            probeMap(store::XS_HEXBINARY, castItem.getp());
           }
 
-          if (haveMap(XS_BASE64BINARY))
+          if (haveMap(store::XS_BASE64BINARY))
           {
             untypedItem->castToBase64Binary(castItem); 
-            probeMap(XS_BASE64BINARY, castItem.getp());
+            probeMap(store::XS_BASE64BINARY, castItem.getp());
           }
         }
       }
 
       // try casting to xs:decimal
-      else if ((haveMap(XS_DECIMAL) || haveMap(XS_LONG) || haveMap(XS_DOUBLE)) &&
+      else if ((haveMap(store::XS_DECIMAL) ||
+                haveMap(store::XS_LONG) ||
+                haveMap(store::XS_DOUBLE)) &&
                untypedItem->castToDecimal(castItem))
       {
         store::ItemHandle<DecimalItem> decimalItem = 
@@ -1328,115 +1330,125 @@
 
         decimalItem->coerceToDouble(castItem, true, lossy);
 
-        probeMap(XS_DOUBLE, castItem.getp());
+        probeMap(store::XS_DOUBLE, castItem.getp());
 
-        if (haveMap(XS_LONG) && decimalItem->castToLong(castItem))
+        if (haveMap(store::XS_LONG) && decimalItem->castToLong(castItem))
         {
-          probeMap(XS_LONG, castItem.getp());
+          probeMap(store::XS_LONG, castItem.getp());
         }
 
-        if (lossy && haveMap(XS_DECIMAL))
+        if (lossy && haveMap(store::XS_DECIMAL))
         {
           castItem.transfer(decimalItem);
-          probeMap(XS_DOUBLE, castItem.getp());
+          probeMap(store::XS_DOUBLE, castItem.getp());
         }
 
         // may also be hexBinary or base64Binary
         if (!sorted)
         {
-          if (haveMap(XS_HEXBINARY))
+          if (haveMap(store::XS_HEXBINARY))
           {
             untypedItem->castToHexBinary(castItem); 
-            probeMap(XS_HEXBINARY, castItem.getp());
+            probeMap(store::XS_HEXBINARY, castItem.getp());
           }
 
-          if (haveMap(XS_BASE64BINARY))
+          if (haveMap(store::XS_BASE64BINARY))
           {
             untypedItem->castToBase64Binary(castItem); 
-            probeMap(XS_BASE64BINARY, castItem.getp());
+            probeMap(store::XS_BASE64BINARY, castItem.getp());
           }
         }
       }
 
       // try casting to xs:double
-      else if ((haveMap(XS_LONG) || haveMap(XS_DOUBLE)) &&
+      else if ((haveMap(store::XS_LONG) || haveMap(store::XS_DOUBLE)) &&
                untypedItem->castToDouble(castItem))
       {
         store::ItemHandle<DoubleItem> doubleItem = 
         static_cast<DoubleItem*>(castItem.getp());
 
-        probeMap(XS_DOUBLE, castItem.getp());
+        probeMap(store::XS_DOUBLE, castItem.getp());
 
-        if (haveMap(XS_LONG) && doubleItem->castToLong(castItem))
+        if (haveMap(store::XS_LONG) && doubleItem->castToLong(castItem))
         {
-          probeMap(XS_LONG, castItem.getp());
+          probeMap(store::XS_LONG, castItem.getp());
         }
       }
 
       // try casting to xs:datetime
-      else if (haveMap(XS_DATETIME) && untypedItem->castToDateTime(castItem))
+      else if (haveMap(store::XS_DATETIME) &&
+               untypedItem->castToDateTime(castItem))
       {
-        probeMap(XS_DATETIME, castItem.getp());
+        probeMap(store::XS_DATETIME, castItem.getp());
       }
 
       // try casting to xs:date
-      else if (haveMap(XS_DATE) && untypedItem->castToDate(castItem))
+      else if (haveMap(store::XS_DATE) &&
+               untypedItem->castToDate(castItem))
       {
-        probeMap(XS_DATE, castItem.getp());
+        probeMap(store::XS_DATE, castItem.getp());
       }
 
       // try casting to xs:time
-      else if (haveMap(XS_TIME) && untypedItem->castToTime(castItem))
+      else if (haveMap(store::XS_TIME) &&
+               untypedItem->castToTime(castItem))
       {
-        probeMap(XS_TIME, castItem.getp());
+        probeMap(store::XS_TIME, castItem.getp());
       }
 
       // try casting to xs:gYearMonth
       if (!sorted && 
-          haveMap(XS_GYEAR_MONTH) && untypedItem->castToGYearMonth(castItem))
+          haveMap(store::XS_GYEAR_MONTH) &&
+          untypedItem->castToGYearMonth(castItem))
       {
-        probeMap(XS_GYEAR_MONTH, castItem.getp());
+        probeMap(store::XS_GYEAR_MONTH, castItem.getp());
       }
 
       // try casting to xs:gMonthDay
       else if (!sorted && 
-               haveMap(XS_GMONTH_DAY) && untypedItem->castToGMonthDay(castItem))
+               haveMap(store::XS_GMONTH_DAY) &&
+               untypedItem->castToGMonthDay(castItem))
       {
-        probeMap(XS_GMONTH_DAY, castItem.getp());
+        probeMap(store::XS_GMONTH_DAY, castItem.getp());
       }
 
       // try casting to xs:gDay
       else if (!sorted &&
-               haveMap(XS_GDAY) && untypedItem->castToGDay(castItem))
+               haveMap(store::XS_GDAY) &&
+               untypedItem->castToGDay(castItem))
       {
-        probeMap(XS_GDAY, castItem.getp());
+        probeMap(store::XS_GDAY, castItem.getp());
       }
 
       // try casting to xs:gMonth
       else if (!sorted &&
-               haveMap(XS_GMONTH) && untypedItem->castToGMonth(castItem))
+               haveMap(store::XS_GMONTH) &&
+               untypedItem->castToGMonth(castItem))
       {
-        probeMap(XS_GMONTH, castItem.getp());
+        probeMap(store::XS_GMONTH, castItem.getp());
       }
 
       // try casting to xs:duration
-      else if (haveMap(XS_DURATION) && untypedItem->castToDuration(castItem))
+      else if (haveMap(store::XS_DURATION) &&
+               untypedItem->castToDuration(castItem))
       {
-        probeMap(XS_DURATION, castItem.getp());
+        probeMap(store::XS_DURATION, castItem.getp());
       }
       
       // try casting to xs:hexBinary
       else if (!sorted &&
-               haveMap(XS_HEXBINARY) && untypedItem->castToHexBinary(castItem))
+               haveMap(store::XS_HEXBINARY) &&
+               untypedItem->castToHexBinary(castItem))
       {
-        probeMap(XS_HEXBINARY, castItem.getp());
+        probeMap(store::XS_HEXBINARY, castItem.getp());
       }
       
       // try casting to xs:base64Binary
       else if (!sorted &&
-               haveMap(XS_BASE64BINARY) && untypedItem->castToBase64Binary(castItem))
+               haveMap(store::XS_BASE64BINARY) &&
+               untypedItem->castToBase64Binary(castItem))
       {
-        probeMap(XS_BASE64BINARY, castItem.getp());
+        probeMap(store::XS_BASE64BINARY, castItem.getp());
       }
       
       break;
@@ -1484,37 +1496,39 @@
   {
     store::Item_t castItem;
 
-    SchemaTypeCode lowerKeyType = (haveLower ? lowerKey->getTypeCode() : XS_LAST);
-    SchemaTypeCode upperKeyType = (haveUpper ? upperKey->getTypeCode() : XS_LAST);
-
-    SchemaTypeCode keyType = (lowerKeyType < upperKeyType ?
-                              lowerKeyType :
-                              upperKeyType);
+    store::SchemaTypeCode lowerKeyType = 
+    (haveLower ? lowerKey->getTypeCode() : store::XS_LAST);
+
+    store::SchemaTypeCode upperKeyType = 
+    (haveUpper ? upperKey->getTypeCode() : store::XS_LAST);
+
+    store::SchemaTypeCode keyType = 
+    (lowerKeyType < upperKeyType ? lowerKeyType : upperKeyType);
 
     switch (keyType)
     {
-    case XS_BOOLEAN:
-    case XS_DATETIME:
-    case XS_DATE:
-    case XS_TIME:
+    case store::XS_BOOLEAN:
+    case store::XS_DATETIME:
+    case store::XS_DATE:
+    case store::XS_TIME:
     {
       probeMap(keyType, lowerKey, upperKey);
       break;
     }
 
-    case XS_DURATION:
-    case XS_YM_DURATION:
-    case XS_DT_DURATION:
+    case store::XS_DURATION:
+    case store::XS_YM_DURATION:
+    case store::XS_DT_DURATION:
     {
-      probeMap(XS_DURATION, lowerKey, upperKey);
+      probeMap(store::XS_DURATION, lowerKey, upperKey);
       break;
     }
 
-    case XS_ANY_URI:
+    case store::XS_ANY_URI:
     {
-      probeMap(XS_ANY_URI, lowerKey, upperKey);
+      probeMap(store::XS_ANY_URI, lowerKey, upperKey);
 
-      if (idx->theMaps[XS_STRING])
+      if (idx->theMaps[store::XS_STRING])
       {
         if (haveLower)
         {
@@ -1528,26 +1542,26 @@
           GET_FACTORY().createString(upperAltKey, tmp);
         }
         
-        probeMap(XS_STRING, lowerAltKey, upperAltKey);
+        probeMap(store::XS_STRING, lowerAltKey, upperAltKey);
       }
 
       break;
     }
 
-    case XS_STRING:
-    case XS_NORMALIZED_STRING:
-    case XS_TOKEN:
-    case XS_NMTOKEN:
-    case XS_LANGUAGE:
-    case XS_NAME:
-    case XS_NCNAME:
-    case XS_ID:
-    case XS_IDREF:
-    case XS_ENTITY:
+    case store::XS_STRING:
+    case store::XS_NORMALIZED_STRING:
+    case store::XS_TOKEN:
+    case store::XS_NMTOKEN:
+    case store::XS_LANGUAGE:
+    case store::XS_NAME:
+    case store::XS_NCNAME:
+    case store::XS_ID:
+    case store::XS_IDREF:
+    case store::XS_ENTITY:
     {
-      probeMap(XS_STRING, lowerKey, upperKey);
+      probeMap(store::XS_STRING, lowerKey, upperKey);
 
-      if (idx->theMaps[XS_ANY_URI])
+      if (idx->theMaps[store::XS_ANY_URI])
       {
         if (haveLower)
         {
@@ -1561,18 +1575,18 @@
           GET_FACTORY().createAnyURI(upperAltKey, tmp);
         }
 
-        probeMap(XS_ANY_URI, lowerAltKey, upperAltKey);
+        probeMap(store::XS_ANY_URI, lowerAltKey, upperAltKey);
       }
 
       break;
     }
 
-    case XS_DOUBLE:
-    case XS_FLOAT:
+    case store::XS_DOUBLE:
+    case store::XS_FLOAT:
     {
-      probeMap(XS_DOUBLE, lowerKey, upperKey);
+      probeMap(store::XS_DOUBLE, lowerKey, upperKey);
 
-      if (idx->theMaps[XS_LONG])
+      if (idx->theMaps[store::XS_LONG])
       {
         if (haveLower)
           doubleToLongProbe(lowerAltKey, lowerKey, true, false);
@@ -1583,33 +1597,33 @@
         if (haveLower && haveUpper)
         {
           if (lowerAltKey && upperAltKey)
-            probeMap(XS_ANY_URI, lowerAltKey, upperAltKey);    
+            probeMap(store::XS_ANY_URI, lowerAltKey, upperAltKey);    
         }
         else if ((haveLower && lowerAltKey) || (haveUpper && upperAltKey))
         {
-          probeMap(XS_ANY_URI, lowerAltKey, upperAltKey);
+          probeMap(store::XS_ANY_URI, lowerAltKey, upperAltKey);
         }
       }
 
       break;
     }
 
-    case XS_DECIMAL:
-    case XS_INTEGER:
-    case XS_NON_POSITIVE_INTEGER:
-    case XS_NEGATIVE_INTEGER:
-    case XS_NON_NEGATIVE_INTEGER:
-    case XS_POSITIVE_INTEGER:
-    case XS_UNSIGNED_LONG:
+    case store::XS_DECIMAL:
+    case store::XS_INTEGER:
+    case store::XS_NON_POSITIVE_INTEGER:
+    case store::XS_NEGATIVE_INTEGER:
+    case store::XS_NON_NEGATIVE_INTEGER:
+    case store::XS_POSITIVE_INTEGER:
+    case store::XS_UNSIGNED_LONG:
     {
-      probeMap(XS_DECIMAL, lowerKey, upperKey);
+      probeMap(store::XS_DECIMAL, lowerKey, upperKey);
 
-      if (idx->theMaps[XS_LONG])
+      if (idx->theMaps[store::XS_LONG])
       {
-        probeMap(XS_LONG, lowerKey, upperKey);
+        probeMap(store::XS_LONG, lowerKey, upperKey);
       }
 
-      if (idx->theMaps[XS_DOUBLE])
+      if (idx->theMaps[store::XS_DOUBLE])
       {
         if (haveLower)
         {
@@ -1623,23 +1637,23 @@
           GET_FACTORY().createDouble(upperAltKey, doubleValue);
         }
 
-        probeMap(XS_DOUBLE, lowerAltKey, upperAltKey);
+        probeMap(store::XS_DOUBLE, lowerAltKey, upperAltKey);
       }
 
       break;
     }
 
-    case XS_LONG:
-    case XS_INT:
-    case XS_SHORT:
-    case XS_BYTE:
-    case XS_UNSIGNED_INT:
-    case XS_UNSIGNED_SHORT:
-    case XS_UNSIGNED_BYTE:
+    case store::XS_LONG:
+    case store::XS_INT:
+    case store::XS_SHORT:
+    case store::XS_BYTE:
+    case store::XS_UNSIGNED_INT:
+    case store::XS_UNSIGNED_SHORT:
+    case store::XS_UNSIGNED_BYTE:
     {
-      probeMap(XS_LONG, lowerKey, upperKey);
+      probeMap(store::XS_LONG, lowerKey, upperKey);
 
-      if (idx->theMaps[XS_DECIMAL])
+      if (idx->theMaps[store::XS_DECIMAL])
       {
         if (haveLower)
         {
@@ -1653,10 +1667,10 @@
           GET_FACTORY().createDecimal(upperAltKey, decimalValue);
         }
 
-        probeMap(XS_DECIMAL, lowerAltKey, upperAltKey);
+        probeMap(store::XS_DECIMAL, lowerAltKey, upperAltKey);
       }
 
-      if (idx->theMaps[XS_DOUBLE])
+      if (idx->theMaps[store::XS_DOUBLE])
       {
         if (haveLower)
         {
@@ -1670,13 +1684,13 @@
           GET_FACTORY().createDouble(upperAltKey, doubleValue);
         }
 
-        probeMap(XS_DOUBLE, lowerAltKey, upperAltKey);
+        probeMap(store::XS_DOUBLE, lowerAltKey, upperAltKey);
       }
 
       break;
     }
 
-    case XS_UNTYPED_ATOMIC:
+    case store::XS_UNTYPED_ATOMIC:
     {
       assert(theProbeKind == store::IndexCondition::BOX_GENERAL);
 
@@ -1690,120 +1704,120 @@
       store::Item_t altKey;
 
       // cast to xs:string
-      if (idx->theMaps[XS_STRING])
+      if (idx->theMaps[store::XS_STRING])
       {
         untypedItem->castToString(altKey);
-        probeMap(XS_STRING, altKey, altKey);
+        probeMap(store::XS_STRING, altKey, altKey);
       }
 
       // cast to xs:anyURI
-      if (idx->theMaps[XS_ANY_URI] && untypedItem->castToUri(altKey))
+      if (idx->theMaps[store::XS_ANY_URI] && untypedItem->castToUri(altKey))
       {
-        probeMap(XS_ANY_URI, altKey, altKey);
+        probeMap(store::XS_ANY_URI, altKey, altKey);
       }
 
       // try casting to xs:long
-      if ((idx->theMaps[XS_LONG] ||
-           idx->theMaps[XS_DOUBLE] ||
-           idx->theMaps[XS_DECIMAL]) &&
+      if ((idx->theMaps[store::XS_LONG] ||
+           idx->theMaps[store::XS_DOUBLE] ||
+           idx->theMaps[store::XS_DECIMAL]) &&
           untypedItem->castToLong(altKey), altKey != NULL)
       {
         store::ItemHandle<LongItem> longItem = 
         static_cast<LongItem*>(altKey.getp());
 
-        if (idx->theMaps[XS_LONG])
+        if (idx->theMaps[store::XS_LONG])
         {
-          probeMap(XS_LONG, altKey, altKey);
+          probeMap(store::XS_LONG, altKey, altKey);
         }
 
-        if (idx->theMaps[XS_DOUBLE])
+        if (idx->theMaps[store::XS_DOUBLE])
         {
           xs_double doubleValue = longItem->getLongValue();
           GET_FACTORY().createDouble(altKey, doubleValue);
-          probeMap(XS_DOUBLE, altKey, altKey);
+          probeMap(store::XS_DOUBLE, altKey, altKey);
         }
 
-        if (idx->theMaps[XS_DECIMAL])
+        if (idx->theMaps[store::XS_DECIMAL])
         {
           xs_decimal decimalValue = longItem->getLongValue();
           GET_FACTORY().createDecimal(altKey, decimalValue);
-          probeMap(XS_DECIMAL, altKey, altKey);
+          probeMap(store::XS_DECIMAL, altKey, altKey);
         }
       }
 
       // try casting to xs:decimal
-      else if ((idx->theMaps[XS_LONG] ||
-                idx->theMaps[XS_DOUBLE] ||
-                idx->theMaps[XS_DECIMAL]) &&
+      else if ((idx->theMaps[store::XS_LONG] ||
+                idx->theMaps[store::XS_DOUBLE] ||
+                idx->theMaps[store::XS_DECIMAL]) &&
                untypedItem->castToDecimal(altKey), altKey != NULL)
       {
         store::ItemHandle<DecimalItem> decimalItem = 
         static_cast<DecimalItem*>(altKey.getp());
 
-        if (idx->theMaps[XS_DECIMAL])
-        {
-          probeMap(XS_DECIMAL, altKey, altKey);
-        }
-
-        if (idx->theMaps[XS_LONG])
-        {
-          probeMap(XS_LONG, altKey, altKey);
-        }
-
-        if (idx->theMaps[XS_DOUBLE])
+        if (idx->theMaps[store::XS_DECIMAL])
+        {
+          probeMap(store::XS_DECIMAL, altKey, altKey);
+        }
+
+        if (idx->theMaps[store::XS_LONG])
+        {
+          probeMap(store::XS_LONG, altKey, altKey);
+        }
+
+        if (idx->theMaps[store::XS_DOUBLE])
         {
           xs_double doubleValue = decimalItem->getDecimalValue();
           GET_FACTORY().createDouble(altKey, doubleValue);
-          probeMap(XS_DOUBLE, altKey, altKey);
+          probeMap(store::XS_DOUBLE, altKey, altKey);
         }
       }
 
       // try casting to xs:double
-      else if ((idx->theMaps[XS_LONG] ||
-               idx->theMaps[XS_DOUBLE]) &&
+      else if ((idx->theMaps[store::XS_LONG] ||
+               idx->theMaps[store::XS_DOUBLE]) &&
                untypedItem->castToDouble(altKey), altKey != NULL)
       {
         store::ItemHandle<DoubleItem> doubleItem = 
         static_cast<DoubleItem*>(altKey.getp());
 
-        if (idx->theMaps[XS_DOUBLE])
+        if (idx->theMaps[store::XS_DOUBLE])
         {
-          probeMap(XS_DOUBLE, altKey, altKey);
+          probeMap(store::XS_DOUBLE, altKey, altKey);
         }
 
-        if (idx->theMaps[XS_LONG])
+        if (idx->theMaps[store::XS_LONG])
         {
           doubleToLongProbe(altKey, doubleItem.getp(), haveLower, haveUpper);
 
           if (altKey)
           {
-            probeMap(XS_LONG, altKey, altKey);
+            probeMap(store::XS_LONG, altKey, altKey);
           }
         }
       }
 
       // try casting to xs:datetime
-      else if (idx->theMaps[XS_DATETIME] && untypedItem->castToDateTime(altKey))
+      else if (idx->theMaps[store::XS_DATETIME] && untypedItem->castToDateTime(altKey))
       {
-        probeMap(XS_DATETIME, altKey, altKey);
+        probeMap(store::XS_DATETIME, altKey, altKey);
       }
 
       // try casting to xs:date
-      else if (idx->theMaps[XS_DATE] && untypedItem->castToDate(altKey))
+      else if (idx->theMaps[store::XS_DATE] && untypedItem->castToDate(altKey))
       {
-        probeMap(XS_DATE, altKey, altKey);
+        probeMap(store::XS_DATE, altKey, altKey);
       }
 
       // try casting to xs:time
-      else if (idx->theMaps[XS_TIME] && untypedItem->castToTime(altKey))
+      else if (idx->theMaps[store::XS_TIME] && untypedItem->castToTime(altKey))
       {
-        probeMap(XS_TIME, altKey, altKey);
+        probeMap(store::XS_TIME, altKey, altKey);
       }
 
       // try casting to xs:duration
-      else if (idx->theMaps[XS_DURATION] && untypedItem->castToDuration(altKey))
+      else if (idx->theMaps[store::XS_DURATION] && untypedItem->castToDuration(altKey))
       {
-        probeMap(XS_DURATION, altKey, altKey);
+        probeMap(store::XS_DURATION, altKey, altKey);
       }
 
       break;
@@ -1817,7 +1831,7 @@
   {
     theIsFullProbe = true;
 
-    for (ulong i = 0; i < XS_LAST; ++i)
+    for (ulong i = 0; i < store::XS_LAST; ++i)
     {
       if (idx->theMaps[i] == NULL)
         continue;
@@ -1833,7 +1847,7 @@
 
 *******************************************************************************/
 void ProbeGeneralIndexIterator::probeMap(
-    SchemaTypeCode targetMap,
+    store::SchemaTypeCode targetMap,
     const store::Item* key)
 {
   if (theIndex->isSorted())
@@ -1855,7 +1869,7 @@
 
 ********************************************************************************/
 void ProbeGeneralIndexIterator::probeMap(
-    SchemaTypeCode targetMap,
+    store::SchemaTypeCode targetMap,
     const store::Item* lowerKey,
     const store::Item* upperKey)
 {
@@ -1869,7 +1883,7 @@
 /*******************************************************************************
 
 ********************************************************************************/
-bool ProbeGeneralIndexIterator::haveMap(SchemaTypeCode targetMap) const
+bool ProbeGeneralIndexIterator::haveMap(store::SchemaTypeCode targetMap) const
 {
   if (theIndex->isSorted())
   {

=== modified file 'src/store/naive/simple_index_general.h'
--- src/store/naive/simple_index_general.h	2011-12-21 14:40:33 +0000
+++ src/store/naive/simple_index_general.h	2012-01-10 13:58:38 +0000
@@ -138,7 +138,7 @@
   static const double         theDoubleMinLong;
 
 protected:
-  SchemaTypeCode              theKeyTypeCode;
+  store::SchemaTypeCode       theKeyTypeCode;
 
   GeneralIndexCompareFunction theCompFunction;
 
@@ -153,17 +153,17 @@
 
   virtual ~GeneralIndex();
 
-  bool isTyped() const { return (theKeyTypeCode != XS_LAST); }
+  bool isTyped() const { return (theKeyTypeCode != store::XS_LAST); }
 
   bool insertInMap(
       store::Item_t& key,
       store::Item_t& node,
-      SchemaTypeCode targetMap,
+      store::SchemaTypeCode targetMap,
       bool untyped);
 
   bool probeMap(
       const store::Item* key,
-      SchemaTypeCode targetMap);
+      store::SchemaTypeCode targetMap);
 
 public:
   const XQPCollator* getCollator(ulong i) const;
@@ -218,7 +218,7 @@
   typedef rchandle<KeyIterator> KeyIterator_t;
 
 private:
-  IndexMap  * theMaps[XS_LAST];
+  IndexMap  * theMaps[store::XS_LAST];
   IndexMap  * theSingleMap;
 
 protected:
@@ -270,7 +270,7 @@
   typedef rchandle<KeyIterator> KeyIterator_t;
 
 private:
-  IndexMap       * theMaps[XS_LAST];
+  IndexMap       * theMaps[store::XS_LAST];
   IndexMap       * theSingleMap;
   SYNC_CODE(Mutex  theMapMutex;)
 
@@ -406,12 +406,12 @@
 
   void initBox();
 
-  bool haveMap(SchemaTypeCode targetMap) const;
+  bool haveMap(store::SchemaTypeCode targetMap) const;
 
-  void probeMap(SchemaTypeCode targetMap, const store::Item* key);
+  void probeMap(store::SchemaTypeCode targetMap, const store::Item* key);
 
   void probeMap(
-      const SchemaTypeCode targetMap,
+      const store::SchemaTypeCode targetMap,
       const store::Item* lowerKey,
       const store::Item* upperKey);
 

=== modified file 'src/store/naive/simple_store.cpp'
--- src/store/naive/simple_store.cpp	2011-12-22 14:14:53 +0000
+++ src/store/naive/simple_store.cpp	2012-01-10 13:58:38 +0000
@@ -29,6 +29,7 @@
 #include "diagnostics/util_macros.h"
 
 #include "store/api/pul.h"
+#include "store/api/xs_type_codes.h"
 
 #include "store/naive/properties.h"
 #include "store/naive/string_pool.h"
@@ -188,75 +189,74 @@
   const char* ns = XS_URI;
   BasicItemFactory* f = theItemFactory;
 
-  theSchemaTypeNames.resize(XS_LAST);
-
-  f->createQName(theSchemaTypeNames[XS_UNTYPED],        ns, "xs", "untyped");
-  f->createQName(theSchemaTypeNames[XS_ANY],            ns, "xs", "anyType");
-
-  f->createQName(theSchemaTypeNames[XS_ANY_SIMPLE],     ns, "xs", "anySimpleType");
-
-  f->createQName(theSchemaTypeNames[XS_ANY_ATOMIC],     ns, "xs", "anyAtomicType");
-
-  f->createQName(theSchemaTypeNames[XS_UNTYPED_ATOMIC], ns, "xs", "untypedAtomic");
-
-  f->createQName(theSchemaTypeNames[XS_ANY_URI],        ns, "xs", "anyURI");
-
-  f->createQName(theSchemaTypeNames[XS_QNAME],          ns, "xs", "QName");
-
-  f->createQName(theSchemaTypeNames[XS_NOTATION],       ns, "xs", "NOTATION");
-
-  f->createQName(theSchemaTypeNames[XS_STRING],         ns, "xs", "string");
-  f->createQName(theSchemaTypeNames[XS_NORMALIZED_STRING], ns, "xs", "normalizedString");
-  f->createQName(theSchemaTypeNames[XS_TOKEN],          ns, "xs", "token");
-  f->createQName(theSchemaTypeNames[XS_NMTOKEN],        ns, "xs", "NMTOKEN");
-  f->createQName(theSchemaTypeNames[XS_LANGUAGE],       ns, "xs", "language");
-  f->createQName(theSchemaTypeNames[XS_NAME],           ns, "xs", "Name");
-  f->createQName(theSchemaTypeNames[XS_NCNAME],         ns, "xs", "NCName");
-  f->createQName(theSchemaTypeNames[XS_ID],             ns, "xs", "ID");
-  f->createQName(theSchemaTypeNames[XS_IDREF],          ns, "xs", "IDREF");
-  f->createQName(theSchemaTypeNames[XS_ENTITY],         ns, "xs", "ENTITY");
-
-  f->createQName(theSchemaTypeNames[XS_DATETIME],       ns, "xs", "dateTime");
-  f->createQName(theSchemaTypeNames[XS_DATE],           ns, "xs", "date");
-  f->createQName(theSchemaTypeNames[XS_TIME],           ns, "xs", "time");
-  f->createQName(theSchemaTypeNames[XS_GYEAR_MONTH],    ns, "xs", "gYearMonth");
-  f->createQName(theSchemaTypeNames[XS_GYEAR],          ns, "xs", "gYear");
-  f->createQName(theSchemaTypeNames[XS_GMONTH_DAY],     ns, "xs", "gMonthDay");
-  f->createQName(theSchemaTypeNames[XS_GDAY],           ns, "xs", "gDay");
-  f->createQName(theSchemaTypeNames[XS_GMONTH],         ns, "xs", "gMonth");
-
-  f->createQName(theSchemaTypeNames[XS_DURATION],       ns, "xs", "duration");
-  f->createQName(theSchemaTypeNames[XS_DT_DURATION],    ns, "xs", "dayTimeDuration");
-  f->createQName(theSchemaTypeNames[XS_YM_DURATION],    ns, "xs", "yearMonthDuration");
-
-  f->createQName(theSchemaTypeNames[XS_FLOAT],          ns, "xs", "float");
-  f->createQName(theSchemaTypeNames[XS_DOUBLE],         ns, "xs", "double");
-  f->createQName(theSchemaTypeNames[XS_DECIMAL],        ns, "xs", "decimal");
-  f->createQName(theSchemaTypeNames[XS_INTEGER],        ns, "xs", "integer");
-  f->createQName(theSchemaTypeNames[XS_NON_POSITIVE_INTEGER], ns, "xs", "nonPositiveInteger");
-  f->createQName(theSchemaTypeNames[XS_NON_NEGATIVE_INTEGER], ns, "xs", "nonNegativeInteger");
-  f->createQName(theSchemaTypeNames[XS_NEGATIVE_INTEGER], ns, "xs", "negativeInteger");
-  f->createQName(theSchemaTypeNames[XS_POSITIVE_INTEGER], ns, "xs", "positiveInteger");
-
-  f->createQName(theSchemaTypeNames[XS_LONG],           ns, "xs", "long");
-  f->createQName(theSchemaTypeNames[XS_INT],            ns, "xs", "int");
-  f->createQName(theSchemaTypeNames[XS_SHORT],          ns, "xs", "short");
-  f->createQName(theSchemaTypeNames[XS_BYTE],           ns, "xs", "byte");
-  f->createQName(theSchemaTypeNames[XS_UNSIGNED_LONG],  ns, "xs", "unsignedLong");
-  f->createQName(theSchemaTypeNames[XS_UNSIGNED_INT],   ns, "xs", "unsignedInt");
-  f->createQName(theSchemaTypeNames[XS_UNSIGNED_SHORT], ns, "xs", "unsignedShort");
-  f->createQName(theSchemaTypeNames[XS_UNSIGNED_BYTE],  ns, "xs", "unsignedByte");
-
-  f->createQName(theSchemaTypeNames[XS_BASE64BINARY],   ns, "xs", "base64Binary");
-  f->createQName(theSchemaTypeNames[XS_HEXBINARY],      ns, "xs", "hexBinary");
-  f->createQName(theSchemaTypeNames[XS_BOOLEAN],        ns, "xs", "boolean");
-
-  f->createQName(theSchemaTypeNames[ZXSE_ERROR], ZXSE_URI, "zxse", "error");
-  f->createQName(theSchemaTypeNames[ZXSE_TUPLE], ZXSE_URI, "zxse", "tuple");
-
-  for (ulong i = 0; i < XS_LAST; ++i)
+  theSchemaTypeNames.resize(store::XS_LAST);
+
+  f->createQName(XS_UNTYPED_QNAME, ns, "xs", "untyped");
+
+  f->createQName(XS_ANY_QNAME, ns, "xs", "anyType");
+
+  f->createQName(XS_ANY_SIMPLE_QNAME, ns, "xs", "anySimpleType");
+
+  f->createQName(theSchemaTypeNames[store::XS_ANY_ATOMIC],     ns, "xs", "anyAtomicType");
+
+  f->createQName(theSchemaTypeNames[store::XS_UNTYPED_ATOMIC], ns, "xs", "untypedAtomic");
+
+  f->createQName(theSchemaTypeNames[store::XS_ANY_URI],        ns, "xs", "anyURI");
+
+  f->createQName(theSchemaTypeNames[store::XS_QNAME],          ns, "xs", "QName");
+
+  f->createQName(theSchemaTypeNames[store::XS_NOTATION],       ns, "xs", "NOTATION");
+
+  f->createQName(theSchemaTypeNames[store::XS_STRING],         ns, "xs", "string");
+  f->createQName(theSchemaTypeNames[store::XS_NORMALIZED_STRING], ns, "xs", "normalizedString");
+  f->createQName(theSchemaTypeNames[store::XS_TOKEN],          ns, "xs", "token");
+  f->createQName(theSchemaTypeNames[store::XS_NMTOKEN],        ns, "xs", "NMTOKEN");
+  f->createQName(theSchemaTypeNames[store::XS_LANGUAGE],       ns, "xs", "language");
+  f->createQName(theSchemaTypeNames[store::XS_NAME],           ns, "xs", "Name");
+  f->createQName(theSchemaTypeNames[store::XS_NCNAME],         ns, "xs", "NCName");
+  f->createQName(theSchemaTypeNames[store::XS_ID],             ns, "xs", "ID");
+  f->createQName(theSchemaTypeNames[store::XS_IDREF],          ns, "xs", "IDREF");
+  f->createQName(theSchemaTypeNames[store::XS_ENTITY],         ns, "xs", "ENTITY");
+
+  f->createQName(theSchemaTypeNames[store::XS_DATETIME],       ns, "xs", "dateTime");
+  f->createQName(theSchemaTypeNames[store::XS_DATE],           ns, "xs", "date");
+  f->createQName(theSchemaTypeNames[store::XS_TIME],           ns, "xs", "time");
+  f->createQName(theSchemaTypeNames[store::XS_GYEAR_MONTH],    ns, "xs", "gYearMonth");
+  f->createQName(theSchemaTypeNames[store::XS_GYEAR],          ns, "xs", "gYear");
+  f->createQName(theSchemaTypeNames[store::XS_GMONTH_DAY],     ns, "xs", "gMonthDay");
+  f->createQName(theSchemaTypeNames[store::XS_GDAY],           ns, "xs", "gDay");
+  f->createQName(theSchemaTypeNames[store::XS_GMONTH],         ns, "xs", "gMonth");
+
+  f->createQName(theSchemaTypeNames[store::XS_DURATION],       ns, "xs", "duration");
+  f->createQName(theSchemaTypeNames[store::XS_DT_DURATION],    ns, "xs", "dayTimeDuration");
+  f->createQName(theSchemaTypeNames[store::XS_YM_DURATION],    ns, "xs", "yearMonthDuration");
+
+  f->createQName(theSchemaTypeNames[store::XS_FLOAT],          ns, "xs", "float");
+  f->createQName(theSchemaTypeNames[store::XS_DOUBLE],         ns, "xs", "double");
+  f->createQName(theSchemaTypeNames[store::XS_DECIMAL],        ns, "xs", "decimal");
+  f->createQName(theSchemaTypeNames[store::XS_INTEGER],        ns, "xs", "integer");
+  f->createQName(theSchemaTypeNames[store::XS_NON_POSITIVE_INTEGER], ns, "xs", "nonPositiveInteger");
+  f->createQName(theSchemaTypeNames[store::XS_NON_NEGATIVE_INTEGER], ns, "xs", "nonNegativeInteger");
+  f->createQName(theSchemaTypeNames[store::XS_NEGATIVE_INTEGER], ns, "xs", "negativeInteger");
+  f->createQName(theSchemaTypeNames[store::XS_POSITIVE_INTEGER], ns, "xs", "positiveInteger");
+
+  f->createQName(theSchemaTypeNames[store::XS_LONG],           ns, "xs", "long");
+  f->createQName(theSchemaTypeNames[store::XS_INT],            ns, "xs", "int");
+  f->createQName(theSchemaTypeNames[store::XS_SHORT],          ns, "xs", "short");
+  f->createQName(theSchemaTypeNames[store::XS_BYTE],           ns, "xs", "byte");
+  f->createQName(theSchemaTypeNames[store::XS_UNSIGNED_LONG],  ns, "xs", "unsignedLong");
+  f->createQName(theSchemaTypeNames[store::XS_UNSIGNED_INT],   ns, "xs", "unsignedInt");
+  f->createQName(theSchemaTypeNames[store::XS_UNSIGNED_SHORT], ns, "xs", "unsignedShort");
+  f->createQName(theSchemaTypeNames[store::XS_UNSIGNED_BYTE],  ns, "xs", "unsignedByte");
+
+  f->createQName(theSchemaTypeNames[store::XS_BASE64BINARY],   ns, "xs", "base64Binary");
+  f->createQName(theSchemaTypeNames[store::XS_HEXBINARY],      ns, "xs", "hexBinary");
+  f->createQName(theSchemaTypeNames[store::XS_BOOLEAN],        ns, "xs", "boolean");
+
+  for (ulong i = 0; i < store::XS_LAST; ++i)
   {
-    theSchemaTypeCodes[theSchemaTypeNames[i].getp()] = static_cast<SchemaTypeCode>(i);
+    theSchemaTypeCodes[theSchemaTypeNames[i].getp()] = 
+    static_cast<store::SchemaTypeCode>(i);
   }
 }
 
@@ -308,10 +308,14 @@
 
     if (theQNamePool != NULL)
     {
-      ulong numTypes = (ulong)theSchemaTypeNames.size();
-      for (ulong i = 0; i < numTypes; i++)
+      csize numTypes = theSchemaTypeNames.size();
+      for (csize i = 0; i < numTypes; ++i)
         theSchemaTypeNames[i] = NULL;
 
+      XS_UNTYPED_QNAME = NULL;
+      XS_ANY_QNAME = NULL;
+      XS_ANY_SIMPLE_QNAME = NULL;
+
       delete theQNamePool;
       theQNamePool = NULL;
     }

=== modified file 'src/store/naive/simple_store.h'
--- src/store/naive/simple_store.h	2011-12-21 14:40:33 +0000
+++ src/store/naive/simple_store.h	2012-01-10 13:58:38 +0000
@@ -67,33 +67,64 @@
 
 
 /*******************************************************************************
-  theSchemaTypeNames     : Maps each enum value from SchemaTypeNames (see
-                           store_defs.h) to its associated QName item.
-
-  theCollectionCounter   : Incremented every time a new collection is created. The
-                           current value of the counter is then assigned as the
-                           id of the new collection.
-
-  theNamespacePool       :
-  theQNamePool           :
-
-  theItemFactory         : Factory to create items.
-  theIteratorFactory     : Factory to create iterators.
-  theNodeFactory         : Factory to create node items.
-
-  theDocuments           : A hashmap that for each xml tree that does not belong
-                           to any collection, maps the URI of the tree to the root
-                           node of the tree.
-  theCollections         : Container which contains the collections of the store.
-                           It includes a map that maps the qname of each collection
-                           to the collection's container object.
-  theIndices             : A hashmap that for each index, maps the qname of the
-                           index to the index container object.
-  theICs                 : A hashmap the for each integrity constraint, maps the
-                           qname of the ic to the ic's container object.
-  theReferencesToNodeMap : A hashmap that maps node references to the referenced
-                           nodes
-  theNodeToReferencesMap : A hashmap that maps nodes into their references
+  theSchemaTypeNames:
+  -------------------
+  Maps each enum value from SchemaTypeNames (see store/api/xs_types_enum.h) to 
+  its associated QName item.
+
+  theSchemaTypeCodes:
+  -------------------
+
+  theCollectionCounter:
+  ---------------------
+  Incremented every time a new collection is created. The current value of the  
+  counter is then assigned as the id of the new collection.
+
+  theNamespacePool:
+  -----------------
+
+  theQNamePool:
+  -------------
+
+  theItemFactory:
+  ---------------
+  Factory to create items.
+
+  theIteratorFactory:
+  -------------------
+  Factory to create iterators.
+
+  theNodeFactory:
+  ---------------
+  Factory to create node items.
+
+  theDocuments:
+  -------------
+  A hashmap that for each xml tree that does not belong to any collection, maps
+  the URI of the tree to the root node of the tree.
+
+  theCollections:
+  ---------------
+  Container which contains the collections of the store. It includes a map that
+  maps the qname of each collection to the collection's container object.
+
+  theIndices:  
+  -----------
+  A hashmap that for each index, maps the qname of the index to the index 
+  container object.
+  
+  theICs:
+  -------
+  A hashmap the for each integrity constraint, maps the qname of the ic to the
+  ic's container object.
+
+  theReferencesToNodeMap:
+  -----------------------
+  A hashmap that maps node references to the referenced nodes
+
+  theNodeToReferencesMap:
+  -----------------------
+  A hashmap that maps nodes into their references
 
 ********************************************************************************/
 class SimpleStore : public store::Store
@@ -118,7 +149,10 @@
   zstring                       theXmlSchemaNs;
 
   std::vector<store::Item_t>    theSchemaTypeNames;
-  std::map<store::Item*, SchemaTypeCode> theSchemaTypeCodes;
+  std::map<store::Item*, store::SchemaTypeCode> theSchemaTypeCodes;
+  store::Item_t                 XS_UNTYPED_QNAME;
+  store::Item_t                 XS_ANY_QNAME;
+  store::Item_t                 XS_ANY_SIMPLE_QNAME;
 
 protected:
   ulong                         theNumUsers;

=== modified file 'src/store/naive/store_defs.h'
--- src/store/naive/store_defs.h	2011-09-30 14:06:33 +0000
+++ src/store/naive/store_defs.h	2012-01-10 13:58:38 +0000
@@ -56,84 +56,6 @@
 
 #define COMMENT_NODE(item) (reinterpret_cast<CommentNode*>((item).getp()))
 
-
-/*******************************************************************************
-  !!! ATTENTION: The order of thr enum values within SchemaTypeCode is important.
-  !!! DO NOT change this order!!!!
-********************************************************************************/
-enum SchemaTypeCode
-{
-  XS_UNTYPED = 0,
-
-  XS_ANY,
-
-  XS_ANY_SIMPLE,
-
-  XS_ANY_ATOMIC,
-
-  XS_UNTYPED_ATOMIC,
-
-  XS_ANY_URI,
-
-  XS_QNAME,
-
-  XS_NOTATION,
-
-  XS_STRING,
-  XS_NORMALIZED_STRING,
-  XS_TOKEN,
-  XS_NMTOKEN,
-  XS_LANGUAGE,
-  XS_NAME,
-  XS_NCNAME,
-  XS_ID,
-  XS_IDREF,
-  XS_ENTITY,
-
-  XS_DATETIME,
-  XS_DATE,
-  XS_TIME,
-
-  XS_GYEAR_MONTH,
-  XS_GYEAR,
-  XS_GMONTH_DAY,
-  XS_GDAY,
-  XS_GMONTH,
-
-  XS_DURATION,
-  XS_DT_DURATION,
-  XS_YM_DURATION,
-
-  XS_FLOAT,
-  XS_DOUBLE,
-
-  XS_DECIMAL,
-  XS_INTEGER,
-  XS_NON_POSITIVE_INTEGER,
-  XS_NON_NEGATIVE_INTEGER,
-  XS_NEGATIVE_INTEGER,
-  XS_POSITIVE_INTEGER,
-  XS_LONG,
-  XS_INT,
-  XS_SHORT,
-  XS_BYTE,
-  XS_UNSIGNED_LONG,
-  XS_UNSIGNED_INT,
-  XS_UNSIGNED_SHORT,
-  XS_UNSIGNED_BYTE,
-
-  XS_BASE64BINARY,
-  XS_HEXBINARY,
-  XS_BOOLEAN,
-
-  ZXSE_ERROR,
-
-  ZXSE_TUPLE,
-
-  XS_LAST
-};
-
-
 }
 }
 #endif

=== modified file 'src/types/casting.cpp'
--- src/types/casting.cpp	2011-12-30 17:55:53 +0000
+++ src/types/casting.cpp	2012-01-10 13:58:38 +0000
@@ -57,10 +57,10 @@
 
 
 #define ATOMIC_TYPE(type) \
-  GENV_TYPESYSTEM.create_atomic_type(TypeConstants::XS_##type, TypeConstants::QUANT_ONE)
+  GENV_TYPESYSTEM.create_atomic_type(store::XS_##type, TypeConstants::QUANT_ONE)
 
 #define ATOMIC_CODE_T \
-  TypeConstants::atomic_type_code_t
+  store::SchemaTypeCode
 
 
 struct ErrorInfo
@@ -1280,25 +1280,25 @@
 
   switch(aTargetAtomicType)
   {
-  case TypeConstants::XS_NORMALIZED_STRING:
+  case store::XS_NORMALIZED_STRING:
   {
     if (GenericCast::instance()->castableToNormalizedString(strval))
       return aFactory->createNormalizedString(result, strval);
     break;
   }
-  case TypeConstants::XS_TOKEN:
+  case store::XS_TOKEN:
   {
     if (GenericCast::instance()->castableToToken(strval))
       return aFactory->createToken(result, strval);
     break;
   }
-  case TypeConstants::XS_LANGUAGE:
+  case store::XS_LANGUAGE:
   {
     if (GenericCast::instance()->castableToLanguage(strval))
       return aFactory->createLanguage(result, strval);
     break;
   }
-  case TypeConstants::XS_NMTOKEN:
+  case store::XS_NMTOKEN:
   {
     ascii::trim_whitespace(strval);
 
@@ -1308,7 +1308,7 @@
     }
     break;
   }
-  case TypeConstants::XS_NAME:
+  case store::XS_NAME:
   {
     ascii::trim_whitespace(strval);
 
@@ -1318,7 +1318,7 @@
     }
     break;
   }
-  case TypeConstants::XS_NCNAME:
+  case store::XS_NCNAME:
   {
     ascii::normalize_whitespace(strval);
     ascii::trim_whitespace(strval);
@@ -1329,19 +1329,19 @@
     }
     break;
   }
-  case TypeConstants::XS_ID:
+  case store::XS_ID:
   {
     if (GenericCast::instance()->castableToNCName(strval))
       return aFactory->createID(result, strval);
     break;
   }
-  case TypeConstants::XS_IDREF:
+  case store::XS_IDREF:
   {
     if (GenericCast::instance()->castableToNCName(strval))
       return aFactory->createIDREF(result, strval);
     break;
   }
-  case TypeConstants::XS_ENTITY:
+  case store::XS_ENTITY:
   {
     if (GenericCast::instance()->castableToNCName(strval))
       return aFactory->createENTITY(result, strval);
@@ -1368,21 +1368,21 @@
 {
   switch(aTargetAtomicType)
   {
-  case TypeConstants::XS_NON_POSITIVE_INTEGER:
+  case store::XS_NON_POSITIVE_INTEGER:
   {
     xs_integer const lInteger = aItem->getIntegerValue();
     if (lInteger <= xs_integer::zero())
       return aFactory->createNonPositiveInteger(result, lInteger);
     break;
   }
-  case TypeConstants::XS_NEGATIVE_INTEGER:
+  case store::XS_NEGATIVE_INTEGER:
   {
     xs_integer const lInteger = aItem->getIntegerValue();
     if (lInteger < xs_integer::zero())
       return aFactory->createNegativeInteger(result, lInteger);
     break;
   }
-  case TypeConstants::XS_LONG:
+  case store::XS_LONG:
   {
     zstring lString;
     aItem->getStringValue2(lString);
@@ -1395,7 +1395,7 @@
     }
     break;
   }
-  case TypeConstants::XS_INT:
+  case store::XS_INT:
   {
     zstring lString;
     aItem->getStringValue2(lString);
@@ -1408,7 +1408,7 @@
     }
     break;
   }
-  case TypeConstants::XS_SHORT:
+  case store::XS_SHORT:
   {
     zstring lString;
     aItem->getStringValue2(lString);
@@ -1421,7 +1421,7 @@
     }
     break;
   }
-  case TypeConstants::XS_BYTE:
+  case store::XS_BYTE:
   {
     zstring lString;
     aItem->getStringValue2(lString);
@@ -1434,14 +1434,14 @@
     }
     break;
   }
-  case TypeConstants::XS_NON_NEGATIVE_INTEGER:
+  case store::XS_NON_NEGATIVE_INTEGER:
   {
     xs_integer const lInteger = aItem->getIntegerValue();
     if (lInteger >= xs_integer::zero())
       return aFactory->createNonNegativeInteger(result, lInteger);
     break;
   }
-  case TypeConstants::XS_UNSIGNED_LONG:
+  case store::XS_UNSIGNED_LONG:
   {
     zstring lString;
     aItem->getStringValue2(lString);
@@ -1454,7 +1454,7 @@
     }
     break;
   }
-  case TypeConstants::XS_UNSIGNED_INT:
+  case store::XS_UNSIGNED_INT:
   {
     zstring lString;
     aItem->getStringValue2(lString);
@@ -1467,7 +1467,7 @@
     }
     break;
   }
-  case TypeConstants::XS_UNSIGNED_SHORT:
+  case store::XS_UNSIGNED_SHORT:
   {
     zstring lString;
     aItem->getStringValue2(lString);
@@ -1480,7 +1480,7 @@
     }
     break;
   }
-  case TypeConstants::XS_UNSIGNED_BYTE:
+  case store::XS_UNSIGNED_BYTE:
   {
     zstring lString;
     aItem->getStringValue2(lString);
@@ -1493,7 +1493,7 @@
     }
     break;
   }
-  case TypeConstants::XS_POSITIVE_INTEGER:
+  case store::XS_POSITIVE_INTEGER:
   {
     xs_integer lInteger = aItem->getIntegerValue();
     if (lInteger > xs_integer::zero())
@@ -1511,7 +1511,7 @@
   For each builtin atomic type T, this array maps the typecode of T to an
   index to be used in addessing theCastingMatrix.
 ********************************************************************************/
-const int GenericCast::theMapping[TypeConstants::ATOMIC_TYPE_CODE_LIST_SIZE] =
+const int GenericCast::theMapping[store::XS_LAST] =
 {
   -1,  //  0 XS_ANY_ATOMIC
    1,  //  1 XS_STRING
@@ -1715,7 +1715,7 @@
 #endif
 
   store::Item_t lItem;
-  ATOMIC_CODE_T sourceTypeCode = TypeConstants::XS_STRING;
+  ATOMIC_CODE_T sourceTypeCode = store::XS_STRING;
   ATOMIC_CODE_T targetTypeCode = TypeOps::get_atomic_type_code(*aTargetType);
   bool valid = true;
 
@@ -1741,8 +1741,8 @@
   DownCastFunc lDownCastFunc = theDownCastMatrix[theMapping[targetTypeCode]];
 
   if (lDownCastFunc != 0 &&
-      targetTypeCode != TypeConstants::XS_STRING &&
-      targetTypeCode != TypeConstants::XS_INTEGER)
+      targetTypeCode != store::XS_STRING &&
+      targetTypeCode != store::XS_INTEGER)
   {
     valid = (*lDownCastFunc)(result,
                              &*result,
@@ -1813,19 +1813,19 @@
     return true;
   }
 
-  if (targetTypeCode == TypeConstants::XS_NOTATION ||
-      targetTypeCode == TypeConstants::XS_ANY_ATOMIC)
+  if (targetTypeCode == store::XS_NOTATION ||
+      targetTypeCode == store::XS_ANY_ATOMIC)
   {
     RAISE_ERROR(err::XPST0080, loc, ERROR_PARAMS(*errorInfo.theTargetType));
   }
 
-  if (sourceTypeCode == TypeConstants::XS_ANY_ATOMIC)
+  if (sourceTypeCode == store::XS_ANY_ATOMIC)
     throw TYPE_EXCEPTION(err::XPTY0004, errorInfo);
 
-  if (targetTypeCode == TypeConstants::XS_NCNAME &&
-      sourceTypeCode != TypeConstants::XS_STRING &&
-      sourceTypeCode != TypeConstants::XS_NCNAME &&
-      sourceTypeCode != TypeConstants::XS_UNTYPED_ATOMIC)
+  if (targetTypeCode == store::XS_NCNAME &&
+      sourceTypeCode != store::XS_STRING &&
+      sourceTypeCode != store::XS_NCNAME &&
+      sourceTypeCode != store::XS_UNTYPED_ATOMIC)
     throw TYPE_EXCEPTION(err::XPTY0004, errorInfo);
 
   CastFunc castFunc = theCastMatrix[theMapping[sourceTypeCode]]
@@ -1833,7 +1833,7 @@
   if (castFunc == 0)
     throw TYPE_EXCEPTION(err::XPTY0004, errorInfo);
 
-  if (theMapping[sourceTypeCode] == theMapping[TypeConstants::XS_STRING])
+  if (theMapping[sourceTypeCode] == theMapping[store::XS_STRING])
   {
     aItem->getStringValue2(sourceString);
   }
@@ -1848,8 +1848,8 @@
   DownCastFunc downCastFunc = theDownCastMatrix[theMapping[targetTypeCode]];
 
   if (downCastFunc != 0 &&
-      targetTypeCode != TypeConstants::XS_STRING &&
-      targetTypeCode != TypeConstants::XS_INTEGER)
+      targetTypeCode != store::XS_STRING &&
+      targetTypeCode != store::XS_INTEGER)
   {
     valid = (*downCastFunc)(result,
                             &*result,
@@ -1887,7 +1887,7 @@
   Schema* schema = lTypeManager->getSchema();
 
   if (aSourceType->type_kind() != XQType::ATOMIC_TYPE_KIND ||
-      (TypeOps::get_atomic_type_code(*aSourceType) != TypeConstants::XS_STRING))
+      (TypeOps::get_atomic_type_code(*aSourceType) != store::XS_STRING))
   {
     throw TYPE_EXCEPTION(err::FORG0001, lErrorInfo);
   }

=== modified file 'src/types/casting.h'
--- src/types/casting.h	2011-06-14 17:26:33 +0000
+++ src/types/casting.h	2012-01-10 13:58:38 +0000
@@ -20,6 +20,9 @@
 #include "common/shared_types.h"
 #include "types/root_typemanager.h"
 
+#include "store/api/xs_type_codes.h"
+
+
 namespace zorba
 {
 	
@@ -43,12 +46,12 @@
                             store::Item_t&,
                             const store::Item*, 
                             RootTypeManager& aTS,
-                            TypeConstants::atomic_type_code_t aTargetAtomicType,
+                            store::SchemaTypeCode aTargetAtomicType,
                             store::ItemFactory*,
                             const ErrorInfo& aErrorInfo
                         ); 
 private:
-  static const int          theMapping[TypeConstants::ATOMIC_TYPE_CODE_LIST_SIZE];
+  static const int          theMapping[store::XS_LAST];
   static const CastFunc     theCastMatrix[23][23];
   static const DownCastFunc theDownCastMatrix[23];
 

=== modified file 'src/types/root_typemanager.cpp'
--- src/types/root_typemanager.cpp	2011-06-14 17:26:33 +0000
+++ src/types/root_typemanager.cpp	2012-01-10 13:58:38 +0000
@@ -260,45 +260,45 @@
   GENV.getStore().getItemFactory()->createQName(ZXSE_TUPLE_QNAME, ZXSE_URI, ZXSE_PREFIX, "tuple");
 
   store::Item* tempQN = NULL;
-  TypeConstants::atomic_type_code_t tempCode;
+  store::SchemaTypeCode tempCode;
 
 #define ATOMIC_TYPE_DEFN(tname)                                                 \
   tname##_TYPE_ONE = new AtomicXQType(this,                                     \
-                                      TypeConstants::XS_##tname,                \
+                                      store::XS_##tname,                \
                                       TypeConstants::QUANT_ONE,                 \
                                       true);                                    \
                                                                                 \
   tname##_TYPE_QUESTION = new AtomicXQType(this,                                \
-                                           TypeConstants::XS_##tname,           \
+                                           store::XS_##tname,           \
                                            TypeConstants::QUANT_QUESTION,       \
                                            true);                               \
                                                                                 \
   tname##_TYPE_STAR = new AtomicXQType(this,                                    \
-                                       TypeConstants::XS_##tname,               \
+                                       store::XS_##tname,               \
                                        TypeConstants::QUANT_STAR,               \
                                        true);                                   \
                                                                                 \
   tname##_TYPE_PLUS = new AtomicXQType(this,                                    \
-                                       TypeConstants::XS_##tname,               \
+                                       store::XS_##tname,               \
                                        TypeConstants::QUANT_PLUS,               \
                                        true);                                   \
                                                                                 \
-  m_atomic_typecode_qname_map[TypeConstants::XS_##tname] = XS_##tname##_QNAME;  \
+  m_atomic_typecode_qname_map[store::XS_##tname] = XS_##tname##_QNAME;  \
                                                                                 \
   tempQN = XS_##tname##_QNAME.getp();                                           \
-  tempCode = TypeConstants::XS_##tname;                                         \
+  tempCode = store::XS_##tname;                                         \
   m_atomic_qnametype_map.insert(tempQN, tempCode);                              \
                                                                                 \
-  m_atomic_typecode_map[TypeConstants::XS_##tname][TypeConstants::QUANT_ONE] =  \
+  m_atomic_typecode_map[store::XS_##tname][TypeConstants::QUANT_ONE] =  \
     &tname##_TYPE_ONE;                                                          \
                                                                                 \
-  m_atomic_typecode_map[TypeConstants::XS_##tname][TypeConstants::QUANT_QUESTION] = \
+  m_atomic_typecode_map[store::XS_##tname][TypeConstants::QUANT_QUESTION] = \
     &tname##_TYPE_QUESTION;                                                     \
                                                                                 \
-  m_atomic_typecode_map[TypeConstants::XS_##tname][TypeConstants::QUANT_STAR] = \
+  m_atomic_typecode_map[store::XS_##tname][TypeConstants::QUANT_STAR] = \
     &tname##_TYPE_STAR;                                                         \
                                                                                 \
-  m_atomic_typecode_map[TypeConstants::XS_##tname][TypeConstants::QUANT_PLUS] = \
+  m_atomic_typecode_map[store::XS_##tname][TypeConstants::QUANT_PLUS] = \
     &tname##_TYPE_PLUS;
 
   ATOMIC_TYPE_DEFN(ANY_ATOMIC)

=== modified file 'src/types/root_typemanager.h'
--- src/types/root_typemanager.h	2011-12-21 12:10:32 +0000
+++ src/types/root_typemanager.h	2012-01-10 13:58:38 +0000
@@ -193,19 +193,18 @@
    * Maps each atomic type code and each quantifier code to a built-in XQType
    * object for that built-in atomic type and quantifier.
    */
-  xqtref_t* m_atomic_typecode_map[TypeConstants::ATOMIC_TYPE_CODE_LIST_SIZE]
-                                 [TypeConstants::QUANTIFIER_LIST_SIZE];
+  xqtref_t* m_atomic_typecode_map[store::XS_LAST][TypeConstants::QUANTIFIER_LIST_SIZE];
 
   /**
    * Maps the typecode of a built-in atomic type to its qname.
    */
-  store::Item* m_atomic_typecode_qname_map[TypeConstants::ATOMIC_TYPE_CODE_LIST_SIZE];
+  store::Item* m_atomic_typecode_qname_map[store::XS_LAST];
 
   /**
    *  Maps the qname of a built-in atomic type to its typecode.
    */
   typedef zorba::HashMap<store::Item*,
-                         TypeConstants::atomic_type_code_t,
+                         store::SchemaTypeCode,
                          qname_hash_equals> qnametype_map_t;
 
   qnametype_map_t m_atomic_qnametype_map;
@@ -215,8 +214,7 @@
    * contains true if T1 is a subtype of T2; otherwise it contains false.
    */
   static const bool 
-  ATOMIC_SUBTYPE_MATRIX[TypeConstants::ATOMIC_TYPE_CODE_LIST_SIZE]
-                       [TypeConstants::ATOMIC_TYPE_CODE_LIST_SIZE];
+  ATOMIC_SUBTYPE_MATRIX[store::XS_LAST][store::XS_LAST];
 
   /**
    * For each quantifier Q, let S(Q) be the following function:
@@ -272,8 +270,7 @@
    * instance, and NO means that the cast is never possible. 
    */
   static const TypeConstants::castable_t 
-  ATOMIC_CAST_MATRIX[TypeConstants::ATOMIC_TYPE_CODE_LIST_SIZE]
-                    [TypeConstants::ATOMIC_TYPE_CODE_LIST_SIZE];
+  ATOMIC_CAST_MATRIX[store::XS_LAST][store::XS_LAST];
 
 public:
   ~RootTypeManager();

=== modified file 'src/types/schema/revalidateUtils.cpp'
--- src/types/schema/revalidateUtils.cpp	2011-07-01 05:22:12 +0000
+++ src/types/schema/revalidateUtils.cpp	2012-01-10 13:58:38 +0000
@@ -605,11 +605,11 @@
   {
     if (schemaType->is_builtin())
     {
-      TypeConstants::atomic_type_code_t schemaTypeCode = 
+      store::SchemaTypeCode schemaTypeCode = 
           TypeOps::get_atomic_type_code(*schemaType);
 
-      if ( schemaTypeCode==TypeConstants::XS_ID ||
-          schemaTypeCode==TypeConstants::XS_IDREF )
+      if ( schemaTypeCode == store::XS_ID ||
+          schemaTypeCode == store::XS_IDREF )
         return false;
       else
         return false; //true;

=== modified file 'src/types/typeconstants.h'
--- src/types/typeconstants.h	2011-06-14 17:26:33 +0000
+++ src/types/typeconstants.h	2012-01-10 13:58:38 +0000
@@ -31,57 +31,7 @@
     QUANTIFIER_LIST_SIZE
   } quantifier_t;
 
-  typedef enum 
-  {
-    INVALID_TYPE_CODE = -1,
-    XS_ANY_ATOMIC = 0,
-    XS_STRING,
-    XS_NORMALIZED_STRING,
-    XS_TOKEN,
-    XS_LANGUAGE,
-    XS_NMTOKEN,
-    XS_NAME,
-    XS_NCNAME,
-    XS_ID,
-    XS_IDREF,
-    XS_ENTITY,
-    XS_UNTYPED_ATOMIC,
-    XS_DATETIME,
-    XS_DATE,
-    XS_TIME,
-    XS_DURATION,
-    XS_DT_DURATION,
-    XS_YM_DURATION,
-    XS_FLOAT,
-    XS_DOUBLE,
-    XS_DECIMAL,
-    XS_INTEGER,
-    XS_NON_POSITIVE_INTEGER,
-    XS_NEGATIVE_INTEGER,
-    XS_LONG,
-    XS_INT,
-    XS_SHORT,
-    XS_BYTE,
-    XS_NON_NEGATIVE_INTEGER,
-    XS_UNSIGNED_LONG,
-    XS_UNSIGNED_INT,
-    XS_UNSIGNED_SHORT,
-    XS_UNSIGNED_BYTE,
-    XS_POSITIVE_INTEGER,
-    XS_GYEAR_MONTH,
-    XS_GYEAR,
-    XS_GMONTH_DAY,
-    XS_GDAY,
-    XS_GMONTH,
-    XS_BOOLEAN,
-    XS_BASE64BINARY,
-    XS_HEXBINARY,
-    XS_ANY_URI,
-    XS_QNAME,
-    XS_NOTATION,
-    ATOMIC_TYPE_CODE_LIST_SIZE // Used to indicate the size of the list.
-  } atomic_type_code_t;
-  
+
   typedef enum 
   {
     NOT_CASTABLE,

=== modified file 'src/types/typeimpl.cpp'
--- src/types/typeimpl.cpp	2011-07-01 05:22:12 +0000
+++ src/types/typeimpl.cpp	2012-01-10 13:58:38 +0000
@@ -93,7 +93,7 @@
 };
 
 
-const char *AtomicXQType::ATOMIC_TYPE_CODE_STRINGS[TypeConstants::ATOMIC_TYPE_CODE_LIST_SIZE] =
+const char* AtomicXQType::ATOMIC_TYPE_CODE_STRINGS[store::XS_LAST] =
 {
   "xs:anyAtomicType",
   "xs:string",

=== modified file 'src/types/typeimpl.h'
--- src/types/typeimpl.h	2011-07-01 05:22:12 +0000
+++ src/types/typeimpl.h	2012-01-10 13:58:38 +0000
@@ -477,24 +477,24 @@
 class AtomicXQType : public XQType
 {
 public:
-   static const char* ATOMIC_TYPE_CODE_STRINGS[TypeConstants::ATOMIC_TYPE_CODE_LIST_SIZE];
+   static const char* ATOMIC_TYPE_CODE_STRINGS[store::XS_LAST];
 
 private:
-   TypeConstants::atomic_type_code_t m_type_code;
+   store::SchemaTypeCode m_type_code;
 
 public:
   SERIALIZABLE_CLASS(AtomicXQType)
   SERIALIZABLE_CLASS_CONSTRUCTOR2(AtomicXQType, XQType)
-  void serialize(::zorba::serialization::Archiver &ar)
+  void serialize(::zorba::serialization::Archiver& ar)
   {
     serialize_baseclass(ar, (XQType*)this);
-    SERIALIZE_ENUM(TypeConstants::atomic_type_code_t, m_type_code);
+    SERIALIZE_ENUM(store::SchemaTypeCode, m_type_code);
   }
 
 public:
    AtomicXQType(
-        const TypeManager *manager,
-        TypeConstants::atomic_type_code_t type_code,
+        const TypeManager* manager,
+        store::SchemaTypeCode type_code,
         TypeConstants::quantifier_t quantifier,
         bool builtin = false)
      :
@@ -503,7 +503,7 @@
    {
    }
 
-  TypeConstants::atomic_type_code_t get_type_code() const { return m_type_code; }
+  store::SchemaTypeCode get_type_code() const { return m_type_code; }
 
   content_kind_t content_kind() const { return SIMPLE_CONTENT_KIND; };
 

=== modified file 'src/types/typemanager.h'
--- src/types/typemanager.h	2011-12-21 12:10:32 +0000
+++ src/types/typemanager.h	2012-01-10 13:58:38 +0000
@@ -31,6 +31,9 @@
 
 #include "zorbaserialization/serialization_engine.h"
 
+#include "store/api/xs_type_codes.h"
+
+
 namespace zorba {
 
 class NodeTest;
@@ -70,7 +73,7 @@
   
   virtual ~TypeManager() { }
 
-  virtual TypeManager *get_parent_type_manager() const = 0;
+  virtual TypeManager* get_parent_type_manager() const = 0;
 
   virtual int level() const { return m_level; }
 
@@ -93,7 +96,7 @@
   virtual xqtref_t create_any_simple_type() const = 0;
 
   virtual xqtref_t create_builtin_atomic_type(
-        TypeConstants::atomic_type_code_t type_code,
+        store::SchemaTypeCode type_code,
         TypeConstants::quantifier_t quantifier) const = 0;
 
   virtual xqtref_t create_named_atomic_type(

=== modified file 'src/types/typemanagerimpl.cpp'
--- src/types/typemanagerimpl.cpp	2011-07-01 05:22:12 +0000
+++ src/types/typemanagerimpl.cpp	2012-01-10 13:58:38 +0000
@@ -191,7 +191,7 @@
   quantifier. The typecode identifies a builtin atomic type.
 ********************************************************************************/
 xqtref_t TypeManagerImpl::create_builtin_atomic_type(
-    TypeConstants::atomic_type_code_t type_code,
+    store::SchemaTypeCode type_code,
     TypeConstants::quantifier_t quantifier) const
 {
   return *GENV_TYPESYSTEM.m_atomic_typecode_map[type_code][quantifier];
@@ -212,7 +212,7 @@
   // Try to resolve the type name as a builtin atomic type
   RootTypeManager::qnametype_map_t& myMap = GENV_TYPESYSTEM.m_atomic_qnametype_map;
 
-  TypeConstants::atomic_type_code_t code = TypeConstants::INVALID_TYPE_CODE;
+  store::SchemaTypeCode code;
 
   if (myMap.get(qname, code))
     return create_builtin_atomic_type(code, quantifier);
@@ -323,7 +323,7 @@
     // Try to resolve the type name as a builtin atomic type
     RootTypeManager::qnametype_map_t& myMap = RTM.m_atomic_qnametype_map;
 
-    TypeConstants::atomic_type_code_t code = TypeConstants::INVALID_TYPE_CODE;
+    store::SchemaTypeCode code = store::XS_LAST;
 
     if (myMap.get(qname, code))
       return create_builtin_atomic_type(code, quant);

=== modified file 'src/types/typemanagerimpl.h'
--- src/types/typemanagerimpl.h	2011-06-14 17:26:33 +0000
+++ src/types/typemanagerimpl.h	2012-01-10 13:58:38 +0000
@@ -98,7 +98,7 @@
   xqtref_t create_any_simple_type() const;
 
   xqtref_t create_builtin_atomic_type(
-        TypeConstants::atomic_type_code_t type_code,
+        store::SchemaTypeCode type_code,
         TypeConstants::quantifier_t quant) const;
 
   xqtref_t create_named_atomic_type(

=== modified file 'src/types/typeops.cpp'
--- src/types/typeops.cpp	2011-07-25 22:22:25 +0000
+++ src/types/typeops.cpp	2012-01-10 13:58:38 +0000
@@ -140,7 +140,7 @@
 /*******************************************************************************
 
 ********************************************************************************/
-TypeConstants::atomic_type_code_t TypeOps::get_atomic_type_code(const XQType& type)
+store::SchemaTypeCode TypeOps::get_atomic_type_code(const XQType& type)
 {
   assert(type.type_kind() == XQType::ATOMIC_TYPE_KIND);
   return (static_cast<const AtomicXQType&>(type)).get_type_code();
@@ -325,15 +325,15 @@
   case XQType::ATOMIC_TYPE_KIND:
     switch (static_cast<const AtomicXQType &>(type).get_type_code()) 
     {
-    case TypeConstants::XS_ANY_ATOMIC:
-    case TypeConstants::XS_DATE:
-    case TypeConstants::XS_TIME:
-    case TypeConstants::XS_DATETIME:
-    case TypeConstants::XS_GYEAR_MONTH:
-    case TypeConstants::XS_GYEAR:
-    case TypeConstants::XS_GMONTH_DAY:
-    case TypeConstants::XS_GDAY:
-    case TypeConstants::XS_GMONTH:
+    case store::XS_ANY_ATOMIC:
+    case store::XS_DATE:
+    case store::XS_TIME:
+    case store::XS_DATETIME:
+    case store::XS_GYEAR_MONTH:
+    case store::XS_GYEAR:
+    case store::XS_GMONTH_DAY:
+    case store::XS_GDAY:
+    case store::XS_GMONTH:
       return true;
     default: return false;
     }
@@ -494,6 +494,17 @@
   Returns true iff "subtype" is a subtype of "supertype".
 ********************************************************************************/
 bool TypeOps::is_subtype(
+    store::SchemaTypeCode subtype,
+    store::SchemaTypeCode supertype)
+{
+  return RootTypeManager::ATOMIC_SUBTYPE_MATRIX[subtype][supertype];
+}
+
+
+/*******************************************************************************
+  Returns true iff "subtype" is a subtype of "supertype".
+********************************************************************************/
+bool TypeOps::is_subtype(
     const TypeManager* tm,
     const XQType& subtype,
     const XQType& supertype,
@@ -730,7 +741,7 @@
 
       const AtomicXQType& a2 = static_cast<const AtomicXQType&>(supertype);
 
-      if (a2.get_type_code() == TypeConstants::XS_ANY_ATOMIC)
+      if (a2.get_type_code() == store::XS_ANY_ATOMIC)
         return true;
 
       xqtref_t subtype = tm->create_named_atomic_type(subitem->getType(),

=== modified file 'src/types/typeops.h'
--- src/types/typeops.h	2011-07-01 05:22:12 +0000
+++ src/types/typeops.h	2012-01-10 13:58:38 +0000
@@ -22,11 +22,14 @@
 #include "common/shared_types.h"
 #include "types/typeconstants.h"
 #include "zorba/typeident.h"
+
+#include "compiler/parser/query_loc.h"
+
+#include "store/api/xs_type_codes.h"
 #include "store/api/item.h"
-#include "compiler/parser/query_loc.h"
-
-
-namespace zorba {
+
+namespace zorba 
+{
 
 typedef TypeIdentifier_t type_ident_ref_t;
 
@@ -91,7 +94,7 @@
    * Returns the atomic_type_code_t for a given type, which is assumed to be
    * a quantified builtin atomic type.
    */
-  static TypeConstants::atomic_type_code_t get_atomic_type_code(const XQType& type);
+  static store::SchemaTypeCode get_atomic_type_code(const XQType& type);
 
   /**
    * Return true is the given type is among the known types of the given type mgr
@@ -161,6 +164,13 @@
   /*
    * Returns true if _subtype_ is a subtype of _supertype_, false otherwise.
    */
+  bool is_subtype(
+        store::SchemaTypeCode subtype,
+        store::SchemaTypeCode supertype);
+
+  /*
+   * Returns true if _subtype_ is a subtype of _supertype_, false otherwise.
+   */
   static bool is_subtype(
         const TypeManager* tm,
         const XQType& subtype,


Follow ups