igxmlscanner2.cpp
来自「IBM的解析xml的工具Xerces的源代码」· C++ 代码 · 共 1,601 行 · 第 1/5 页
CPP
1,601 行
*curCountPtr = fElemCount; fUndeclaredAttrRegistry->put((void *)namePtr, curCountPtr); } else if(*curCountPtr < fElemCount) *curCountPtr = fElemCount; else { emitError ( XMLErrs::AttrAlreadyUsedInSTag , namePtr , elemDecl->getFullName() ); } } else // schema grammar { unsigned int *curCountPtr = fUndeclaredAttrRegistryNS->get(suffPtr, uriId); if(!curCountPtr) { curCountPtr = getNewUIntPtr(); *curCountPtr = fElemCount; fUndeclaredAttrRegistryNS->put((void *)suffPtr, uriId, curCountPtr); } else if(*curCountPtr < fElemCount) *curCountPtr = fElemCount; else { emitError ( XMLErrs::AttrAlreadyUsedInSTag , namePtr , elemDecl->getFullName() ); fPSVIElemContext.fErrorOccurred = true; } } } if(fGrammarType == Grammar::SchemaGrammarType ) { // if we've found either an attDef or an attDefForWildCard, // then we're doing full validation and it may still be valid. if(!attDef && !attDefForWildCard) { if(!laxThisOne && !skipThisOne) { fPSVIElemContext.fErrorOccurred = true; } if(getPSVIHandler()) { if(!laxThisOne && !skipThisOne) { attrValid = PSVIItem::VALIDITY_INVALID; } else if(laxThisOne) { attrValid = PSVIItem::VALIDITY_NOTKNOWN; attrAssessed = PSVIItem::VALIDATION_PARTIAL; } else { attrValid = PSVIItem::VALIDITY_NOTKNOWN; attrAssessed = PSVIItem::VALIDATION_NONE; } } } } bool errorCondition = fValidate && !attDefForWildCard && !attDef; if (errorCondition && !skipThisOne && !laxThisOne) { // // Its not valid for this element, so issue an error if we are // validating. // XMLBufBid bbMsg(&fBufMgr); XMLBuffer& bufMsg = bbMsg.getBuffer(); if (uriId != fEmptyNamespaceId) { XMLBufBid bbURI(&fBufMgr); XMLBuffer& bufURI = bbURI.getBuffer(); getURIText(uriId, bufURI); bufMsg.append(chOpenCurly); bufMsg.append(bufURI.getRawBuffer()); bufMsg.append(chCloseCurly); } bufMsg.append(suffPtr); fValidator->emitError ( XMLValid::AttNotDefinedForElement , bufMsg.getRawBuffer() , elemDecl->getFullName() ); } // Now normalize the raw value since we have the attribute type. We // don't care about the return status here. If it failed, an error // was issued, which is all we care about. if (attDefForWildCard) { normalizeAttValue ( attDefForWildCard , namePtr , curPair->getValue() , normBuf ); // If we found an attdef for this one, then lets validate it. if (fNormalizeData) { DatatypeValidator* tempDV = ((SchemaAttDef*) attDefForWildCard)->getDatatypeValidator(); if (tempDV && tempDV->getWSFacet() != DatatypeValidator::PRESERVE) { // normalize the attribute according to schema whitespace facet XMLBufBid bbtemp(&fBufMgr); XMLBuffer& tempBuf = bbtemp.getBuffer(); ((SchemaValidator*) fValidator)->normalizeWhiteSpace(tempDV, normBuf.getRawBuffer(), tempBuf); normBuf.set(tempBuf.getRawBuffer()); } } if (fValidate ) { fValidator->validateAttrValue ( attDefForWildCard , normBuf.getRawBuffer() , false , elemDecl ); attrValidator = ((SchemaValidator*)fValidator)->getMostRecentAttrValidator(); if(((SchemaValidator *)fValidator)->getErrorOccurred()) { fPSVIElemContext.fErrorOccurred = true; if(getPSVIHandler()) attrValid = PSVIItem::VALIDITY_INVALID; } } else // no decl; default DOMTypeInfo to anySimpleType attrValidator = DatatypeValidatorFactory::getBuiltInRegistry()->get(SchemaSymbols::fgDT_ANYSIMPLETYPE); // Save the type for later use attType = attDefForWildCard->getType(); } else { normalizeAttValue ( attDef , namePtr , curPair->getValue() , normBuf ); // If we found an attdef for this one, then lets validate it. if (attDef) { if (fNormalizeData && (fGrammarType == Grammar::SchemaGrammarType)) { DatatypeValidator* tempDV = ((SchemaAttDef*) attDef)->getDatatypeValidator(); if (tempDV && tempDV->getWSFacet() != DatatypeValidator::PRESERVE) { // normalize the attribute according to schema whitespace facet XMLBufBid bbtemp(&fBufMgr); XMLBuffer& tempBuf = bbtemp.getBuffer(); ((SchemaValidator*) fValidator)->normalizeWhiteSpace(tempDV, normBuf.getRawBuffer(), tempBuf); normBuf.set(tempBuf.getRawBuffer()); } } if (fValidate && !skipThisOne) { fValidator->validateAttrValue ( attDef , normBuf.getRawBuffer() , false , elemDecl ); if(fGrammarType == Grammar::SchemaGrammarType) { attrValidator = ((SchemaValidator*)fValidator)->getMostRecentAttrValidator(); if(((SchemaValidator *)fValidator)->getErrorOccurred()) { fPSVIElemContext.fErrorOccurred = true; if (getPSVIHandler()) attrValid = PSVIItem::VALIDITY_INVALID; } } } else if(fGrammarType == Grammar::SchemaGrammarType) attrValidator = DatatypeValidatorFactory::getBuiltInRegistry()->get(SchemaSymbols::fgDT_ANYSIMPLETYPE); } else // no attDef at all; default to anySimpleType { if(fGrammarType == Grammar::SchemaGrammarType) attrValidator = DatatypeValidatorFactory::getBuiltInRegistry()->get(SchemaSymbols::fgDT_ANYSIMPLETYPE); } // Save the type for later use attType = (attDef)?attDef->getType():XMLAttDef::CData; } // now fill in the PSVIAttributes entry for this attribute: if(getPSVIHandler() && fGrammarType == Grammar::SchemaGrammarType) { psviAttr = fPSVIAttrList->getPSVIAttributeToFill(suffPtr, fURIStringPool->getValueForId(uriId)); SchemaAttDef *actualAttDef = 0; if(attDef) actualAttDef = (SchemaAttDef *)attDef; else if (attDefForWildCard) actualAttDef = (SchemaAttDef *)attDefForWildCard; if(actualAttDef) { XSAttributeDeclaration *attrDecl = (XSAttributeDeclaration *)fModel->getXSObject(actualAttDef); DatatypeValidator * attrDataType = actualAttDef->getDatatypeValidator(); XSSimpleTypeDefinition *validatingType = (XSSimpleTypeDefinition *)fModel->getXSObject(attrDataType); if(attrValid != PSVIItem::VALIDITY_VALID) { psviAttr->reset ( fRootElemName , attrValid , attrAssessed , validatingType , 0 , actualAttDef->getValue() , false , attrDecl , 0 ); } else { XSSimpleTypeDefinition *memberType = 0; if(validatingType->getVariety() == XSSimpleTypeDefinition::VARIETY_UNION) memberType = (XSSimpleTypeDefinition *)fModel->getXSObject(attrValidator); psviAttr->reset ( fRootElemName , attrValid , attrAssessed , validatingType , memberType , actualAttDef->getValue() , false , attrDecl , (memberType)?attrValidator:attrDataType ); } } else { psviAttr->reset ( fRootElemName , attrValid , attrAssessed , 0 , 0 , 0 , false , 0 , 0 ); } } } else { // Just normalize as CDATA attType = XMLAttDef::CData; normalizeAttRawValue ( namePtr , curPair->getValue() , normBuf ); if((uriId == fXMLNSNamespaceId) || XMLString::equals(getURIText(uriId), SchemaSymbols::fgURI_XSI)) attrValidator = DatatypeValidatorFactory::getBuiltInRegistry()->get(SchemaSymbols::fgDT_ANYURI); if(getPSVIHandler() && fGrammarType == Grammar::SchemaGrammarType) { psviAttr = fPSVIAttrList->getPSVIAttributeToFill(suffPtr, fURIStringPool->getValueForId(uriId)); XSSimpleTypeDefinition *validatingType = (attrValidator) ? (XSSimpleTypeDefinition *)fModel->getXSObject(attrValidator) : 0; // no attribute declarations for these... psviAttr->reset( fRootElemName , PSVIItem::VALIDITY_NOTKNOWN , PSVIItem::VALIDATION_NONE , validatingType , 0 , 0 , false , 0 , attrValidator ); } } // Add this attribute to the attribute list that we use to pass them // to the handler. We reuse its existing elements but expand it as // required. XMLAttr* curAttr; // check for duplicate namespace attributes: // by checking for qualified names with the same local part and with prefixes // which have been bound to namespace names that are identical. if (fGrammarType == Grammar::DTDGrammarType) { if (!toUseHashTable) { for (unsigned int attrIndex=0; attrIndex < retCount; attrIndex++) { curAttr = toFill.elementAt(attrIndex); if (uriId == curAttr->getURIId() && XMLString::equals(suffPtr, curAttr->getName())) { emitError
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?