SchemaAttDef::SchemaAttDef(const SchemaAttDef* other) : XMLAttDef(other->getValue(), other->getType(), other->getDefaultType(), other->getEnumeration(), other->getMemoryManager()) , fElemId(XMLElementDecl::fgInvalidElemId) , fAttName(0) , fDatatypeValidator(other->fDatatypeValidator) , fAnyDatatypeValidator(other->fAnyDatatypeValidator) , fMemberTypeValidator(other->fMemberTypeValidator) , fNamespaceList(0) , fValidity(other->fValidity) , fValidation(other->fValidation) , fPSVIScope(other->fPSVIScope) , fBaseAttDecl(other->fBaseAttDecl) { QName* otherName = other->getAttName(); fAttName = new (getMemoryManager()) QName(otherName->getPrefix(), otherName->getLocalPart(), otherName->getURI(), getMemoryManager()); if (other->fNamespaceList && other->fNamespaceList->size()) { fNamespaceList = new (getMemoryManager()) ValueVectorOf<unsigned int>(*(other->fNamespaceList)); } }
// --------------------------------------------------------------------------- // XercesAttGroupInfo: Getter methods // --------------------------------------------------------------------------- const SchemaAttDef* XercesAttGroupInfo::getAttDef(const XMLCh* const baseName, const int uriId) const { // If no list, then return a null if (!fAttributes) return 0; XMLSize_t attSize = fAttributes->size(); for (XMLSize_t i=0; i<attSize; i++) { const SchemaAttDef* attDef = fAttributes->elementAt(i); QName* attName = attDef->getAttName(); if (uriId == (int) attName->getURI() && XMLString::equals(baseName, attName->getLocalPart())) { return attDef; } } return 0; }
bool XercesAttGroupInfo::containsAttribute(const XMLCh* const name, const unsigned int uri) { if (fAttributes) { XMLSize_t attCount = fAttributes->size(); if (attCount) { for (XMLSize_t i=0; i < attCount; i++) { QName* attName = fAttributes->elementAt(i)->getAttName(); if (attName->getURI() == uri && XMLString::equals(attName->getLocalPart(),name)) { return true; } } } } return false; }
int MixedContentModel::validateContentSpecial(QName** const children , const unsigned int childCount , const unsigned int , GrammarResolver* const pGrammarResolver , XMLStringPool* const pStringPool) const { SubstitutionGroupComparator comparator(pGrammarResolver, pStringPool); // must match order if (fOrdered) { unsigned int inIndex = 0; for (unsigned int outIndex = 0; outIndex < childCount; outIndex++) { // Get the current child out of the source index QName* curChild = children[outIndex]; // If its PCDATA, then we just accept that if (curChild->getURI() == XMLElementDecl::fgPCDataElemId) continue; ContentSpecNode::NodeTypes type = fChildTypes[inIndex]; QName* inChild = fChildren[inIndex]; if (type == ContentSpecNode::Leaf) { if ( !comparator.isEquivalentTo(curChild, inChild)) return outIndex; } else if (type == ContentSpecNode::Any) { } else if (type == ContentSpecNode::Any_NS) { if (inChild->getURI() != curChild->getURI()) return outIndex; } else if (type == ContentSpecNode::Any_Other) { if (inChild->getURI() == curChild->getURI()) return outIndex; } // advance index inIndex++; } } // can appear in any order else { for (unsigned int outIndex = 0; outIndex < childCount; outIndex++) { // Get the current child out of the source index QName* curChild = children[outIndex]; // If its PCDATA, then we just accept that if (curChild->getURI() == XMLElementDecl::fgPCDataElemId) continue; // And try to find it in our list unsigned int inIndex = 0; for (; inIndex < fCount; inIndex++) { ContentSpecNode::NodeTypes type = fChildTypes[inIndex]; QName* inChild = fChildren[inIndex]; if (type == ContentSpecNode::Leaf) { if ( comparator.isEquivalentTo(curChild, inChild)) break; } else if (type == ContentSpecNode::Any) { break; } else if (type == ContentSpecNode::Any_NS) { if (inChild->getURI() == curChild->getURI()) break; } else if (type == ContentSpecNode::Any_Other) { if (inChild->getURI() != curChild->getURI()) break; } // REVISIT: What about checking for multiple ANY matches? // The content model ambiguity *could* be checked // by the caller before constructing the mixed // content model. } // We did not find this one, so the validation failed if (inIndex == fCount) return outIndex; } } // Everything seems to be in order, so return success // success return -1; }
int DFAContentModel::validateContentSpecial(QName** const children , const unsigned int childCount , const unsigned int , GrammarResolver* const pGrammarResolver , XMLStringPool* const pStringPool) const { SubstitutionGroupComparator comparator(pGrammarResolver, pStringPool); if (childCount == 0) return fEmptyOk ? -1 : 0; // // Lets loop through the children in the array and move our way // through the states. Note that we use the fElemMap array to map // an element index to a state index. // unsigned int curState = 0; unsigned int nextState = 0; unsigned int childIndex = 0; for (; childIndex < childCount; childIndex++) { // Get the current element index out QName* curElem = children[childIndex]; // If this is text in a Schema mixed content model, skip it. if ( fIsMixed && ( curElem->getURI() == XMLElementDecl::fgPCDataElemId)) continue; // Look up this child in our element map unsigned int elemIndex = 0; for (; elemIndex < fElemMapSize; elemIndex++) { QName* inElem = fElemMap[elemIndex]; ContentSpecNode::NodeTypes type = fElemMapType[elemIndex]; if (type == ContentSpecNode::Leaf) { if (comparator.isEquivalentTo(curElem, inElem) ) { nextState = fTransTable[curState][elemIndex]; if (nextState != XMLContentModel::gInvalidTrans) break; } } else if ((type & 0x0f)== ContentSpecNode::Any) { nextState = fTransTable[curState][elemIndex]; if (nextState != XMLContentModel::gInvalidTrans) break; } else if ((type & 0x0f) == ContentSpecNode::Any_NS) { if (inElem->getURI() == curElem->getURI()) { nextState = fTransTable[curState][elemIndex]; if (nextState != XMLContentModel::gInvalidTrans) break; } } else if ((type & 0x0f) == ContentSpecNode::Any_Other) { if (inElem->getURI() != curElem->getURI()) { nextState = fTransTable[curState][elemIndex]; if (nextState != XMLContentModel::gInvalidTrans) break; } } }//for elemIndex // If "nextState" is -1, we found a match, but the transition is invalid if (nextState == XMLContentModel::gInvalidTrans) return childIndex; // If we didn't find it, then obviously not valid if (elemIndex == fElemMapSize) return childIndex; curState = nextState; nextState = 0; }//for childIndex // // We transitioned all the way through the input list. However, that // does not mean that we ended in a final state. So check whether // our ending state is a final state. // if (!fFinalStateFlags[curState]) return childIndex; //success return -1; }