uint32_t deHashAttributes( const QueryLoc& loc, static_context* sctx, const store::Iterator_t& it, XQPCollator* collator, int timezone) { uint32_t lHash = FNV_32_INIT; std::vector<uint32_t> lInnerHashes; store::Item_t attr; it->open(); while (it->next(attr)) { lInnerHashes.push_back(deHash(loc, sctx, attr, collator, timezone)); } std::sort(lInnerHashes.begin(), lInnerHashes.end()); for(std::vector<uint32_t>::iterator it = lInnerHashes.begin(); it != lInnerHashes.end(); ++it) { lHash = hashfun::h32(&(*it), sizeof(*it), lHash); } return lHash; }
uint32_t deHashChildren( const QueryLoc& loc, static_context* sctx, const store::Iterator_t& it, XQPCollator* collator, int timezone) { uint32_t lHash = FNV_32_INIT; uint32_t lInnerHash; store::Item_t child; it->open(); while (it->next(child)) { if (child->getNodeKind() == store::StoreConsts::piNode || child->getNodeKind() == store::StoreConsts::commentNode) continue; lInnerHash = deHash(loc, sctx, child, collator, timezone); lHash = hashfun::h32(&lInnerHash, sizeof(lInnerHash), lHash); } return lHash; }
bool deepEqualAttributes( const QueryLoc& loc, static_context* sctx, const store::Iterator_t& it1, const store::Iterator_t& it2, XQPCollator* collator, int timezone, bool raiseError) { store::Item_t child1, child2; int c1count = 0, c2count = 0; it1->open(); it2->open(); while (it1->next(child1)) { c1count++; it2->reset(); bool found = false; while (it2->next(child2)) { if (deepEqual(loc, sctx, child1, child2, collator, timezone, raiseError)) { found = true; break; } } if (!found) return false; } it2->reset(); while (it2->next(child2)) c2count++; if (c1count != c2count) return false; return true; }
bool deepEqualChildren( const QueryLoc& loc, static_context* sctx, const store::Iterator_t& it1, const store::Iterator_t& it2, XQPCollator* collator, int timezone, bool raiseError) { store::Item_t child1, child2; bool c1Valid, c2Valid; it1->open(); it2->open(); while (1) { while ((c1Valid = it1->next(child1)) && (child1->getNodeKind() == store::StoreConsts::piNode || child1->getNodeKind() == store::StoreConsts::commentNode)) ; while ((c2Valid = it2->next(child2)) && (child2->getNodeKind() == store::StoreConsts::piNode || child2->getNodeKind() == store::StoreConsts::commentNode)) ; if (!c1Valid && !c2Valid) return true; else if (!c1Valid || !c2Valid) return false; else if (!deepEqual(loc, sctx, child1, child2, collator, timezone, raiseError)) return false; } return true; }
void SchemaValidatorImpl::validateAttributes( EventSchemaValidator& schemaValidator, store::Iterator_t attributes) { store::Item_t attribute; while ( attributes->next(attribute) ) { ZORBA_ASSERT(attribute->isNode()); ZORBA_ASSERT(attribute->getNodeKind() == store::StoreConsts::attributeNode); //cout << " vup - attr: " << attribute->getNodeName()->getLocalName()-> // c_str() << "\n"; cout.flush(); store::Item_t attName = attribute->getNodeName(); schemaValidator.attr(attName, attribute->getStringValue()); } }
int SchemaValidatorImpl::processChildren( store::PUL* pul, namespace_context& nsCtx, TypeManager* typeManager, EventSchemaValidator& schemaValidator, store::Iterator_t children, std::vector<store::Item_t>& typedValues, const QueryLoc& loc) { store::Item_t child; store::Item_t typeName; int noOfChildren = 0; while ( children->next(child) ) { noOfChildren++; if ( child->isNode() ) { //cout << " vup - processChildren: " << child->getType()->getLocalName() // ->c_str() << "\n"; cout.flush(); switch ( child->getNodeKind() ) { case store::StoreConsts::elementNode: processElement(pul, typeManager, schemaValidator, child, loc); break; case store::StoreConsts::attributeNode: ZORBA_ASSERT(false); break; case store::StoreConsts::documentNode: ZORBA_ASSERT(false); break; case store::StoreConsts::textNode: { //cout << " vup - pC text: '" << child->getStringValue()-> // normalizeSpace()->str() << "'\n"; cout.flush(); zstring childStringValue; child->getStringValue2(childStringValue); schemaValidator.text(childStringValue); store::Item_t typeQName = schemaValidator.getTypeQName(); processTextValue(pul, typeManager, nsCtx, typeQName, childStringValue, child, typedValues, loc); } break; case store::StoreConsts::piNode: //cout << " vup - pi: " << child->getStringValue() << "\n"; cout.flush(); // do nothing break; case store::StoreConsts::commentNode: //cout << " vup - comment: " << child->getStringValue() << "\n"; cout.flush(); // do nothing break; case store::StoreConsts::anyNode: //cout << " vup - any: " << child->getStringValue() << "\n"; cout.flush(); ZORBA_ASSERT(false); break; default: ZORBA_ASSERT(false); } } } return noOfChildren; }