Chris Hillery has proposed merging lp:~zorba-coders/zorba/temp-csx-schema into 
lp:zorba.

Requested reviews:
  Matthias Brantner (matthias-brantner)
  Chris Hillery (ceejatec)
Related bugs:
  Bug #935666 in Zorba: "Item types need to have their own class"
  https://bugs.launchpad.net/zorba/+bug/935666

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/temp-csx-schema/+merge/96035

Ignore for now
-- 
https://code.launchpad.net/~zorba-coders/zorba/temp-csx-schema/+merge/96035
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'include/zorba/item.h'
--- include/zorba/item.h	2012-02-28 20:45:43 +0000
+++ include/zorba/item.h	2012-03-06 01:49:21 +0000
@@ -131,6 +131,11 @@
   bool
   isAtomic() const;
 
+  /**
+   * @return the type of this item based on the enum values in store_const.h
+   */
+  store::SchemaTypeCode getTypeCode() const;
+
   /** \brief Get the type of the Item.
    *
    * See http://www.w3.org/TR/xpath-datamodel/#types.

=== modified file 'include/zorba/item_factory.h'
--- include/zorba/item_factory.h	2012-02-28 20:45:43 +0000
+++ include/zorba/item_factory.h	2012-03-06 01:49:21 +0000
@@ -628,7 +628,6 @@
                         bool aHasTypedValue,
                         bool aHasEmptyValue,
                         NsBindings aNsBindings) = 0;
-
       /**
       * Create a new attribute node N and place it among the
       * attributes of a given parent node. If no parent is given, N becomes the
@@ -698,7 +697,39 @@
       virtual Item createTextNode(
         Item   parent,
         String content) = 0;
-}; // class ItemFactory
+
+      /**
+      * @brief Assigns a simple typed value to an element node.
+      *
+      * Creates a simple typed value for an element. Note that this may only
+      * be done once per element. This method should only be used during
+      * creation of a new tree. Using this method to modify elements after
+      * processing has begun has undefined results.
+      *
+      *
+      * @param aElement       The element for the typed value; may not be NULL.
+      * @param aTypedValue    The typed value for the element.
+      */
+      virtual void
+      assignElementTypedValue(Item& aElement,
+                              Item aTypedValue) = 0;
+      /**
+      * @brief Assigns a simple typed value to an element node.
+      *
+      * Creates a simple typed value for an element. Note that this may only
+      * be done once per element. This method should only be used during
+      * creation of a new tree. Using this method to modify elements after
+      * processing has begun has undefined results.
+      *
+      *
+      * @param aElement       The element for the typed value; may not be NULL.
+      * @param aTypedValue    The typed value for the element.
+      */
+      virtual void
+      assignElementTypedValue(Item& aElement,
+                              std::vector<Item>& aTypedValue) = 0;
+
+  }; // class ItemFactory
 
 } // namespace zorba
 #endif

=== modified file 'include/zorba/store_consts.h'
--- include/zorba/store_consts.h	2011-06-14 17:26:33 +0000
+++ include/zorba/store_consts.h	2012-03-06 01:49:21 +0000
@@ -21,6 +21,71 @@
 
 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
+};
+
 class ZORBA_DLL_PUBLIC StoreConsts
 {
  public:

=== modified file 'src/api/item.cpp'
--- src/api/item.cpp	2012-02-28 20:45:43 +0000
+++ src/api/item.cpp	2012-03-06 01:49:21 +0000
@@ -157,6 +157,18 @@
   return false;
 }
 
+store::SchemaTypeCode
+Item::getTypeCode() const
+{
+  ITEM_TRY
+
+    SYNC_CODE(AutoLock lock(GENV_STORE.getGlobalLock(), Lock::READ);)
+
+    return m_item->getTypeCode();
+
+  ITEM_CATCH
+    return store::XS_ANY_ATOMIC;
+}
 
 Item Item::getType() const
 {

=== modified file 'src/api/itemfactoryimpl.cpp'
--- src/api/itemfactoryimpl.cpp	2012-02-29 17:15:09 +0000
+++ src/api/itemfactoryimpl.cpp	2012-03-06 01:49:21 +0000
@@ -708,6 +708,30 @@
   return &*lItem;
 }
 
+void convertNsBindings(
+    zorba::NsBindings& aInBindings,
+    store::NsBindings& aOutBindings)
+{
+  zorba::NsBindings::iterator lIter;
+  for (lIter = aInBindings.begin(); lIter != aInBindings.end(); ++lIter)
+  {
+    zstring lFirst = Unmarshaller::getInternalString(lIter->first);
+    zstring lSecond = Unmarshaller::getInternalString(lIter->second);
+    aOutBindings.push_back(std::pair<zstring, zstring>(lFirst, lSecond));
+  }
+}
+
+void convertItemVector(
+    std::vector<zorba::Item>& aInItems,
+    std::vector<store::Item_t>& aOutItems)
+{
+  std::vector<Item>::iterator lIter;
+
+  for (lIter = aInItems.begin(); lIter != aInItems.end(); ++lIter)
+  {
+    aOutItems.push_back(Unmarshaller::getInternalItem(*lIter));
+  }
+}
 
 zorba::Item ItemFactoryImpl::createElementNode(
     Item& aParent,
@@ -721,14 +745,7 @@
   store::Item_t lNodeName = Unmarshaller::getInternalItem(aNodeName);
   store::Item_t lTypeName = Unmarshaller::getInternalItem(aTypeName);
   store::NsBindings lNsBindings;
-  
-  std::vector<std::pair<String, String> >::iterator lIter;
-  for (lIter = aNsBindings.begin(); lIter != aNsBindings.end(); ++lIter) 
-  {
-    zstring lFirst = Unmarshaller::getInternalString(lIter->first);
-    zstring lSecond = Unmarshaller::getInternalString(lIter->second);
-    lNsBindings.push_back(std::pair<zstring, zstring>(lFirst, lSecond));
-    }
+  convertNsBindings(aNsBindings, lNsBindings);
 
   zstring lBaseUri;
   theItemFactory->createElementNode(lItem,
@@ -742,6 +759,33 @@
   return &*lItem;
 }
 
+void ItemFactoryImpl::assignElementTypedValue(
+    Item &aElement,
+    Item aTypedValue)
+{
+  store::Item_t lStoreElement = Unmarshaller::getInternalItem(aElement);
+
+  // Create the internal text node where the Zorba store holds the typed value.
+  store::Item_t lText;
+  store::Item_t lTypedValue = Unmarshaller::getInternalItem(aTypedValue);
+  theItemFactory->createTextNode(lText, lStoreElement, lTypedValue);
+}
+
+void ItemFactoryImpl::assignElementTypedValue(
+    Item &aElement,
+    std::vector<Item> &aTypedValue)
+{
+  store::Item_t lStoreElement = Unmarshaller::getInternalItem(aElement);
+
+  // Convert typed value vector.
+  std::vector<store::Item_t> lTypedValue;
+  convertItemVector(aTypedValue, lTypedValue);
+
+  // Create the internal text node where the Zorba store holds the typed value.
+  store::Item_t lText;
+  theItemFactory->createTextNode(lText, lStoreElement, lTypedValue);
+}
+
 
 zorba::Item ItemFactoryImpl::createAttributeNode(
     Item aParent,
@@ -772,12 +816,7 @@
   store::Item_t lNodeName = Unmarshaller::getInternalItem(aNodeName);
   store::Item_t lTypeName = Unmarshaller::getInternalItem(aTypeName);
   std::vector<store::Item_t> lTypedValue;
-  std::vector<Item>::iterator lIter;
-
-  for (lIter = aTypedValue.begin(); lIter != aTypedValue.end(); ++lIter) 
-  {
-    lTypedValue.push_back(Unmarshaller::getInternalItem(*lIter));
-  }
+  convertItemVector(aTypedValue, lTypedValue);
 
   theItemFactory->createAttributeNode(lItem,
                                       Unmarshaller::getInternalItem(aParent),

=== modified file 'src/api/itemfactoryimpl.h'
--- src/api/itemfactoryimpl.h	2012-02-28 20:45:43 +0000
+++ src/api/itemfactoryimpl.h	2012-03-06 01:49:21 +0000
@@ -222,6 +222,14 @@
                         bool aHasEmptyValue,
                         NsBindings aNsBindings);
 
+      virtual void
+      assignElementTypedValue(Item& aElement,
+                              Item aTypedValue);
+
+      virtual void
+      assignElementTypedValue(Item& aElement,
+                              std::vector<Item>& aTypedValue);
+
       virtual Item
       createAttributeNode(Item aParent,
         Item aNodeName,

=== modified file 'src/runtime/core/arithmetic_impl.h'
--- src/runtime/core/arithmetic_impl.h	2012-01-10 10:52:15 +0000
+++ src/runtime/core/arithmetic_impl.h	2012-03-06 01:49:21 +0000
@@ -25,7 +25,8 @@
 
 #include "runtime/base/binarybase.h" 
 
-#include "store/api/xs_type_codes.h"
+//#include "store/api/xs_type_codes.h"
+#include <zorba/store_consts.h>
 
 
 namespace zorba {

=== modified file 'src/runtime/numerics/NumericsImpl.h'
--- src/runtime/numerics/NumericsImpl.h	2012-01-10 10:52:15 +0000
+++ src/runtime/numerics/NumericsImpl.h	2012-03-06 01:49:21 +0000
@@ -23,7 +23,8 @@
 #include "runtime/base/binarybase.h" // TODO remove after iterator refactoring
 #include "runtime/base/narybase.h"
 
-#include "store/api/xs_type_codes.h"
+//#include "store/api/xs_type_codes.h"
+#include <zorba/store_consts.h>
 
 namespace zorba
 {

=== modified file 'src/runtime/spec/plan_iter_visitor_h.xq'
--- src/runtime/spec/plan_iter_visitor_h.xq	2012-01-11 17:30:25 +0000
+++ src/runtime/spec/plan_iter_visitor_h.xq	2012-03-06 01:49:21 +0000
@@ -27,7 +27,7 @@
   '#include <vector>',$gen:newline,
   '#include "common/common.h"',$gen:newline,
   '#include "zorbatypes/zorbatypes_decl.h"',$gen:newline,
-  '#include "store/api/xs_type_codes.h"',$gen:newline,
+  '#include <zorba/store_consts.h>',$gen:newline,
   '#include "zorbatypes/rchandle.h"',$gen:newline,
   '#include "zorbatypes/zstring.h"',$gen:newline
   ),'')

=== modified file 'src/runtime/visitors/pregenerated/planiter_visitor.h'
--- src/runtime/visitors/pregenerated/planiter_visitor.h	2012-02-16 14:11:02 +0000
+++ src/runtime/visitors/pregenerated/planiter_visitor.h	2012-03-06 01:49:21 +0000
@@ -25,7 +25,7 @@
 #include <vector>
 #include "common/common.h"
 #include "zorbatypes/zorbatypes_decl.h"
-#include "store/api/xs_type_codes.h"
+#include <zorba/store_consts.h>
 #include "zorbatypes/rchandle.h"
 #include "zorbatypes/zstring.h"
 

=== modified file 'src/store/api/item.h'
--- src/store/api/item.h	2012-02-29 17:15:09 +0000
+++ src/store/api/item.h	2012-03-06 01:49:21 +0000
@@ -26,7 +26,8 @@
 #include "zorbatypes/rclock.h"
 #include "zorbatypes/schema_types.h"
 
-#include "store/api/xs_type_codes.h"
+//#include "store/api/xs_type_codes.h"
+#include <zorba/store_consts.h>
 #include "store/api/shared_types.h"
 
 #ifndef ZORBA_NO_FULL_TEXT

=== removed file 'src/store/api/xs_type_codes.h'
--- src/store/api/xs_type_codes.h	2012-01-10 10:52:15 +0000
+++ src/store/api/xs_type_codes.h	1970-01-01 00:00:00 +0000
@@ -1,94 +0,0 @@
-/*
- * 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.h'
--- src/store/naive/atomic_items.h	2012-02-29 17:15:09 +0000
+++ src/store/naive/atomic_items.h	2012-03-06 01:49:21 +0000
@@ -29,9 +29,16 @@
 
 #include "store/api/item.h"
 #include "store/api/item_handle.h"
+<<<<<<< TREE
 #include "store/api/xs_type_codes.h"
 #include "store_defs.h"
 #include "shared_types.h"
+=======
+//#include "store/api/xs_type_codes.h"
+#include <zorba/store_consts.h>
+#include "store/naive/store_defs.h"
+#include "store/naive/shared_types.h"
+>>>>>>> MERGE-SOURCE
 
 #ifndef ZORBA_NO_FULL_TEXT
 #include "naive_ft_token_iterator.h"

=== modified file 'src/store/naive/simple_store.cpp'
--- src/store/naive/simple_store.cpp	2012-02-28 20:45:43 +0000
+++ src/store/naive/simple_store.cpp	2012-03-06 01:49:21 +0000
@@ -29,7 +29,8 @@
 #include "diagnostics/util_macros.h"
 
 #include "store/api/pul.h"
-#include "store/api/xs_type_codes.h"
+//#include "store/api/xs_type_codes.h"
+#include <zorba/store_consts.h>
 
 #include "properties.h"
 #include "string_pool.h"

=== modified file 'src/types/casting.cpp'
--- src/types/casting.cpp	2012-02-29 17:15:09 +0000
+++ src/types/casting.cpp	2012-03-06 01:49:21 +0000
@@ -34,7 +34,8 @@
 #include "store/api/item_factory.h"
 #include "store/api/item.h"
 #include "store/api/store.h"
-#include "store/api/xs_type_codes.h"
+//#include "store/api/xs_type_codes.h"
+#include <zorba/store_consts.h>
 
 #include "types/typeops.h"
 #include "types/typemanagerimpl.h"

=== modified file 'src/types/casting.h'
--- src/types/casting.h	2012-02-28 18:16:50 +0000
+++ src/types/casting.h	2012-03-06 01:49:21 +0000
@@ -20,7 +20,8 @@
 #include "common/shared_types.h"
 #include "types/root_typemanager.h"
 
-#include "store/api/xs_type_codes.h"
+//#include "store/api/xs_type_codes.h"
+#include <zorba/store_consts.h>
 
 
 namespace zorba

=== modified file 'src/types/schema/schema.cpp'
--- src/types/schema/schema.cpp	2011-11-02 06:14:25 +0000
+++ src/types/schema/schema.cpp	2012-03-06 01:49:21 +0000
@@ -51,6 +51,7 @@
 # include <xercesc/util/XercesDefs.hpp>
 # include <xercesc/util/BinInputStream.hpp>
 # include <zorbatypes/xerces_xmlcharray.h>
+# include <xercesc/framework/psvi/XSAnnotation.hpp>
 #endif /* ZORBA_NO_XMLSCHEMA */
 
 
@@ -425,6 +426,8 @@
     parser->setFeature(XMLUni::fgXercesDisableDefaultEntityResolution, true);
     // skip DTDs
     parser->setFeature(XMLUni::fgXercesLoadExternalDTD, false);
+    // OpenCSX - generates syntethic annotations
+    parser->setFeature(XMLUni::fgXercesGenerateSyntheticAnnotations, true);
 
     parser->setProperty(XMLUni::fgXercesScannerName,
                         (void *)XMLUni::fgSGXMLScanner);
@@ -739,6 +742,15 @@
 
   if (decl)
   {
+    //XSAnnotation* xsa = NULL;
+    //xsa = decl->getAnnotation();
+    //if(xsa == NULL){
+    //  TRACE("Error!! xsa is NULL --- " << xsa << "\n");
+    //} else {
+    //  TRACE( "DEBUG>> decl->getAnnotation()->getAnnotationString(): " 
+    //    << StrX(xsa->getAnnotationString()) << "\n");
+    //}
+
     typeDef = decl->getTypeDefinition();
 
     // this works only on the element that is a substitution,

=== modified file 'src/types/schema/validate.cpp'
--- src/types/schema/validate.cpp	2011-09-22 21:50:20 +0000
+++ src/types/schema/validate.cpp	2012-03-06 01:49:21 +0000
@@ -246,7 +246,7 @@
     {
       //cout << "Validate element" << "\n"; cout.flush();
       schemaValidator.startDoc();
-      
+
       // ask for the type of the root element to populate the cache
       // with anonymous types
       typeManager->getSchema()->

=== modified file 'src/types/typemanager.h'
--- src/types/typemanager.h	2012-01-10 10:52:15 +0000
+++ src/types/typemanager.h	2012-03-06 01:49:21 +0000
@@ -31,7 +31,8 @@
 
 #include "zorbaserialization/serialization_engine.h"
 
-#include "store/api/xs_type_codes.h"
+//#include "store/api/xs_type_codes.h"
+#include <zorba/store_consts.h>
 
 
 namespace zorba {

=== modified file 'src/types/typeops.h'
--- src/types/typeops.h	2012-01-11 10:30:49 +0000
+++ src/types/typeops.h	2012-03-06 01:49:21 +0000
@@ -25,7 +25,8 @@
 
 #include "compiler/parser/query_loc.h"
 
-#include "store/api/xs_type_codes.h"
+//#include "store/api/xs_type_codes.h"
+#include <zorba/store_consts.h>
 #include "store/api/item.h"
 
 namespace zorba 

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

Reply via email to