void SchemaValidatorImpl::validateSimpleContent( store::Item *typeQName, zstring newValue, std::vector<store::Item_t>& resultList) { TypeManager* typeManager = theSctx->get_typemanager(); Schema* schema = typeManager->getSchema(); ZORBA_ASSERT( schema ); const xqtref_t& targetType = schema->createXQTypeFromTypeName(typeManager, typeQName); schema->parseUserSimpleTypes(newValue, targetType, resultList, QueryLoc::null, false); }
bool SchemaValidatorImpl::isPossibleSimpleContentRevalidation( store::Item* typeQName) { TypeManager* typeManager = theSctx->get_typemanager(); //StaticContextConsts::validation_mode_t mode = theSctx->validation_mode(); Schema* schema = typeManager->getSchema(); if ( !schema ) { // no schema available no change to pul return false; } xqtref_t schemaType = schema->createXQTypeFromTypeName(typeManager, typeQName); if ( schemaType.getp() ) return isPossibleSimpleContentRevalImpl(schemaType); else return false; }
void SchemaValidatorImpl::validateAfterUpdate( store::Item* item, zorba::store::PUL* pul, const QueryLoc& loc) { ZORBA_ASSERT(item->isNode()); TypeManager* typeManager = theSctx->get_typemanager(); StaticContextConsts::validation_mode_t mode = theSctx->validation_mode(); if (mode == StaticContextConsts::skip_validation) return; bool isLax = (mode == StaticContextConsts::lax_validation); Schema* schema = typeManager->getSchema(); if ( !schema ) { // no schema available no change to pul return; } EventSchemaValidator schemaValidator = EventSchemaValidator(typeManager, schema->getGrammarPool(), isLax, theLoc); switch ( item->getNodeKind() ) { case store::StoreConsts::documentNode: { //cout << "Validate after update document" << "\n"; cout.flush(); schemaValidator.startDoc(); store::NsBindings bindings; namespace_context nsCtx = namespace_context(theSctx, bindings); std::vector<store::Item_t> typedValues; processChildren(pul, nsCtx, typeManager, schemaValidator, item->getChildren(), typedValues, loc); schemaValidator.endDoc(); //cout << "End Validate after update doc" << "\n"; cout.flush(); return; } case store::StoreConsts::elementNode: { //cout << "Validate after update element" << "\n"; cout.flush(); schemaValidator.startDoc(); processElement(pul, typeManager, schemaValidator, item, loc); schemaValidator.endDoc(); //cout << "End Validate after update elem" << "\n"; cout.flush(); return; } default: throw XQUERY_EXCEPTION( err::XQDY0061, ERROR_PARAMS( ZED( NotDocOrElementNode ) ), ERROR_LOC( theLoc ) ); } }