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 #if !defined(SAXPARSER_HPP)
00129 #define SAXPARSER_HPP
00130
00131 #include <sax/Parser.hpp>
00132 #include <internal/VecAttrListImpl.hpp>
00133 #include <framework/XMLDocumentHandler.hpp>
00134 #include <framework/XMLElementDecl.hpp>
00135 #include <framework/XMLEntityHandler.hpp>
00136 #include <framework/XMLErrorReporter.hpp>
00137 #include <validators/DTD/DocTypeHandler.hpp>
00138
00139 class DocumentHandler;
00140 class EntityResolver;
00141 class XMLPScanToken;
00142 class XMLScanner;
00143 class XMLValidator;
00144
00145
00155
00156 class SAXParser :
00157
00158 public Parser
00159 , public XMLDocumentHandler
00160 , public XMLErrorReporter
00161 , public XMLEntityHandler
00162 , public DocTypeHandler
00163 {
00164 public :
00165
00166
00167
00168 enum ValSchemes
00169 {
00170 Val_Never
00171 , Val_Always
00172 , Val_Auto
00173 };
00174
00175
00176
00177
00178
00179
00182
00187 SAXParser(XMLValidator* const valToAdopt = 0);
00188
00192 ~SAXParser();
00194
00195
00198
00204 DocumentHandler* getDocumentHandler();
00205
00212 const DocumentHandler* getDocumentHandler() const;
00213
00220 EntityResolver* getEntityResolver();
00221
00228 const EntityResolver* getEntityResolver() const;
00229
00236 ErrorHandler* getErrorHandler();
00237
00244 const ErrorHandler* getErrorHandler() const;
00245
00252 const XMLValidator& getValidator() const;
00253
00261 ValSchemes getValidationScheme() const;
00262
00273 bool getDoSchema() const;
00274
00285 int getErrorCount() const;
00286
00296 bool getDoNamespaces() const;
00297
00307 bool getExitOnFirstFatalError() const;
00308
00319 bool getValidationConstraintFatal() const;
00321
00322
00323
00324
00325
00326
00329
00346 void setDoNamespaces(const bool newState);
00347
00364 void setValidationScheme(const ValSchemes newScheme);
00365
00379 void setDoSchema(const bool newState);
00380
00381
00397 void setExitOnFirstFatalError(const bool newState);
00398
00414 void setValidationConstraintFatal(const bool newState);
00416
00417
00418
00419
00420
00421
00424
00437 void installAdvDocHandler(XMLDocumentHandler* const toInstall);
00438
00448 bool removeAdvDocHandler(XMLDocumentHandler* const toRemove);
00450
00451
00452
00453
00454
00455
00458
00470 virtual void parse(const InputSource& source, const bool reuseGrammar = false);
00471
00484 virtual void parse(const XMLCh* const systemId, const bool reuseGrammar = false);
00485
00496 virtual void parse(const char* const systemId, const bool reuseGrammar = false);
00497
00508 virtual void setDocumentHandler(DocumentHandler* const handler);
00509
00519 virtual void setDTDHandler(DTDHandler* const handler);
00520
00531 virtual void setErrorHandler(ErrorHandler* const handler);
00532
00544 virtual void setEntityResolver(EntityResolver* const resolver);
00546
00547
00548
00549
00550
00551
00554
00585 bool parseFirst
00586 (
00587 const XMLCh* const systemId
00588 , XMLPScanToken& toFill
00589 , const bool reuseGrammar = false
00590 );
00591
00622 bool parseFirst
00623 (
00624 const char* const systemId
00625 , XMLPScanToken& toFill
00626 , const bool reuseGrammar = false
00627 );
00628
00659 bool parseFirst
00660 (
00661 const InputSource& source
00662 , XMLPScanToken& toFill
00663 , const bool reuseGrammar = false
00664 );
00665
00690 bool parseNext(XMLPScanToken& token);
00691
00713 void parseReset(XMLPScanToken& token);
00714
00716
00717
00718
00719
00720
00721
00722
00725
00739 virtual void attDef
00740 (
00741 const DTDElementDecl& elemDecl
00742 , const DTDAttDef& attDef
00743 , const bool ignoring
00744 );
00745
00755 virtual void doctypeComment
00756 (
00757 const XMLCh* const comment
00758 );
00759
00776 virtual void doctypeDecl
00777 (
00778 const DTDElementDecl& elemDecl
00779 , const XMLCh* const publicId
00780 , const XMLCh* const systemId
00781 , const bool hasIntSubset
00782 );
00783
00797 virtual void doctypePI
00798 (
00799 const XMLCh* const target
00800 , const XMLCh* const data
00801 );
00802
00814 virtual void doctypeWhitespace
00815 (
00816 const XMLCh* const chars
00817 , const unsigned int length
00818 );
00819
00832 virtual void elementDecl
00833 (
00834 const DTDElementDecl& decl
00835 , const bool isIgnored
00836 );
00837
00848 virtual void endAttList
00849 (
00850 const DTDElementDecl& elemDecl
00851 );
00852
00859 virtual void endIntSubset();
00860
00867 virtual void endExtSubset();
00868
00883 virtual void entityDecl
00884 (
00885 const DTDEntityDecl& entityDecl
00886 , const bool isPEDecl
00887 , const bool isIgnored
00888 );
00889
00894 virtual void resetDocType();
00895
00908 virtual void notationDecl
00909 (
00910 const XMLNotationDecl& notDecl
00911 , const bool isIgnored
00912 );
00913
00924 virtual void startAttList
00925 (
00926 const DTDElementDecl& elemDecl
00927 );
00928
00935 virtual void startIntSubset();
00936
00943 virtual void startExtSubset();
00944
00957 virtual void TextDecl
00958 (
00959 const XMLCh* const versionStr
00960 , const XMLCh* const encodingStr
00961 );
00963
00964
00965
00966
00967
00968
00971
00986 virtual void docCharacters
00987 (
00988 const XMLCh* const chars
00989 , const unsigned int length
00990 , const bool cdataSection
00991 );
00992
01002 virtual void docComment
01003 (
01004 const XMLCh* const comment
01005 );
01006
01026 virtual void docPI
01027 (
01028 const XMLCh* const target
01029 , const XMLCh* const data
01030 );
01031
01043 virtual void endDocument();
01044
01061 virtual void endElement
01062 (
01063 const XMLElementDecl& elemDecl
01064 , const unsigned int urlId
01065 , const bool isRoot
01066 );
01067
01078 virtual void endEntityReference
01079 (
01080 const XMLEntityDecl& entDecl
01081 );
01082
01102 virtual void ignorableWhitespace
01103 (
01104 const XMLCh* const chars
01105 , const unsigned int length
01106 , const bool cdataSection
01107 );
01108
01113 virtual void resetDocument();
01114
01125 virtual void startDocument();
01126
01153 virtual void startElement
01154 (
01155 const XMLElementDecl& elemDecl
01156 , const unsigned int urlId
01157 , const XMLCh* const elemPrefix
01158 , const RefVectorOf<XMLAttr>& attrList
01159 , const unsigned int attrCount
01160 , const bool isEmpty
01161 , const bool isRoot
01162 );
01163
01173 virtual void startEntityReference
01174 (
01175 const XMLEntityDecl& entDecl
01176 );
01177
01195 virtual void XMLDecl
01196 (
01197 const XMLCh* const versionStr
01198 , const XMLCh* const encodingStr
01199 , const XMLCh* const standaloneStr
01200 , const XMLCh* const actualEncodingStr
01201 );
01203
01204
01205
01206
01207
01208
01211
01234 virtual void error
01235 (
01236 const unsigned int errCode
01237 , const XMLCh* const msgDomain
01238 , const XMLErrorReporter::ErrTypes errType
01239 , const XMLCh* const errorText
01240 , const XMLCh* const systemId
01241 , const XMLCh* const publicId
01242 , const unsigned int lineNum
01243 , const unsigned int colNum
01244 );
01245
01254 virtual void resetErrors();
01256
01257
01258
01259
01260
01261
01264
01275 virtual void endInputSource(const InputSource& inputSource);
01276
01291 virtual bool expandSystemId
01292 (
01293 const XMLCh* const systemId
01294 , XMLBuffer& toFill
01295 );
01296
01304 virtual void resetEntities();
01305
01320 virtual InputSource* resolveEntity
01321 (
01322 const XMLCh* const publicId
01323 , const XMLCh* const systemId
01324 );
01325
01337 virtual void startInputSource(const InputSource& inputSource);
01339
01340
01343
01353 bool getDoValidation() const;
01354
01368 void setDoValidation(const bool newState);
01370
01371
01372 protected :
01373
01374
01375
01376 SAXParser(const SAXParser&);
01377 void operator=(const SAXParser&);
01378
01379
01380
01381
01382
01383
01384
01385
01386
01387
01388
01389
01390
01391
01392
01393
01394
01395
01396
01397
01398
01399
01400
01401
01402
01403
01404
01405
01406
01407
01408
01409
01410
01411
01412
01413
01414
01415
01416
01417
01418
01419
01420
01421
01422
01423
01424
01425
01426
01427 VecAttrListImpl fAttrList;
01428 DocumentHandler* fDocHandler;
01429 DTDHandler* fDTDHandler;
01430 unsigned int fElemDepth;
01431 EntityResolver* fEntityResolver;
01432 ErrorHandler* fErrorHandler;
01433 unsigned int fAdvDHCount;
01434 XMLDocumentHandler** fAdvDHList;
01435 unsigned int fAdvDHListSize;
01436 bool fParseInProgress;
01437 XMLScanner* fScanner;
01438 };
01439
01440
01441
01442
01443
01444 inline DocumentHandler* SAXParser::getDocumentHandler()
01445 {
01446 return fDocHandler;
01447 }
01448
01449 inline const DocumentHandler* SAXParser::getDocumentHandler() const
01450 {
01451 return fDocHandler;
01452 }
01453
01454 inline EntityResolver* SAXParser::getEntityResolver()
01455 {
01456 return fEntityResolver;
01457 }
01458
01459 inline const EntityResolver* SAXParser::getEntityResolver() const
01460 {
01461 return fEntityResolver;
01462 }
01463
01464 inline ErrorHandler* SAXParser::getErrorHandler()
01465 {
01466 return fErrorHandler;
01467 }
01468
01469 inline const ErrorHandler* SAXParser::getErrorHandler() const
01470 {
01471 return fErrorHandler;
01472 }
01473
01474 #endif