00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244 #if !defined(SAXPARSER_HPP)
00245 #define SAXPARSER_HPP
00246
00247 #include <xercesc/sax/Parser.hpp>
00248 #include <xercesc/internal/VecAttrListImpl.hpp>
00249 #include <xercesc/framework/XMLDocumentHandler.hpp>
00250 #include <xercesc/framework/XMLElementDecl.hpp>
00251 #include <xercesc/framework/XMLEntityHandler.hpp>
00252 #include <xercesc/framework/XMLErrorReporter.hpp>
00253 #include <xercesc/framework/XMLBuffer.hpp>
00254 #include <xercesc/util/SecurityManager.hpp>
00255 #include <xercesc/validators/DTD/DocTypeHandler.hpp>
00256
00257 XERCES_CPP_NAMESPACE_BEGIN
00258
00259
00260 class DocumentHandler;
00261 class EntityResolver;
00262 class XMLPScanToken;
00263 class XMLScanner;
00264 class XMLValidator;
00265 class Grammar;
00266 class GrammarResolver;
00267 class XMLGrammarPool;
00268 class XMLEntityResolver;
00269 class XMLResourceIdentifier;
00270 class PSVIHandler;
00271
00282 class SAXParser :
00283
00284 public XMemory
00285 , public Parser
00286 , public XMLDocumentHandler
00287 , public XMLErrorReporter
00288 , public XMLEntityHandler
00289 , public DocTypeHandler
00290 {
00291 public :
00292
00293
00294
00303 enum ValSchemes
00304 {
00305 Val_Never
00306 , Val_Always
00307 , Val_Auto
00308 };
00309
00310
00311
00312
00313
00324 SAXParser
00325 (
00326 XMLValidator* const valToAdopt = 0
00327 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00328 , XMLGrammarPool* const gramPool = 0
00329 );
00330
00334 ~SAXParser();
00336
00337
00338
00339
00340
00349 DocumentHandler* getDocumentHandler();
00350
00357 const DocumentHandler* getDocumentHandler() const;
00358
00365 EntityResolver* getEntityResolver();
00366
00373 const EntityResolver* getEntityResolver() const;
00374
00381 XMLEntityResolver* getXMLEntityResolver();
00382
00389 const XMLEntityResolver* getXMLEntityResolver() const;
00390
00397 ErrorHandler* getErrorHandler();
00398
00405 const ErrorHandler* getErrorHandler() const;
00406
00413 PSVIHandler* getPSVIHandler();
00414
00421 const PSVIHandler* getPSVIHandler() const;
00422
00429 const XMLValidator& getValidator() const;
00430
00438 ValSchemes getValidationScheme() const;
00439
00450 bool getDoSchema() const;
00451
00462 bool getValidationSchemaFullChecking() const;
00463
00474 int getErrorCount() const;
00475
00485 bool getDoNamespaces() const;
00486
00496 bool getExitOnFirstFatalError() const;
00497
00508 bool getValidationConstraintFatal() const;
00509
00529 XMLCh* getExternalSchemaLocation() const;
00530
00550 XMLCh* getExternalNoNamespaceSchemaLocation() const;
00551
00567 SecurityManager* getSecurityManager() const;
00568
00580 bool getLoadExternalDTD() const;
00581
00592 bool isCachingGrammarFromParse() const;
00593
00604 bool isUsingCachedGrammarInParse() const;
00605
00617 bool getCalculateSrcOfs() const;
00618
00629 bool getStandardUriConformant() const;
00630
00637 Grammar* getGrammar(const XMLCh* const nameSpaceKey);
00638
00644 Grammar* getRootGrammar();
00645
00652 const XMLCh* getURIText(unsigned int uriId) const;
00653
00659 unsigned int getSrcOffset() const;
00660
00662
00663
00664
00665
00666
00667
00683 void setDoNamespaces(const bool newState);
00684
00701 void setValidationScheme(const ValSchemes newScheme);
00702
00718 void setDoSchema(const bool newState);
00719
00736 void setValidationSchemaFullChecking(const bool schemaFullChecking);
00737
00753 void setExitOnFirstFatalError(const bool newState);
00754
00774 void setValidationConstraintFatal(const bool newState);
00775
00796 void setExternalSchemaLocation(const XMLCh* const schemaLocation);
00797
00806 void setExternalSchemaLocation(const char* const schemaLocation);
00807
00822 void setExternalNoNamespaceSchemaLocation(const XMLCh* const noNamespaceSchemaLocation);
00823
00832 void setExternalNoNamespaceSchemaLocation(const char* const noNamespaceSchemaLocation);
00833
00849 void setSecurityManager(SecurityManager* const securityManager);
00850
00867 void setLoadExternalDTD(const bool newState);
00868
00886 void cacheGrammarFromParse(const bool newState);
00887
00906 void useCachedGrammarInParse(const bool newState);
00907
00920 void setCalculateSrcOfs(const bool newState);
00921
00932 void setStandardUriConformant(const bool newState);
00933
00941 void useScanner(const XMLCh* const scannerName);
00942
00944
00945
00946
00947
00948
00949
00965 void installAdvDocHandler(XMLDocumentHandler* const toInstall);
00966
00976 bool removeAdvDocHandler(XMLDocumentHandler* const toRemove);
00978
00979
00980
00981
00982
00983
00986
01014 bool parseFirst
01015 (
01016 const XMLCh* const systemId
01017 , XMLPScanToken& toFill
01018 );
01019
01047 bool parseFirst
01048 (
01049 const char* const systemId
01050 , XMLPScanToken& toFill
01051 );
01052
01080 bool parseFirst
01081 (
01082 const InputSource& source
01083 , XMLPScanToken& toFill
01084 );
01085
01110 bool parseNext(XMLPScanToken& token);
01111
01133 void parseReset(XMLPScanToken& token);
01134
01136
01137
01138
01139
01140
01170 Grammar* loadGrammar(const InputSource& source,
01171 const short grammarType,
01172 const bool toCache = false);
01173
01199 Grammar* loadGrammar(const XMLCh* const systemId,
01200 const short grammarType,
01201 const bool toCache = false);
01202
01227 Grammar* loadGrammar(const char* const systemId,
01228 const short grammarType,
01229 const bool toCache = false);
01230
01234 void resetCachedGrammarPool();
01235
01237
01238
01239
01240
01241
01242
01254 virtual void parse(const InputSource& source);
01255
01265 virtual void parse(const XMLCh* const systemId);
01266
01274 virtual void parse(const char* const systemId);
01275
01286 virtual void setDocumentHandler(DocumentHandler* const handler);
01287
01297 virtual void setDTDHandler(DTDHandler* const handler);
01298
01309 virtual void setErrorHandler(ErrorHandler* const handler);
01310
01321 virtual void setPSVIHandler(PSVIHandler* const handler);
01322
01338 virtual void setEntityResolver(EntityResolver* const resolver);
01339
01355 virtual void setXMLEntityResolver(XMLEntityResolver* const resolver);
01356
01358
01359
01360
01361
01362
01363
01381 virtual void docCharacters
01382 (
01383 const XMLCh* const chars
01384 , const unsigned int length
01385 , const bool cdataSection
01386 );
01387
01397 virtual void docComment
01398 (
01399 const XMLCh* const comment
01400 );
01401
01421 virtual void docPI
01422 (
01423 const XMLCh* const target
01424 , const XMLCh* const data
01425 );
01426
01438 virtual void endDocument();
01439
01459 virtual void endElement
01460 (
01461 const XMLElementDecl& elemDecl
01462 , const unsigned int urlId
01463 , const bool isRoot
01464 , const XMLCh* const elemPrefix
01465 );
01466
01477 virtual void endEntityReference
01478 (
01479 const XMLEntityDecl& entDecl
01480 );
01481
01501 virtual void ignorableWhitespace
01502 (
01503 const XMLCh* const chars
01504 , const unsigned int length
01505 , const bool cdataSection
01506 );
01507
01512 virtual void resetDocument();
01513
01524 virtual void startDocument();
01525
01552 virtual void startElement
01553 (
01554 const XMLElementDecl& elemDecl
01555 , const unsigned int urlId
01556 , const XMLCh* const elemPrefix
01557 , const RefVectorOf<XMLAttr>& attrList
01558 , const unsigned int attrCount
01559 , const bool isEmpty
01560 , const bool isRoot
01561 );
01562
01572 virtual void startEntityReference
01573 (
01574 const XMLEntityDecl& entDecl
01575 );
01576
01594 virtual void XMLDecl
01595 (
01596 const XMLCh* const versionStr
01597 , const XMLCh* const encodingStr
01598 , const XMLCh* const standaloneStr
01599 , const XMLCh* const actualEncodingStr
01600 );
01602
01603
01604
01605
01606
01607
01633 virtual void error
01634 (
01635 const unsigned int errCode
01636 , const XMLCh* const msgDomain
01637 , const XMLErrorReporter::ErrTypes errType
01638 , const XMLCh* const errorText
01639 , const XMLCh* const systemId
01640 , const XMLCh* const publicId
01641 , const XMLSSize_t lineNum
01642 , const XMLSSize_t colNum
01643 );
01644
01653 virtual void resetErrors();
01655
01656
01657
01658
01659
01660
01674 virtual void endInputSource(const InputSource& inputSource);
01675
01690 virtual bool expandSystemId
01691 (
01692 const XMLCh* const systemId
01693 , XMLBuffer& toFill
01694 );
01695
01703 virtual void resetEntities();
01704
01727 virtual InputSource* resolveEntity
01728 (
01729 const XMLCh* const publicId
01730 , const XMLCh* const systemId
01731 , const XMLCh* const baseURI = 0
01732 );
01733
01750 virtual InputSource* resolveEntity
01751 (
01752 XMLResourceIdentifier* resourceIdentifier
01753 );
01754
01766 virtual void startInputSource(const InputSource& inputSource);
01768
01769
01770
01771
01772
01789 virtual void attDef
01790 (
01791 const DTDElementDecl& elemDecl
01792 , const DTDAttDef& attDef
01793 , const bool ignore
01794 );
01795
01805 virtual void doctypeComment
01806 (
01807 const XMLCh* const comment
01808 );
01809
01828 virtual void doctypeDecl
01829 (
01830 const DTDElementDecl& elemDecl
01831 , const XMLCh* const publicId
01832 , const XMLCh* const systemId
01833 , const bool hasIntSubset
01834 , const bool hasExtSubset = false
01835 );
01836
01850 virtual void doctypePI
01851 (
01852 const XMLCh* const target
01853 , const XMLCh* const data
01854 );
01855
01867 virtual void doctypeWhitespace
01868 (
01869 const XMLCh* const chars
01870 , const unsigned int length
01871 );
01872
01885 virtual void elementDecl
01886 (
01887 const DTDElementDecl& decl
01888 , const bool isIgnored
01889 );
01890
01901 virtual void endAttList
01902 (
01903 const DTDElementDecl& elemDecl
01904 );
01905
01912 virtual void endIntSubset();
01913
01920 virtual void endExtSubset();
01921
01936 virtual void entityDecl
01937 (
01938 const DTDEntityDecl& entityDecl
01939 , const bool isPEDecl
01940 , const bool isIgnored
01941 );
01942
01947 virtual void resetDocType();
01948
01961 virtual void notationDecl
01962 (
01963 const XMLNotationDecl& notDecl
01964 , const bool isIgnored
01965 );
01966
01977 virtual void startAttList
01978 (
01979 const DTDElementDecl& elemDecl
01980 );
01981
01988 virtual void startIntSubset();
01989
01996 virtual void startExtSubset();
01997
02010 virtual void TextDecl
02011 (
02012 const XMLCh* const versionStr
02013 , const XMLCh* const encodingStr
02014 );
02016
02017
02018
02019
02020
02033 bool getDoValidation() const;
02034
02048 void setDoValidation(const bool newState);
02050
02051
02052 protected :
02053
02054
02055
02062 const XMLScanner& getScanner() const;
02063
02068 GrammarResolver* getGrammarResolver() const;
02069
02070
02071 private:
02072
02073
02074
02075 SAXParser(const SAXParser&);
02076 SAXParser& operator=(const SAXParser&);
02077
02078
02079
02080
02081 void initialize();
02082 void cleanUp();
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
02118
02119
02120
02121
02122
02123
02124
02125
02126
02127
02128
02129
02130
02131
02132
02133
02134
02135
02136
02137
02138 bool fParseInProgress;
02139 unsigned int fElemDepth;
02140 unsigned int fAdvDHCount;
02141 unsigned int fAdvDHListSize;
02142 VecAttrListImpl fAttrList;
02143 DocumentHandler* fDocHandler;
02144 DTDHandler* fDTDHandler;
02145 EntityResolver* fEntityResolver;
02146 XMLEntityResolver* fXMLEntityResolver;
02147 ErrorHandler* fErrorHandler;
02148 PSVIHandler* fPSVIHandler;
02149 XMLDocumentHandler** fAdvDHList;
02150 XMLScanner* fScanner;
02151 GrammarResolver* fGrammarResolver;
02152 XMLStringPool* fURIStringPool;
02153 XMLValidator* fValidator;
02154 MemoryManager* fMemoryManager;
02155 XMLGrammarPool* fGrammarPool;
02156 XMLBuffer fElemQNameBuf;
02157 };
02158
02159
02160
02161
02162
02163 inline DocumentHandler* SAXParser::getDocumentHandler()
02164 {
02165 return fDocHandler;
02166 }
02167
02168 inline const DocumentHandler* SAXParser::getDocumentHandler() const
02169 {
02170 return fDocHandler;
02171 }
02172
02173 inline EntityResolver* SAXParser::getEntityResolver()
02174 {
02175 return fEntityResolver;
02176 }
02177
02178 inline XMLEntityResolver* SAXParser::getXMLEntityResolver()
02179 {
02180 return fXMLEntityResolver;
02181 }
02182
02183 inline const XMLEntityResolver* SAXParser::getXMLEntityResolver() const
02184 {
02185 return fXMLEntityResolver;
02186 }
02187
02188 inline const EntityResolver* SAXParser::getEntityResolver() const
02189 {
02190 return fEntityResolver;
02191 }
02192
02193 inline ErrorHandler* SAXParser::getErrorHandler()
02194 {
02195 return fErrorHandler;
02196 }
02197
02198 inline const ErrorHandler* SAXParser::getErrorHandler() const
02199 {
02200 return fErrorHandler;
02201 }
02202
02203 inline PSVIHandler* SAXParser::getPSVIHandler()
02204 {
02205 return fPSVIHandler;
02206 }
02207
02208 inline const PSVIHandler* SAXParser::getPSVIHandler() const
02209 {
02210 return fPSVIHandler;
02211 }
02212
02213 inline const XMLScanner& SAXParser::getScanner() const
02214 {
02215 return *fScanner;
02216 }
02217
02218 inline GrammarResolver* SAXParser::getGrammarResolver() const
02219 {
02220 return fGrammarResolver;
02221 }
02222
02223 XERCES_CPP_NAMESPACE_END
02224
02225 #endif