void SelectorMatcher::startElement(const XMLElementDecl& elemDecl, const unsigned int urlId, const XMLCh* const elemPrefix, const RefVectorOf<XMLAttr>& attrList, const unsigned int attrCount) { XPathMatcher::startElement(elemDecl, urlId, elemPrefix, attrList, attrCount); fElementDepth++; // activate the fields, if selector is matched int matched = isMatched(); if ((fMatchedDepth == -1 && ((matched & XP_MATCHED) == XP_MATCHED)) || ((matched & XP_MATCHED_D) == XP_MATCHED_D)) { IdentityConstraint* ic = fSelector->getIdentityConstraint(); int count = ic->getFieldCount(); fMatchedDepth = fElementDepth; fFieldActivator->startValueScopeFor(ic, fInitialDepth); for (int i = 0; i < count; i++) { XPathMatcher* matcher = fFieldActivator->activateField(ic->getFieldAt(i), fInitialDepth); matcher->startElement(elemDecl, urlId, elemPrefix, attrList, attrCount); } } }
// --------------------------------------------------------------------------- // IdentityConstraintHandler: methods // --------------------------------------------------------------------------- void IdentityConstraintHandler::deactivateContext( SchemaElementDecl* const elem , const XMLCh* const content) { int oldCount = fMatcherStack->getMatcherCount(); if (oldCount || elem->getIdentityConstraintCount()) { for (int i = oldCount - 1; i >= 0; i--) { XPathMatcher* matcher = fMatcherStack->getMatcherAt(i); matcher->endElement(*(elem), content); } if (fMatcherStack->size() > 0) { fMatcherStack->popContext(); } // handle everything *but* keyref's. int newCount = fMatcherStack->getMatcherCount(); for (int j = oldCount - 1; j >= newCount; j--) { XPathMatcher* matcher = fMatcherStack->getMatcherAt(j); IdentityConstraint* ic = matcher->getIdentityConstraint(); if (ic && (ic->getType() != IdentityConstraint::KEYREF)) fValueStoreCache->transplant(ic, matcher->getInitialDepth()); } // now handle keyref's... for (int k = oldCount - 1; k >= newCount; k--) { XPathMatcher* matcher = fMatcherStack->getMatcherAt(k); IdentityConstraint* ic = matcher->getIdentityConstraint(); if (ic && (ic->getType() == IdentityConstraint::KEYREF)) { ValueStore* values = fValueStoreCache->getValueStoreFor(ic, matcher->getInitialDepth()); if (values) { // nothing to do if nothing matched! values->endDcocumentFragment(fValueStoreCache); } } } fValueStoreCache->endElement(); } }
void SelectorMatcher::startElement(const XMLElementDecl& elemDecl, const unsigned int urlId, const XMLCh* const elemPrefix, const RefVectorOf<XMLAttr>& attrList, const XMLSize_t attrCount, ValidationContext* validationContext /*=0*/) { XPathMatcher::startElement(elemDecl, urlId, elemPrefix, attrList, attrCount, validationContext); fElementDepth++; for(XMLSize_t k = 0;k<fLocationPathSize;k++) { // use the match flag of each member of the union unsigned char matched = 0; if (((fMatched[k] & XP_MATCHED) == XP_MATCHED) && ((fMatched[k] & XP_MATCHED_DP) != XP_MATCHED_DP)) matched = fMatched[k]; if ((fMatchedDepth[k] == -1 && ((matched & XP_MATCHED) == XP_MATCHED)) || ((matched & XP_MATCHED_D) == XP_MATCHED_D)) { IdentityConstraint* ic = fSelector->getIdentityConstraint(); XMLSize_t count = ic->getFieldCount(); fMatchedDepth[k] = fElementDepth; fFieldActivator->startValueScopeFor(ic, fInitialDepth); for (XMLSize_t i = 0; i < count; i++) { XPathMatcher* matcher = fFieldActivator->activateField(ic->getFieldAt(i), fInitialDepth); matcher->startElement(elemDecl, urlId, elemPrefix, attrList, attrCount, validationContext); } break; } } }
// --------------------------------------------------------------------------- // IdentityConstraint: operators // --------------------------------------------------------------------------- bool IdentityConstraint::operator ==(const IdentityConstraint& other) const { if (getType() != other.getType()) return false; if (!XMLString::equals(fIdentityConstraintName, other.fIdentityConstraintName)) return false; if (*fSelector != *(other.fSelector)) return false; XMLSize_t fieldCount = fFields->size(); if (fieldCount != other.fFields->size()) return false; for (XMLSize_t i = 0; i < fieldCount; i++) { if (*(fFields->elementAt(i)) != *(other.fFields->elementAt(i))) return false; } return true; }