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

Commit message:
fixed error messages for FORG0001 and FOCA0002 + removed uses of XQUERY_EXCEPTION_VAR macros

Requested reviews:
  Markos Zaharioudakis (markos-za)

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

fixed error messages for FORG0001 and FOCA0002 + removed uses of XQUERY_EXCEPTION_VAR macros
-- 
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/142760
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/api/base64impl.cpp'
--- src/api/base64impl.cpp	2012-09-19 21:16:15 +0000
+++ src/api/base64impl.cpp	2013-01-10 19:32:23 +0000
@@ -26,18 +26,19 @@
 #include "diagnostics/xquery_exception.h"
 #include "util/base64_util.h"
 
-#define CATCH_BASE64_EXCEPTION()                                            \
-  catch ( base64::exception const &e ) {                                    \
-    throw XQUERY_EXCEPTION(                                                 \
-      err::FORG0001, ERROR_PARAMS( e.invalid_char(), ZED( Base64BadChar ) ) \
-    );                                                                      \
-  }                                                                         \
-  catch ( std::invalid_argument const& ) {                                  \
-    throw XQUERY_EXCEPTION(                                                 \
-      err::FORG0001, ERROR_PARAMS( "", ZED( Base64Multiple4 ) )             \
-    );                                                                      \
+#define CATCH_BASE64_EXCEPTION()                                        \
+  catch (const base64::exception& e)                                    \
+  {                                                                     \
+    throw XQUERY_EXCEPTION(err::FORG0001,                               \
+    ERROR_PARAMS(ZED(FORG0001_Base64BadChar_2),  e.invalid_char()));    \
+  }                                                                     \
+  catch (const std::invalid_argument&)                                  \
+  {                                                                     \
+    throw XQUERY_EXCEPTION(err::FORG0001,                               \
+    ERROR_PARAMS(ZED(FORG0001_Base64Multiple4)));                       \
   }
 
+
 namespace zorba {
 namespace encoding {
 

=== modified file 'src/api/itemfactoryimpl.cpp'
--- src/api/itemfactoryimpl.cpp	2012-10-08 12:09:36 +0000
+++ src/api/itemfactoryimpl.cpp	2013-01-10 19:32:23 +0000
@@ -16,21 +16,29 @@
 #include "stdafx.h"
 
 #define  __STDC_LIMIT_MACROS
+
 #include <zorba/item.h>
 #include <zorba/zorba_string.h>
+
 #include "diagnostics/xquery_diagnostics.h"
+#include "diagnostics/util_macros.h"
+
 #include "api/itemfactoryimpl.h"
 
 #include "zorbatypes/duration.h"
+
 #include "system/globalenv.h"
+
 #include "store/api/item_factory.h"
-#include <store/api/store.h>
+#include "store/api/store.h"
 #include "store/api/copymode.h"
+#include "store/api/item.h"
+
 #include "api/unmarshaller.h"
+
 #include "types/casting.h"
 
-#include "store/api/item.h"
-#include <runtime/util/item_iterator.h>
+#include "runtime/util/item_iterator.h"
 
 
 namespace zorba {
@@ -112,14 +120,16 @@
   zstring const &lLocalname = Unmarshaller::getInternalString( aLocalname );
   
   if (!GenericCast::instance()->castableToNCName(lLocalname.c_str()))
-    throw XQUERY_EXCEPTION(
-      err::FORG0001, ERROR_PARAMS( lLocalname, ZED( MustBeNCName ) )
-    );
+  {
+    RAISE_ERROR_NO_LOC(err::FORG0001, 
+    ERROR_PARAMS(ZED(FORG0001_LocalNotNCName_2), lLocalname));
+  }
 
   if (lPrefix.size() && !GenericCast::instance()->castableToNCName(lPrefix.c_str()))
-    throw XQUERY_EXCEPTION(
-      err::FORG0001, ERROR_PARAMS( lPrefix, ZED( MustBeNCName ) )
-    );
+  {
+    RAISE_ERROR_NO_LOC(err::FORG0001, 
+    ERROR_PARAMS(ZED(FORG0001_PrefixNotNCName_2), lPrefix));
+  }
   
   store::Item_t lItem;
   theItemFactory->createQName(lItem, lNamespace, lPrefix, lLocalname);
@@ -135,44 +145,51 @@
   zstring const &lLocalname = Unmarshaller::getInternalString( aLocalname );
 
   if (!GenericCast::instance()->castableToNCName(lLocalname.c_str()))
-    throw XQUERY_EXCEPTION(
-      err::FORG0001, ERROR_PARAMS( lLocalname, ZED( MustBeNCName ) )
-    );
+  {
+    RAISE_ERROR_NO_LOC(err::FORG0001, 
+    ERROR_PARAMS(ZED(FORG0001_LocalNotNCName_2), lLocalname));
+  }
   
   store::Item_t lItem;
   theItemFactory->createQName(lItem, lNamespace, zstring(), lLocalname);
   return &*lItem;
 }
   
+
 Item
 ItemFactoryImpl::createQName(const String& aQNameString)
 {
-  zstring const &lQNameString = Unmarshaller::getInternalString( aQNameString );
+  const zstring& lQNameString = Unmarshaller::getInternalString( aQNameString );
   store::Item_t lItem;
 
   size_t lOpen  = lQNameString.find("{");
   size_t lClose = lQNameString.find("}");
 
-  if (lOpen == 0 && lClose != std::string::npos) {
+  if (lOpen == 0 && lClose != std::string::npos) 
+  {
     zstring const &lNamespace = lQNameString.substr(1, lClose - 1);
     zstring const &lLocalname = lQNameString.substr(lClose+1);
     theItemFactory->createQName(lItem, lNamespace, zstring(), lLocalname);
+
     if (!GenericCast::instance()->castableToNCName(lLocalname.c_str()))
-      throw XQUERY_EXCEPTION(
-        err::FORG0001, ERROR_PARAMS( lLocalname, ZED( MustBeNCName ) )
-      );
+    {
+      RAISE_ERROR_NO_LOC(err::FORG0001, 
+      ERROR_PARAMS(ZED(FORG0001_LocalNotNCName_2), lLocalname));
+    }
   }
   return &*lItem;
 }
 
+
 Item ItemFactoryImpl::createNCName(const String& aValue)
 {
   zstring lString = Unmarshaller::getInternalString(aValue);
 
   if (!GenericCast::instance()->castableToNCName(lString.c_str()))
-    throw XQUERY_EXCEPTION(
-      err::FORG0001, ERROR_PARAMS( lString, ZED( MustBeNCName ) )
-    );
+  {
+    RAISE_ERROR_NO_LOC(err::FORG0001,
+    ERROR_PARAMS(ZED(FORG0001_NameNotNCName_2), lString));
+  }
   
   store::Item_t lItem;
   theItemFactory->createNCName(lItem, lString);
@@ -191,9 +208,7 @@
   }
   else
   {
-    throw ZORBA_EXCEPTION(
-      zerr::ZSTR0040_TYPE_ERROR, ERROR_PARAMS( lMessage )
-    );
+    throw ZORBA_EXCEPTION(zerr::ZSTR0040_TYPE_ERROR, ERROR_PARAMS(lMessage));
   }
   return &*lItem;
 }

=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml	2013-01-08 08:34:08 +0000
+++ src/diagnostics/diagnostic_en.xml	2013-01-10 19:32:23 +0000
@@ -455,6 +455,10 @@
        is of nonzero length and is not in the lexical space of \c xs:anyURI.
       </comment>
       <value>${"1": }invalid URI literal${: 2}</value>
+
+      <entry key="BadHexDigit_3">
+        <value>'$3': invalid hexedecimal digit</value>
+      </entry>
     </diagnostic>
 
     <diagnostic code="XQST0047">
@@ -1020,7 +1024,20 @@
       <comment>
        Invalid lexical value.
       </comment>
-      <value>"$1": invalid lexical value${: 2}</value>
+      <value>$1</value>
+
+      <entry key="BadLexicalQName_2">
+        <value>"$2": value is not a valid lexical QName</value>
+      </entry>
+
+      <entry key="NoURIforPrefix_2">
+        <value>no namespace URI provided for prefix in lexical QName "$2"</value>
+      </entry>
+
+      <entry key="NoCastTo_234">
+        <value>"$2": value of type $3 is not castable to type $4</value>
+      </entry>
+
     </diagnostic>
 
     <diagnostic code="FOCA0003">
@@ -1188,7 +1205,52 @@
       <comment>
        Invalid value for cast/constructor.
       </comment>
-      <value>${"1": }invalid value for cast/constructor${: 2}</value>
+
+      <value>$1</value>
+
+      <entry key="NoCastTo_234">
+        <value>"$2": value of type $3 is not castable to type $4</value>
+      </entry>
+
+      <entry key="NoCastTo_234o">
+        <value>"$2": value is not castable to type $3${: 4}</value>
+      </entry>
+
+      <entry key="LocalNotNCName_2">
+        <value>"$2": local name in qname is not an xs:NCName</value>
+      </entry>
+
+      <entry key="PrefixNotNCName_2">
+        <value>"$2": prefix in qname is not an xs:NCName</value>
+      </entry>
+
+      <entry key="NameNotNCName_2">
+        <value>"$2": name is not an xs:NCName</value>
+      </entry>
+
+      <entry key="PrefixNotBound_2">
+        <value>"$2": prefix has no known namespace binding</value>
+      </entry>
+
+      <entry key="Base64BadChar_2">
+        <value>"$2": invalid Base64 character</value>
+      </entry>
+
+      <entry key="Base64Multiple4">
+        <value>Base64 data must be a multiple of 4 characters</value>
+      </entry>
+
+      <entry key="HexBinaryMustBeEven">
+        <value>HexBinary value must contain an even number of characters</value>
+      </entry>
+
+      <entry key="BadHexDigit_2">
+        <value>'$2': invalid hexedecimal digit</value>
+      </entry>
+
+      <entry key="NoTypeInCtx_2">
+        <value>"$2": type no defined in current context</value>
+      </entry>
     </diagnostic>
 
     <diagnostic code="FORG0002">
@@ -3029,10 +3091,6 @@
       <value>"$2": invalid authority for "file" scheme</value>
     </entry>
 
-    <entry key="BadHexDigit_3">
-      <value>'$3': invalid hexedecimal digit</value>
-    </entry>
-
     <entry key="BadHexSequence">
       <value>invalid hexedecimal sequence</value>
     </entry>
@@ -3113,14 +3171,6 @@
       <value>unsupported XQuery version</value>
     </entry>
 
-    <entry key="Base64BadChar">
-      <value>invalid Base64 character</value>
-    </entry>
-
-    <entry key="Base64Multiple4">
-      <value>Base64 data must be a multiple of 4 characters</value>
-    </entry>
-
     <entry key="BaseURI">
       <value>base URI</value>
     </entry>
@@ -3129,10 +3179,6 @@
       <value>box condition has more columns than index</value>
     </entry>
 
-    <entry key="CastFromToFailed_34">
-      <value>$3 to $4 cast failed</value>
-    </entry>
-
     <entry key="CharExpected_3">
       <value>'$3' expected</value>
     </entry>
@@ -3285,10 +3331,6 @@
       <value>valid values are: yes, no, omit</value>
     </entry>
 
-    <entry key="HexBinaryMustBeEven">
-      <value>HexBinary value must contain an even number of characters</value>
-    </entry>
-
     <entry key="IncompleteKeyInIndexBuild">
       <value>incomplete key during index build</value>
     </entry>
@@ -3309,10 +3351,6 @@
       <value>must be absolute</value>
     </entry>
 
-    <entry key="MustBeNCName">
-      <value>must be an xs:NCName</value>
-    </entry>
-
     <entry key="NoAttrNodesInDocument">
       <value>document node must not contain attribute nodes</value>
     </entry>
@@ -3445,10 +3483,6 @@
       <value>can not treat as "$4"</value>
     </entry>
 
-    <entry key="NoTypeInCtx">
-      <value>undefined type in current context</value>
-    </entry>
-
     <entry key="NoTypeInMainModule_4">
       <value>type of variable "$4" is not among the in-scope types of the main module</value>
     </entry>

=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp	2013-01-08 08:34:08 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp	2013-01-10 19:32:23 +0000
@@ -31,7 +31,7 @@
   { "FOAR0001", "division by zero" },
   { "FOAR0002", "numeric operation overflow/underflow${: 1}" },
   { "FOCA0001", "\"$1\": value too large for decimal" },
-  { "FOCA0002", "\"$1\": invalid lexical value${: 2}" },
+  { "FOCA0002", "$1" },
   { "FOCA0003", "\"$1\": value too large for integer" },
   { "FOCA0005", "NaN supplied as float/double value" },
   { "FOCA0006", "\"$1\": string to be cast to decimal has too many digits of precision" },
@@ -56,7 +56,7 @@
   { "FOFI0002", "invalid argument in format-integer: $1" },
   { "FONS0004", "\"$1\": no namespace found for prefix" },
   { "FONS0005", "base-URI not defined in the static context" },
-  { "FORG0001", "${\"1\": }invalid value for cast/constructor${: 2}" },
+  { "FORG0001", "$1" },
   { "FORG0002", "\"$1\": invalid argument to fn:resolve-uri()${: 2}" },
   { "FORG0003", "fn:zero-or-one() called with a sequnce containing more than one item" },
   { "FORG0004", "fn:one-or-more() called with a sequence containing no items" },
@@ -537,7 +537,6 @@
   { "~BadCharInBraces_3", "'$3': illegal character within { }" },
   { "~BadDecDigit_3", "'$3': invalid decimal digit" },
   { "~BadFileURIAuthority_2", "\"$2\": invalid authority for \"file\" scheme" },
-  { "~BadHexDigit_3", "'$3': invalid hexedecimal digit" },
   { "~BadHexSequence", "invalid hexedecimal sequence" },
   { "~BadItem", "invalid item" },
   { "~BadIterator", "invalid iterator" },
@@ -560,11 +559,8 @@
   { "~BadXMLForXQDoc_3", "can not parse as XML for xqdoc: $3" },
   { "~BadXMLNoOpeningTag", "closing tag without matching opening tag" },
   { "~BadXQueryVersion", "unsupported XQuery version" },
-  { "~Base64BadChar", "invalid Base64 character" },
-  { "~Base64Multiple4", "Base64 data must be a multiple of 4 characters" },
   { "~BaseURI", "base URI" },
   { "~BoxCondTooManyColumns", "box condition has more columns than index" },
-  { "~CastFromToFailed_34", "$3 to $4 cast failed" },
   { "~CharExpected_3", "'$3' expected" },
   { "~CloneNotImplemented", "clone() not implemented for expression" },
   { "~ClosingBraceWithoutOpen", "'}' encountered without '{' first" },
@@ -592,6 +588,20 @@
   { "~ExprReturnsTooManyUpdateLists", "expression does not return a pending update list" },
   { "~ExternFnDeterministic", "only external functions may be declared deterministic" },
   { "~ExternFnNondeterministic", "only external functions may be declared nondeterministic" },
+  { "~FOCA0002_BadLexicalQName_2", "\"$2\": value is not a valid lexical QName" },
+  { "~FOCA0002_NoCastTo_234", "\"$2\": value of type $3 is not castable to type $4" },
+  { "~FOCA0002_NoURIforPrefix_2", "no namespace URI provided for prefix in lexical QName \"$2\"" },
+  { "~FORG0001_BadHexDigit_2", "'$2': invalid hexedecimal digit" },
+  { "~FORG0001_Base64BadChar_2", "\"$2\": invalid Base64 character" },
+  { "~FORG0001_Base64Multiple4", "Base64 data must be a multiple of 4 characters" },
+  { "~FORG0001_HexBinaryMustBeEven", "HexBinary value must contain an even number of characters" },
+  { "~FORG0001_LocalNotNCName_2", "\"$2\": local name in qname is not an xs:NCName" },
+  { "~FORG0001_NameNotNCName_2", "\"$2\": name is not an xs:NCName" },
+  { "~FORG0001_NoCastTo_234", "\"$2\": value of type $3 is not castable to type $4" },
+  { "~FORG0001_NoCastTo_234o", "\"$2\": value is not castable to type $3${: 4}" },
+  { "~FORG0001_NoTypeInCtx_2", "\"$2\": type no defined in current context" },
+  { "~FORG0001_PrefixNotBound_2", "\"$2\": prefix has no known namespace binding" },
+  { "~FORG0001_PrefixNotNCName_2", "\"$2\": prefix in qname is not an xs:NCName" },
   { "~FTST0009_BadStemmerLang", "for current stemmer" },
   { "~FTST0009_BadStopWordsLang", "for current stop words" },
   { "~FTST0009_BadThesaurusLang", "for given thesaurus" },
@@ -614,7 +624,6 @@
   { "~GoodValuesAreXMLEtc", "valid values are: xml, html, xhtml, text, binary, json, jsoniq" },
   { "~GoodValuesAreYesNo", "valid values are: yes, no" },
   { "~GoodValuesAreYesNoOmit", "valid values are: yes, no, omit" },
-  { "~HexBinaryMustBeEven", "HexBinary value must contain an even number of characters" },
   { "~IncompleteKeyInIndexBuild", "incomplete key during index build" },
   { "~IncompleteKeyInIndexRefresh", "incomplete key during index refresh" },
   { "~JNDY0021_IllegalCharacter_2", "'$2': illegal JSON character" },
@@ -648,7 +657,6 @@
   { "~LibModVersionMismatch_3", "XQuery library version can not be imported by a $3 version module" },
   { "~ModuleNotFound", "module not found" },
   { "~MustBeAbsoluteURI", "must be absolute" },
-  { "~MustBeNCName", "must be an xs:NCName" },
   { "~NoAttrNodesInDocument", "document node must not contain attribute nodes" },
   { "~NoBindURI", "namespace URI can not be bound to prefix" },
   { "~NoCastToCInt_2", "\"$2\": 2nd operand can not be cast from \"xs:integer\" to C++ \"int\"" },
@@ -682,7 +690,6 @@
   { "~NoSerializationCallbackForTraceStream", "no SerializationCallback for required trace stream" },
   { "~NoSourceURI", "no URI" },
   { "~NoTreatAs_4", "can not treat as \"$4\"" },
-  { "~NoTypeInCtx", "undefined type in current context" },
   { "~NoTypeInMainModule_4", "type of variable \"$4\" is not among the in-scope types of the main module" },
   { "~NoTypeInModule_45", "type of variable \"$4\" is not among the in-scope types module \"$5\"" },
   { "~NoURIAuthority", "no authority" },
@@ -897,6 +904,7 @@
   { "~XPTY0004_NoTypePromote_23", "$2 can not be promoted to type $3" },
   { "~XPTY0117_NodeCast", "Cannot cast node to xs:QName" },
   { "~XPTY0117_NotationParam_23", "$2 can not be promoted to parameter type xs:NOTATION of function $3()" },
+  { "~XQST0046_BadHexDigit_3", "'$3': invalid hexedecimal digit" },
   { "~XQST0106_CONFLICTING", "conflicting" },
   { "~XQST0106_THE_SAME", "the same" },
   { "~XUDY0021_AttributeName", "\"$3\": attribute with the same name already exists" },

=== modified file 'src/diagnostics/pregenerated/dict_zed_keys.h'
--- src/diagnostics/pregenerated/dict_zed_keys.h	2013-01-08 08:34:08 +0000
+++ src/diagnostics/pregenerated/dict_zed_keys.h	2013-01-10 19:32:23 +0000
@@ -46,6 +46,7 @@
 #define ZED_XPTY0004_MultiValuedGroupingKey "~XPTY0004_MultiValuedGroupingKey"
 #define ZED_XPTY0117_NodeCast "~XPTY0117_NodeCast"
 #define ZED_XPTY0117_NotationParam_23 "~XPTY0117_NotationParam_23"
+#define ZED_XQST0046_BadHexDigit_3 "~XQST0046_BadHexDigit_3"
 #define ZED_XQST0106_THE_SAME "~XQST0106_THE_SAME"
 #define ZED_XQST0106_CONFLICTING "~XQST0106_CONFLICTING"
 #define ZED_XPDY0002_VariableHasNoValue_2 "~XPDY0002_VariableHasNoValue_2"
@@ -55,6 +56,20 @@
 #define ZED_FTST0009_BadStemmerLang "~FTST0009_BadStemmerLang"
 #define ZED_FTST0009_BadThesaurusLang "~FTST0009_BadThesaurusLang"
 #define ZED_FTST0009_BadTokenizerLang "~FTST0009_BadTokenizerLang"
+#define ZED_FOCA0002_BadLexicalQName_2 "~FOCA0002_BadLexicalQName_2"
+#define ZED_FOCA0002_NoURIforPrefix_2 "~FOCA0002_NoURIforPrefix_2"
+#define ZED_FOCA0002_NoCastTo_234 "~FOCA0002_NoCastTo_234"
+#define ZED_FORG0001_NoCastTo_234 "~FORG0001_NoCastTo_234"
+#define ZED_FORG0001_NoCastTo_234o "~FORG0001_NoCastTo_234o"
+#define ZED_FORG0001_LocalNotNCName_2 "~FORG0001_LocalNotNCName_2"
+#define ZED_FORG0001_PrefixNotNCName_2 "~FORG0001_PrefixNotNCName_2"
+#define ZED_FORG0001_NameNotNCName_2 "~FORG0001_NameNotNCName_2"
+#define ZED_FORG0001_PrefixNotBound_2 "~FORG0001_PrefixNotBound_2"
+#define ZED_FORG0001_Base64BadChar_2 "~FORG0001_Base64BadChar_2"
+#define ZED_FORG0001_Base64Multiple4 "~FORG0001_Base64Multiple4"
+#define ZED_FORG0001_HexBinaryMustBeEven "~FORG0001_HexBinaryMustBeEven"
+#define ZED_FORG0001_BadHexDigit_2 "~FORG0001_BadHexDigit_2"
+#define ZED_FORG0001_NoTypeInCtx_2 "~FORG0001_NoTypeInCtx_2"
 #define ZED_XUST0001_CONCAT "~XUST0001_CONCAT"
 #define ZED_XUST0001_TRYCATCH "~XUST0001_TRYCATCH"
 #define ZED_XUST0001_Generic "~XUST0001_Generic"
@@ -107,7 +122,6 @@
 #define ZED_BadCharInBraces_3 "~BadCharInBraces_3"
 #define ZED_BadDecDigit_3 "~BadDecDigit_3"
 #define ZED_BadFileURIAuthority_2 "~BadFileURIAuthority_2"
-#define ZED_BadHexDigit_3 "~BadHexDigit_3"
 #define ZED_BadHexSequence "~BadHexSequence"
 #define ZED_BadItem "~BadItem"
 #define ZED_BadIterator "~BadIterator"
@@ -128,11 +142,8 @@
 #define ZED_BadXMLNoOpeningTag "~BadXMLNoOpeningTag"
 #define ZED_BadXMLForXQDoc_3 "~BadXMLForXQDoc_3"
 #define ZED_BadXQueryVersion "~BadXQueryVersion"
-#define ZED_Base64BadChar "~Base64BadChar"
-#define ZED_Base64Multiple4 "~Base64Multiple4"
 #define ZED_BaseURI "~BaseURI"
 #define ZED_BoxCondTooManyColumns "~BoxCondTooManyColumns"
-#define ZED_CastFromToFailed_34 "~CastFromToFailed_34"
 #define ZED_CharExpected_3 "~CharExpected_3"
 #define ZED_CloneNotImplemented "~CloneNotImplemented"
 #define ZED_ClosingBraceWithoutOpen "~ClosingBraceWithoutOpen"
@@ -171,13 +182,11 @@
 #define ZED_GoodValuesAreXMLEtc "~GoodValuesAreXMLEtc"
 #define ZED_GoodValuesAreYesNo "~GoodValuesAreYesNo"
 #define ZED_GoodValuesAreYesNoOmit "~GoodValuesAreYesNoOmit"
-#define ZED_HexBinaryMustBeEven "~HexBinaryMustBeEven"
 #define ZED_IncompleteKeyInIndexBuild "~IncompleteKeyInIndexBuild"
 #define ZED_IncompleteKeyInIndexRefresh "~IncompleteKeyInIndexRefresh"
 #define ZED_LibModVersionMismatch_3 "~LibModVersionMismatch_3"
 #define ZED_ModuleNotFound "~ModuleNotFound"
 #define ZED_MustBeAbsoluteURI "~MustBeAbsoluteURI"
-#define ZED_MustBeNCName "~MustBeNCName"
 #define ZED_NoAttrNodesInDocument "~NoAttrNodesInDocument"
 #define ZED_NoBindURI "~NoBindURI"
 #define ZED_NoCastToCInt_2 "~NoCastToCInt_2"
@@ -211,7 +220,6 @@
 #define ZED_NoSerializationCallbackForTraceStream "~NoSerializationCallbackForTraceStream"
 #define ZED_NoSourceURI "~NoSourceURI"
 #define ZED_NoTreatAs_4 "~NoTreatAs_4"
-#define ZED_NoTypeInCtx "~NoTypeInCtx"
 #define ZED_NoTypeInMainModule_4 "~NoTypeInMainModule_4"
 #define ZED_NoTypeInModule_45 "~NoTypeInModule_45"
 #define ZED_NoURIAuthority "~NoURIAuthority"

=== modified file 'src/runtime/qnames/qnames_impl.cpp'
--- src/runtime/qnames/qnames_impl.cpp	2012-09-19 21:16:15 +0000
+++ src/runtime/qnames/qnames_impl.cpp	2013-01-10 19:32:23 +0000
@@ -31,6 +31,8 @@
 #include "store/api/item_factory.h"
 #include "store/api/item.h"
 
+#include "diagnostics/util_macros.h"
+
 
 namespace zorba {
 #define GENV_GCAST (*GenericCast::instance ())
@@ -66,19 +68,22 @@
       resLocal = qname.substr(index+1, qname.size() - index);
 
       // must check for FOCA0002 first
-      if (!GENV_GCAST.castableToNCName(resPre) || ! GENV_GCAST.castableToNCName(resLocal))
-        throw XQUERY_EXCEPTION(
-          err::FOCA0002, ERROR_PARAMS( qname ), ERROR_LOC(loc)
-        );
+      if (!GENV_GCAST.castableToNCName(resPre) ||
+          ! GENV_GCAST.castableToNCName(resLocal))
+      {
+        RAISE_ERROR(err::FOCA0002, loc,
+        ERROR_PARAMS(ZED(FOCA0002_BadLexicalQName_2), qname));
+      }
     }
     else
     {
       resLocal = qname;
 
       if (! GENV_GCAST.castableToNCName(resLocal))
-        throw XQUERY_EXCEPTION(
-          err::FOCA0002, ERROR_PARAMS( qname ), ERROR_LOC(loc)
-        );
+      {
+        RAISE_ERROR(err::FOCA0002, loc,
+        ERROR_PARAMS(ZED(FOCA0002_BadLexicalQName_2), qname));
+      }
     }
 
     if (consumeNext(itemElem, theChild1, planState ))
@@ -100,9 +105,7 @@
       }
 
       if (!found && !resPre.empty())
-        throw XQUERY_EXCEPTION(
-          err::FONS0004, ERROR_PARAMS( resPre ), ERROR_LOC( loc )
-        );
+        RAISE_ERROR(err::FONS0004, loc, ERROR_PARAMS(resPre));
     }
 
     GENV_ITEMFACTORY->createQName(result, resNs, resPre, resLocal);
@@ -146,9 +149,10 @@
   if (index != zstring::npos)
   {
     if (resNs.empty())
-      throw XQUERY_EXCEPTION(
-        err::FOCA0002, ERROR_PARAMS( resNs ), ERROR_LOC(loc)
-      );
+    {
+      RAISE_ERROR(err::FOCA0002, loc,
+      ERROR_PARAMS(ZED(FOCA0002_NoURIforPrefix_2), qname));
+    }
 
     resPre = qname.substr(0, index);
     resLocal = qname.substr(index+1, qname.size() - index);
@@ -161,9 +165,8 @@
   if ((index != zstring::npos && ! GENV_GCAST.castableToNCName(resPre)) ||
       ! GENV_GCAST.castableToNCName(resLocal))
   {
-    throw XQUERY_EXCEPTION(
-      err::FOCA0002, ERROR_PARAMS( qname ), ERROR_LOC(loc)
-    );
+    RAISE_ERROR(err::FOCA0002, loc,
+    ERROR_PARAMS(ZED(FOCA0002_BadLexicalQName_2), qname));
   }
 
   GENV_ITEMFACTORY->createQName(result, resNs, resPre, resLocal);

=== modified file 'src/store/naive/atomic_items.cpp'
--- src/store/naive/atomic_items.cpp	2012-12-25 20:27:54 +0000
+++ src/store/naive/atomic_items.cpp	2013-01-10 19:32:23 +0000
@@ -2679,7 +2679,10 @@
   catch ( std::range_error const& )
   {
     RAISE_ERROR_NO_LOC(err::FORG0001,
-    ERROR_PARAMS(theValue, ZED(CastFromToFailed_34), "integer", "long"));
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234),
+                 getStringValue(),
+                 "xs:integer",
+                 "xs:long"));
   }
 }
 
@@ -2693,7 +2696,10 @@
   catch ( std::range_error const& ) 
   {
     RAISE_ERROR_NO_LOC(err::FORG0001,
-    ERROR_PARAMS(theValue, ZED(CastFromToFailed_34), "integer", "unsignedInt"));
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234),
+                 getStringValue(),
+                 "xs:integer",
+                 "xs:unsignedInt"));
   }
 }
 
@@ -2793,10 +2799,11 @@
   }
   catch ( std::range_error const& )
   {
-    throw XQUERY_EXCEPTION(
-      err::FORG0001,
-      ERROR_PARAMS( theValue, ZED( CastFromToFailed_34 ), "integer", "long" )
-    );
+    RAISE_ERROR_NO_LOC(err::FORG0001,
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234),
+                 getStringValue(),
+                 "xs:nonPositiveInteger",
+                 "xs:long"));
   }
 }
 
@@ -2882,6 +2889,7 @@
   }
 }
 
+
 store::Item* NonNegativeIntegerItem::getType() const
 {
   return GET_STORE().theSchemaTypeNames[store::XS_NON_NEGATIVE_INTEGER];
@@ -2893,26 +2901,30 @@
   return xs_decimal(theValue);
 }
 
+
 xs_integer NonNegativeIntegerItem::getIntegerValue() const
 {
   return xs_integer(theValue);
 }
 
+
 xs_long NonNegativeIntegerItem::getLongValue() const
 {
   try
   {
     return to_xs_long(theValue);
   }
-  catch ( std::range_error const& )
+  catch (const std::range_error& )
   {
-    throw XQUERY_EXCEPTION(
-      err::FORG0001,
-      ERROR_PARAMS( theValue, ZED( CastFromToFailed_34 ), "integer", "long" )
-    );
+    RAISE_ERROR_NO_LOC(err::FORG0001,
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234),
+                 getStringValue(),
+                 "xs:nonNegativeInteger",
+                 "xs:long"));
   }
 }
 
+
 zstring NonNegativeIntegerItem::getStringValue() const
 {
   return theValue.toString();

=== modified file 'src/types/casting.cpp'
--- src/types/casting.cpp	2013-01-10 13:14:51 +0000
+++ src/types/casting.cpp	2013-01-10 19:32:23 +0000
@@ -96,29 +96,89 @@
 };
 
 
-void throwTypeException(const Diagnostic& errcode, const ErrorInfo& info)
-{              
-  if (info.theSourceType)
-  {                      
-    throw XQUERY_EXCEPTION_VAR(errcode,
-    ERROR_PARAMS(*info.theSourceType, ZED(NoCastTo_34o), *info.theTargetType),
-    ERROR_LOC(info.theLoc));
-  }                                           
-  else                                        
-  {
-    TypeManager& tm = GENV_TYPESYSTEM;
-                                     
-    xqtref_t sourceType =
-    tm.create_builtin_atomic_type(info.theSourceTypeCode,
-                                  TypeConstants::QUANT_ONE);
-
-    xqtref_t targetType =
-    tm.create_builtin_atomic_type(info.theTargetTypeCode,
-                                  TypeConstants::QUANT_ONE);
-
-    throw XQUERY_EXCEPTION_VAR(errcode,
-    ERROR_PARAMS(*sourceType, ZED(NoCastTo_34o), *targetType),
-    ERROR_LOC(info.theLoc));    
+void throwXPTY0004Exception(const ErrorInfo& info)
+{              
+  if (info.theSourceType)
+  {                      
+    RAISE_ERROR(err::XPTY0004, info.theLoc,
+    ERROR_PARAMS(*info.theSourceType, ZED(NoCastTo_34o), *info.theTargetType));
+  }                                           
+  else                                        
+  {
+    TypeManager& tm = GENV_TYPESYSTEM;
+                                     
+    xqtref_t sourceType =
+    tm.create_builtin_atomic_type(info.theSourceTypeCode,
+                                  TypeConstants::QUANT_ONE);
+
+    xqtref_t targetType =
+    tm.create_builtin_atomic_type(info.theTargetTypeCode,
+                                  TypeConstants::QUANT_ONE);
+
+    RAISE_ERROR(err::XPTY0004, info.theLoc,
+    ERROR_PARAMS(*sourceType, ZED(NoCastTo_34o), *targetType));
+  }                                           
+}
+
+
+void throwFOCA0002Exception(const zstring& str, const ErrorInfo& info)
+{              
+  if (info.theSourceType)
+  {                      
+    RAISE_ERROR(err::FOCA0002, info.theLoc,
+    ERROR_PARAMS(ZED(FOCA0002_NoCastTo_234),
+                 str,
+                 info.theSourceType->toSchemaString(),
+                 info.theTargetType->toSchemaString()));
+  }                                           
+  else                                        
+  {
+    TypeManager& tm = GENV_TYPESYSTEM;
+                                     
+    xqtref_t sourceType =
+    tm.create_builtin_atomic_type(info.theSourceTypeCode,
+                                  TypeConstants::QUANT_ONE);
+
+    xqtref_t targetType =
+    tm.create_builtin_atomic_type(info.theTargetTypeCode,
+                                  TypeConstants::QUANT_ONE);
+
+    RAISE_ERROR(err::FOCA0002, info.theLoc,
+    ERROR_PARAMS(ZED(FOCA0002_NoCastTo_234),
+                 str,
+                 sourceType->toSchemaString(),
+                 targetType->toSchemaString()));
+  }                                           
+}
+
+
+void throwFORG0001Exception(const zstring& str, const ErrorInfo& info)
+{              
+  if (info.theTargetType)
+  {                      
+    RAISE_ERROR(err::FORG0001, info.theLoc,
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234),
+                 str,
+                 info.theSourceType->toSchemaString(),
+                 info.theTargetType->toSchemaString()));
+  }                                           
+  else                                        
+  {
+    TypeManager& tm = GENV_TYPESYSTEM;
+
+    xqtref_t sourceType =
+    tm.create_builtin_atomic_type(info.theSourceTypeCode,
+                                  TypeConstants::QUANT_ONE);
+
+    xqtref_t targetType =
+    tm.create_builtin_atomic_type(info.theTargetTypeCode,
+                                  TypeConstants::QUANT_ONE);
+
+    RAISE_ERROR(err::FORG0001, info.theLoc,
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234),
+                 str,
+                 sourceType->toSchemaString(),
+                 targetType->toSchemaString()));
   }                                           
 }
 
@@ -134,7 +194,7 @@
     zstring& strval,                \
     store::ItemFactory*,            \
     const namespace_context* nsCtx, \
-    const ErrorInfo& aErrorInfo)    \
+    const ErrorInfo& errInfo)       \
 {                                   \
   result = (aItem);                 \
 }                                   \
@@ -175,7 +235,7 @@
     zstring& strval,                \
     store::ItemFactory* aFactory,   \
     const namespace_context* nsCtx, \
-    const ErrorInfo& aErrorInfo)    \
+    const ErrorInfo& errInfo)       \
 
 
 
@@ -194,11 +254,11 @@
   }
   catch (std::invalid_argument const&) 
   {
-    throwTypeException(err::FORG0001, aErrorInfo);
+    throwFORG0001Exception(strval, errInfo);
   }
-  catch ( std::range_error const& ) 
+  catch (const std::range_error& ) 
   {
-    throw XQUERY_EXCEPTION(err::FOAR0002, ERROR_PARAMS(strval));
+    RAISE_ERROR(err::FOAR0002, errInfo.theLoc, ERROR_PARAMS(strval));
   }
 }
 
@@ -212,11 +272,11 @@
   }
   catch (std::invalid_argument const& ) 
   {
-    throwTypeException(err::FORG0001, aErrorInfo);
+    throwFORG0001Exception(strval, errInfo);
   }
-  catch (std::range_error const& ) 
+  catch (const std::range_error& ) 
   {
-    throw XQUERY_EXCEPTION(err::FOAR0002, ERROR_PARAMS(strval));
+    RAISE_ERROR(err::FOAR0002, errInfo.theLoc, ERROR_PARAMS(strval));
   }
 }
 
@@ -228,9 +288,9 @@
     xs_decimal const n(strval.c_str());
     aFactory->createDecimal(result, n);
   }
-  catch ( std::exception const& ) 
+  catch (const std::exception& ) 
   {
-    throwTypeException( err::FORG0001, aErrorInfo );
+    throwFORG0001Exception(strval, errInfo);
   }
 }
 
@@ -242,13 +302,31 @@
     xs_integer const n(strval.c_str());
     aFactory->createInteger(result, n);
   }
-  catch ( std::invalid_argument const& ) 
-  {
-    throwTypeException( err::FORG0001, aErrorInfo );
-  }
-  catch ( std::range_error const& ) 
-  {
-    throwTypeException( err::FOAR0002, aErrorInfo );
+  catch (const std::invalid_argument& ) 
+  {
+    throwFORG0001Exception(strval, errInfo);
+  }
+  catch (const std::range_error& ) 
+  {
+    RAISE_ERROR(err::FOAR0002, errInfo.theLoc, ERROR_PARAMS(strval));
+  }
+}
+
+
+T1_TO_T2(str, uint)
+{
+  try 
+  {
+    const xs_nonNegativeInteger n(strval.c_str());
+    aFactory->createNonNegativeInteger(result, n);
+  }
+  catch (const std::invalid_argument& )
+  {
+    throwFORG0001Exception(strval, errInfo);
+  }
+  catch (const std::range_error& )
+  {
+    RAISE_ERROR(err::FOAR0002, errInfo.theLoc, ERROR_PARAMS(strval));
   }
 }
 
@@ -263,7 +341,8 @@
     aFactory->createDuration(result, &d);
     return;
   }
-  throwTypeException(err::FORG0001, aErrorInfo);
+
+  throwFORG0001Exception(strval, errInfo);
 }
 
 
@@ -277,7 +356,8 @@
     aFactory->createYearMonthDuration(result, &d);
     return;
   }
-  throwTypeException( err::FORG0001, aErrorInfo );
+
+  throwFORG0001Exception(strval, errInfo);
 }
 
 
@@ -291,7 +371,8 @@
     aFactory->createDayTimeDuration(result, &d);
     return;
   }
-  throwTypeException( err::FORG0001, aErrorInfo );
+
+  throwFORG0001Exception(strval, errInfo);
 }
 
 
@@ -303,7 +384,8 @@
     aFactory->createDateTime(result, &dt);
     return;
   }
-  throwTypeException( err::FORG0001, aErrorInfo );
+
+  throwFORG0001Exception(strval, errInfo);
 }
 
 
@@ -315,7 +397,8 @@
     aFactory->createTime(result, &t);
     return;
   }
-  throwTypeException( err::FORG0001, aErrorInfo );
+
+  throwFORG0001Exception(strval, errInfo);
 }
 
 
@@ -327,7 +410,8 @@
     aFactory->createDate(result, &d);
     return;
   }
-  throwTypeException( err::FORG0001, aErrorInfo );
+
+  throwFORG0001Exception(strval, errInfo);
 }
 
 
@@ -339,7 +423,8 @@
     aFactory->createGYearMonth(result, &ym);
     return;
   }
-  throwTypeException( err::FORG0001, aErrorInfo );
+
+  throwFORG0001Exception(strval, errInfo);
 }
 
 
@@ -351,7 +436,8 @@
     aFactory->createGYear(result, &y);
     return;
   }
-  throwTypeException( err::FORG0001, aErrorInfo );
+
+  throwFORG0001Exception(strval, errInfo);
 }
 
 
@@ -364,7 +450,7 @@
     return;
   }
 
-  throwTypeException( err::FORG0001, aErrorInfo );
+  throwFORG0001Exception(strval, errInfo);
 }
 
 
@@ -376,7 +462,8 @@
     aFactory->createGDay(result, &d);
     return;
   }
-  throwTypeException( err::FORG0001, aErrorInfo );
+
+  throwFORG0001Exception(strval, errInfo);
 }
 
 
@@ -389,7 +476,7 @@
     return;
   }
 
-  throwTypeException( err::FORG0001, aErrorInfo );
+  throwFORG0001Exception(strval, errInfo);
 }
 
 
@@ -426,14 +513,16 @@
   }
   else
   {
-    throwTypeException( err::FORG0001, aErrorInfo );
+    throwFORG0001Exception(strval, errInfo);
   }
 
   pos = str - strval.c_str();
   ascii::skip_whitespace(strval.c_str(), len, &pos);
 
   if (pos != len)
-    throwTypeException( err::FORG0001, aErrorInfo );
+  {
+    throwFORG0001Exception(strval, errInfo);
+  }
 
   aFactory->createBoolean(result, lRetValue);
 }
@@ -448,7 +537,7 @@
     return;
   }
 
-  throwTypeException( err::FORG0001, aErrorInfo );
+  throwFORG0001Exception(strval, errInfo);
 }
 
 
@@ -460,7 +549,8 @@
     aFactory->createHexBinary(result, n);
     return;
   }
-  throwTypeException( err::FORG0001, aErrorInfo );
+
+  throwFORG0001Exception(strval, errInfo);
 }
 
 
@@ -474,7 +564,7 @@
   }
   catch (ZorbaException& e)
   {
-    e.set_diagnostic( err::FORG0001 );
+    e.set_diagnostic(err::FORG0001);
     throw;
   }
 }
@@ -488,7 +578,7 @@
   zstring::size_type lidx = strval.rfind(":", strval.size(), 1);
 
   if (idx != lidx)
-    throwTypeException(err::FORG0001, aErrorInfo);
+    throwFORG0001Exception(strval, errInfo);
 
   zstring nsuri;
   zstring prefix;
@@ -507,20 +597,26 @@
   {
     prefix = strval.substr(0, idx);
 
-    if (!GenericCast::instance()->castableToNCName(prefix))
-      throwTypeException(err::FORG0001, aErrorInfo);
+    if (!GenericCast::castableToNCName(prefix))
+    {
+      RAISE_ERROR(err::FORG0001, errInfo.theLoc,
+      ERROR_PARAMS(ZED(FORG0001_PrefixNotNCName_2), prefix));
+    }
 
     if (nsCtx)
     {
       if (!nsCtx->findBinding(prefix, nsuri))
-        throw XQUERY_EXCEPTION(err::FONS0004, ERROR_PARAMS(prefix));
+        RAISE_ERROR(err::FONS0004, errInfo.theLoc, ERROR_PARAMS(prefix));
     }
 
     local = strval.substr(idx + 1);
   }
 
-  if (!GenericCast::instance()->castableToNCName(local))
-    throwTypeException( err::FORG0001, aErrorInfo );
+  if (!GenericCast::castableToNCName(local))
+  {
+    RAISE_ERROR(err::FORG0001, errInfo.theLoc,
+    ERROR_PARAMS(ZED(FORG0001_LocalNotNCName_2), local));
+  }
 
   aFactory->createQName(result, nsuri, prefix, local);
 }
@@ -541,11 +637,15 @@
     local = strval.substr(pos+1, strval.size());
   }
   else
+  {
     local = strval;
+  }
 
   if (!nsCtx->findBinding(prefix, uri))
-    ZORBA_ERROR_DESC_OSS(err::FORG0001, "Prefix '" << prefix
-                         << "' not found in current namespace context.");
+  {
+    RAISE_ERROR(err::FORG0001, errInfo.theLoc, 
+    ERROR_PARAMS(ZED(FORG0001_PrefixNotBound_2), prefix));
+  }
 
   store::Item_t qname;
   aFactory->createQName(qname, uri, prefix, local);
@@ -565,7 +665,7 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_flt(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_flt(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
@@ -573,7 +673,7 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_dbl(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_dbl(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
@@ -581,7 +681,7 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_dec(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_dec(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
@@ -589,7 +689,7 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_int(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_int(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
@@ -597,7 +697,7 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_dur(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_dur(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
@@ -605,7 +705,7 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_yMD(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_yMD(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
@@ -613,7 +713,7 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_dTD(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_dTD(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
@@ -621,7 +721,7 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_dT(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_dT(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
@@ -629,7 +729,7 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_tim(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_tim(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
@@ -637,7 +737,7 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_dat(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_dat(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
@@ -645,7 +745,7 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_gYM(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_gYM(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
@@ -653,7 +753,7 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_gYr(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_gYr(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
@@ -661,7 +761,7 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_gMD(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_gMD(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
@@ -669,7 +769,7 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_gDay(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_gDay(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
@@ -677,7 +777,7 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_gMon(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_gMon(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
@@ -685,7 +785,7 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_bool(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_bool(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
@@ -693,7 +793,7 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_b64(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_b64(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
@@ -701,7 +801,7 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_hxB(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_hxB(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
@@ -709,7 +809,7 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_aURI(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_aURI(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
@@ -717,13 +817,13 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_uA(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_uA(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
 T1_TO_T2(flt, str)
 {
-  uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);
+  uA_str(result, aItem, strval, aFactory, nsCtx, errInfo);
 }
 
 
@@ -740,9 +840,9 @@
     xs_decimal const n( aItem->getFloatValue() );
     aFactory->createDecimal(result, n);
   }
-  catch ( std::exception const& /*e*/ ) 
+  catch (const std::exception&) 
   {
-    throwTypeException( err::FOCA0002, aErrorInfo );
+    throwFOCA0002Exception(aItem->getStringValue(), errInfo);
   }
 }
 
@@ -753,9 +853,9 @@
   {
     aFactory->createInteger(result, xs_integer(aItem->getFloatValue()));
   }
-  catch ( std::exception const& ) 
+  catch (const std::exception&) 
   {
-    throwTypeException( err::FOCA0002, aErrorInfo );
+    throwFOCA0002Exception(aItem->getStringValue(), errInfo);
   }
 }
 
@@ -770,13 +870,13 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_uA(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_uA(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
 T1_TO_T2(dbl, str)
 {
-  uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);
+  uA_str(result, aItem, strval, aFactory, nsCtx, errInfo);
 }
 
 
@@ -793,9 +893,9 @@
     xs_decimal const n( aItem->getDoubleValue() );
     aFactory->createDecimal(result, n);
   }
-  catch ( std::exception const& ) 
+  catch (const std::exception&) 
   {
-    throwTypeException(err::FOCA0002, aErrorInfo);
+    throwFOCA0002Exception(aItem->getStringValue(), errInfo);
   }
 }
 
@@ -806,9 +906,9 @@
   {
     aFactory->createInteger(result, xs_integer(aItem->getDoubleValue()));
   }
-  catch ( std::exception const& ) 
+  catch (const std::exception& ) 
   {
-    throwTypeException( err::FOCA0002, aErrorInfo );
+    throwFOCA0002Exception(aItem->getStringValue(), errInfo);
   }
 }
 
@@ -823,13 +923,13 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_uA(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_uA(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
 T1_TO_T2(dec, str)
 {
-  uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);
+  uA_str(result, aItem, strval, aFactory, nsCtx, errInfo);
 }
 
 
@@ -861,13 +961,13 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_uA(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_uA(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
 T1_TO_T2(int, str)
 {
-  uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);
+  uA_str(result, aItem, strval, aFactory, nsCtx, errInfo);
 }
 
 
@@ -899,13 +999,13 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_uA(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_uA(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
 T1_TO_T2(dur, str)
 {
-  uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);
+  uA_str(result, aItem, strval, aFactory, nsCtx, errInfo);
 }
 
 
@@ -929,13 +1029,13 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_uA(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_uA(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
 T1_TO_T2(yMD, str)
 {
-  uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);
+  uA_str(result, aItem, strval, aFactory, nsCtx, errInfo);
 }
 
 
@@ -959,13 +1059,13 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_uA(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_uA(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
 T1_TO_T2(dTD, str)
 {
-  uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);
+  uA_str(result, aItem, strval, aFactory, nsCtx, errInfo);
 }
 
 
@@ -989,13 +1089,13 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_uA(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_uA(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
 T1_TO_T2(dT, str)
 {
-  uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);
+  uA_str(result, aItem, strval, aFactory, nsCtx, errInfo);
 }
 
 
@@ -1059,13 +1159,13 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_uA(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_uA(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
 T1_TO_T2(tim, str)
 {
-  uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);
+  uA_str(result, aItem, strval, aFactory, nsCtx, errInfo);
 }
 
 
@@ -1073,13 +1173,13 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_uA(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_uA(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
 T1_TO_T2(dat, str)
 {
-  uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);
+  uA_str(result, aItem, strval, aFactory, nsCtx, errInfo);
 }
 
 
@@ -1135,13 +1235,13 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_uA(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_uA(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
 T1_TO_T2(gYM, str)
 {
-  uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);
+  uA_str(result, aItem, strval, aFactory, nsCtx, errInfo);
 }
 
 
@@ -1149,13 +1249,13 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_uA(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_uA(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
 T1_TO_T2(gYr, str)
 {
-  uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);
+  uA_str(result, aItem, strval, aFactory, nsCtx, errInfo);
 }
 
 
@@ -1163,13 +1263,13 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_uA(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_uA(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
 T1_TO_T2(gMD, str)
 {
-  uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);
+  uA_str(result, aItem, strval, aFactory, nsCtx, errInfo);
 }
 
 
@@ -1177,13 +1277,13 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_uA(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_uA(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
 T1_TO_T2(gDay, str)
 {
-  uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);
+  uA_str(result, aItem, strval, aFactory, nsCtx, errInfo);
 }
 
 
@@ -1191,13 +1291,13 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_uA(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_uA(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
 T1_TO_T2(gMon, str)
 {
-  uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);
+  uA_str(result, aItem, strval, aFactory, nsCtx, errInfo);
 }
 
 
@@ -1205,13 +1305,13 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_uA(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_uA(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
 T1_TO_T2(bool, str)
 {
-  uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);
+  uA_str(result, aItem, strval, aFactory, nsCtx, errInfo);
 }
 
 
@@ -1255,13 +1355,13 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_uA(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_uA(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
 T1_TO_T2(b64, str)
 {
-  uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);
+  uA_str(result, aItem, strval, aFactory, nsCtx, errInfo);
 }
 
 
@@ -1286,13 +1386,13 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_uA(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_uA(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
 T1_TO_T2(hxB, str)
 {
-  uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);
+  uA_str(result, aItem, strval, aFactory, nsCtx, errInfo);
 }
 
 
@@ -1307,13 +1407,13 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_uA(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_uA(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
 T1_TO_T2(aURI, str)
 {
-  uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);
+  uA_str(result, aItem, strval, aFactory, nsCtx, errInfo);
 }
 
 
@@ -1321,13 +1421,13 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_uA(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_uA(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
 T1_TO_T2(QN, str)
 {
-  uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);
+  uA_str(result, aItem, strval, aFactory, nsCtx, errInfo);
 }
 
 
@@ -1335,13 +1435,13 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_uA(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_uA(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
 T1_TO_T2(NOT, str)
 {
-  uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);
+  uA_str(result, aItem, strval, aFactory, nsCtx, errInfo);
 }
 
 
@@ -1349,13 +1449,13 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_uA(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_uA(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
 T1_TO_T2(uint, str)
 {
-  uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo);
+  uA_str(result, aItem, strval, aFactory, nsCtx, errInfo);
 }
 
 
@@ -1387,7 +1487,7 @@
 {
   zstring strval2;
   aItem->getStringValue2(strval2);
-  str_int(result, aItem, strval2, aFactory, nsCtx, aErrorInfo);
+  str_int(result, aItem, strval2, aFactory, nsCtx, errInfo);
 }
 
 
@@ -1398,9 +1498,9 @@
     xs_nonNegativeInteger const n(aItem->getFloatValue());
     aFactory->createNonNegativeInteger(result, n);
   }
-  catch ( std::exception const& ) 
+  catch (const std::exception& ) 
   {
-    throwTypeException( err::FOCA0002, aErrorInfo );
+    throwFOCA0002Exception(aItem->getStringValue(), errInfo);
   }
 }
 
@@ -1412,9 +1512,9 @@
     xs_nonNegativeInteger const n(aItem->getIntegerValue());
     aFactory->createNonNegativeInteger(result, n);
   }
-  catch ( std::exception const& ) 
+  catch (const std::exception& ) 
   {
-    throwTypeException( err::FOCA0002, aErrorInfo );
+    throwFOCA0002Exception(aItem->getStringValue(), errInfo);
   }
 }
 
@@ -1426,9 +1526,9 @@
     xs_integer const n(aItem->getIntegerValue());
     aFactory->createInteger(result, n);
   }
-  catch ( std::exception const& ) 
+  catch (const std::exception& ) 
   {
-    throwTypeException( err::FOCA0002, aErrorInfo );
+    throwFOCA0002Exception(aItem->getStringValue(), errInfo);
   }
 }
 
@@ -1440,9 +1540,9 @@
     xs_nonNegativeInteger const n(aItem->getDoubleValue());
     aFactory->createInteger(result, n);
   }
-  catch ( std::exception const& ) 
+  catch (const std::exception& ) 
   {
-    throwTypeException( err::FOCA0002, aErrorInfo );
+    throwFOCA0002Exception(aItem->getStringValue(), errInfo);
   }
 }
 
@@ -1463,24 +1563,6 @@
 }
 
 
-T1_TO_T2(str, uint)
-{
-  try 
-  {
-    xs_nonNegativeInteger const n(strval.c_str());
-    aFactory->createNonNegativeInteger(result, n);
-  }
-  catch ( std::invalid_argument const& )
-  {
-    throwTypeException( err::FORG0001, aErrorInfo );
-  }
-  catch ( std::range_error const& )
-  {
-    throwTypeException( err::FOCA0002, aErrorInfo );
-  }
-}
-
-
 T1_TO_T2(NUL, str)
 {
   zstring val("null");
@@ -1496,7 +1578,7 @@
     const store::Item* aItem,
     store::SchemaTypeCode aTargetAtomicType,
     store::ItemFactory* factory,
-    const ErrorInfo& aErrorInfo)
+    const ErrorInfo& errInfo)
 {
   zstring strval;
   aItem->getStringValue2(strval);
@@ -1557,7 +1639,7 @@
     ascii::normalize_whitespace(strval);
     ascii::trim_whitespace(strval);
 
-    if (GenericCast::instance()->castableToNCName(strval))
+    if (GenericCast::castableToNCName(strval))
     {
       factory->createNCName(result, strval);
       return;
@@ -1566,7 +1648,7 @@
   }
   case store::XS_ID:
   {
-    if (GenericCast::instance()->castableToNCName(strval))
+    if (GenericCast::castableToNCName(strval))
     {
       factory->createID(result, strval);
       return;
@@ -1575,7 +1657,7 @@
   }
   case store::XS_IDREF:
   {
-    if (GenericCast::instance()->castableToNCName(strval))
+    if (GenericCast::castableToNCName(strval))
     {
       factory->createIDREF(result, strval);
       return;
@@ -1584,7 +1666,7 @@
   }
   case store::XS_ENTITY:
   {
-    if (GenericCast::instance()->castableToNCName(strval))
+    if (GenericCast::castableToNCName(strval))
     {
       factory->createENTITY(result, strval);
       return;
@@ -1595,7 +1677,7 @@
     ZORBA_ASSERT(false);
   }
 
-  throwTypeException(err::FORG0001, aErrorInfo);
+  throwFORG0001Exception(strval, errInfo);
 }
 
 
@@ -1795,7 +1877,7 @@
     ZORBA_ASSERT(false);
   }
 
-  throwTypeException(err::FORG0001, errInfo);
+  throwFORG0001Exception(aItem->getStringValue(), errInfo);
 }
 
 
@@ -2047,6 +2129,7 @@
     const QueryLoc& loc)
 {
   const TypeManager* ttm = targetType->get_manager();
+
   if (ttm != tm && ttm != &GENV_TYPESYSTEM && !TypeOps::is_in_scope(tm, *targetType))
   {
     RAISE_ERROR(err::XPTY0004, loc,
@@ -2129,8 +2212,13 @@
         }
       }
 
+      xqtref_t sourceType = tm->create_value_type(item);
+
       RAISE_ERROR(err::FORG0001, loc,
-      ERROR_PARAMS(item->getStringValue(), ZED(NoCastTo_34o), udt->toSchemaString()));
+      ERROR_PARAMS(ZED(FORG0001_NoCastTo_234),
+                   item->getStringValue(),
+                   sourceType->toSchemaString(),
+                   udt->toSchemaString()));
     } // union
 #endif // ZORBA_NO_XMLSCHEMA
   } // list or union
@@ -2195,7 +2283,7 @@
     CastFunc castFunc = theCastMatrix[theMapping[sourceTypeCode]]
                                       [theMapping[targetTypeCode]];
     if (castFunc == 0)
-      throwTypeException(err::XPTY0004, errInfo);
+      throwXPTY0004Exception(errInfo);
 
     (*castFunc)(result, item, str, factory, nsCtx, errInfo);
   }
@@ -2323,7 +2411,7 @@
 
   if (sourceTypeCode == store::XS_ANY_ATOMIC)
   {
-    throwTypeException(err::XPTY0004, errInfo);
+    throwXPTY0004Exception(errInfo);
   }
 
   if (targetTypeCode == store::XS_NCNAME &&
@@ -2331,14 +2419,14 @@
       sourceTypeCode != store::XS_NCNAME &&
       sourceTypeCode != store::XS_UNTYPED_ATOMIC)
   {
-    throwTypeException(err::XPTY0004, errInfo);
+    throwXPTY0004Exception(errInfo);
   }
 
   CastFunc castFunc = theCastMatrix[theMapping[sourceTypeCode]]
                                     [theMapping[targetTypeCode]];
   if (castFunc == 0)
   {
-    throwTypeException(err::XPTY0004, errInfo);
+    throwXPTY0004Exception(errInfo);
   }
 
   if (theMapping[sourceTypeCode] == theMapping[store::XS_STRING])
@@ -2392,50 +2480,14 @@
     ERROR_PARAMS(ZED(BadType_23o), *sourceType, ZED(NoCastTo_45o), "QName"));
   }
 
-  ErrorInfo errorInfo(sourceType.getp(), rtm.QNAME_TYPE_ONE.getp(), loc);
+  ErrorInfo errInfo(sourceType.getp(), rtm.QNAME_TYPE_ONE.getp(), loc);
 
   zstring strval;
   item->getStringValue2(strval);
-  ascii::trim_whitespace(strval);
-
-  zstring::size_type idx = strval.find(":");
-  zstring::size_type lidx = strval.rfind(":", strval.size(), 1);
-  if (idx != lidx)
-    throwTypeException(err::FORG0001, errorInfo);
-
-  zstring prefix;
-  zstring nsuri;
-  zstring local;
-
-  if (idx == zstring::npos)
-  {
-    if (nsCtx && !isAttrName)
-    {
-      nsCtx->findBinding(prefix, nsuri);
-    }
-
-    local = strval;
-  }
-  else
-  {
-    prefix = strval.substr(0, idx);
-
-    if (!GenericCast::instance()->castableToNCName(prefix))
-      throwTypeException(err::FORG0001, errorInfo);
-
-    if (nsCtx)
-    {
-      if (!nsCtx->findBinding(prefix, nsuri))
-        throw XQUERY_EXCEPTION(err::FONS0004, ERROR_PARAMS(prefix));
-    }
-
-    local = strval.substr(idx + 1);
-  }
-
-  if (!GenericCast::instance()->castableToNCName(local.c_str()))
-    throwTypeException(err::FORG0001, errorInfo );
-
-  return GENV_ITEMFACTORY->createQName(result, nsuri, prefix, local);
+
+  str_QN(result, item, strval, GENV_ITEMFACTORY, nsCtx, errInfo);
+
+  return true;
 }
 
 

=== modified file 'src/types/schema/XercesParseUtils.cpp'
--- src/types/schema/XercesParseUtils.cpp	2012-09-19 21:16:15 +0000
+++ src/types/schema/XercesParseUtils.cpp	2013-01-10 19:32:23 +0000
@@ -67,9 +67,8 @@
   }
   else
   {
-    throw XQUERY_EXCEPTION(
-      err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "boolean" )
-    );
+    throw XQUERY_EXCEPTION(err::FORG0001, 
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:boolean"));
   }
 }
 
@@ -96,9 +95,8 @@
   }
   else
   {
-    throw XQUERY_EXCEPTION(
-      err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "integer" )
-    );
+    throw XQUERY_EXCEPTION(err::FORG0001, 
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:integer"));
   }
 }
 
@@ -125,10 +123,8 @@
   }
   else
   {
-    throw XQUERY_EXCEPTION(
-      err::FORG0001,
-      ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "positiveInteger" )
-    );
+    throw XQUERY_EXCEPTION(err::FORG0001,
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:positiveInteger"));
   }
 }
 
@@ -155,10 +151,8 @@
   }
   else
   {
-    throw XQUERY_EXCEPTION(
-      err::FORG0001,
-      ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "nonPositiveInteger" )
-    );
+    throw XQUERY_EXCEPTION(err::FORG0001,
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:nonPositiveInteger"));
   }
 }
 
@@ -185,13 +179,12 @@
   }
   else
   {
-    throw XQUERY_EXCEPTION(
-      err::FORG0001,
-      ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "negativeInteger" )
-    );
+    throw XQUERY_EXCEPTION(err::FORG0001,
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:negativeInteger"));
   }
 }
 
+
 bool XercesParseUtils::parseXSNonNegativeInteger(
     const zstring& textValue,
     store::Item_t &result)
@@ -214,13 +207,12 @@
   }
   else
   {
-    throw XQUERY_EXCEPTION(
-      err::FORG0001,
-      ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "nonNegativeInteger" )
-    );
+    throw XQUERY_EXCEPTION(err::FORG0001,
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:nonNegativeInteger"));
   }
 }
 
+
 bool XercesParseUtils::parseXSUnsignedByte(
     const zstring& textValue,
     store::Item_t &result)
@@ -243,13 +235,12 @@
   }
   else
   {
-    throw XQUERY_EXCEPTION(
-      err::FORG0001, 
-      ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "unsignedByte" )
-    );
+    throw XQUERY_EXCEPTION(err::FORG0001, 
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:unsignedByte"));
   }
 }
 
+
 bool XercesParseUtils::parseXSUnsignedShort(
     const zstring& textValue,
     store::Item_t &result)
@@ -272,12 +263,12 @@
   }
   else
   {
-    throw XQUERY_EXCEPTION(
-      err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "unsignedShort" )
-    );
+    throw XQUERY_EXCEPTION(err::FORG0001, 
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:unsignedShort"));
   }
 }
 
+
 bool XercesParseUtils::parseXSUnsignedInt(
     const zstring& textValue,
     store::Item_t &result)
@@ -300,14 +291,15 @@
   }
   else
   {
-    throw XQUERY_EXCEPTION(
-      err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "unsignedInt" )
-    );
+    throw XQUERY_EXCEPTION(err::FORG0001,
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:unsignedInt"));
   }
 }
 
+
 bool XercesParseUtils::parseXSUnsignedLong(
-    const zstring& textValue, store::Item_t &result)
+    const zstring& textValue,
+    store::Item_t &result)
 {
   XMLCh* content = XMLString::transcode(textValue.c_str());    
   XSValue::DataType datatype = XSValue::dt_unsignedLong;
@@ -327,13 +319,12 @@
   }
   else
   {
-    throw XQUERY_EXCEPTION(
-      err::FORG0001, 
-      ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "unsignedLong" )
-    );
+    throw XQUERY_EXCEPTION(err::FORG0001, 
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:unsignedLong"));
   }
 }
 
+
 bool XercesParseUtils::parseXSByte(
     const zstring& textValue,
     store::Item_t &result)
@@ -356,12 +347,12 @@
   }
   else
   {
-    throw XQUERY_EXCEPTION(
-      err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "byte" )
-    );
+    throw XQUERY_EXCEPTION(err::FORG0001,
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:byte"));
   }
 }
 
+
 bool XercesParseUtils::parseXSShort(
     const zstring& textValue,
     store::Item_t &result)
@@ -384,12 +375,12 @@
   }
   else
   {
-    throw XQUERY_EXCEPTION(
-      err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "short" )
-    );
+    throw XQUERY_EXCEPTION(err::FORG0001,
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:short"));
   }
 }
 
+
 bool XercesParseUtils::parseXSInt(
     const zstring& textValue,
     store::Item_t &result)
@@ -412,12 +403,12 @@
   }
   else
   {
-    throw XQUERY_EXCEPTION(
-      err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "int" )
-    );
+    throw XQUERY_EXCEPTION(err::FORG0001,
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:int"));
   }
 }
 
+
 bool XercesParseUtils::parseXSLong(
     const zstring& textValue,
     store::Item_t &result)
@@ -440,12 +431,12 @@
   }
   else
   {
-    throw XQUERY_EXCEPTION(
-      err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "long" )
-    );
+    throw XQUERY_EXCEPTION(err::FORG0001,
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:long"));
   }
 }
 
+
 bool XercesParseUtils::parseXSFloat(
     const zstring& textValue,
     store::Item_t &result)
@@ -470,7 +461,8 @@
     //textValue = textValue.trim(" \n\r\t",4);
     zstring textValue2;
     utf8::normalize_whitespace(textValue, &textValue2);
-    try {
+    try
+    {
       xs_float const n(textValue2.c_str());
       return GENV_ITEMFACTORY->createFloat(result, n);
     }
@@ -479,11 +471,11 @@
     }
   }
 
-  throw XQUERY_EXCEPTION(
-    err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "float" )
-  );
+  throw XQUERY_EXCEPTION(err::FORG0001,
+  ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:float"));
 }
 
+
 bool XercesParseUtils::parseXSDouble(
     const zstring& textValue,
     store::Item_t &result)
@@ -517,11 +509,11 @@
     }
   }
 
-  throw XQUERY_EXCEPTION(
-    err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "double" )
-  );
+  throw XQUERY_EXCEPTION(err::FORG0001,
+  ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:double"));
 }
 
+
 bool XercesParseUtils::parseXSDecimal(
     const zstring& textValue,
     store::Item_t &result)
@@ -542,12 +534,12 @@
   }
   else
   {
-    throw XQUERY_EXCEPTION(
-      err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "decimal" )
-    );
+    throw XQUERY_EXCEPTION(err::FORG0001,
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:decimal"));
   }
 }
 
+
 // string types
 bool XercesParseUtils::parseXSString(
     const zstring& textValue,
@@ -560,6 +552,7 @@
   return factory->createString(result, textValue2);
 }
 
+
 bool XercesParseUtils::parseXSNormalizedString(
     const zstring& textValue,
     store::Item_t &result)
@@ -600,9 +593,8 @@
   }
   else
   {
-    throw XQUERY_EXCEPTION(
-      err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "NMToken" )
-    );
+    throw XQUERY_EXCEPTION(err::FORG0001,
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:NMToken"));
   }
 }
 
@@ -629,9 +621,8 @@
   }
   else
   {
-    throw XQUERY_EXCEPTION(
-      err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "NMToken" )
-    );
+    throw XQUERY_EXCEPTION(err::FORG0001,
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:NMToken"));
   }
 }
 
@@ -659,9 +650,8 @@
   }
   else
   {
-    throw XQUERY_EXCEPTION(
-      err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "Name" )
-    );
+    throw XQUERY_EXCEPTION(err::FORG0001,
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:Name"));
   }
 }
 
@@ -688,9 +678,8 @@
   }
   else
   {
-    throw XQUERY_EXCEPTION(
-      err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "NCName" )
-    );
+    throw XQUERY_EXCEPTION(err::FORG0001,
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:NCName"));
   }
 }
 
@@ -717,9 +706,8 @@
   }
   else
   {
-    throw XQUERY_EXCEPTION(
-      err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "ID" )
-    );
+    throw XQUERY_EXCEPTION(err::FORG0001,
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:ID"));
   }
 }
 
@@ -746,9 +734,8 @@
   }
   else
   {
-    throw XQUERY_EXCEPTION(
-      err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "IDREF" )
-    );
+    throw XQUERY_EXCEPTION(err::FORG0001,
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:IDREF"));
   }
 }
 
@@ -775,9 +762,8 @@
   }
   else
   {
-    throw XQUERY_EXCEPTION(
-      err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "ENTITY" )
-    );
+    throw XQUERY_EXCEPTION(err::FORG0001,
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:ENTITY"));
   }
 }
 
@@ -804,9 +790,8 @@
   }
   else
   {
-    throw XQUERY_EXCEPTION(
-      err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "NOTATION" )
-    );
+    throw XQUERY_EXCEPTION(err::FORG0001,
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:NOTATION"));
   }
 }
 
@@ -855,9 +840,8 @@
     }
   }
 
-  throw XQUERY_EXCEPTION(
-    err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "dateTime" )
-  );
+  throw XQUERY_EXCEPTION(err::FORG0001,
+  ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:dateTime"));
 }
 
 
@@ -896,9 +880,8 @@
     }
   }
 
-  throw XQUERY_EXCEPTION(
-    err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "date" )
-  );
+  throw XQUERY_EXCEPTION(err::FORG0001,
+  ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:date"));
 }
 
 
@@ -942,9 +925,8 @@
     }
   }
 
-  throw XQUERY_EXCEPTION(
-    err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "time" )
-  );
+  throw XQUERY_EXCEPTION(err::FORG0001,
+  ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:time"));
 }
 
 
@@ -978,9 +960,8 @@
     }
   }
 
-  throw XQUERY_EXCEPTION(
-    err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "gYearMonth" )
-  );
+  throw XQUERY_EXCEPTION(err::FORG0001,
+  ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:gYearMonth"));
 }
 
 
@@ -1013,9 +994,8 @@
     }
   }
   
-  throw XQUERY_EXCEPTION(
-    err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "gYear" )
-  );
+  throw XQUERY_EXCEPTION(err::FORG0001,
+  ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:gYear"));
 }
 
 
@@ -1048,9 +1028,8 @@
     }
   }
 
-  throw XQUERY_EXCEPTION(
-    err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "gMonthDay" )
-  );
+  throw XQUERY_EXCEPTION(err::FORG0001,
+  ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:gMonthDay"));
 }
 
 
@@ -1082,9 +1061,8 @@
     }
   }
 
-  throw XQUERY_EXCEPTION(
-    err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "gDay" )
-  );
+  throw XQUERY_EXCEPTION(err::FORG0001,
+  ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:gDay"));
 }
 
 
@@ -1116,9 +1094,8 @@
     }
   }
 
-  throw XQUERY_EXCEPTION(
-    err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "gDay" )
-  );
+  throw XQUERY_EXCEPTION(err::FORG0001,
+  ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:gDay"));
 }
 
 
@@ -1154,9 +1131,8 @@
       return factory->createDuration(result, &tValue);
   }
 
-  throw XQUERY_EXCEPTION(
-    err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "duration" )
-  );
+  throw XQUERY_EXCEPTION(err::FORG0001,
+  ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:duration"));
 }
 
 
@@ -1172,10 +1148,8 @@
     return factory->createYearMonthDuration(result, &d);
   }
 
-  throw XQUERY_EXCEPTION(
-    err::FORG0001,
-    ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "yearMonthDuration" )
-  );
+  throw XQUERY_EXCEPTION(err::FORG0001,
+  ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:yearMonthDuration"));
 }
 
 
@@ -1191,10 +1165,8 @@
     return factory->createDayTimeDuration(result, &d);
   }
 
-  throw XQUERY_EXCEPTION(
-    err::FORG0001,
-    ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "dayTimeDuration" )
-  );
+  throw XQUERY_EXCEPTION(err::FORG0001,
+  ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:dayTimeDuration"));
 }
 
 
@@ -1241,10 +1213,8 @@
     return factory->createBase64Binary(result, tValue);
   }
 
-  throw XQUERY_EXCEPTION(
-    err::FORG0001,
-    ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "base64Binary" )
-  );
+  throw XQUERY_EXCEPTION(err::FORG0001,
+  ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:base64Binary"));
 }
 
 
@@ -1269,9 +1239,8 @@
     return factory->createHexBinary(result, tValue);
   }
 
-  throw XQUERY_EXCEPTION(
-    err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "hexBinary" )
-  );
+  throw XQUERY_EXCEPTION(err::FORG0001,
+  ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:hexBinary"));
 }
 
 
@@ -1296,9 +1265,8 @@
     return factory->createAnyURI(result, textValue2);
   }
 
-  throw XQUERY_EXCEPTION(
-    err::FORG0001, ERROR_PARAMS( textValue, ZED( NoCastTo_34o ), "anyURI" )
-  );
+  throw XQUERY_EXCEPTION(err::FORG0001,
+  ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, "xs:anyURI"));
 }
 
 

=== modified file 'src/types/schema/schema.cpp'
--- src/types/schema/schema.cpp	2013-01-08 08:34:08 +0000
+++ src/types/schema/schema.cpp	2013-01-10 19:32:23 +0000
@@ -1691,7 +1691,7 @@
       if (!xsiTypeDV)
       {
         RAISE_ERROR(err::FORG0001, loc,
-        ERROR_PARAMS(targetType, ZED(NoTypeInCtx)));
+        ERROR_PARAMS(ZED(FORG0001_NoTypeInCtx_2), targetType->toSchemaString()));
       }
 
       // workaround for validating xs:NOTATION with Xerces
@@ -1712,8 +1712,8 @@
         }
         else
         {
-          ZORBA_ERROR_DESC_OSS(err::FORG0001, "Prefix '" << prefix <<
-              "' not found in current namespace context.");
+          RAISE_ERROR(err::FORG0001, loc,
+          ERROR_PARAMS(ZED(FORG0001_PrefixNotBound_2), prefix));
         }
       }
       else
@@ -1725,7 +1725,7 @@
     else
     {
       RAISE_ERROR(err::FORG0001, loc,
-      ERROR_PARAMS(targetType, ZED(NoTypeInCtx)));
+      ERROR_PARAMS(ZED(FORG0001_NoTypeInCtx_2), targetType->toSchemaString()));
     }
   }
   catch (XMLException& idve)
@@ -1734,7 +1734,10 @@
     transcode(idve.getMessage(), msg);
 
     RAISE_ERROR(err::FORG0001, loc,
-    ERROR_PARAMS(textValue, ZED(NoCastTo_34o), targetType, msg));
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o),
+                 textValue,
+                 targetType->toSchemaString(),
+                 msg));
   }
   catch(const OutOfMemoryException&)
   {
@@ -1831,7 +1834,7 @@
   if (atomicTextValues.empty())
   {
     RAISE_ERROR(err::FORG0001, loc,
-    ERROR_PARAMS(textValue, ZED(NoCastTo_34o), udt->toSchemaString()));
+    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, udt->toSchemaString()));
   }
 
   for (csize i = 0; i < atomicTextValues.size() ; ++i)
@@ -1881,7 +1884,7 @@
   }
 
   RAISE_ERROR(err::FORG0001, loc,
-  ERROR_PARAMS(textValue, ZED(NoCastTo_34o), udt->toSchemaString()));
+  ERROR_PARAMS(ZED(FORG0001_NoCastTo_234o), textValue, udt->toSchemaString()));
 }
 
 
@@ -1906,8 +1909,7 @@
   const UserDefinedXQType* udXQType =
     static_cast<const UserDefinedXQType*>(aTargetType.getp());
 
-  ZORBA_ASSERT( udXQType->isAtomic() || udXQType->isList() ||
-                udXQType->isUnion() );
+  ZORBA_ASSERT(udXQType->isAtomic() || udXQType->isList() || udXQType->isUnion());
 
 
   switch ( udXQType->getTypeCategory() )

=== modified file 'src/zorbatypes/URI.cpp'
--- src/zorbatypes/URI.cpp	2012-09-19 21:16:15 +0000
+++ src/zorbatypes/URI.cpp	2013-01-10 19:32:23 +0000
@@ -945,26 +945,30 @@
         {
           if ( lIndex + 2 >= lEnd )
           {
-            throw XQUERY_EXCEPTION(
-              err::XQST0046, ERROR_PARAMS( uri, ZED( BadHexSequence ) )
-            );
+            throw XQUERY_EXCEPTION(err::XQST0046,
+            ERROR_PARAMS(uri, ZED(BadHexSequence)));
           }
+
           unicode::code_point lHex1 = lCodepoints[++lIndex];
-          if(!ascii::is_xdigit(lHex1))
-            throw XQUERY_EXCEPTION(
-              err::XQST0046, ERROR_PARAMS( uri, ZED( BadHexDigit_3 ), lHex1 )
-            );
+
+          if (!ascii::is_xdigit(lHex1))
+          {
+            throw XQUERY_EXCEPTION(err::XQST0046,
+            ERROR_PARAMS(uri, ZED(XQST0046_BadHexDigit_3), lHex1));
+          }
+
           unicode::code_point lHex2 = lCodepoints[++lIndex];
-          if(!ascii::is_xdigit(lHex2))
-            throw XQUERY_EXCEPTION(
-              err::XQST0046, ERROR_PARAMS( uri, ZED( BadHexDigit_3 ), lHex2 )
-            );
+
+          if (!ascii::is_xdigit(lHex2))
+          {
+            throw XQUERY_EXCEPTION(err::XQST0046,
+            ERROR_PARAMS(uri, ZED(XQST0046_BadHexDigit_3), lHex2));
+          }
         }
         else if (!is_unreserved_char(lCp) && !is_path_character(lCp) && valid)
         {
-          throw XQUERY_EXCEPTION(
-            err::XQST0046, ERROR_PARAMS( uri, ZED( BadUnicodeChar_3 ), lCp )
-          );
+          throw XQUERY_EXCEPTION(err::XQST0046,
+          ERROR_PARAMS(uri, ZED(BadUnicodeChar_3), lCp));
         }
         ++lIndex;
       }

=== modified file 'src/zorbatypes/binary.cpp'
--- src/zorbatypes/binary.cpp	2012-09-19 21:16:15 +0000
+++ src/zorbatypes/binary.cpp	2013-01-10 19:32:23 +0000
@@ -28,16 +28,16 @@
 #include "util/base64_util.h"
 #include "util/stl_util.h"
 
-#define CATCH_BASE64_EXCEPTION()                                            \
-  catch ( base64::exception const &e ) {                                    \
-    throw XQUERY_EXCEPTION(                                                 \
-      err::FORG0001, ERROR_PARAMS( e.invalid_char(), ZED( Base64BadChar ) ) \
-    );                                                                      \
-  }                                                                         \
-  catch ( std::invalid_argument const& ) {                                  \
-    throw XQUERY_EXCEPTION(                                                 \
-      err::FORG0001, ERROR_PARAMS( "", ZED( Base64Multiple4 ) )             \
-    );                                                                      \
+#define CATCH_BASE64_EXCEPTION()                                        \
+  catch (const base64::exception& e)                                    \
+  {                                                                     \
+    throw XQUERY_EXCEPTION(err::FORG0001,                               \
+    ERROR_PARAMS(ZED(FORG0001_Base64BadChar_2), e.invalid_char()));     \
+  }                                                                     \
+  catch (const std::invalid_argument& )                                 \
+  {                                                                     \
+    throw XQUERY_EXCEPTION(err::FORG0001,                               \
+    ERROR_PARAMS(ZED(FORG0001_Base64Multiple4)));                       \
   }
 
 using namespace std;
@@ -330,9 +330,8 @@
 
   if (len % 2 != 0) 
   {
-    throw XQUERY_EXCEPTION(
-      err::FORG0001, ERROR_PARAMS( "", ZED( HexBinaryMustBeEven ) )
-    );
+    throw XQUERY_EXCEPTION(err::FORG0001,
+    ERROR_PARAMS(ZED(FORG0001_HexBinaryMustBeEven)));
   }
 
   for (size_t i = 0; i < len; ++i)
@@ -349,9 +348,8 @@
     }
     else
     {
-      throw XQUERY_EXCEPTION(
-        err::FORG0001, ERROR_PARAMS( lChar, ZED( BadHexDigit_3 ), lChar )
-      );
+      throw XQUERY_EXCEPTION(err::FORG0001,
+      ERROR_PARAMS(ZED(FORG0001_BadHexDigit_2), lChar));
     }
   }
 }


Follow ups