00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 #if !defined(XERCESC_INCLUDE_GUARD_SAXPARSER_HPP)
00023 #define XERCESC_INCLUDE_GUARD_SAXPARSER_HPP
00024 
00025 #include <xercesc/sax/Parser.hpp>
00026 #include <xercesc/internal/VecAttrListImpl.hpp>
00027 #include <xercesc/framework/XMLDocumentHandler.hpp>
00028 #include <xercesc/framework/XMLElementDecl.hpp>
00029 #include <xercesc/framework/XMLEntityHandler.hpp>
00030 #include <xercesc/framework/XMLErrorReporter.hpp>
00031 #include <xercesc/framework/XMLBuffer.hpp>
00032 #include <xercesc/util/SecurityManager.hpp>
00033 #include <xercesc/validators/common/Grammar.hpp>
00034 #include <xercesc/validators/DTD/DocTypeHandler.hpp>
00035 
00036 
00037 XERCES_CPP_NAMESPACE_BEGIN
00038 
00039 
00040 class DocumentHandler;
00041 class EntityResolver;
00042 class XMLPScanToken;
00043 class XMLScanner;
00044 class XMLValidator;
00045 class GrammarResolver;
00046 class XMLGrammarPool;
00047 class XMLEntityResolver;
00048 class XMLResourceIdentifier;
00049 class PSVIHandler;
00050 
00069 class PARSERS_EXPORT SAXParser :
00070 
00071     public XMemory
00072     , public Parser
00073     , public XMLDocumentHandler
00074     , public XMLErrorReporter
00075     , public XMLEntityHandler
00076     , public DocTypeHandler
00077 {
00078 public :
00079     
00080     
00081     
00090     enum ValSchemes
00091     {
00092         Val_Never
00093         , Val_Always
00094         , Val_Auto
00095     };
00096 
00097 
00098     
00099     
00100     
00111     SAXParser
00112     (
00113           XMLValidator*   const valToAdopt = 0
00114         , MemoryManager*  const manager = XMLPlatformUtils::fgMemoryManager
00115         , XMLGrammarPool* const gramPool = 0
00116     );
00117 
00121     ~SAXParser();
00123 
00124 
00125     
00126     
00127     
00136     DocumentHandler* getDocumentHandler();
00137 
00144     const DocumentHandler* getDocumentHandler() const;
00145 
00152     EntityResolver* getEntityResolver();
00153 
00160     const EntityResolver* getEntityResolver() const;
00161 
00168     XMLEntityResolver* getXMLEntityResolver();
00169 
00176     const XMLEntityResolver* getXMLEntityResolver() const;
00177 
00184     ErrorHandler* getErrorHandler();
00185 
00192     const ErrorHandler* getErrorHandler() const;
00193 
00200     PSVIHandler* getPSVIHandler();
00201 
00208     const PSVIHandler* getPSVIHandler() const;
00209 
00216     const XMLValidator& getValidator() const;
00217 
00225     ValSchemes getValidationScheme() const;
00226 
00237     bool getDoSchema() const;
00238 
00249     bool getValidationSchemaFullChecking() const;
00250 
00261     bool getIdentityConstraintChecking() const;
00262 
00273     int getErrorCount() const;
00274 
00284     bool getDoNamespaces() const;
00285 
00295     bool getExitOnFirstFatalError() const;
00296 
00307     bool getValidationConstraintFatal() const;
00308 
00328     XMLCh* getExternalSchemaLocation() const;
00329 
00349     XMLCh* getExternalNoNamespaceSchemaLocation() const;
00350 
00366     SecurityManager* getSecurityManager() const;
00367 
00381     XMLSize_t getLowWaterMark() const;
00382 
00394     bool getLoadExternalDTD() const;
00395 
00407     bool getLoadSchema() const;
00408 
00419     bool isCachingGrammarFromParse() const;
00420 
00431     bool isUsingCachedGrammarInParse() const;
00432 
00444     bool getCalculateSrcOfs() const;
00445 
00456     bool getStandardUriConformant() const;
00457 
00464     Grammar* getGrammar(const XMLCh* const nameSpaceKey);
00465 
00471     Grammar* getRootGrammar();
00472 
00479     const XMLCh* getURIText(unsigned int uriId) const;
00480 
00487     XMLFilePos getSrcOffset() const;
00488 
00500     bool getGenerateSyntheticAnnotations() const;
00501 
00509     bool getValidateAnnotations() const;
00510 
00518     bool getIgnoreCachedDTD() const;
00519 
00527     bool getIgnoreAnnotations() const;
00528 
00536     bool getDisableDefaultEntityResolution() const;
00537 
00545     bool getSkipDTDValidation() const;
00546 
00554     bool getHandleMultipleImports() const;
00556 
00557 
00558     
00559     
00560     
00561 
00574     void setGenerateSyntheticAnnotations(const bool newValue);
00575 
00583     void setValidateAnnotations(const bool newValue);
00584 
00598     void setDoNamespaces(const bool newState);
00599 
00616     void setValidationScheme(const ValSchemes newScheme);
00617 
00633     void setDoSchema(const bool newState);
00634 
00651     void setValidationSchemaFullChecking(const bool schemaFullChecking);
00652 
00664     void setIdentityConstraintChecking(const bool identityConstraintChecking);
00665 
00681     void setExitOnFirstFatalError(const bool newState);
00682 
00702     void setValidationConstraintFatal(const bool newState);
00703 
00724     void setExternalSchemaLocation(const XMLCh* const schemaLocation);
00725 
00734     void setExternalSchemaLocation(const char* const schemaLocation);
00735 
00750     void setExternalNoNamespaceSchemaLocation(const XMLCh* const noNamespaceSchemaLocation);
00751 
00760     void setExternalNoNamespaceSchemaLocation(const char* const noNamespaceSchemaLocation);
00761 
00777     void setSecurityManager(SecurityManager* const securityManager);
00778 
00792     void setLowWaterMark(XMLSize_t lwm);
00793 
00810     void setLoadExternalDTD(const bool newState);
00811 
00827     void setLoadSchema(const bool newState);
00828 
00846     void cacheGrammarFromParse(const bool newState);
00847 
00866     void useCachedGrammarInParse(const bool newState);
00867 
00880     void setCalculateSrcOfs(const bool newState);
00881 
00892     void setStandardUriConformant(const bool newState);
00893 
00901     void useScanner(const XMLCh* const scannerName);
00902 
00913     void setInputBufferSize(const XMLSize_t bufferSize);
00914 
00929     void setIgnoreCachedDTD(const bool newValue);
00930 
00940     void setIgnoreAnnotations(const bool newValue);
00941 
00956     void setDisableDefaultEntityResolution(const bool newValue);
00957 
00970     void setSkipDTDValidation(const bool newValue);
00971 
00983     void setHandleMultipleImports(const bool newValue);
00985 
00986 
00987     
00988     
00989     
00990 
01008     void installAdvDocHandler(XMLDocumentHandler* const toInstall);
01009 
01021     bool removeAdvDocHandler(XMLDocumentHandler* const toRemove);
01023 
01024 
01025     
01026     
01027     
01028 
01031 
01059     bool parseFirst
01060     (
01061         const   XMLCh* const    systemId
01062         ,       XMLPScanToken&  toFill
01063     );
01064 
01092     bool parseFirst
01093     (
01094         const   char* const     systemId
01095         ,       XMLPScanToken&  toFill
01096     );
01097 
01125     bool parseFirst
01126     (
01127         const   InputSource&    source
01128         ,       XMLPScanToken&  toFill
01129     );
01130 
01155     bool parseNext(XMLPScanToken& token);
01156 
01178     void parseReset(XMLPScanToken& token);
01179 
01181 
01182     
01183     
01184     
01185 
01214     Grammar* loadGrammar(const InputSource& source,
01215                          const Grammar::GrammarType grammarType,
01216                          const bool toCache = false);
01217 
01242     Grammar* loadGrammar(const XMLCh* const systemId,
01243                          const Grammar::GrammarType grammarType,
01244                          const bool toCache = false);
01245 
01269     Grammar* loadGrammar(const char* const systemId,
01270                          const Grammar::GrammarType grammarType,
01271                          const bool toCache = false);
01272 
01276     void resetCachedGrammarPool();
01277 
01279 
01280 
01281     
01282     
01283     
01284 
01296     virtual void parse(const InputSource& source);
01297 
01307     virtual void parse(const XMLCh* const systemId);
01308 
01316     virtual void parse(const char* const systemId);
01317 
01328     virtual void setDocumentHandler(DocumentHandler* const handler);
01329 
01339     virtual void setDTDHandler(DTDHandler* const handler);
01340 
01351     virtual void setErrorHandler(ErrorHandler* const handler);
01352 
01363     virtual void setPSVIHandler(PSVIHandler* const handler);
01364 
01380     virtual void setEntityResolver(EntityResolver* const resolver);
01381 
01397     virtual void setXMLEntityResolver(XMLEntityResolver* const resolver);
01398 
01400 
01401 
01402     
01403     
01404     
01405 
01423     virtual void docCharacters
01424     (
01425         const   XMLCh* const    chars
01426         , const XMLSize_t       length
01427         , const bool            cdataSection
01428     );
01429 
01439     virtual void docComment
01440     (
01441         const   XMLCh* const    comment
01442     );
01443 
01463     virtual void docPI
01464     (
01465         const   XMLCh* const    target
01466         , const XMLCh* const    data
01467     );
01468 
01480     virtual void endDocument();
01481 
01501     virtual void endElement
01502     (
01503         const   XMLElementDecl& elemDecl
01504         , const unsigned int    urlId
01505         , const bool            isRoot
01506         , const XMLCh* const    elemPrefix
01507     );
01508 
01519     virtual void endEntityReference
01520     (
01521         const   XMLEntityDecl&  entDecl
01522     );
01523 
01543     virtual void ignorableWhitespace
01544     (
01545         const   XMLCh* const    chars
01546         , const XMLSize_t       length
01547         , const bool            cdataSection
01548     );
01549 
01554     virtual void resetDocument();
01555 
01566     virtual void startDocument();
01567 
01594     virtual void startElement
01595     (
01596         const   XMLElementDecl&         elemDecl
01597         , const unsigned int            urlId
01598         , const XMLCh* const            elemPrefix
01599         , const RefVectorOf<XMLAttr>&   attrList
01600         , const XMLSize_t               attrCount
01601         , const bool                    isEmpty
01602         , const bool                    isRoot
01603     );
01604 
01614     virtual void startEntityReference
01615     (
01616         const   XMLEntityDecl&  entDecl
01617     );
01618 
01636     virtual void XMLDecl
01637     (
01638         const   XMLCh* const    versionStr
01639         , const XMLCh* const    encodingStr
01640         , const XMLCh* const    standaloneStr
01641         , const XMLCh* const    actualEncodingStr
01642     );
01644 
01645 
01646     
01647     
01648     
01649 
01675     virtual void error
01676     (
01677         const   unsigned int                errCode
01678         , const XMLCh* const                msgDomain
01679         , const XMLErrorReporter::ErrTypes  errType
01680         , const XMLCh* const                errorText
01681         , const XMLCh* const                systemId
01682         , const XMLCh* const                publicId
01683         , const XMLFileLoc                  lineNum
01684         , const XMLFileLoc                  colNum
01685     );
01686 
01695     virtual void resetErrors();
01697 
01698 
01699     
01700     
01701     
01702 
01716     virtual void endInputSource(const InputSource& inputSource);
01717 
01732     virtual bool expandSystemId
01733     (
01734         const   XMLCh* const    systemId
01735         ,       XMLBuffer&      toFill
01736     );
01737 
01745     virtual void resetEntities();
01746 
01763     virtual InputSource* resolveEntity
01764     (
01765         XMLResourceIdentifier* resourceIdentifier
01766     );
01767 
01779     virtual void startInputSource(const InputSource& inputSource);
01781 
01782 
01783     
01784     
01785     
01802     virtual void attDef
01803     (
01804         const   DTDElementDecl& elemDecl
01805         , const DTDAttDef&      attDef
01806         , const bool            ignore
01807     );
01808 
01818     virtual void doctypeComment
01819     (
01820         const   XMLCh* const    comment
01821     );
01822 
01841     virtual void doctypeDecl
01842     (
01843         const   DTDElementDecl& elemDecl
01844         , const XMLCh* const    publicId
01845         , const XMLCh* const    systemId
01846         , const bool            hasIntSubset
01847         , const bool            hasExtSubset = false
01848     );
01849 
01863     virtual void doctypePI
01864     (
01865         const   XMLCh* const    target
01866         , const XMLCh* const    data
01867     );
01868 
01880     virtual void doctypeWhitespace
01881     (
01882         const   XMLCh* const    chars
01883         , const XMLSize_t       length
01884     );
01885 
01898     virtual void elementDecl
01899     (
01900         const   DTDElementDecl& decl
01901         , const bool            isIgnored
01902     );
01903 
01914     virtual void endAttList
01915     (
01916         const   DTDElementDecl& elemDecl
01917     );
01918 
01925     virtual void endIntSubset();
01926 
01933     virtual void endExtSubset();
01934 
01949     virtual void entityDecl
01950     (
01951         const   DTDEntityDecl&  entityDecl
01952         , const bool            isPEDecl
01953         , const bool            isIgnored
01954     );
01955 
01960     virtual void resetDocType();
01961 
01974     virtual void notationDecl
01975     (
01976         const   XMLNotationDecl&    notDecl
01977         , const bool                isIgnored
01978     );
01979 
01990     virtual void startAttList
01991     (
01992         const   DTDElementDecl& elemDecl
01993     );
01994 
02001     virtual void startIntSubset();
02002 
02009     virtual void startExtSubset();
02010 
02023     virtual void TextDecl
02024     (
02025         const   XMLCh* const    versionStr
02026         , const XMLCh* const    encodingStr
02027     );
02029 
02030 protected :
02031     
02032     
02033     
02040     const XMLScanner& getScanner() const;
02041 
02046     GrammarResolver* getGrammarResolver() const;
02047 
02048 
02049 private:
02050     
02051     
02052     
02053     SAXParser(const SAXParser&);
02054     SAXParser& operator=(const SAXParser&);
02055 
02056     
02057     
02058     
02059     void initialize();
02060     void cleanUp();
02061     void resetInProgress();
02062 
02063     
02064     
02065     
02066     
02067     
02068     
02069     
02070     
02071     
02072     
02073     
02074     
02075     
02076     
02077     
02078     
02079     
02080     
02081     
02082     
02083     
02084     
02085     
02086     
02087     
02088     
02089     
02090     
02091     
02092     
02093     
02094     
02095     
02096     
02097     
02098     
02099     
02100     
02101     
02102     
02103     
02104     
02105     
02106     
02107     
02108     
02109     
02110     
02111     
02112     
02113     
02114     
02115     
02116     
02117     bool                 fParseInProgress;
02118     XMLSize_t            fElemDepth;
02119     XMLSize_t            fAdvDHCount;
02120     XMLSize_t            fAdvDHListSize;
02121     VecAttrListImpl      fAttrList;
02122     DocumentHandler*     fDocHandler;
02123     DTDHandler*          fDTDHandler;
02124     EntityResolver*      fEntityResolver;
02125     XMLEntityResolver*   fXMLEntityResolver;
02126     ErrorHandler*        fErrorHandler;
02127     PSVIHandler*         fPSVIHandler;
02128     XMLDocumentHandler** fAdvDHList;
02129     XMLScanner*          fScanner;
02130     GrammarResolver*     fGrammarResolver;
02131     XMLStringPool*       fURIStringPool;
02132     XMLValidator*        fValidator;
02133     MemoryManager*       fMemoryManager;
02134     XMLGrammarPool*      fGrammarPool;
02135     XMLBuffer            fElemQNameBuf;
02136 };
02137 
02138 
02139 
02140 
02141 
02142 inline DocumentHandler* SAXParser::getDocumentHandler()
02143 {
02144     return fDocHandler;
02145 }
02146 
02147 inline const DocumentHandler* SAXParser::getDocumentHandler() const
02148 {
02149     return fDocHandler;
02150 }
02151 
02152 inline EntityResolver* SAXParser::getEntityResolver()
02153 {
02154     return fEntityResolver;
02155 }
02156 
02157 inline XMLEntityResolver* SAXParser::getXMLEntityResolver()
02158 {
02159     return fXMLEntityResolver;
02160 }
02161 
02162 inline const XMLEntityResolver* SAXParser::getXMLEntityResolver() const
02163 {
02164     return fXMLEntityResolver;
02165 }
02166 
02167 inline const EntityResolver* SAXParser::getEntityResolver() const
02168 {
02169     return fEntityResolver;
02170 }
02171 
02172 inline ErrorHandler* SAXParser::getErrorHandler()
02173 {
02174     return fErrorHandler;
02175 }
02176 
02177 inline const ErrorHandler* SAXParser::getErrorHandler() const
02178 {
02179     return fErrorHandler;
02180 }
02181 
02182 inline PSVIHandler* SAXParser::getPSVIHandler()
02183 {
02184     return fPSVIHandler;
02185 }
02186 
02187 inline const PSVIHandler* SAXParser::getPSVIHandler() const
02188 {
02189     return fPSVIHandler;
02190 }
02191 
02192 inline const XMLScanner& SAXParser::getScanner() const
02193 {
02194     return *fScanner;
02195 }
02196 
02197 inline GrammarResolver* SAXParser::getGrammarResolver() const
02198 {
02199     return fGrammarResolver;
02200 }
02201 
02202 XERCES_CPP_NAMESPACE_END
02203 
02204 #endif