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

Commit message:
some error cleanup in translator.cpp

Requested reviews:
  Markos Zaharioudakis (markos-za)

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

some error cleanup in translator.cpp
-- 
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/170800
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'include/zorba/pregenerated/diagnostic_list.h'
--- include/zorba/pregenerated/diagnostic_list.h	2013-06-15 02:57:08 +0000
+++ include/zorba/pregenerated/diagnostic_list.h	2013-06-21 12:18:31 +0000
@@ -168,6 +168,8 @@
 
 extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0120;
 
+extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0122;
+
 extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0123;
 
 extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0126;

=== modified file 'modules/w3c/pregenerated/xqt-errors.xq'
--- modules/w3c/pregenerated/xqt-errors.xq	2013-06-19 14:19:40 +0000
+++ modules/w3c/pregenerated/xqt-errors.xq	2013-06-21 12:18:31 +0000
@@ -720,6 +720,15 @@
 
 (:~
  :
+ : It is a static error if the name of a feature in require-feature or
+ : prohibit-feature is not in the lexical space of QName.
+ : 
+ : @see http://www.w3.org/2005/xqt-errors
+:)
+declare variable $err:XQST0122 as xs:QName := fn:QName($err:NS, "err:XQST0122");
+
+(:~
+ :
  : It is a static error if the name of a feature in require-feature is not
  : recognized by the implementation.
  : 

=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp	2013-06-20 09:52:25 +0000
+++ src/compiler/translator/translator.cpp	2013-06-21 12:18:31 +0000
@@ -1182,6 +1182,36 @@
 
 
 /*******************************************************************************
+
+********************************************************************************/
+store::Item_t parse_and_expand_qname(
+    const zstring& value,
+    const char* default_ns,
+    const QueryLoc& loc) const
+{
+  zstring prefix;
+  zstring localName;
+
+  zstring::size_type n = value.rfind(':');
+
+  if (n == zstring::npos)
+  {
+    localName = value;
+  }
+  else
+  {
+    prefix = value.substr( 0, n );
+    localName = value.substr( n+1 );
+  }
+
+  store::Item_t lQName;
+  theSctx->expand_qname(lQName, default_ns, prefix, localName, loc );
+
+  return lQName;
+}
+
+
+/*******************************************************************************
   Create a var_expr for a variable with a given qname item, kind, and type
 ********************************************************************************/
 var_expr* create_var(
@@ -1306,7 +1336,7 @@
 
 
 /*******************************************************************************
-  Lookup a context variable, i.e., the var (if any) representing the context
+  Lookup a focus variable, i.e., the var (if any) representing the context
   item, or the context position, or the context size. The variable is identified
   by its qname.
 
@@ -1321,17 +1351,7 @@
 
   if (var == NULL)
   {
-    if (theIsInIndexDomain)
-    {
-      RAISE_ERROR(zerr::ZDST0032_INDEX_REFERENCES_CTX_ITEM, loc,
-      ERROR_PARAMS(theIndexDecl->getName()->getStringValue()));
-    }
-    else
-    {
-      zstring varName = static_context::var_name(qname);
-      RAISE_ERROR(err::XPDY0002, loc, 
-      ERROR_PARAMS(ZED(XPDY0002_ContextUndeclared_2), varName));
-    }
+    ZORBA_ASSERT(false);
   }
 
   return var->getVar();
@@ -1459,36 +1479,6 @@
   csize n = foExpr->num_args();
 
   const function* func = foExpr->get_func();
-  FunctionConsts::FunctionKind fkind = func->getKind();
-
-  if (fkind == FunctionConsts::FN_ZORBA_XQDDF_PROBE_INDEX_RANGE_VALUE_N ||
-      fkind == FunctionConsts::FN_ZORBA_XQDDF_PROBE_INDEX_RANGE_VALUE_SKIP_N)
-  {
-    csize nStarterParams =
-    (fkind == FunctionConsts::FN_ZORBA_XQDDF_PROBE_INDEX_RANGE_VALUE_N  ? 1 : 2);
-
-    if  (n < (6 + nStarterParams) || (n - nStarterParams) % 6 != 0)
-    {
-      const store::Item* qname = NULL;
-
-      if (n > 0)
-        qname = foExpr->get_arg(0)->getQName();
-
-      zstring lMsgPart;
-      ztd::to_string(nStarterParams, &lMsgPart);
-      lMsgPart += " + multiple of 6";
-      if (qname != NULL)
-      {
-        RAISE_ERROR(zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS, loc,
-        ERROR_PARAMS(qname->getStringValue(), "index", n, lMsgPart));
-      }
-      else
-      {
-        RAISE_ERROR(zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS, loc,
-        ERROR_PARAMS("anonymous", "index", n, lMsgPart));
-      }
-    }
-  }
 
   for (csize i = 0; i < n; ++i)
   {
@@ -2220,8 +2210,7 @@
       theSctx->bind_ns(pfx, targetNS, loc);
   }
 
-  zstring xsdTNS = zstring(XML_SCHEMA_NS);
-  if (xsdTNS.compare(targetNS) == 0)
+  if (targetNS == XML_SCHEMA_NS)
   {
     // Xerces doesn't like importing XMLSchema.xsd schema4schema, so we skip it
     // see Xerces-C++ bug: https://issues.apache.org/jira/browse/XERCESC-1980
@@ -2231,7 +2220,6 @@
   store::Item_t targetNSItem = NULL;
   zstring tmp = targetNS;
   ITEM_FACTORY->createAnyURI(targetNSItem, tmp);
-  ZORBA_ASSERT(targetNSItem != NULL);
 
   // Form up a vector of candidate URIs: any location hints, followed
   // by the imported URI itself.
@@ -2239,7 +2227,7 @@
 
   if (atlist != NULL)
   {
-    for (ulong i = 0; i < atlist->size(); ++i)
+    for (csize i = 0; i < atlist->size(); ++i)
     {
       // If current uri is relative, turn it to an absolute one, using the
       // base uri from the sctx.
@@ -2255,12 +2243,14 @@
     std::auto_ptr<internal::Resource> lSchema;
     internal::StreamResource* lStream = NULL;
     zstring lErrorMessage;
+
     for (std::vector<zstring>::iterator lIter = lCandidates.begin();
          lIter != lCandidates.end();
          ++lIter)
     {
       lSchema = theSctx->resolve_uri(*lIter, internal::EntityData::SCHEMA,
                                      lErrorMessage);
+
       lStream = dynamic_cast<internal::StreamResource*>(lSchema.get());
       if (lStream != NULL)
       {
@@ -2271,7 +2261,7 @@
     if (lStream == NULL)
     {
       RAISE_ERROR(err::XQST0059, loc,
-      ERROR_PARAMS(ZED(XQST0059_SpecificationMessage), lNsURI, "", lErrorMessage));
+      ERROR_PARAMS(ZED(XQST0059_UnknownSchema_23o), lNsURI, lErrorMessage));
     }
 
     // If we got this far, we have a valid StreamResource.
@@ -2339,7 +2329,8 @@
       // but since the chances are small that more than 1 restart is needed,
       // it probably compensates to the performance degradation by allocating
       // another vector
-      if (lIter->first == lPrefixStr) {
+      if (lIter->first == lPrefixStr)
+      {
         lPrefixStr += "_";
         lIter = lNsBindings.begin();
       }
@@ -2371,13 +2362,11 @@
   import_schema_auto_prefix(lLoc, aSchemaURI.c_str(), NULL);
 
   store::Item_t qname;
-  return theExprManager->create_validate_expr(theRootSctx,
-                                              theUDF,
-                                              lLoc,
-                                              ParseConstants::val_strict,
-                                              qname,
-                                              aExpr,
-                                              theSctx->get_typemanager());
+  return CREATE(validate)(theRootSctx, theUDF, lLoc,
+                          ParseConstants::val_strict,
+                          qname,
+                          aExpr,
+                          theSctx->get_typemanager());
 }
 
 
@@ -2486,13 +2475,16 @@
 {
   TRACE_VISIT();
   
-  // The CompilerCB->theCommonLanguageEnabled needs to be checked here as well because the 
-  // options declarations have not been translated yet, so the static context feature might not 
-  // be set.
-  if (theSctx->is_feature_set(feature::common_language) || theCCB->theCommonLanguageEnabled)
+  // The CompilerCB->theCommonLanguageEnabled needs to be checked here as well
+  // because the options declarations have not been translated yet, so the static
+  // context feature might not be set.
+  if (theSctx->is_feature_set(feature::common_language) ||
+      theCCB->theCommonLanguageEnabled)
   {    
     theCCB->theXQueryDiagnostics->add_warning(
-        NEW_XQUERY_WARNING(zwarn::ZWST0009_COMMON_LANGUAGE_WARNING, WARN_PARAMS(ZED(ZWST0009_VERSION_DECL)), WARN_LOC(loc)));
+    NEW_XQUERY_WARNING(zwarn::ZWST0009_COMMON_LANGUAGE_WARNING,
+                       WARN_PARAMS(ZED(ZWST0009_VERSION_DECL)),
+                       WARN_LOC(loc)));
   }
 
   if (v.get_language_kind() == VersionDecl::jsoniq)
@@ -2551,7 +2543,7 @@
   if (version == StaticContextConsts::xquery_version_unknown)
   {
     RAISE_ERROR(err::XQST0031, loc,
-    ERROR_PARAMS(versionStr, ZED(BadXQueryVersion)));
+    ERROR_PARAMS(ZED(XQST0031_BadXQueryVersion_2), versionStr));
   }
 
   theSctx->set_xquery_version(version);
@@ -3366,7 +3358,9 @@
     theRootSctx->get_candidate_uris(targetNS,
                                     internal::EntityData::MODULE,
                                     candidateURIs);
+
     theRootSctx->add_imported_builtin_module(targetNS);
+
 #ifdef NDEBUG
     // We cannot skip the math or the sctx introspection modules because they
     // contain some non-external functions as well.
@@ -3472,8 +3466,10 @@
     if (theModulesInfo->mod_ns_map.get(compURI, importedNS))
     {
       if (importedNS != targetNS)
+      {
         RAISE_ERROR(err::XQST0059, loc,
-        ERROR_PARAMS(ZED(XQST0059_SpecificationMessage), targetNS, compURI));
+        ERROR_PARAMS(ZED(XQST0059_WrongModule_234), targetNS, compURI, importedNS));
+      }
 
       bool found = theModulesInfo->mod_sctx_map.get(compURI, importedSctx);
       ZORBA_ASSERT(found);
@@ -3489,7 +3485,7 @@
       // Resolve the URI. Again, note the use of versioned_uri() here,
       // rather than using compURI directly, because we want the version
       // fragment to be passed to the mappers.
-      zstring lErrorMessage;
+      zstring errorMsg;
       std::auto_ptr<internal::Resource> resource;
       internal::StreamResource* streamResource = NULL;
 
@@ -3497,7 +3493,7 @@
       {
         resource = theSctx->resolve_uri(compModVer.versioned_uri(),
                                         internal::EntityData::MODULE,
-                                        lErrorMessage);
+                                        errorMsg);
 
         streamResource = dynamic_cast<internal::StreamResource*>(resource.get());
       }
@@ -3515,8 +3511,7 @@
       else
       {
         RAISE_ERROR(err::XQST0059, loc,
-        ERROR_PARAMS(ZED(XQST0059_SpecificationMessage),
-                     targetNS, compURI, lErrorMessage));
+        ERROR_PARAMS(ZED(XQST0059_UnknownModule_234o), targetNS, compURI, errorMsg));
       }
 
       // Get the parent of the query root sctx. This is the user-specified sctx
@@ -3573,7 +3568,7 @@
       if (mod_ast == NULL)
       {
         RAISE_ERROR(err::XQST0059, loc,
-        ERROR_PARAMS(ZED(XQST0059_SpecificationMessage), targetNS, compURI));
+        ERROR_PARAMS(ZED(XQST0059_BadModule_23), targetNS, compURI));
       }
 
       importedNS = mod_ast->get_decl()->get_target_namespace().str();
@@ -3584,7 +3579,7 @@
       if (importedNS != targetNS)
       {
         RAISE_ERROR(err::XQST0059, loc,
-        ERROR_PARAMS(ZED(XQST0059_SpecificationMessage), targetNS, compURI));
+        ERROR_PARAMS(ZED(XQST0059_WrongModule_234), targetNS, compURI, importedNS));
       }
 
       // translate the imported module
@@ -3731,6 +3726,8 @@
 
   TypeManager* tm = CTX_TM;
 
+  bool haveXQueryOptions = false;
+
   // Translation of the VFO list must be done in two passes because of mutually
   // recursive functions and also because the defining expr of a declared var
   // may reference a function that is declared after the var. So, here's the
@@ -3753,17 +3750,16 @@
     {
       store::Item_t qnameItem;
       zstring value = opt_decl->get_val().str();
-
       rchandle<QName> lQName = opt_decl->get_qname();
+
       if (theSctx->xquery_version() >= StaticContextConsts::xquery_version_3_0 &&
           lQName->get_namespace().empty() && lQName->get_prefix().empty())
       {
-        theSctx->expand_qname(
-           qnameItem,
-           static_context::XQUERY_NS,
-           "",
-           lQName->get_localname(),
-           lQName->get_location());
+        theSctx->expand_qname(qnameItem,
+                              static_context::XQUERY_NS,
+                              "",
+                              lQName->get_localname(),
+                              lQName->get_location());
       }
       else
       {
@@ -3775,12 +3771,17 @@
         }
       }
 
-      if (qnameItem->getNamespace() == static_context::XQUERY_NS &&
-          qnameItem->getLocalName() != "require-feature" &&
-          qnameItem->getLocalName() != "prohibit-feature")
+      if (qnameItem->getNamespace() == static_context::XQUERY_NS)
       {
-        RAISE_ERROR(err::XQST0123, loc,
-        ERROR_PARAMS(ZED(UnrecognizedXQueryOption), qnameItem->getLocalName()));
+        haveXQueryOptions = true;
+
+        if (qnameItem->getLocalName() != "require-feature" &&
+            qnameItem->getLocalName() != "prohibit-feature")
+        {
+          RAISE_ERROR(err::XQST0123, loc,
+          ERROR_PARAMS(ZED(XQST0123_UnrecognizedXQueryOption_2),
+                       qnameItem->getLocalName()));
+        }
       }
 
       if (qnameItem->getNamespace() == static_context::ZORBA_OPTION_FEATURE_NS &&
@@ -3933,7 +3934,7 @@
         ns == static_context::XQUERY_MATH_FN_NS)
     {
       RAISE_ERROR(err::XQST0045, func_decl->get_location(),
-      ERROR_PARAMS(qnameItem->getLocalName(), ZED(FUNCTION), ns));
+      ERROR_PARAMS(ZED(XQST0045_FUNCTION_23), qnameItem->getStringValue(), ns));
     }
 
     if (! theModuleNamespace.empty() && ns != theModuleNamespace)
@@ -4101,7 +4102,8 @@
     bind_fn(f, numParams, loc);
   }
 
-  check_xquery_feature_options(loc);
+  if (haveXQueryOptions)
+    check_xquery_feature_options(loc);
 }
 
 
@@ -4184,44 +4186,49 @@
 
 
 void parse_feature_list(
-    const zstring& anOptionName,
+    const zstring& optionQName,
     std::map<zstring, bool>* aFeatures,
     bool aRequired,
     const QueryLoc& loc)
 {
   // Looking up feature options.
   zstring lFeatureList;
-  store::Item_t lFeatureQName = parse_and_expand_qname(
-      anOptionName,
-      static_context::XQUERY_NS,
-      loc);
-  theSctx->lookup_option(lFeatureQName, lFeatureList);
+
+  store::Item_t optionQNameItem =
+  parse_and_expand_qname(optionQName, static_context::XQUERY_NS, loc);
+
+  theSctx->lookup_option(optionQNameItem, lFeatureList);
   
   if (aFeatures == NULL || lFeatureList.empty())
   {
     return;
   }
+
   size_t lPositionLeft = 0;
   size_t lPositionRight = lFeatureList.find(" ", lPositionLeft);
   bool lLastTime = lPositionRight == zstring::npos;
+
   while (lPositionRight != zstring::npos || lLastTime)
   {
-    zstring lFeature = lFeatureList.substr(
-        lPositionLeft,
-        lPositionRight - lPositionLeft);
-    store::Item_t lFeatureQName = parse_and_expand_qname(
-        lFeature,
-        static_context::XQUERY_NS,
-        loc);
+    zstring lFeature =
+    lFeatureList.substr(lPositionLeft, lPositionRight - lPositionLeft);
+
+    store::Item_t lFeatureQName = 
+    parse_and_expand_qname(lFeature, static_context::XQUERY_NS, loc);
+
     // Requiring a non-recognized feature.
     if (aRequired && lFeatureQName->getNamespace() != static_context::XQUERY_NS)
     {
-      RAISE_ERROR(err::XQST0123, loc, ERROR_PARAMS(lFeature));
+      RAISE_ERROR(err::XQST0123, loc,
+      ERROR_PARAMS(ZED(XQST0123_UnrecognizedRequiredFeature_2), lFeature));
     }
+
     zstring lFeatureName = lFeatureQName->getLocalName();
+
     if (aRequired && !is_recognized_feature(lFeatureName))
     {
-      RAISE_ERROR(err::XQST0123, loc, ERROR_PARAMS(lFeature));
+      RAISE_ERROR(err::XQST0123, loc,
+      ERROR_PARAMS(ZED(XQST0123_UnrecognizedRequiredFeature_2), lFeature));
     }
 
     // Only adding to the feature matrix if recognized.
@@ -4249,32 +4256,6 @@
 }
 
 
-store::Item_t parse_and_expand_qname(
-    const zstring& value,
-    const char* default_ns,
-    const QueryLoc& loc) const
-{
-  zstring lPrefix;
-  zstring lLocalName;
-
-  zstring::size_type n = value.rfind(':');
-
-  if ( n == zstring::npos )
-  {
-    lLocalName = value;
-  }
-  else
-  {
-    lPrefix = value.substr( 0, n );
-    lLocalName = value.substr( n+1 );
-  }
-  store::Item_t lQName;
-  theSctx->expand_qname( lQName, default_ns, lPrefix, lLocalName, loc );
-
-  return lQName;
-}
-
-
 bool is_recognized_feature(const zstring& aFeatureName)
 {
   return aFeatureName == "static-typing" ||
@@ -4315,6 +4296,32 @@
 
 
 /*******************************************************************************
+  OptionDecl ::= DECLARE_OPTION  QNAME  STRING_LITERAL
+********************************************************************************/
+void* begin_visit(const OptionDecl& v)
+{
+  TRACE_VISIT();
+
+  // Actual binding of options was already done at VFO_DeclList time; here we
+  // take actions based on certain specific options.
+
+  // TODO probably we should have some kind of option-callback mechanism,
+  // rather than processing all built-in Zorba options here
+  //store::Item_t qnameItem;
+  //zstring value = v.get_val().str();
+
+  //expand_no_default_qname(qnameItem, v.get_qname(), loc);
+
+  return no_state;
+}
+
+void end_visit(const OptionDecl& v, void* /*visit_state*/)
+{
+  TRACE_VISIT_OUT();
+}
+
+
+/*******************************************************************************
 
   AnnotatedDecl ::= "declare" Annotation* (VarDecl | FunctionDecl)
 
@@ -4864,7 +4871,9 @@
     if (AnnotationInternal::lookup(expandedQName) == AnnotationInternal::zann_end)
     {
       RAISE_ERROR(err::XQST0045, loc,
-      ERROR_PARAMS(expandedQName->getLocalName(), ZED(ANNOTATION), annotNS));
+      ERROR_PARAMS(ZED(XQST0045_ANNOTATION_23),
+                   expandedQName->getStringValue(),
+                   annotNS));
     }
 
     //recognised = true;
@@ -4903,32 +4912,6 @@
 
 
 /*******************************************************************************
-  OptionDecl ::= DECLARE_OPTION  QNAME  STRING_LITERAL
-********************************************************************************/
-void* begin_visit(const OptionDecl& v)
-{
-  TRACE_VISIT();
-
-  // Actual binding of options was already done at VFO_DeclList time; here we
-  // take actions based on certain specific options.
-
-  // TODO probably we should have some kind of option-callback mechanism,
-  // rather than processing all built-in Zorba options here
-  //store::Item_t qnameItem;
-  //zstring value = v.get_val().str();
-
-  //expand_no_default_qname(qnameItem, v.get_qname(), loc);
-
-  return no_state;
-}
-
-void end_visit(const OptionDecl& v, void* /*visit_state*/)
-{
-  TRACE_VISIT_OUT();
-}
-
-
-/*******************************************************************************
   [*] CollectionDecl ::= "declare" Annotation* "collection" QName
                          ("as" CollectionTypeDecl)?
 

=== modified file 'src/context/static_context.cpp'
--- src/context/static_context.cpp	2013-06-18 23:53:59 +0000
+++ src/context/static_context.cpp	2013-06-21 12:18:31 +0000
@@ -3528,6 +3528,8 @@
     OptionMap::iterator lIt = theOptionMap->find(qname2);
     if (lIt != theOptionMap->end())
     {
+      // if there was already an earlier declarationof the same option, append
+      // the value of the current declaration to the value of the earlier decl.
       std::ostringstream lOss;
       lOss << lIt.getValue().theValue << " " << option.theValue;
       option.theValue = lOss.str();
@@ -3535,7 +3537,7 @@
   }
   
   // If option namespace starts with zorba options namespace
-  if ( lNamespace.find(ZORBA_OPTIONS_NS) == 0 )
+  else if ( lNamespace.find(ZORBA_OPTIONS_NS) == 0 )
   {
     if (lNamespace == ZORBA_OPTION_FEATURE_NS &&
         (lLocalName == "enable" || lLocalName == "disable"))

=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml	2013-06-20 12:00:37 +0000
+++ src/diagnostics/diagnostic_en.xml	2013-06-21 12:18:31 +0000
@@ -253,7 +253,7 @@
        prefix that cannot be expanded into a namespace URI by using the
        statically known namespaces.
       </comment>
-      <value>"$1": can not expand namespace prefix to URI</value>
+      <value>"$1": can not expand prefix of lexical QName to namespace URI</value>
     </diagnostic>
 
     <diagnostic code="XPST0083">
@@ -434,7 +434,11 @@
        It is a static error if the version number specified in a version
        declaration is not supported by the implementation.
       </comment>
-      <value>"$1": $2</value>
+      <value>$1</value>
+
+      <entry key="BadXQueryVersion_2">
+        <value>"$2": unsupported XQuery version</value>
+      </entry>
     </diagnostic>
 
     <diagnostic code="XQST0032">
@@ -558,7 +562,16 @@
        <code>http://www.w3.org/2001/XMLSchema-instance</code>,
        <code>http://www.w3.org/2005/xpath-functions</code>.
       </comment>
-      <value>"$1": $2 declared in reserved namespace${ 3}</value>
+      <value>$1</value>
+
+      <entry key="FUNCTION_23">
+        <value>"$2": function name in reserved namespace "$3"</value>
+      </entry>
+      
+      <entry key="ANNOTATION_23">
+        <value>"$2": annotation name in reserved namespace "$3"</value>
+      </entry>
+
     </diagnostic>
 
     <diagnostic code="XQST0046">
@@ -586,7 +599,7 @@
        It is a static error if a function or variable declared in a library
        module is not in the target namespace of the library module.
       </comment>
-      <value>"$1": not in library namespace</value>
+      <value>"$1": QName not in library namespace</value>
     </diagnostic>
 
     <diagnostic code="XQST0049">
@@ -633,7 +646,7 @@
         It is a static error if multiple schema imports specify the same target
         namespace.
       </comment>
-      <value>duplicate import of schema with target namespace $1</value>
+      <value>duplicate import of schema with target namespace "$1"</value>
     </diagnostic>
 
     <diagnostic code="XQST0059">
@@ -643,9 +656,23 @@
         target namespace.
       </comment>
       <value>$1</value>
-      <entry key="SpecificationMessage">
-        <value>"$2": target namespace not found for schema/module${ "3"}${: 4}</value>
-      </entry>
+
+      <entry key="UnknownSchema_23o">
+        <value>no schema found for target namespace "$2"${ : 3}</value>
+      </entry>
+
+      <entry key="UnknownModule_234o">
+        <value>module "$2" not found at location "$3"${ : 4}</value>
+      </entry>
+
+      <entry key="BadModule_23">
+        <value>module "$2" at location "$3" is not library module</value>
+      </entry>
+
+      <entry key="WrongModule_234">
+        <value>attempt to import module "$2" at location "$3" actually imports module "$4"</value>
+      </entry>
+
       <entry key="XercesMessage">
         <value>$2,$3: error in schema${ with System ID "4"}${ with Public ID "5"}${: 6}</value>
       </entry>
@@ -656,7 +683,7 @@
        It is a static error if the name of a function in a function declaration
        is not in a namespace (expanded QName has a null namespace URI).
       </comment>
-      <value>"$1": function name has a null namespace URI</value>
+      <value>"$1": function name is in no namespace</value>
     </diagnostic>
 
     <diagnostic code="XQST0065">
@@ -936,12 +963,29 @@
       <value>"$1": feature not supported</value>
     </diagnostic>
     
+    <diagnostic code="XQST0122">
+      <comment>
+        It is a static error if the name of a feature in require-feature or
+        prohibit-feature is not in the lexical space of QName.
+      </comment>
+      <value>$1</value>
+    </diagnostic>
+
     <diagnostic code="XQST0123">
       <comment>
         It is a static error if the name of a feature in require-feature is not
         recognized by the implementation.
       </comment>
       <value>$1</value>
+
+      <entry key="UnrecognizedXQueryOption_2">
+        <value>"$2": unrecognized option in XQuery namespace</value>
+      </entry>
+
+      <entry key="UnrecognizedRequiredFeature_2">
+        <value>"$2": unrecognized required feature</value>
+      </entry>
+
     </diagnostic>
     
     <diagnostic code="XQST0126">
@@ -3710,10 +3754,6 @@
       <value>can not parse as XML for xqdoc: $3</value>
     </entry>
 
-    <entry key="BadXQueryVersion">
-      <value>unsupported XQuery version</value>
-    </entry>
-
     <entry key="BaseURI">
       <value>base URI</value>
     </entry>
@@ -4451,14 +4491,6 @@
       <value>a DOCTYPE declaration must appear before any element or text node, and at most once</value>
     </entry>
 
-    <entry key="FUNCTION">
-      <value>function</value>
-    </entry>
-
-    <entry key="ANNOTATION">
-      <value>annotation</value>
-    </entry>
-
     <!--////////// libxml2 Errors //////////////////////////////////////////-->
 
     <entry key="libxml_ERR_1"> <!-- XML_ERR_INTERNAL_ERROR -->
@@ -5082,10 +5114,6 @@
       <value>"$5": duplicate attribute enumeration value token</value>
     </entry>
 
-    <entry key="UnrecognizedXQueryOption">
-      <value>"$2": unrecognized XQuery namespace option</value>
-    </entry>
-
   </subvalues>
 
 </diagnostic-list>

=== modified file 'src/diagnostics/pregenerated/diagnostic_list.cpp'
--- src/diagnostics/pregenerated/diagnostic_list.cpp	2013-06-15 02:57:08 +0000
+++ src/diagnostics/pregenerated/diagnostic_list.cpp	2013-06-21 12:18:31 +0000
@@ -235,6 +235,9 @@
 XQueryErrorCode XQST0120( "XQST0120" );
 
 
+XQueryErrorCode XQST0122( "XQST0122" );
+
+
 XQueryErrorCode XQST0123( "XQST0123" );
 
 

=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp	2013-06-20 12:00:37 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp	2013-06-21 12:18:31 +0000
@@ -146,7 +146,7 @@
   { "XPST0017", "\"$1\": $2" },
   { "XPST0051", "$1" },
   { "XPST0080", "\"$1\": invalid type for \"cast\" or \"castable\" exression" },
-  { "XPST0081", "\"$1\": can not expand namespace prefix to URI" },
+  { "XPST0081", "\"$1\": can not expand prefix of lexical QName to namespace URI" },
   { "XPST0083", "\"$1\": not a string literal" },
   { "XPTY0004", "$1" },
   { "XPTY0018", "path expression last step must not have nodes and atomic values" },
@@ -173,7 +173,7 @@
   { "XQST0012", "invalid schema definitions" },
   { "XQST0013", "invalid pragma content" },
   { "XQST0022", "namespace declaration attribute is not a URI literal" },
-  { "XQST0031", "\"$1\": $2" },
+  { "XQST0031", "$1" },
   { "XQST0032", "multiple base URI declarations" },
   { "XQST0033", "\"$1\": namespace prefix already bound to \"$2\"" },
   { "XQST0034", "\"$1\": duplicate function declaration" },
@@ -182,18 +182,18 @@
   { "XQST0038", "multiple default collation declarations" },
   { "XQST0039", "\"$1\": duplicate parameter name" },
   { "XQST0040", "\"$1\": non-distinct expanded attribute QName" },
-  { "XQST0045", "\"$1\": $2 declared in reserved namespace${ 3}" },
+  { "XQST0045", "$1" },
   { "XQST0046", "${\"1\": }invalid URI literal${: 2}" },
   { "XQST0047", "\"$1\": duplicate target namespace" },
-  { "XQST0048", "\"$1\": not in library namespace" },
+  { "XQST0048", "\"$1\": QName not in library namespace" },
   { "XQST0049", "\"$1\": duplicate variable declaration" },
   { "XQST0052", "\"$1\": not defined as simple type" },
   { "XQST0054", "${\"1\": }variable must not depend on itself" },
   { "XQST0055", "multiple copy-namespaces declarations" },
   { "XQST0057", "schema import with empty target namespace" },
-  { "XQST0058", "duplicate import of schema with target namespace $1" },
+  { "XQST0058", "duplicate import of schema with target namespace \"$1\"" },
   { "XQST0059", "$1" },
-  { "XQST0060", "\"$1\": function name has a null namespace URI" },
+  { "XQST0060", "\"$1\": function name is in no namespace" },
   { "XQST0065", "multiple ordering mode declarations" },
   { "XQST0066", "multiple element/type/function namespace declarations" },
   { "XQST0067", "multiple construction declarations" },
@@ -220,6 +220,7 @@
   { "XQST0114", "\"$1\": duplicate decimal format property" },
   { "XQST0116", "$1" },
   { "XQST0120", "\"$1\": feature not supported" },
+  { "XQST0122", "$1" },
   { "XQST0123", "$1" },
   { "XQST0126", "impossible to require all extension features" },
   { "XQST0127", "$1 : impossible to require and prohibit at the same time" },
@@ -505,7 +506,6 @@
 #if !defined(ZORBA_NO_FULL_TEXT)
   { "ZXQP8403", "thesaurus data error${: 1}" },
 #endif
-  { "~ANNOTATION", "annotation" },
   { "~AllMatchesHasExcludes", "AllMatches contains StringExclude" },
   { "~AlreadySpecified", "already specified" },
   { "~AppliedAt", "applied at" },
@@ -552,7 +552,6 @@
   { "~BadXMLDocument_2o", "malformed XML document${ at \"2\"}" },
   { "~BadXMLForXQDoc_3", "can not parse as XML for xqdoc: $3" },
   { "~BadXMLNoOpeningTag", "closing tag without matching opening tag" },
-  { "~BadXQueryVersion", "unsupported XQuery version" },
   { "~BaseURI", "base URI" },
   { "~BoxCondTooManyColumns", "box condition has more columns than index" },
   { "~CharExpected_3", "'$3' expected" },
@@ -636,7 +635,6 @@
   { "~FTST0009_BadStopWordsLang", "for current stop words" },
   { "~FTST0009_BadThesaurusLang", "for given thesaurus" },
   { "~FTST0009_BadTokenizerLang", "for current tokenizer" },
-  { "~FUNCTION", "function" },
   { "~FileNotFoundOrReadable", "file not found or readable" },
   { "~FnNilledArgNotNode", "fn:nilled() argument not a node" },
   { "~FnOnlyInXQueryVersion_3", "function only available in XQuery $3" },
@@ -885,7 +883,6 @@
   { "~UnescapedChar_3", "character '$3' must be escaped here" },
 #endif
   { "~UnexpectedElement", "unexpected element" },
-  { "~UnrecognizedXQueryOption", "\"$2\": unrecognized XQuery namespace option" },
   { "~VarValMustBeSingleItem_2", "\"$2\": variable value must be single item" },
   { "~XMLParserInitFailed", "XML parser initialization failed" },
   { "~XMLParserNoCreateTree", "XML tree creation failed" },
@@ -933,14 +930,20 @@
   { "~XQDY0074_NameSapceConstructor", "$2: cannot cast prefix to xs:NCName" },
   { "~XQDY0074_NoEmptyLocalname", "can not convert empty local name to xs:QName" },
   { "~XQDY0074_NotCastToQName", "$2: can not convert to xs:QName" },
+  { "~XQST0031_BadXQueryVersion_2", "\"$2\": unsupported XQuery version" },
   { "~XQST0036_NoParamTypeInMainModule_23", "\"$2\": parameter type of function \"$3\" is not among the in-scope types of the main module" },
   { "~XQST0036_NoParamTypeInModule_234", "\"$2\": parameter type of function \"$3\" is not among the in-scope types of module \"$4\"" },
   { "~XQST0036_NoRetTypeInMainModule_23", "\"$2\": return type of function \"$3\" is not among the in-scope types of the main module" },
   { "~XQST0036_NoRetTypeInModule_234", "\"$2\": return type of function \"$3\" is not among the in-scope types of module \"$4\"" },
   { "~XQST0036_NoVarTypeInMainModule_23", "\"$2\": type of variable \"$3\" is not among the in-scope types of the main module" },
   { "~XQST0036_NoVarTypeInModule_234", "\"$2\": type of variable \"$3\" is not among the in-scope types of module \"$4\"" },
+  { "~XQST0045_ANNOTATION_23", "\"$2\": annotation name in reserved namespace \"$3\"" },
+  { "~XQST0045_FUNCTION_23", "\"$2\": function name in reserved namespace \"$3\"" },
   { "~XQST0046_BadHexDigit_3", "'$3': invalid hexedecimal digit" },
-  { "~XQST0059_SpecificationMessage", "\"$2\": target namespace not found for schema/module${ \"3\"}${: 4}" },
+  { "~XQST0059_BadModule_23", "module \"$2\" at location \"$3\" is not library module" },
+  { "~XQST0059_UnknownModule_234o", "module \"$2\" not found at location \"$3\"${ : 4}" },
+  { "~XQST0059_UnknownSchema_23o", "no schema found for target namespace \"$2\"${ : 3}" },
+  { "~XQST0059_WrongModule_234", "attempt to import module \"$2\" at location \"$3\" actually imports module \"$4\"" },
   { "~XQST0059_XercesMessage", "$2,$3: error in schema${ with System ID \"4\"}${ with Public ID \"5\"}${: 6}" },
   { "~XQST0070_ReservedPrefixInDecl_2", "\"$2\": reserved prefix can not appear in namespace declaration" },
   { "~XQST0070_ReservedPrefixInImport_2", "\"$2\": reserved prefix can not appear in schema or module import" },
@@ -954,6 +957,8 @@
   { "~XQST0106_Duplicate", "$2: annotation appears more than once in declaration" },
   { "~XQST0116_Conflicting", "$2: conflicting annotations in declaration" },
   { "~XQST0116_Duplicate", "$2: annotation appears more than once in declaration" },
+  { "~XQST0123_UnrecognizedRequiredFeature_2", "\"$2\": unrecognized required feature" },
+  { "~XQST0123_UnrecognizedXQueryOption_2", "\"$2\": unrecognized option in XQuery namespace" },
   { "~XUDY0021_AttributeName", "\"$3\": attribute with the same name already exists" },
   { "~XUST0001_CONCAT", "comma expression with updating and non-updating branches" },
   { "~XUST0001_Generic", "updating expression illegal here" },

=== modified file 'src/diagnostics/pregenerated/dict_zed_keys.h'
--- src/diagnostics/pregenerated/dict_zed_keys.h	2013-06-20 12:00:37 +0000
+++ src/diagnostics/pregenerated/dict_zed_keys.h	2013-06-21 12:18:31 +0000
@@ -54,14 +54,20 @@
 #define ZED_XPTY0004_PiTarget_2 "~XPTY0004_PiTarget_2"
 #define ZED_XPTY0117_NodeCast "~XPTY0117_NodeCast"
 #define ZED_XPTY0117_NotationParam_23 "~XPTY0117_NotationParam_23"
+#define ZED_XQST0031_BadXQueryVersion_2 "~XQST0031_BadXQueryVersion_2"
 #define ZED_XQST0036_NoVarTypeInMainModule_23 "~XQST0036_NoVarTypeInMainModule_23"
 #define ZED_XQST0036_NoVarTypeInModule_234 "~XQST0036_NoVarTypeInModule_234"
 #define ZED_XQST0036_NoRetTypeInMainModule_23 "~XQST0036_NoRetTypeInMainModule_23"
 #define ZED_XQST0036_NoRetTypeInModule_234 "~XQST0036_NoRetTypeInModule_234"
 #define ZED_XQST0036_NoParamTypeInMainModule_23 "~XQST0036_NoParamTypeInMainModule_23"
 #define ZED_XQST0036_NoParamTypeInModule_234 "~XQST0036_NoParamTypeInModule_234"
+#define ZED_XQST0045_FUNCTION_23 "~XQST0045_FUNCTION_23"
+#define ZED_XQST0045_ANNOTATION_23 "~XQST0045_ANNOTATION_23"
 #define ZED_XQST0046_BadHexDigit_3 "~XQST0046_BadHexDigit_3"
-#define ZED_XQST0059_SpecificationMessage "~XQST0059_SpecificationMessage"
+#define ZED_XQST0059_UnknownSchema_23o "~XQST0059_UnknownSchema_23o"
+#define ZED_XQST0059_UnknownModule_234o "~XQST0059_UnknownModule_234o"
+#define ZED_XQST0059_BadModule_23 "~XQST0059_BadModule_23"
+#define ZED_XQST0059_WrongModule_234 "~XQST0059_WrongModule_234"
 #define ZED_XQST0059_XercesMessage "~XQST0059_XercesMessage"
 #define ZED_XQST0070_ReservedPrefixInDecl_2 "~XQST0070_ReservedPrefixInDecl_2"
 #define ZED_XQST0070_ReservedPrefixInModule_2 "~XQST0070_ReservedPrefixInModule_2"
@@ -75,6 +81,8 @@
 #define ZED_XQST0106_Conflicting "~XQST0106_Conflicting"
 #define ZED_XQST0116_Duplicate "~XQST0116_Duplicate"
 #define ZED_XQST0116_Conflicting "~XQST0116_Conflicting"
+#define ZED_XQST0123_UnrecognizedXQueryOption_2 "~XQST0123_UnrecognizedXQueryOption_2"
+#define ZED_XQST0123_UnrecognizedRequiredFeature_2 "~XQST0123_UnrecognizedRequiredFeature_2"
 #define ZED_XPDY0002_VariableHasNoValue_2 "~XPDY0002_VariableHasNoValue_2"
 #define ZED_XPDY0002_VariableUndeclared_2 "~XPDY0002_VariableUndeclared_2"
 #define ZED_XPDY0002_ContextUndeclared_2 "~XPDY0002_ContextUndeclared_2"
@@ -232,7 +240,6 @@
 #define ZED_BadXMLDocument_2o "~BadXMLDocument_2o"
 #define ZED_BadXMLNoOpeningTag "~BadXMLNoOpeningTag"
 #define ZED_BadXMLForXQDoc_3 "~BadXMLForXQDoc_3"
-#define ZED_BadXQueryVersion "~BadXQueryVersion"
 #define ZED_BaseURI "~BaseURI"
 #define ZED_BoxCondTooManyColumns "~BoxCondTooManyColumns"
 #define ZED_CharExpected_3 "~CharExpected_3"
@@ -411,8 +418,6 @@
 #define ZED_ParseFragmentInvalidOptions "~ParseFragmentInvalidOptions"
 #define ZED_ParseFragmentDoctypeNotAllowed "~ParseFragmentDoctypeNotAllowed"
 #define ZED_ParseFragmentDoctypeNotAllowedHere "~ParseFragmentDoctypeNotAllowedHere"
-#define ZED_FUNCTION "~FUNCTION"
-#define ZED_ANNOTATION "~ANNOTATION"
 #define ZED_libxml_ERR_1 "~libxml_ERR_1"
 #define ZED_libxml_ERR_2 "~libxml_ERR_2"
 #define ZED_libxml_ERR_4 "~libxml_ERR_4"
@@ -558,7 +563,6 @@
 #define ZED_libxml_ERR_539 "~libxml_ERR_539"
 #define ZED_libxml_ERR_540 "~libxml_ERR_540"
 #define ZED_libxml_ERR_541 "~libxml_ERR_541"
-#define ZED_UnrecognizedXQueryOption "~UnrecognizedXQueryOption"
 
 #endif /* ZORBA_DIAGNOSTICS_ZED_KEYS */
 /*

=== modified file 'src/types/schema/schema.cpp'
--- src/types/schema/schema.cpp	2013-05-16 17:38:41 +0000
+++ src/types/schema/schema.cpp	2013-06-21 12:18:31 +0000
@@ -168,8 +168,7 @@
  * A Xerces EntityResolver that looks for a specific URL and returns
  * InputSource that reads from a particular std::istream.
  */
-class StaticContextEntityResolver : 
-    public XERCES_CPP_NAMESPACE::EntityResolver
+class StaticContextEntityResolver :  public XERCES_CPP_NAMESPACE::EntityResolver
 {
 public:
   /**
@@ -180,9 +179,12 @@
     const XMLCh* const systemId)
   {
     TRACE("pId: " << StrX(publicId) << "  sId: " << StrX(systemId));
+
     if (XMLString::compareString(systemId, theLogicalURI) == 0)
     {
-      TRACE("logiUri: " << StrX(theLogicalURI) << " physicalUri: " << StrX(thePhysicalURI));
+      TRACE("logiUri: " << StrX(theLogicalURI) << " physicalUri: "
+            << StrX(thePhysicalURI));
+
       // Pass memory ownership of the istream to the IstreamInputSource
       InputSource* lRetval = new IstreamInputSource(theStream, theStreamReleaser);
       theStreamReleaser = nullptr;
@@ -228,18 +230,28 @@
         zstring base = fullBase.substr(0, i == zstring::npos ? fullBase.length() : i+1);
         URI resolvedURI( base, lUri.toString(), true);
         lResolved = resolvedURI.toString();
-        TRACE("i: " << i << " base: " << base << " lUri: " << lUri << " lRes: " << lResolved);
+
+        TRACE("i: " << i << " base: " << base << " lUri: " << lUri
+              << " lRes: " << lResolved);
       }
       else
+      {
         lResolved = lStrId;
-      
+      }
+
       try
       {
-        TRACE("lId: " << StrX(lId) << " lResolved: " << lResolved << " thePhysURI: " << StrX(thePhysicalURI));
+        TRACE("lId: " << StrX(lId) << " lResolved: " << lResolved
+              << " thePhysURI: " << StrX(thePhysicalURI));
+
         zstring lErrorMessage;
-        lResource = theSctx->resolve_uri(lResolved, internal::EntityData::SCHEMA, lErrorMessage);
+        lResource = theSctx->resolve_uri(lResolved,
+                                         internal::EntityData::SCHEMA,
+                                         lErrorMessage);
+
         internal::StreamResource* lStream =
-            dynamic_cast<internal::StreamResource*>(lResource.get());
+        dynamic_cast<internal::StreamResource*>(lResource.get());
+
         if (lStream != NULL)
         {
           // Pass memory ownership of this istream to the new IstreamInputSource
@@ -263,13 +275,8 @@
         {
           // We didn't find it. If we return NULL here, Xerces will try to
           // resolve it its own way, which we don't want to happen.
-          throw XQUERY_EXCEPTION(
-            err::XQST0059,
-            ERROR_PARAMS(
-              ZED( XQST0059_SpecificationMessage ),
-              lResolved
-            )
-          );
+          throw XQUERY_EXCEPTION(err::XQST0059,
+          ERROR_PARAMS(ZED(XQST0059_UnknownSchema_23o), lResolved));
         }
       }
       catch (ZorbaException const& e)

=== modified file 'test/rbkt/Queries/zorba/index/error3.xq'
--- test/rbkt/Queries/zorba/index/error3.xq	2013-02-07 17:24:36 +0000
+++ test/rbkt/Queries/zorba/index/error3.xq	2013-06-21 12:18:31 +0000
@@ -3,10 +3,10 @@
 :)
 
 
-import module namespace index_ddl = "http://www.zorba-xquery.com/modules/store/static/indexes/ddl";;
+import module namespace iddl = "http://www.zorba-xquery.com/modules/store/static/indexes/ddl";;
 
 import module namespace idx = "http://www.w3.org/TestModules/idx"; at
                               "error_module2.xqlib";
 
-index_ddl:create(xs:QName("idx:foo"));
-index_ddl:drop-index(xs:QName("idx:foo"));
+iddl:create(xs:QName("idx:foo"));
+iddl:drop-index(xs:QName("idx:foo"));

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