Cezar Andrei has proposed merging 
lp:~zorba-coders/zorba/bug857842-textWithComment into lp:zorba.

Requested reviews:
  Cezar Andrei (cezar-andrei)
  Matthias Brantner (matthias-brantner)
Related bugs:
  Bug #857842 in Zorba: "Assertion failed with simple content element with 
comments"
  https://bugs.launchpad.net/zorba/+bug/857842

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug857842-textWithComment/+merge/103944

Fix for Bug #857842 Assertion failed with simple content element with comments
Make use of XML_SCHEMA_NS definition from ns_consts.h.
Skip whole text when part of mixed content, this allows w3c_update_testsuite to 
pass.
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug857842-textWithComment/+merge/103944
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog	2012-04-25 17:16:48 +0000
+++ ChangeLog	2012-04-27 21:00:30 +0000
@@ -41,6 +41,7 @@
   * Fixed bug #949910 (has-children may be invoked on all nodes). Internally, zorba::store::Item::getChildren() now returns NULL on node classes without offspring (instead of raising an error).
   * Fixed Bug #933490: Error ItemFactoryImpl::createBase64Binary with istream
   * Fixed bug #867112 (Diagnostic Handler was not working on external APIs)
+  * Fixed bug #857842 (Assertion failed with simple content element with comments)
 
 
 version 2.2

=== modified file 'src/api/xmldatamanagerimpl.cpp'
--- src/api/xmldatamanagerimpl.cpp	2012-04-24 12:39:38 +0000
+++ src/api/xmldatamanagerimpl.cpp	2012-04-27 21:00:30 +0000
@@ -33,18 +33,15 @@
 #include "api/staticcontextimpl.h"
 #include "api/documentmanagerimpl.h"
 #include "api/collectionmanagerimpl.h"
-
+#include "context/static_context.h"
 #include "diagnostics/xquery_diagnostics.h"
-
+#include "runtime/util/flowctl_exception.h"
 #include "store/api/collection.h"
 #include "store/api/item.h"
-#include "system/globalenv.h"
 #include "store/api/store.h"
 #include "store/api/item_factory.h"
-
-#include "context/static_context.h"
-
-#include "runtime/util/flowctl_exception.h"
+#include "system/globalenv.h"
+#include "zorbamisc/ns_consts.h"
 
 #ifndef ZORBA_NO_FULL_TEXT
 #include "stemmer_wrapper.h"
@@ -292,7 +289,7 @@
     Item empty_item;
     Item validated_options;
     NsBindings nsPairs;
-    Item untyped_type = theFactory->createQName("http://www.w3.org/2001/XMLSchema";, "xs", "untyped");
+    Item untyped_type = theFactory->createQName(XML_SCHEMA_NS, XML_SCHEMA_PREFIX, "untyped");
     Item options_node = theFactory->createElementNode(empty_item,
         theFactory->createQName(static_context::ZORBA_XML_FN_OPTIONS_NS, "options"),
         untyped_type, false, false, nsPairs);
@@ -340,7 +337,7 @@
     Item empty_item;
     Item validated_options;
     NsBindings nsPairs;
-    Item untyped_type = theFactory->createQName("http://www.w3.org/2001/XMLSchema";, "xs", "untyped");
+    Item untyped_type = theFactory->createQName(XML_SCHEMA_NS, XML_SCHEMA_PREFIX, "untyped");
     Item options_node = theFactory->createElementNode(empty_item,
         theFactory->createQName(static_context::ZORBA_XML_FN_OPTIONS_NS, "options"),
         untyped_type, false, false, nsPairs);

=== modified file 'src/compiler/parsetree/parsenode_print_xqdoc_visitor.cpp'
--- src/compiler/parsetree/parsenode_print_xqdoc_visitor.cpp	2012-04-24 12:39:38 +0000
+++ src/compiler/parsetree/parsenode_print_xqdoc_visitor.cpp	2012-04-27 21:00:30 +0000
@@ -38,6 +38,8 @@
 #include "store/api/iterator.h"
 
 #include "system/globalenv.h"
+#include "zorbamisc/ns_consts.h"
+
 
 using namespace std;
 
@@ -499,10 +501,10 @@
   theVersion("1.0"),
   theFactory(GENV_ITEMFACTORY)
 {
-  theNamespaceMap["fn"] = "http://www.w3.org/2005/xpath-functions";;
-  theNamespaceMap[""] = "http://www.w3.org/2005/xpath-functions";;
-  theNamespaceMap["xs"] = "http://www.w3.org/2001/XMLSchema";;
-  theNamespaceMap["local"] = "http://www.w3.org/2005/xquery-local-functions";;
+  theNamespaceMap["fn"] = XQUERY_XPATH_FN_NS;
+  theNamespaceMap[""] = XQUERY_XPATH_FN_NS;
+  theNamespaceMap[XML_SCHEMA_PREFIX] = XML_SCHEMA_NS;
+  theNamespaceMap["local"] = XQUERY_LOCAL_FN_NS;
 }
 
 

=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp	2012-04-24 12:39:38 +0000
+++ src/compiler/translator/translator.cpp	2012-04-27 21:00:30 +0000
@@ -83,6 +83,7 @@
 
 #include "zorbatypes/URI.h"
 #include "zorbatypes/numconversions.h"
+#include "zorbamisc/ns_consts.h"
 
 #ifdef ZORBA_WITH_DEBUGGER
 #include "debugger/debugger_commons.h"
@@ -105,7 +106,6 @@
 
 
 #define NODE_SORT_OPT
-#define XS_URI "http://www.w3.org/2001/XMLSchema";
 
 namespace zorba
 {
@@ -2011,7 +2011,7 @@
       theSctx->bind_ns(pfx, targetNS, loc, err::XQST0033);
   }
 
-  zstring xsdTNS = zstring(XS_URI);
+  zstring xsdTNS = zstring(XML_SCHEMA_NS);
   if ( xsdTNS.compare(targetNS)==0 )
   {
     // Xerces doesn't like importing XMLSchema.xsd schema4schema, so we skip it

=== modified file 'src/runtime/strings/strings_impl.cpp'
--- src/runtime/strings/strings_impl.cpp	2012-04-24 12:39:38 +0000
+++ src/runtime/strings/strings_impl.cpp	2012-04-27 21:00:30 +0000
@@ -1840,7 +1840,7 @@
   store::NsBindings   ns_binding;
   zstring baseURI;
   GENV_ITEMFACTORY->createQName(untyped_type_name,
-                                "http://www.w3.org/2001/XMLSchema";, "xs", "untyped");
+                                XML_SCHEMA_NS, XML_SCHEMA_PREFIX, "untyped");
   GENV_ITEMFACTORY->createQName(non_match_element_name,
                                 static_context::W3C_FN_NS, "fn", "non-match");
   GENV_ITEMFACTORY->createElementNode(non_match_elem, parent, non_match_element_name, untyped_type_name, false, false, ns_binding, baseURI);
@@ -1969,7 +1969,7 @@
   store::NsBindings   ns_binding;
   zstring baseURI;
   GENV_ITEMFACTORY->createQName(untyped_type_name,
-                                "http://www.w3.org/2001/XMLSchema";, "xs", "untyped");
+                                XML_SCHEMA_NS, XML_SCHEMA_PREFIX, "untyped");
   GENV_ITEMFACTORY->createQName(match_element_name,
                                 static_context::W3C_FN_NS, "fn", "match");
   store::Item_t match_elem;
@@ -2129,7 +2129,7 @@
     store::NsBindings   ns_binding;
     zstring baseURI;
     GENV_ITEMFACTORY->createQName(untyped_type_name,
-                                  "http://www.w3.org/2001/XMLSchema";, "xs", "untyped");
+                                  XML_SCHEMA_NS, XML_SCHEMA_PREFIX, "untyped");
     GENV_ITEMFACTORY->createQName(result_element_name,
                                   static_context::W3C_FN_NS, "fn", "analyze-string-result");
     GENV_ITEMFACTORY->createElementNode(result, NULL, result_element_name, untyped_type_name, false, false, ns_binding, baseURI);

=== modified file 'src/types/root_typemanager.cpp'
--- src/types/root_typemanager.cpp	2012-04-24 12:39:38 +0000
+++ src/types/root_typemanager.cpp	2012-04-27 21:00:30 +0000
@@ -20,16 +20,18 @@
 #include <zorba/identtypes.h>
 #include <zorba/typeident.h>
 
-#include "zorbatypes/datetime.h"
-#include "zorbatypes/duration.h"
+#include "store/api/item_factory.h"
+#include "store/api/store.h"
 
 #include "system/globalenv.h"
 
 #include "types/root_typemanager.h"
 #include "types/node_test.h"
 
-#include "store/api/item_factory.h"
-#include "store/api/store.h"
+#include "zorbamisc/ns_consts.h"
+
+#include "zorbatypes/datetime.h"
+#include "zorbatypes/duration.h"
 
 
 
@@ -200,14 +202,11 @@
   TypeManagerImpl(NULL),
   m_atomic_qnametype_map(ATOMIC_QNAMETYPE_MAP_SIZE, false)
 {
-#define XS_URI "http://www.w3.org/2001/XMLSchema";
-#define XS_PREFIX "xs"
-
 #define ZXSE_URI "http://www.zorba-xquery.com/zorba/schema-extensions";
 #define ZXSE_PREFIX "zxse"
 
 #define XSQNDECL(var, local)  \
-  GENV.getStore().getItemFactory()->createQName(var, XS_URI, XS_PREFIX, local)
+  GENV.getStore().getItemFactory()->createQName(var, XML_SCHEMA_NS, XML_SCHEMA_PREFIX, local)
 
   XSQNDECL(XS_ANY_ATOMIC_QNAME, "anyAtomicType");
   XSQNDECL(XS_STRING_QNAME, "string");

=== modified file 'src/types/schema/validate.cpp'
--- src/types/schema/validate.cpp	2012-04-26 20:54:34 +0000
+++ src/types/schema/validate.cpp	2012-04-27 21:00:30 +0000
@@ -473,6 +473,10 @@
     const QueryLoc& loc)
 {
   store::Item_t child;
+  bool inTextContent = false;
+  bool hasChildrenElements = false;
+  zstring textNodeValue = zstring("");
+  std::vector<store::Item*> textContent;
 
   while ( children->next(child) )
   {
@@ -485,6 +489,15 @@
       switch ( child->getNodeKind() )
       {
       case store::StoreConsts::elementNode:
+        if (inTextContent)
+        {
+          hasChildrenElements = true;
+          processTextContent(sctx, typeManager, schemaValidator, parent,
+                             hasChildrenElements, textNodeValue, textContent, loc);
+          textNodeValue = "";
+          inTextContent = false;
+          textContent.clear();
+        }
         processElement(sctx, typeManager, schemaValidator, parent, child, loc);
         break;
 
@@ -498,100 +511,104 @@
 
       case store::StoreConsts::textNode:
       {
+        // keep on adding the text
+        inTextContent = true;
         zstring childStringValue;
         child->getStringValue2(childStringValue);
-        schemaValidator.text(childStringValue);
-
-        store::Item_t typeQName = schemaValidator.getTypeQName();
-
-        store::Item_t validatedTextNode;
-
-        TypeIdentifier_t typeIdentifier =
-          TypeIdentifier::createNamedType(
-            Unmarshaller::newString( typeQName->getNamespace() ),
-            Unmarshaller::newString( typeQName->getLocalName() )
-          );
-
-        //xqType is NULL, create_type can't find it
-        xqtref_t xqType = typeManager->create_type(*typeIdentifier);
-
-#if 0   // enable this to debug children values
-        if ( typeQName.getp() && xqType.getp() )
-        {
-          cout << "     - text: '" << childStringValue << "' T: " <<
-            typeQName->getLocalName() << "\n"; cout.flush();
-          cout << "        xqT: " << xqType->toString() << "  content_kind: " <<
-            (long)xqType->content_kind() << " tKind:" << (long)xqType->type_kind() << " \n";
-          cout.flush();
-        }
-        else
-          cout << "     - text2: '" << childStringValue << "' tQN: " <<
-            (typeQName ? typeQName->getStringValue() : "NULL") <<
-            " xqT:" << ( xqType.getp() ? xqType.getp()->toString() : "NULL" )
-               << "\n"; cout.flush();
-#endif
-
-        if ( xqType != NULL &&
-             xqType->content_kind() == XQType::SIMPLE_CONTENT_KIND )
-        {
-          store::NsBindings nsBindings;
-          parent->getNamespaceBindings(nsBindings);
-          std::vector<store::Item_t> typedValues;
-          
-          processTextValue(sctx,
-                           typeManager,
-                           nsBindings,
-                           typeQName,
-                           childStringValue,
-                           typedValues,
-                           loc);
-
-          if ( typedValues.size() == 1 ) // hack around serialization bug
-            GENV_ITEMFACTORY->createTextNode(validatedTextNode, parent,
-                                             typedValues[0]);
-          else
-            GENV_ITEMFACTORY->createTextNode(validatedTextNode, parent,
-                                             typedValues);
-        }
-        else if ( xqType!=NULL &&
-                  (xqType->content_kind()==XQType::ELEMENT_ONLY_CONTENT_KIND ||
-                   xqType->content_kind()==XQType::EMPTY_CONTENT_KIND ))
-        {
-          // if text not valid the schemaValidator should have already
-          // thrown an error
-
-          // XQ XP Datamodel Spec: http://www.w3.org/TR/xpath-datamodel/
-          // section 6.7.4 Construction from a PSVI
-          if ( !utf8::is_whitespace(childStringValue) )
-          {
-            zstring empty;
-            GENV_ITEMFACTORY->createTextNode(validatedTextNode,
-                                             parent,
-                                             empty);
-            //cout << "      -- create empty text : ElementOnly || Empty" << endl;
-          }
-          else 
-          {
-            //cout << "      -- skip this text: (ElemOnly || Empty) && whitespace" << endl;
-          }
-        }
-        else
-          //if ( xqType!=NULL &&
-          //     xqType->content_kind()==XQType::MIXED_CONTENT_KIND )
-        {
-          // if text not valid the schemaValidator should have already
-          // thrown an error
-          GENV_ITEMFACTORY->createTextNode(validatedTextNode,
-                                           parent,
-                                           childStringValue);
-          //cout << "      -- create empty text: Mixed" << endl;
-        }
+        textNodeValue += childStringValue;
+        textContent.push_back(child.getp());
       }
       break;
 
       case store::StoreConsts::piNode:
       {
         //cout << "     - pi: " << child->getStringValue() << "\n";cout.flush();
+        if ( inTextContent )
+        {
+          textContent.push_back(child.getp());
+        }
+        else
+        {
+          store::Item_t piNode;
+          zstring piTarget =child->getTarget();
+          zstring childStringValue;
+          child->getStringValue2(childStringValue);
+          zstring childBaseUri;
+          child->getBaseURI(childBaseUri);
+
+          GENV_ITEMFACTORY->createPiNode(piNode, parent, piTarget,
+                                         childStringValue, childBaseUri);
+        }
+      }
+      break;
+
+      case store::StoreConsts::commentNode:
+      {
+        //cout << "     - comment: " << child->getStringValue() <<
+        //        "\n"; cout.flush();
+        if ( inTextContent )
+        {
+          textContent.push_back(child.getp());
+        }
+        else
+        {
+          store::Item_t commentNode;
+          zstring childStringValue;
+          child->getStringValue2(childStringValue);
+          GENV_ITEMFACTORY->createCommentNode(commentNode, parent, childStringValue);
+        }
+      }
+      break;
+
+      case store::StoreConsts::anyNode:
+        //cout << "     - any: " << child->getStringValue() <<"\n";cout.flush();
+        ZORBA_ASSERT(false);
+        break;
+
+      default:
+        ZORBA_ASSERT(false);
+      }
+    }
+  }
+
+  if (inTextContent)
+  {
+    processTextContent(sctx, typeManager, schemaValidator, parent,
+                       hasChildrenElements, textNodeValue, textContent, loc);
+    textNodeValue = "";
+    inTextContent = false;
+  }
+}
+
+void Validator::processTextContent(
+    const static_context* sctx,
+    TypeManager* typeManager,
+    EventSchemaValidator& schemaValidator,
+    store::Item* parent,
+    bool hasChildrenElements,
+    zstring& textNodeValue,
+    std::vector<store::Item*>& textContent,
+    const QueryLoc& loc)
+{
+  for ( std::size_t i = 0; i<textContent.size(); i++)
+  {
+    store::Item* child = textContent[i];
+    switch ( child->getNodeKind() )
+    {
+    case store::StoreConsts::textNode:
+    {
+      if (hasChildrenElements)
+      {
+        zstring childStringValue;
+        child->getStringValue2(childStringValue);
+        finishTextNode(sctx, typeManager, schemaValidator, parent,
+                        childStringValue, loc);
+      }
+    }
+    break;
+
+    case store::StoreConsts::piNode:
+    {
         store::Item_t piNode;
         zstring piTarget =child->getTarget();
         zstring childStringValue;
@@ -601,31 +618,134 @@
 
         GENV_ITEMFACTORY->createPiNode(piNode, parent, piTarget,
                                        childStringValue, childBaseUri);
-      }
-      break;
+    }
+    break;
 
-      case store::StoreConsts::commentNode:
-      {
-        //cout << "     - comment: " << child->getStringValue() <<
-        //"\n"; cout.flush();
+    case store::StoreConsts::commentNode:
+    {
         store::Item_t commentNode;
         zstring childStringValue;
         child->getStringValue2(childStringValue);
         GENV_ITEMFACTORY->createCommentNode(commentNode, parent, childStringValue);
-      }
+    }
+    break;
+
+    case store::StoreConsts::elementNode:
+    case store::StoreConsts::attributeNode:
+    case store::StoreConsts::documentNode:
+    case store::StoreConsts::anyNode:
+      //cout << "     - any: " << child->getStringValue() <<"\n";cout.flush();
+      ZORBA_ASSERT(false);
       break;
 
-      case store::StoreConsts::anyNode:
-        //cout << "     - any: " << child->getStringValue() <<"\n";cout.flush();
-        ZORBA_ASSERT(false);
-        break;
-
-      default:
-        ZORBA_ASSERT(false);
-      }
-    }
-  }
-}
+    default:
+      ZORBA_ASSERT(false);
+    }
+  }
+
+  if (!hasChildrenElements)
+  {
+    finishTextNode(sctx, typeManager, schemaValidator, parent,
+                    textNodeValue, loc);
+  }
+}
+
+void Validator::finishTextNode(
+    const static_context* sctx,
+    TypeManager* typeManager,
+    EventSchemaValidator& schemaValidator,
+    store::Item* parent,
+    zstring& textNodeValue,
+    const QueryLoc& loc)
+{
+  schemaValidator.text(textNodeValue);
+
+  store::Item_t typeQName = schemaValidator.getTypeQName();
+
+  store::Item_t validatedTextNode;
+
+  TypeIdentifier_t typeIdentifier =
+    TypeIdentifier::createNamedType(
+      Unmarshaller::newString( typeQName->getNamespace() ),
+      Unmarshaller::newString( typeQName->getLocalName() )
+    );
+
+  //xqType is NULL, create_type can't find it
+  xqtref_t xqType = typeManager->create_type(*typeIdentifier);
+
+#if 0   // enable this to debug children values
+  if ( typeQName.getp() && xqType.getp() )
+  {
+    cout << "     - text: '" << textNodeValue << "' T: " <<
+      typeQName->getLocalName() << "\n"; cout.flush();
+    cout << "        xqT: " << xqType->toString() << "  content_kind: " <<
+      (long)xqType->content_kind() << " tKind:" << (long)xqType->type_kind() << " \n";
+    cout.flush();
+  }
+  else
+    cout << "     - text2: '" << textNodeValue << "' tQN: " <<
+      (typeQName ? typeQName->getStringValue() : "NULL") <<
+      " xqT:" << ( xqType.getp() ? xqType.getp()->toString() : "NULL" )
+         << "\n"; cout.flush();
+#endif
+
+  if ( xqType != NULL &&
+       xqType->content_kind() == XQType::SIMPLE_CONTENT_KIND )
+  {
+    store::NsBindings nsBindings;
+    parent->getNamespaceBindings(nsBindings);
+    std::vector<store::Item_t> typedValues;
+
+    processTextValue(sctx,
+                     typeManager,
+                     nsBindings,
+                     typeQName,
+                     textNodeValue,
+                     typedValues,
+                     loc);
+
+    if ( typedValues.size() == 1 ) // hack around serialization bug
+      GENV_ITEMFACTORY->createTextNode(validatedTextNode, parent,
+                                       typedValues[0]);
+    else
+      GENV_ITEMFACTORY->createTextNode(validatedTextNode, parent,
+                                       typedValues);
+  }
+  else if ( xqType!=NULL &&
+            (xqType->content_kind()==XQType::ELEMENT_ONLY_CONTENT_KIND ||
+             xqType->content_kind()==XQType::EMPTY_CONTENT_KIND ))
+  {
+    // if text not valid the schemaValidator should have already
+    // thrown an error
+
+    // XQ XP Datamodel Spec: http://www.w3.org/TR/xpath-datamodel/
+    // section 6.7.4 Construction from a PSVI
+    if ( !utf8::is_whitespace(textNodeValue) )
+    {
+      zstring empty;
+      GENV_ITEMFACTORY->createTextNode(validatedTextNode,
+                                       parent,
+                                       empty);
+      //cout << "      -- create empty text : ElementOnly || Empty" << endl;
+    }
+    else
+    {
+      //cout << "      -- skip this text: (ElemOnly || Empty) && whitespace" << endl;
+    }
+  }
+  else
+    //if ( xqType!=NULL &&
+    //     xqType->content_kind()==XQType::MIXED_CONTENT_KIND )
+  {
+    // if text not valid the schemaValidator should have already
+    // thrown an error
+    GENV_ITEMFACTORY->createTextNode(validatedTextNode,
+                                     parent,
+                                     textNodeValue);
+    //cout << "      -- create empty text: Mixed" << endl;
+  }
+}
+
 
 
 void Validator::processNamespaces (

=== modified file 'src/types/schema/validate.h'
--- src/types/schema/validate.h	2012-04-24 12:39:38 +0000
+++ src/types/schema/validate.h	2012-04-27 21:00:30 +0000
@@ -20,6 +20,8 @@
 #ifndef ZORBA_NO_XMLSCHEMA
 
 
+#include <vector>
+
 #include "common/shared_types.h"
 
 #include "compiler/parser/parse_constants.h"
@@ -117,6 +119,24 @@
         store::Iterator_t children,
         const QueryLoc& loc);
 
+  static void processTextContent(
+        const static_context* sctx,
+        TypeManager* typeManager,
+        EventSchemaValidator& schemaValidator,
+        store::Item* parent,
+        bool hasChildrenElements,
+        zstring& textNodeValue,
+        std::vector<store::Item*>& textContent,
+        const QueryLoc& loc);
+
+  static void finishTextNode(
+        const static_context* sctx,
+        TypeManager* typeManager,
+        EventSchemaValidator& schemaValidator,
+        store::Item* parent,
+        zstring& textNodeValue,
+        const QueryLoc& loc);
+
   static store::Item_t processElement(
         const static_context* sctx,
         TypeManager* typeManager, 

=== modified file 'src/util/http_util.cpp'
--- src/util/http_util.cpp	2012-04-24 12:39:38 +0000
+++ src/util/http_util.cpp	2012-04-27 21:00:30 +0000
@@ -23,6 +23,7 @@
 #include <api/unmarshaller.h>
 #include "http_util.h"
 #include "error_util.h"
+#include "zorbamisc/ns_consts.h"
 
 
 namespace zorba {
@@ -51,10 +52,10 @@
     Item lNodeName = lFactory->createQName("http://expath.org/ns/http-client";, "http", "request");
     Item lEmptyItem;
     NsBindings nsPairs;
-    nsPairs.push_back(std::make_pair(String("xs"), String("http://www.w3.org/2001/XMLSchema";)));
+    nsPairs.push_back(std::make_pair(String(XML_SCHEMA_PREFIX), String(XML_SCHEMA_NS)));
     Item lRequestElement = lFactory->createElementNode(lEmptyItem, lNodeName,
-                                                       lFactory->createQName("http://www.w3.org/2001/XMLSchema";,
-                                                                             "xs", "untyped"),
+                                                       lFactory->createQName(XML_SCHEMA_NS,
+                                                                             XML_SCHEMA_PREFIX, "untyped"),
                                                        true, false, nsPairs);
     lFactory->createAttributeNode(lRequestElement, lFactory->createQName("", "method"), Item(), lFactory->createString("GET"));
     lFactory->createAttributeNode(lRequestElement, lFactory->createQName("", "href"), Item(), lFactory->createString(theUri.c_str()));

=== modified file 'src/zorbamisc/ns_consts.h'
--- src/zorbamisc/ns_consts.h	2012-04-24 12:39:38 +0000
+++ src/zorbamisc/ns_consts.h	2012-04-27 21:00:30 +0000
@@ -31,9 +31,11 @@
 
 #define XML_NS                  W3C_NS "XML/1998/namespace"
 #define XML_SCHEMA_NS           W3C_NS "2001/XMLSchema"
+#define XML_SCHEMA_PREFIX       "xs"
 
 #define XQUERY_ERR_NS           W3C_NS "2005/xqt-errors"                //not predeclared in XQuery 3.0
 #define XQUERY_LOCAL_FN_NS      W3C_NS "2005/xquery-local-functions"
+#define XQUERY_XPATH_FN_NS      W3C_NS "2005/xpath-functions"
 #define XQUERY_MATH_FN_NS       W3C_NS "2005/xpath-functions/math"      //not predeclared in XQuery 3.0
 
 #define XSI_NS                  W3C_NS "2001/XMLSchema-instance"

=== modified file 'src/zorbaserialization/serialize_zorba_types.cpp'
--- src/zorbaserialization/serialize_zorba_types.cpp	2012-04-24 12:39:38 +0000
+++ src/zorbaserialization/serialize_zorba_types.cpp	2012-04-27 21:00:30 +0000
@@ -35,6 +35,8 @@
 #include "store/api/item_factory.h"
 //#include "store/api/tuples.h"
 
+#include "zorbamisc/ns_consts.h"
+
 #include "zorbatypes/datetime.h"
 #include "zorbatypes/collation_manager.h"
 #include "zorbatypes/integer.h"
@@ -455,7 +457,7 @@
         type = obj->getType();
         name_of_type = type->getLocalName();
         const zstring& ns =type->getNamespace();
-        is_qname = (name_of_type == "QName" && ns == "http://www.w3.org/2001/XMLSchema";);
+        is_qname = (name_of_type == "QName" && ns == XML_SCHEMA_NS);
       }
 
       ar & is_qname;
@@ -484,7 +486,7 @@
       }
       else if (!ar.is_serializing_out())
       {
-        GENV_ITEMFACTORY->createQName(type, "http://www.w3.org/2001/XMLSchema";, "xs", "QName");
+        GENV_ITEMFACTORY->createQName(type, XML_SCHEMA_NS, XML_SCHEMA_PREFIX, "QName");
       }
 
       if(!ar.is_serializing_out())
@@ -982,7 +984,7 @@
       //  store::simplestore::ElementNode *elem_node = dynamic_cast<store::simplestore::ElementNode*>(obj);
       //  haveTypedValue = elem_node->haveTypedValue();
       //  haveEmptyValue = elem_node->haveEmptyValue();
-        if(!ZSTREQ(name_of_type->getNamespace(), "http://www.w3.org/2001/XMLSchema";) ||
+        if(!ZSTREQ(name_of_type->getNamespace(), XML_SCHEMA_NS) ||
            !ZSTREQ(name_of_type->getLocalName(), "untyped"))
           haveTypedValue = true;
       }

-- 
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