Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/markos-scratch into lp:zorba.
Requested reviews: Markos Zaharioudakis (markos-za) For more details, see: https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/86380 allow for the default element and function namespaces to be set multiple times via the c++ api -- https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/86380 Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/api/staticcontextimpl.cpp' --- src/api/staticcontextimpl.cpp 2011-12-20 09:04:58 +0000 +++ src/api/staticcontextimpl.cpp 2011-12-20 11:12:31 +0000 @@ -194,7 +194,7 @@ ********************************************************************************/ String -StaticContextImpl::getNamespaceURIByPrefix( const String& aPrefix ) const +StaticContextImpl::getNamespaceURIByPrefix(const String& aPrefix) const { try { @@ -220,12 +220,11 @@ ********************************************************************************/ bool -StaticContextImpl::setDefaultElementAndTypeNamespace( const String& aURI ) +StaticContextImpl::setDefaultElementAndTypeNamespace(const String& aURI) { ZORBA_TRY const zstring& lURI = Unmarshaller::getInternalString(aURI); - QueryLoc loc; - theCtx->set_default_elem_type_ns(lURI, loc); + theCtx->set_default_elem_type_ns(lURI, false, QueryLoc::null); return true; ZORBA_CATCH return false; @@ -236,7 +235,7 @@ ********************************************************************************/ String -StaticContextImpl::getDefaultElementAndTypeNamespace( ) const +StaticContextImpl::getDefaultElementAndTypeNamespace() const { try { @@ -258,12 +257,12 @@ ********************************************************************************/ bool -StaticContextImpl::setDefaultFunctionNamespace( const String& aURI ) +StaticContextImpl::setDefaultFunctionNamespace(const String& aURI) { ZORBA_TRY const zstring& lURI = Unmarshaller::getInternalString(aURI); QueryLoc loc; - theCtx->set_default_function_ns(lURI, loc); + theCtx->set_default_function_ns(lURI, false, loc); return true; ZORBA_CATCH return false; === modified file 'src/compiler/translator/translator.cpp' --- src/compiler/translator/translator.cpp 2011-12-20 09:04:58 +0000 +++ src/compiler/translator/translator.cpp 2011-12-20 11:12:31 +0000 @@ -1981,7 +1981,7 @@ RAISE_ERROR(err::XQST0070, loc, ERROR_PARAMS(pfx, ZED(NoRebindPrefix))); if (prefix->get_default_bit()) - theSctx->set_default_elem_type_ns(targetNS, loc); + theSctx->set_default_elem_type_ns(targetNS, true, loc); if (! pfx.empty()) theSctx->bind_ns(pfx, targetNS, loc, err::XQST0033); @@ -2658,10 +2658,10 @@ switch (v.get_mode()) { case ParseConstants::ns_element_default: - theSctx->set_default_elem_type_ns(v.get_default_namespace(), loc); + theSctx->set_default_elem_type_ns(v.get_default_namespace(), true, loc); break; case ParseConstants::ns_function_default: - theSctx->set_default_function_ns(v.get_default_namespace(), loc); + theSctx->set_default_function_ns(v.get_default_namespace(), true, loc); break; } return NULL; @@ -10841,35 +10841,29 @@ { if ((ZSTREQ(prefix, "xml") && !ZSTREQ(uri, XML_NS))) { - throw XQUERY_EXCEPTION( - err::XQST0070, - ERROR_PARAMS( prefix, ZED( NoRebindPrefix ) ), - ERROR_LOC( loc ) - ); + RAISE_ERROR(err::XQST0070, loc, + ERROR_PARAMS(prefix, ZED(NoRebindPrefix))); } if ((ZSTREQ(uri, XML_NS) && !ZSTREQ(prefix, "xml")) || ZSTREQ(uri, XMLNS_NS)) { - throw XQUERY_EXCEPTION( - err::XQST0070, ERROR_PARAMS( uri, ZED( NoBindURI ) ), ERROR_LOC( loc ) - ); + RAISE_ERROR(err::XQST0070, loc, ERROR_PARAMS(uri, ZED(NoBindURI))); } theSctx->bind_ns(prefix, uri, loc, err::XQST0071); theNSCtx->bind_ns(prefix, uri); if (prefix.empty()) - theSctx->set_default_elem_type_ns(uri, loc); + theSctx->set_default_elem_type_ns(uri, true, loc); } else if (valueExpr == NULL) { if (ZSTREQ(prefix, "xml")) - throw XQUERY_EXCEPTION( - err::XQST0070, - ERROR_PARAMS( prefix, ZED( NoRebindPrefix ) ), - ERROR_LOC( loc ) - ); + { + RAISE_ERROR(err::XQST0070, loc, + ERROR_PARAMS(prefix, ZED(NoRebindPrefix))); + } // unbind the prefix zstring empty; @@ -10877,7 +10871,7 @@ theNSCtx->bind_ns(prefix, empty); if (prefix.empty()) - theSctx->set_default_elem_type_ns(empty, loc); + theSctx->set_default_elem_type_ns(empty, true, loc); } else { === modified file 'src/context/root_static_context.cpp' --- src/context/root_static_context.cpp 2011-12-20 09:04:58 +0000 +++ src/context/root_static_context.cpp 2011-12-20 11:12:31 +0000 @@ -82,9 +82,9 @@ bind_ns(pfx, ns, loc); } - set_default_elem_type_ns(zstring(), loc); + set_default_elem_type_ns(zstring(), true, loc); - set_default_function_ns(W3C_FN_NS, loc); + set_default_function_ns(W3C_FN_NS, true, loc); set_context_item_type(GENV_TYPESYSTEM.ITEM_TYPE_ONE); === modified file 'src/context/static_context.cpp' --- src/context/static_context.cpp 2011-12-20 09:04:58 +0000 +++ src/context/static_context.cpp 2011-12-20 11:12:31 +0000 @@ -1792,6 +1792,7 @@ ********************************************************************************/ void static_context::set_default_elem_type_ns( const zstring& ns, + bool raiseError, const QueryLoc& loc) { if (!theHaveDefaultElementNamespace) @@ -1799,9 +1800,13 @@ theDefaultElementNamespace = ns; theHaveDefaultElementNamespace = true; } + else if (raiseError) + { + throw XQUERY_EXCEPTION(err::XQST0066, ERROR_LOC(loc)); + } else { - throw XQUERY_EXCEPTION(err::XQST0066, ERROR_LOC(loc)); + theDefaultElementNamespace = ns; } } @@ -1827,6 +1832,7 @@ ********************************************************************************/ void static_context::set_default_function_ns( const zstring& ns, + bool raiseError, const QueryLoc& loc) { if (!theHaveDefaultFunctionNamespace) @@ -1834,9 +1840,13 @@ theDefaultFunctionNamespace = ns; theHaveDefaultFunctionNamespace = true; } + else if (raiseError) + { + throw XQUERY_EXCEPTION(err::XQST0066, ERROR_LOC(loc)); + } else { - throw XQUERY_EXCEPTION(err::XQST0066, ERROR_LOC(loc)); + theDefaultFunctionNamespace = ns; } } === modified file 'src/context/static_context.h' --- src/context/static_context.h 2011-12-20 09:04:58 +0000 +++ src/context/static_context.h 2011-12-20 11:12:31 +0000 @@ -739,11 +739,17 @@ // const zstring& default_elem_type_ns() const; - void set_default_elem_type_ns(const zstring& ns, const QueryLoc& loc); + void set_default_elem_type_ns( + const zstring& ns, + bool raiseError, + const QueryLoc& loc); const zstring& default_function_ns() const; - void set_default_function_ns(const zstring& ns, const QueryLoc& loc); + void set_default_function_ns( + const zstring& ns, + bool raiseError, + const QueryLoc& loc); void bind_ns( const zstring& prefix,
-- 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