dombuilderimpl.cpp
来自「IBM的解析xml的工具Xerces的源代码」· C++ 代码 · 共 725 行 · 第 1/2 页
CPP
725 行
(XMLString::compareIString(name, XMLUni::fgXercesStandardUriConformant) == 0) || (XMLString::compareIString(name, XMLUni::fgXercesDOMHasPSVIInfo) == 0) || (XMLString::compareIString(name, XMLUni::fgXercesValidateAnnotations) == 0) || (XMLString::compareIString(name, XMLUni::fgXercesGenerateSyntheticAnnotations) == 0) || (XMLString::compareIString(name, XMLUni::fgXercesIdentityConstraintChecking) == 0) ) { return true; } else if (XMLString::compareIString(name, XMLUni::fgDOMSupportedMediatypesOnly) == 0 || XMLString::compareIString(name, XMLUni::fgDOMInfoset) == 0 || XMLString::compareIString(name, XMLUni::fgDOMCanonicalForm) == 0 ) { if (!state) return true; } else if (XMLString::compareIString(name, XMLUni::fgDOMNamespaceDeclarations) == 0 || XMLString::compareIString(name, XMLUni::fgDOMCDATASections) == 0 ) { if (state) return true; } else if ((XMLString::compareIString(name, XMLUni::fgXercesSchema) == 0) || (XMLString::compareIString(name, XMLUni::fgXercesSchemaFullChecking) == 0) || (XMLString::compareIString(name, XMLUni::fgXercesLoadExternalDTD) == 0) || (XMLString::compareIString(name, XMLUni::fgXercesContinueAfterFatalError) == 0) || (XMLString::compareIString(name, XMLUni::fgXercesValidationErrorAsFatal) == 0) || (XMLString::compareIString(name, XMLUni::fgXercesCacheGrammarFromParse) == 0) || (XMLString::compareIString(name, XMLUni::fgXercesUseCachedGrammarInParse) == 0)) { return true; } return false;}// ---------------------------------------------------------------------------// DOMBuilderImpl: Non standard extension// ---------------------------------------------------------------------------void DOMBuilderImpl::setProperty(const XMLCh* const name, void* value){ if (XMLString::compareIString(name, XMLUni::fgXercesSchemaExternalSchemaLocation) == 0) { setExternalSchemaLocation((XMLCh*)value); } else if (XMLString::compareIString(name, XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation) == 0) { setExternalNoNamespaceSchemaLocation((XMLCh*)value); } else if (XMLString::compareIString(name, XMLUni::fgXercesSecurityManager) == 0) { setSecurityManager((SecurityManager*)value); } else if (XMLString::equals(name, XMLUni::fgXercesScannerName)) { AbstractDOMParser::useScanner((const XMLCh*) value); } else if (XMLString::equals(name, XMLUni::fgXercesParserUseDocumentFromImplementation)) { useImplementation((const XMLCh*) value); } else throw DOMException(DOMException::NOT_FOUND_ERR, 0, getMemoryManager());}void* DOMBuilderImpl::getProperty(const XMLCh* const name) const{ if (XMLString::compareIString(name, XMLUni::fgXercesSchemaExternalSchemaLocation) == 0) return (void*)getExternalSchemaLocation(); else if (XMLString::compareIString(name, XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation) == 0) return (void*)getExternalNoNamespaceSchemaLocation(); else if (XMLString::compareIString(name, XMLUni::fgXercesSecurityManager) == 0) return (void*)getSecurityManager(); else throw DOMException(DOMException::NOT_FOUND_ERR, 0, getMemoryManager()); return 0;}void DOMBuilderImpl::release(){ DOMBuilderImpl* builder = (DOMBuilderImpl*) this; delete builder;}void DOMBuilderImpl::resetDocumentPool(){ resetPool();}// ---------------------------------------------------------------------------// DOMBuilderImpl: Parsing methods// ---------------------------------------------------------------------------DOMDocument* DOMBuilderImpl::parse(const DOMInputSource& source){ Wrapper4DOMInputSource isWrapper((DOMInputSource*) &source, false, getMemoryManager()); AbstractDOMParser::parse(isWrapper); if (fUserAdoptsDocument) return adoptDocument(); else return getDocument();}DOMDocument* DOMBuilderImpl::parseURI(const XMLCh* const systemId){ AbstractDOMParser::parse(systemId); if (fUserAdoptsDocument) return adoptDocument(); else return getDocument();}DOMDocument* DOMBuilderImpl::parseURI(const char* const systemId){ AbstractDOMParser::parse(systemId); if (fUserAdoptsDocument) return adoptDocument(); else return getDocument();}void DOMBuilderImpl::parseWithContext(const DOMInputSource&, DOMNode* const, const short){ throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0, getMemoryManager());}// ---------------------------------------------------------------------------// DOMBuilderImpl: Implementation of the XMLErrorReporter interface// ---------------------------------------------------------------------------void DOMBuilderImpl::error( const unsigned int code , const XMLCh* const , const XMLErrorReporter::ErrTypes errType , const XMLCh* const errorText , const XMLCh* const systemId , const XMLCh* const , const XMLSSize_t lineNum , const XMLSSize_t colNum){ if (fErrorHandler) { short severity = DOMError::DOM_SEVERITY_ERROR; if (errType == XMLErrorReporter::ErrType_Warning) severity = DOMError::DOM_SEVERITY_WARNING; else if (errType == XMLErrorReporter::ErrType_Fatal) severity = DOMError::DOM_SEVERITY_FATAL_ERROR; DOMLocatorImpl location((int)lineNum, (int) colNum, getCurrentNode(), systemId); DOMErrorImpl domError(severity, errorText, &location); // if user return false, we should stop the process, so throw an error if (!fErrorHandler->handleError(domError) && !getScanner()->getInException()) throw (XMLErrs::Codes) code; }}void DOMBuilderImpl::resetErrors(){}// ---------------------------------------------------------------------------// DOMBuilderImpl: Implementation of XMLEntityHandler interface// ---------------------------------------------------------------------------InputSource*DOMBuilderImpl::resolveEntity(const XMLCh* const publicId, const XMLCh* const systemId, const XMLCh* const baseURI){ // // Just map it to the SAX entity resolver. If there is not one installed, // return a null pointer to cause the default resolution. // if (fEntityResolver) { DOMInputSource* is = fEntityResolver->resolveEntity(publicId, systemId, baseURI); if (is) return new (getMemoryManager()) Wrapper4DOMInputSource(is, true, getMemoryManager()); } return 0;}InputSource*DOMBuilderImpl::resolveEntity( XMLResourceIdentifier* resourceIdentifier ){ // // Just map it to the SAX entity resolver. If there is not one installed, // return a null pointer to cause the default resolution. // if (fEntityResolver) { DOMInputSource* is = fEntityResolver->resolveEntity(resourceIdentifier->getPublicId(), resourceIdentifier->getSystemId(), resourceIdentifier->getBaseURI()); if (is) return new (getMemoryManager()) Wrapper4DOMInputSource(is, true, getMemoryManager()); } if (fXMLEntityResolver) { return(fXMLEntityResolver->resolveEntity(resourceIdentifier)); } return 0;}// ---------------------------------------------------------------------------// DOMBuilderImpl: Grammar preparsing methods// ---------------------------------------------------------------------------Grammar* DOMBuilderImpl::loadGrammar(const char* const systemId, const short grammarType, const bool toCache){ // Avoid multiple entrance if (getParseInProgress()) ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); Grammar* grammar = 0; try { setParseInProgress(true); if (grammarType == Grammar::DTDGrammarType) getScanner()->setDocTypeHandler(0); grammar = getScanner()->loadGrammar(systemId, grammarType, toCache); // Release DOM tree - DTD DOMDocument* doc = adoptDocument(); if (doc) doc->release(); if (grammarType == Grammar::DTDGrammarType) getScanner()->setDocTypeHandler(this); setParseInProgress(false); } catch(const OutOfMemoryException&) { throw; } catch(...) { if (grammarType == Grammar::DTDGrammarType) getScanner()->setDocTypeHandler(this); setParseInProgress(false); throw; } return grammar;}Grammar* DOMBuilderImpl::loadGrammar(const XMLCh* const systemId, const short grammarType, const bool toCache){ // Avoid multiple entrance if (getParseInProgress()) ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); Grammar* grammar = 0; try { setParseInProgress(true); if (grammarType == Grammar::DTDGrammarType) getScanner()->setDocTypeHandler(0); grammar = getScanner()->loadGrammar(systemId, grammarType, toCache); // Release DOM tree - DTD DOMDocument* doc = adoptDocument(); if (doc) doc->release(); if (grammarType == Grammar::DTDGrammarType) getScanner()->setDocTypeHandler(this); setParseInProgress(false); } catch(const OutOfMemoryException&) { throw; } catch(...) { if (grammarType == Grammar::DTDGrammarType) getScanner()->setDocTypeHandler(this); setParseInProgress(false); throw; } return grammar;}Grammar* DOMBuilderImpl::loadGrammar(const DOMInputSource& source, const short grammarType, const bool toCache){ // Avoid multiple entrance if (getParseInProgress()) ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); Grammar* grammar = 0; try { Wrapper4DOMInputSource isWrapper((DOMInputSource*) &source, false, getMemoryManager()); setParseInProgress(true); if (grammarType == Grammar::DTDGrammarType) getScanner()->setDocTypeHandler(0); grammar = getScanner()->loadGrammar(isWrapper, grammarType, toCache); // Release DOM tree - DTD DOMDocument* doc = adoptDocument(); if (doc) doc->release(); if (grammarType == Grammar::DTDGrammarType) getScanner()->setDocTypeHandler(this); setParseInProgress(false); } catch(const OutOfMemoryException&) { throw; } catch(...) { if (grammarType == Grammar::DTDGrammarType) getScanner()->setDocTypeHandler(this); setParseInProgress(false); throw; } return grammar;}void DOMBuilderImpl::resetCachedGrammarPool(){ getGrammarResolver()->resetCachedGrammar();}Grammar* DOMBuilderImpl::getGrammar(const XMLCh* const nameSpaceKey) const{ return getGrammarResolver()->getGrammar(nameSpaceKey);}Grammar* DOMBuilderImpl::getRootGrammar() const{ return getScanner()->getRootGrammar();}const XMLCh* DOMBuilderImpl::getURIText(unsigned int uriId) const{ return getScanner()->getURIText(uriId);}unsigned int DOMBuilderImpl::getSrcOffset() const{ return getScanner()->getSrcOffset();}XERCES_CPP_NAMESPACE_END
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?