void SimpleLazyTempSeqIter::init( const store::TempSeq_t& seq, xs_integer startPos, xs_integer endPos) { assert(seq->isLazy()); theTempSeq = static_cast<SimpleLazyTempSeq*>(seq.getp()); try { theStartPos = to_xs_long(startPos); } catch ( std::range_error const& ) { throw ZORBA_EXCEPTION( zerr::ZSTR0060_RANGE_EXCEPTION, ERROR_PARAMS( startPos, ZED( ZSTR0060_ForSequence ) ) ); } try { theEndPos = to_xs_long(endPos); } catch ( std::range_error const& ) { throw ZORBA_EXCEPTION( zerr::ZSTR0060_RANGE_EXCEPTION, ERROR_PARAMS( endPos, ZED( ZSTR0060_ForSequence ) ) ); } theCurPos = theStartPos - 1; }
AnnotationList::RuleBitSet AnnotationList::checkDuplicateDeclarations( DeclarationKind declKind, const QueryLoc& loc) const { RuleBitSet lCurrAnn; // mark and detect duplicates for (Annotations::const_iterator ite = theAnnotationList.begin(); ite != theAnnotationList.end(); ++ite) { const store::Item* qname = (*ite)->getQName(); AnnotationId id = (*ite)->getId(); // detect duplicate annotations (if we "know" them) if (id != AnnotationInternal::zann_end && lCurrAnn.test(id)) { if (declKind == var_decl) { RAISE_ERROR(err::XQST0116, loc, ERROR_PARAMS(ZED(XQST0116_Duplicate), qname->getStringValue())); } else { RAISE_ERROR(err::XQST0106, loc, ERROR_PARAMS(ZED(XQST0106_Duplicate), qname->getStringValue())); } } lCurrAnn.set(id); } return lCurrAnn; }
Item ItemFactoryImpl::createQName( const String& aNamespace, const String& aPrefix, const String& aLocalname) { zstring const &lNamespace = Unmarshaller::getInternalString( aNamespace ); zstring const &lPrefix = Unmarshaller::getInternalString( aPrefix ); zstring const &lLocalname = Unmarshaller::getInternalString( aLocalname ); if (!GenericCast::instance()->castableToNCName(lLocalname.c_str())) { RAISE_ERROR_NO_LOC(err::FORG0001, ERROR_PARAMS(ZED(FORG0001_LocalNotNCName_2), lLocalname)); } if (lPrefix.size() && !GenericCast::instance()->castableToNCName(lPrefix.c_str())) { RAISE_ERROR_NO_LOC(err::FORG0001, ERROR_PARAMS(ZED(FORG0001_PrefixNotNCName_2), lPrefix)); } store::Item_t lItem; theItemFactory->createQName(lItem, lNamespace, lPrefix, lLocalname); return &*lItem; }
SimpleLazyTempSeqIter::SimpleLazyTempSeqIter( const SimpleLazyTempSeq* tempSeq, xs_integer startPos, xs_integer endPos) : theTempSeq(const_cast<SimpleLazyTempSeq*>(tempSeq)) { try { theStartPos = to_xs_long(startPos); } catch ( std::range_error const& ) { throw ZORBA_EXCEPTION( zerr::ZSTR0060_RANGE_EXCEPTION, ERROR_PARAMS( startPos, ZED( ZSTR0060_ForSequence ) ) ); } try { theEndPos = to_xs_long(endPos); } catch ( std::range_error const& ) { throw ZORBA_EXCEPTION( zerr::ZSTR0060_RANGE_EXCEPTION, ERROR_PARAMS( endPos, ZED( ZSTR0060_ForSequence ) ) ); } theCurPos = theStartPos - 1; }
bool OpNumericUnaryIterator::nextImpl(store::Item_t& result, PlanState& planState) const { store::Item_t item; store::SchemaTypeCode type; const TypeManager* tm = theSctx->get_typemanager(); PlanIteratorState* state; DEFAULT_STACK_INIT(PlanIteratorState, state, planState); if (consumeNext(item, theChild.getp(), planState )) { assert(item->isAtomic()); type = item->getTypeCode(); if (type == store::XS_UNTYPED_ATOMIC) { GenericCast::castToBuiltinAtomic(item, item, store::XS_DOUBLE, NULL, loc); type = store::XS_DOUBLE; } // TODO Optimizations (e.g. if item has already the correct type and value, // it does not have to be created newly) if (TypeOps::is_subtype(type, store::XS_DOUBLE)) { GENV_ITEMFACTORY-> createDouble(result, (thePlus ? item->getDoubleValue() : -item->getDoubleValue())); } else if (TypeOps::is_subtype(type, store::XS_FLOAT)) { GENV_ITEMFACTORY-> createFloat(result, (thePlus ? item->getFloatValue() : -item->getFloatValue())); } else if (TypeOps::is_subtype(type, store::XS_INTEGER)) { GENV_ITEMFACTORY-> createInteger(result, (thePlus ? item->getIntegerValue() : -item->getIntegerValue())); } else if (TypeOps::is_subtype(type, store::XS_DECIMAL)) { GENV_ITEMFACTORY-> createDecimal(result, (thePlus ? item->getDecimalValue() : -item->getDecimalValue())); } else { xqtref_t type = tm->create_value_type(item); RAISE_ERROR(err::XPTY0004, loc, ERROR_PARAMS(ZED(BadTypeFor_23), type->toSchemaString(), ZED(UnaryArithOp))); } STACK_PUSH(true, state); } STACK_END(state); }
void dynamic_context::get_variable( ulong varid, const store::Item_t& varname, const QueryLoc& loc, store::Item_t& itemValue, store::TempSeq_t& seqValue) const { itemValue = NULL; seqValue = NULL; if (varid >= theVarValues.size() || theVarValues[varid].theState == VarValue::undeclared) { zstring varName = static_context::var_name(varname.getp()); if (varid >= theVarValues.size() || theVarValues[varid].theIsExternalOrLocal || (varid > 0 && varid < MAX_IDVARS_RESERVED)) { RAISE_ERROR(err::XPDY0002, loc, ERROR_PARAMS(ZED(XPDY0002_VariableUndeclared_2), varName)); } else { RAISE_ERROR(err::XQDY0054, loc, ERROR_PARAMS(varName)); } } const VarValue& var = theVarValues[varid]; if (var.theState == VarValue::declared) { zstring varName = static_context::var_name(varname.getp()); if (var.theIsExternalOrLocal) { RAISE_ERROR(err::XPDY0002, loc, ERROR_PARAMS(ZED(XPDY0002_VariableHasNoValue_2), varName)); } else { RAISE_ERROR(err::XQDY0054, loc, ERROR_PARAMS(varName)); } } if (var.theState == VarValue::item) itemValue = var.theValue.item; else seqValue = var.theValue.temp_seq; }
void cacheable_function::useLegacyCache(XQueryDiagnostics* aDiag) { if (isUpdating() || isVariadic()) { if (aDiag) { aDiag->add_warning( NEW_XQUERY_WARNING(zwarn::ZWST0005_CACHING_NOT_POSSIBLE, WARN_PARAMS(getName()->getStringValue(), isUpdating() ? ZED(ZWST0005_UPDATING) : ZED(ZWST0005_VARIADIC)), WARN_LOC(theLoc))); } theHasCache = false; return; } if (isSequential() || !isDeterministic()) { if (aDiag) { aDiag->add_warning( NEW_XQUERY_WARNING(zwarn::ZWST0006_CACHING_MIGHT_NOT_BE_INTENDED, WARN_PARAMS(getName()->getStringValue(), (isSequential() ? "sequential" : "non-deterministic")), WARN_LOC(theLoc))); } } parseCachingAnnotations(aDiag); theHasCache = true; theIsCacheAutomatic = false; theCacheAcrossSnapshots = true; }
void relpath_expr::compute_scripting_kind() { theScriptingKind = UNKNOWN_SCRIPTING_KIND; for (unsigned i = 0; i < size(); ++i) { expr* step = theSteps[i]; if (step->is_updating()) { throw XQUERY_EXCEPTION(err::XUST0001, ERROR_PARAMS(ZED(XUST0001_Generic)), ERROR_LOC(get_loc())); } theScriptingKind |= step->get_scripting_detail(); } theScriptingKind &= ~VACUOUS_EXPR; if (is_sequential(theScriptingKind)) theScriptingKind &= ~SIMPLE_EXPR; checkScriptingKind(); }
void AnnotationList::checkLiterals(DeclarationKind k, const QueryLoc& loc) const { for (Annotations::const_iterator ite = theAnnotationList.begin(); ite != theAnnotationList.end(); ++ite) { AnnotationInternal* lAnn = *ite; switch (lAnn->getId()) { case AnnotationInternal::zann_exclude_from_cache_key: case AnnotationInternal::zann_compare_with_deep_equal: //One or more integers if (!lAnn->getNumLiterals()) { RAISE_ERROR(zerr::ZXQP0062_INVALID_ANNOTATION_LITERALS_NUMBER, loc, ERROR_PARAMS( AnnotationInternal::lookup(lAnn->getId())->getStringValue(), ZED(ZXQP0062_ONE_OR_MORE_LITERALS))); } for (csize i=0; i<lAnn->getNumLiterals(); ++i) checkLiteralType(lAnn, lAnn->getLiteral(i), store::XS_INTEGER, loc); break; default: break; } } }
static void x2j_children( store::Item_t const &parent, vector<store::Item_t> *children ) { ZORBA_ASSERT( children ); store::Iterator_t i( parent->getChildren() ); i->open(); store::Item_t child_item, temp_item; while ( i->next( child_item ) ) { if ( !x2j_map_atomic( child_item, &temp_item ) ) { if ( !child_item->isNode() ) throw XQUERY_EXCEPTION( zerr::ZJ2X0001_JSONML_ARRAY_BAD_JSON, ERROR_PARAMS( ZED( ZJ2X0001_BadElement ), child_item->getKind() ) ); switch ( child_item->getNodeKind() ) { case store::StoreConsts::elementNode: x2j_element( child_item, &temp_item ); break; case store::StoreConsts::textNode: { zstring s( child_item->getStringValue() ); GENV_ITEMFACTORY->createString( temp_item, s ); break; } default: continue; } // switch } // if children->push_back( temp_item ); } // while i->close(); }
/******************************************************************************* declare function is-available-document($uri as xs:string) as xs:boolean ********************************************************************************/ bool IsAvailableDocumentIterator::nextImpl( store::Item_t& result, PlanState& aPlanState) const { zstring lRetrievedUriString; zstring lResolvedUriString; store::Item_t lUri; PlanIteratorState* state; DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState); consumeNext(lUri, theChildren[0].getp(), aPlanState); // absolutize retrieved uri try { lUri->getStringValue2(lRetrievedUriString); lResolvedUriString = theSctx->resolve_relative_uri(lRetrievedUriString, true); } catch (ZorbaException const&) { RAISE_ERROR(err::FODC0004, loc, ERROR_PARAMS(lResolvedUriString, ZED(NoResolveRelativeURI))); } // check if document exists in the store GENV_ITEMFACTORY-> createBoolean(result, GENV_STORE.getDocument(lResolvedUriString) != NULL); STACK_PUSH(true, state); STACK_END(state); }
void SimpleLazyTempSeq::purgeUpTo(xs_integer position) { xs_long pos; try { pos = to_xs_long(position); } catch (std::range_error const&) { throw ZORBA_EXCEPTION(zerr::ZSTR0060_RANGE_EXCEPTION, ERROR_PARAMS(position,ZED(ZSTR0060_ForSequence))); } ZORBA_ASSERT(pos >= thePurgedUpTo); ZORBA_ASSERT(static_cast<std::vector<store::Item*>::size_type>(pos - thePurgedUpTo) <= theItems.size()); std::vector<store::Item*>::iterator ite = theItems.begin(); std::vector<store::Item*>::iterator end = theItems.begin() + static_cast<std::vector<store::Item*>::size_type>(pos - thePurgedUpTo); for (; ite != end; ++ite) { (*ite)->removeReference(); } theItems.erase(theItems.begin(), end); thePurgedUpTo = pos; }
void SimpleLazyTempSeq::getItem(xs_integer position, store::Item_t& result) { xs_long pos; try { pos = to_xs_long(position); } catch (std::range_error const&) { RAISE_ERROR_NO_LOC(zerr::ZSTR0060_RANGE_EXCEPTION, ERROR_PARAMS(position,ZED(ZSTR0060_ForSequence))); } ZORBA_ASSERT(pos > thePurgedUpTo); std::vector<store::Item*>::size_type numItemsToBuffer = pos - thePurgedUpTo; while (!theMatFinished && theItems.size() < numItemsToBuffer) { matNextItem(); } if (theItems.size() >= numItemsToBuffer) { std::vector<store::Item*>::size_type sPos = static_cast<std::vector<store::Item*>::size_type>(pos - thePurgedUpTo - 1); result = theItems[sPos]; } else { result = NULL; } }
void AnnotationList::checkRequiredDeclarations( RuleBitSet declaredAnn, DeclarationKind declKind, const QueryLoc& loc) const { // check rules std::vector<AnnotationRequirement>::const_iterator ite = AnnotationInternal::theRequiredRuleSet.begin(); std::vector<AnnotationRequirement>::const_iterator end = AnnotationInternal::theRequiredRuleSet.end(); for (; ite != end; ++ite) { const AnnotationId& lCurrAnn = ite->first; const RuleBitSet& lCurrSet = ite->second; if (declaredAnn.test(lCurrAnn) && (declaredAnn & lCurrSet).count() == 0) { // build error string to return set of required annotations std::ostringstream lProblems; for (csize i = 0, j = 0; i < AnnotationInternal::zann_end; ++i) { if (lCurrSet.test(i)) { AnnotationId id = static_cast<AnnotationId>(i); lProblems << AnnotationInternal::lookup(id)->getStringValue() << ((j == lCurrSet.count() - 1) ? "" : ", "); ++j; } } if (declKind == var_decl) { RAISE_ERROR(err::XQST0116, loc, ERROR_PARAMS(ZED(XQST0116_Requirement), AnnotationInternal::lookup(lCurrAnn)->getStringValue(), lProblems.str())); } else { RAISE_ERROR(err::XQST0106, loc, ERROR_PARAMS(ZED(XQST0106_Requirement), AnnotationInternal::lookup(lCurrAnn)->getStringValue(), lProblems.str())); } } } }
/******************************************************************************* declare updating function remove($uri as xs:string) as empty-sequence() ********************************************************************************/ bool RemoveDocumentIterator::nextImpl( store::Item_t& result, PlanState& aPlanState) const { zstring lRetrievedUriString; zstring lResolvedUriString; store::Item_t lUri; store::Item_t lResolvedUriItem; store::PUL_t lPul; PlanIteratorState* state; DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState); consumeNext(lUri, theChildren[0].getp(), aPlanState); // absolutize retrieved uri try { lUri->getStringValue2(lRetrievedUriString); lResolvedUriString = theSctx->resolve_relative_uri(lRetrievedUriString, true); } catch (ZorbaException const&) { RAISE_ERROR(err::FODC0004, loc, ERROR_PARAMS(lResolvedUriString, ZED(NoResolveRelativeURI))); } // check if document exists in the store if (GENV_STORE.getDocument(lResolvedUriString) == NULL) { RAISE_ERROR(zerr::ZXQD0002_DOCUMENT_NOT_VALID, loc, ERROR_PARAMS(lResolvedUriString, ZED(NoURIInStore))); } // create the pul and add the primitive GENV_ITEMFACTORY->createAnyURI(lResolvedUriItem, lResolvedUriString); lPul = GENV_ITEMFACTORY->createPendingUpdateList(); lPul->addDeleteDocument(&loc, lResolvedUriItem); result.transfer(lPul); STACK_PUSH(result != NULL, state); STACK_END(state); }
void AnnotationList::checkConflictingDeclarations( RuleBitSet currAnn, DeclarationKind declKind, const QueryLoc& loc) const { // check rules std::vector<RuleBitSet>::const_iterator ite = AnnotationInternal::theConflictRuleSet.begin(); std::vector<RuleBitSet>::const_iterator end = AnnotationInternal::theConflictRuleSet.end(); for (; ite != end; ++ite) { const RuleBitSet& lCurrSet = *ite; if ((currAnn & lCurrSet).count() > 1) { // build error string to return set of conflicting annotations std::ostringstream lProblems; for (csize i = 0, j = 0; i < AnnotationInternal::zann_end; ++i) { if (lCurrSet.test(i)) { AnnotationId id = static_cast<AnnotationId>(i); lProblems << AnnotationInternal::lookup(id)->getStringValue() << ((j == (currAnn & lCurrSet).count() - 1) ? "" : ", "); ++j; } } if (declKind == var_decl) { RAISE_ERROR(err::XQST0116, loc, ERROR_PARAMS(ZED(XQST0116_Conflicting), lProblems.str())); } else { RAISE_ERROR(err::XQST0106, loc, ERROR_PARAMS(ZED(XQST0106_Conflicting), lProblems.str())); } } } }
void ArithOperationsCommons::createError( const TypeManager* tm, const char* aOp, const QueryLoc* aLoc, store::SchemaTypeCode aType0, store::SchemaTypeCode aType1) { xqtref_t t0 = tm->create_builtin_atomic_type(aType0,SequenceType::QUANT_ONE); xqtref_t t1 = tm->create_builtin_atomic_type(aType1,SequenceType::QUANT_ONE); RAISE_ERROR(err::XPTY0004, aLoc, ERROR_PARAMS(ZED(OperationNotPossibleWithTypes_234), aOp, *t0, *t1 )); }
/****************************************************************************** Create a dummy main module to wrap a library module. ******************************************************************************/ parsenode_t XQueryCompiler::createMainModule( parsenode_t aLibraryModule, std::istream& aXQuery, const zstring& aFileName) { //get the namespace from the LibraryModule LibraryModule* mod_ast = dynamic_cast<LibraryModule *>(&*aLibraryModule); if (!mod_ast) throw ZORBA_EXCEPTION(zerr::ZAPI0002_XQUERY_COMPILATION_FAILED, ERROR_PARAMS(ZED(BadLibraryModule))); const zstring& lib_namespace = mod_ast->get_decl()->get_target_namespace(); URI lURI(lib_namespace); if(!lURI.is_absolute()) { throw XQUERY_EXCEPTION(err::XQST0046, ERROR_PARAMS(lURI.toString(), ZED(MustBeAbsoluteURI)), ERROR_LOC(mod_ast->get_decl()->get_location())); } // Set up the original query stream as the result of resolving the // library module's URI aXQuery.clear(); aXQuery.seekg(0); FakeLibraryModuleURLResolver* aFakeResolver = new FakeLibraryModuleURLResolver(aFileName, aXQuery); theCompilerCB->theRootSctx->add_url_resolver(aFakeResolver); // create a dummy main module and parse it std::stringstream lDocStream; zstring tmp; zorba::xml::escape(lib_namespace, &tmp); lDocStream << "import module namespace m = '" << tmp << "'; 1"; return parse(lDocStream, aFileName); }
Item ItemFactoryImpl::createNCName(const String& aValue) { zstring lString = Unmarshaller::getInternalString(aValue); if (!GenericCast::instance()->castableToNCName(lString.c_str())) { RAISE_ERROR_NO_LOC(err::FORG0001, ERROR_PARAMS(ZED(FORG0001_NameNotNCName_2), lString)); } store::Item_t lItem; theItemFactory->createNCName(lItem, lString); return &*lItem; }
void cacheable_function::useStrictlyDeterministicCache(XQueryDiagnostics* aDiag) { if (isUpdating() || isSequential() || isVariadic()) { if (aDiag) { aDiag->add_warning( NEW_XQUERY_WARNING(zwarn::ZWST0005_CACHING_NOT_POSSIBLE, WARN_PARAMS(getName()->getStringValue(), isUpdating() ? ZED(ZWST0005_UPDATING) : (isSequential() ? ZED(ZWST0005_SEQUENTIAL) : ZED(ZWST0005_VARIADIC))), WARN_LOC(theLoc))); } theHasCache = false; } else { parseCachingAnnotations(aDiag); theHasCache = true; theIsCacheAutomatic = false; theCacheAcrossSnapshots = false; } }
/******************************************************************************* declare function document($uri as xs:string) as document-node() ********************************************************************************/ bool RetrieveDocumentIterator::nextImpl( store::Item_t& result, PlanState& aPlanState) const { zstring lRetrievedUriString; zstring lResolvedUriString; store::Item_t lUri; store::Item_t lResolvedUriItem; PlanIteratorState* state; DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState); consumeNext(lUri, theChildren[0].getp(), aPlanState); // absolutize retrieved uri try { lUri->getStringValue2(lRetrievedUriString); lResolvedUriString = theSctx->resolve_relative_uri(lRetrievedUriString, true); } catch (ZorbaException const&) { RAISE_ERROR(err::FODC0004, loc, ERROR_PARAMS(lResolvedUriString, ZED( NoResolveRelativeURI))); } // check if document exists in the store if ((result = GENV_STORE.getDocument(lResolvedUriString)) == NULL) { RAISE_ERROR(zerr::ZXQD0002_DOCUMENT_NOT_VALID, loc, ERROR_PARAMS(lResolvedUriString, ZED( NoURIInStore))); } STACK_PUSH(true, state); STACK_END(state); }
bool IntegerDivideOperation::compute<store::XS_DOUBLE,store::XS_DOUBLE>( store::Item_t& result, dynamic_context* /* dctx */, const TypeManager* /* tm */, const QueryLoc* loc, const store::Item* i0, const store::Item* i1 ) { xs_double d0 = i0->getDoubleValue(); xs_double d1 = i1->getDoubleValue(); if ( d1 == numeric_consts<xs_double>::zero() ) { throw XQUERY_EXCEPTION( err::FOAR0001, ERROR_LOC( loc ) ); } if (i0->isNaN() || i1->isNaN()) { throw XQUERY_EXCEPTION( err::FOAR0002, ERROR_PARAMS( ZED( DivisionNoNaN ) ), ERROR_LOC( loc ) ); } if (i0->isPosOrNegInf()) { throw XQUERY_EXCEPTION( err::FOAR0002, ERROR_PARAMS( ZED( DivisionNoINF ) ), ERROR_LOC( loc ) ); } if (i0->isPosOrNegInf()) { // idiv with +-INF divisor has 0 as result return GENV_ITEMFACTORY->createInteger(result, numeric_consts<xs_integer>::zero()); } xs_integer const lInteger( d0 / d1 ); return GENV_ITEMFACTORY->createInteger (result, lInteger ); }
void dynamic_context::set_variable( ulong varid, const store::Item_t& varname, const QueryLoc& loc, store::Iterator_t& valueIter) { if (varid >= theVarValues.size() || theVarValues[varid].theState == VarValue::undeclared) { RAISE_ERROR(err::XPDY0002, loc, ERROR_PARAMS(ZED(XPDY0002_VariableUndeclared_2), varname->getStringValue())); } valueIter->open(); // For now, use eager eval because the assignment expression may reference // the variable itself, and the current value of the variable is overwriten // here by this temp sequence. TODO: use lazy eval if we know the the // assignment expression does not reference the variable itself. store::TempSeq_t seq = GENV_STORE.createTempSeq(valueIter, false); // no lazy eval valueIter->close(); VarValue& var = theVarValues[varid]; // variables can be set multiple times, so we need to make sure to remove // previously set temp sequences if (var.theState == VarValue::item) { assert(var.theValue.item != NULL); var.theValue.item->removeReference(); } else if (var.theState == VarValue::temp_seq) { assert(var.theValue.temp_seq != NULL); RCHelper::removeReference(var.theValue.temp_seq); } else if (var.theState == VarValue::declared) { assert(var.theValue.item == NULL); } else { ZORBA_ASSERT(false); } var.theState = VarValue::temp_seq; var.theValue.temp_seq = seq.release(); }
void json_to_xml( store::Item_t const &json_item, store::Item_t *xml_item ) { ZORBA_ASSERT( xml_item ); switch ( json_item->getKind() ) { case store::Item::ARRAY: *xml_item = j2x_array( json_item, nullptr ); break; case store::Item::OBJECT: throw XQUERY_EXCEPTION( zerr::ZJ2X0001_JSONML_ARRAY_BAD_JSON, ERROR_PARAMS( ZED( ZJ2X0001_ArrayRequired ) ) ); default: ZORBA_ASSERT( false ); } }
/******************************************************************************* declare updating function put($uri as xs:string, $doc as xs:document-node()) as empty-sequence() ********************************************************************************/ bool PutDocumentIterator::nextImpl( store::Item_t& result, PlanState& aPlanState) const { zstring lRetrievedUriString; zstring lResolvedUriString; store::Item_t lUri; store::Item_t lDoc; store::Item_t lResolvedUriItem; std::unique_ptr<store::PUL> lPul; PlanIteratorState* state; DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState); consumeNext(lUri, theChildren[0].getp(), aPlanState); // absolutize retrieved uri try { lUri->getStringValue2(lRetrievedUriString); lResolvedUriString = theSctx->resolve_relative_uri(lRetrievedUriString, true); } catch (ZorbaException const&) { RAISE_ERROR(err::FODC0004, loc, ERROR_PARAMS(lResolvedUriString, ZED(NoResolveRelativeURI))); } // check if document already exists in the store if (GENV_STORE.getDocument(lResolvedUriString) != NULL) { RAISE_ERROR(zerr::ZAPI0020_DOCUMENT_ALREADY_EXISTS, loc, ERROR_PARAMS(lResolvedUriString)); } // create the pul and add the primitive GENV_ITEMFACTORY->createAnyURI(lResolvedUriItem, lResolvedUriString); lPul.reset(GENV_ITEMFACTORY->createPendingUpdateList()); consumeNext(lDoc, theChildren[1].getp(), aPlanState); lPul->addCreateDocument(&loc, lResolvedUriItem, lDoc); result = lPul.release(); STACK_PUSH(result != NULL, state); STACK_END(state); }
static bool get_bool_opt( store::Item_t const &object, char const *opt_name, bool *result ) { store::Item_t opt_item; if ( get_json_option( object, opt_name, &opt_item ) ) { if ( !IS_ATOMIC_TYPE( opt_item, XS_BOOLEAN ) ) throw XQUERY_EXCEPTION( jse::INVALID_OPTION, ERROR_PARAMS( opt_item->getStringValue(), opt_name, ZED( INVALID_OPTION_jse_MustBeBoolean ) ) ); *result = opt_item->getBooleanValue(); return true; } return false; }
void relpath_expr::add_back(expr* step) { if (step->is_updating()) { throw XQUERY_EXCEPTION(err::XUST0001, ERROR_PARAMS(ZED(XUST0001_Generic)), ERROR_LOC(get_loc())); } theScriptingKind |= step->get_scripting_detail(); if (theScriptingKind & VACUOUS_EXPR) theScriptingKind &= ~VACUOUS_EXPR; if (is_sequential(theScriptingKind)) theScriptingKind &= ~SIMPLE_EXPR; checkScriptingKind(); theSteps.push_back(step); }
// --------------------------------------------------------------------------- // LoadSchemaErrorHandler: Overrides of the SAX ErrorHandler interface // --------------------------------------------------------------------------- void LoadSchemaErrorHandler::error(const XERCES_CPP_NAMESPACE::SAXParseException& e) { zstring system_id, public_id; if ( e.getSystemId() ) system_id = StrX( e.getSystemId() ).localFormOrDefault( "" ); if ( e.getPublicId() ) public_id = StrX( e.getPublicId() ).localFormOrDefault( "" ); theSawErrors = true; throw XQUERY_EXCEPTION( err::XQST0059, ERROR_PARAMS( ZED( XQST0059_XercesMessage ), e.getLineNumber(), e.getColumnNumber(), system_id, public_id, StrX( e.getMessage() ).localFormOrDefault( "" ) ), ERROR_LOC( theQueryLoc ) ); }
void dynamic_context::set_variable( ulong varid, const store::Item_t& varname, const QueryLoc& loc, store::Item_t& valueItem) { if (varid >= theVarValues.size() || theVarValues[varid].theState == VarValue::undeclared) { RAISE_ERROR(err::XPDY0002, loc, ERROR_PARAMS(ZED(XPDY0002_VariableUndeclared_2), varname->getStringValue())); } VarValue& var = theVarValues[varid]; // variables can be set multiple times, so we need to make sure to remove // previously set temp sequences if (var.theState == VarValue::item) { assert(var.theValue.item != NULL); var.theValue.item->removeReference(); } else if (var.theState == VarValue::temp_seq) { assert(var.theValue.temp_seq != NULL); RCHelper::removeReference(var.theValue.temp_seq); } else if (var.theState == VarValue::declared) { assert(var.theValue.item == NULL); } else { ZORBA_ASSERT(false); } var.theState = VarValue::item; var.theValue.item = valueItem.release(); }
Item ItemFactoryImpl::createQName(const String& 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) { 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())) { RAISE_ERROR_NO_LOC(err::FORG0001, ERROR_PARAMS(ZED(FORG0001_LocalNotNCName_2), lLocalname)); } } return &*lItem; }