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 #if !defined(SAXPARSER_HPP)
00123 #define SAXPARSER_HPP
00124
00125 #include <sax/Parser.hpp>
00126 #include <internal/VecAttrListImpl.hpp>
00127 #include <framework/XMLDocumentHandler.hpp>
00128 #include <framework/XMLElementDecl.hpp>
00129 #include <framework/XMLEntityHandler.hpp>
00130 #include <framework/XMLErrorReporter.hpp>
00131 #include <validators/DTD/DocTypeHandler.hpp>
00132
00133 class DocumentHandler;
00134 class EntityResolver;
00135 class XMLPScanToken;
00136 class XMLScanner;
00137 class XMLValidator;
00138
00139
00149
00150 class SAXParser :
00151
00152 public Parser
00153 , public XMLDocumentHandler
00154 , public XMLErrorReporter
00155 , public XMLEntityHandler
00156 , public DocTypeHandler
00157 {
00158 public :
00159
00160
00161
00162 enum ValSchemes
00163 {
00164 Val_Never
00165 , Val_Always
00166 , Val_Auto
00167 };
00168
00169
00170
00171
00172
00173
00176
00181 SAXParser(XMLValidator* const valToAdopt = 0);
00182
00186 ~SAXParser();
00188
00189
00192
00198 DocumentHandler* getDocumentHandler();
00199
00206 const DocumentHandler* getDocumentHandler() const;
00207
00214 EntityResolver* getEntityResolver();
00215
00222 const EntityResolver* getEntityResolver() const;
00223
00230 ErrorHandler* getErrorHandler();
00231
00238 const ErrorHandler* getErrorHandler() const;
00239
00246 const XMLScanner& getScanner() const;
00247
00254 const XMLValidator& getValidator() const;
00255
00263 ValSchemes getValidationScheme() const;
00264
00275 bool getDoSchema() const;
00276
00287 int getErrorCount() const;
00288
00298 bool getDoNamespaces() const;
00299
00309 bool getExitOnFirstFatalError() const;
00310
00321 bool getValidationConstraintFatal() const;
00323
00324
00325
00326
00327
00328
00331
00348 void setDoNamespaces(const bool newState);
00349
00366 void setValidationScheme(const ValSchemes newScheme);
00367
00381 void setDoSchema(const bool newState);
00382
00383
00399 void setExitOnFirstFatalError(const bool newState);
00400
00416 void setValidationConstraintFatal(const bool newState);
00418
00419
00420
00421
00422
00423
00426
00439 void installAdvDocHandler(XMLDocumentHandler* const toInstall);
00440
00450 bool removeAdvDocHandler(XMLDocumentHandler* const toRemove);
00452
00453
00454
00455
00456
00457
00460
00472 virtual void parse(const InputSource& source, const bool reuseGrammar = false);
00473
00486 virtual void parse(const XMLCh* const systemId, const bool reuseGrammar = false);
00487
00498 virtual void parse(const char* const systemId, const bool reuseGrammar = false);
00499
00510 virtual void setDocumentHandler(DocumentHandler* const handler);
00511
00521 virtual void setDTDHandler(DTDHandler* const handler);
00522
00533 virtual void setErrorHandler(ErrorHandler* const handler);
00534
00546 virtual void setEntityResolver(EntityResolver* const resolver);
00548
00549
00550
00551
00552
00553
00556
00587 bool parseFirst
00588 (
00589 const XMLCh* const systemId
00590 , XMLPScanToken& toFill
00591 , const bool reuseGrammar = false
00592 );
00593
00624 bool parseFirst
00625 (
00626 const char* const systemId
00627 , XMLPScanToken& toFill
00628 , const bool reuseGrammar = false
00629 );
00630
00661 bool parseFirst
00662 (
00663 const InputSource& source
00664 , XMLPScanToken& toFill
00665 , const bool reuseGrammar = false
00666 );
00667
00692 bool parseNext(XMLPScanToken& token);
00693
00715 void parseReset(XMLPScanToken& token);
00716
00718
00719
00720
00721
00722
00723
00724
00727
00741 virtual void attDef
00742 (
00743 const DTDElementDecl& elemDecl
00744 , const DTDAttDef& attDef
00745 , const bool ignoring
00746 );
00747
00757 virtual void doctypeComment
00758 (
00759 const XMLCh* const comment
00760 );
00761
00778 virtual void doctypeDecl
00779 (
00780 const DTDElementDecl& elemDecl
00781 , const XMLCh* const publicId
00782 , const XMLCh* const systemId
00783 , const bool hasIntSubset
00784 );
00785
00799 virtual void doctypePI
00800 (
00801 const XMLCh* const target
00802 , const XMLCh* const data
00803 );
00804
00816 virtual void doctypeWhitespace
00817 (
00818 const XMLCh* const chars
00819 , const unsigned int length
00820 );
00821
00834 virtual void elementDecl
00835 (
00836 const DTDElementDecl& decl
00837 , const bool isIgnored
00838 );
00839
00850 virtual void endAttList
00851 (
00852 const DTDElementDecl& elemDecl
00853 );
00854
00861 virtual void endIntSubset();
00862
00869 virtual void endExtSubset();
00870
00885 virtual void entityDecl
00886 (
00887 const DTDEntityDecl& entityDecl
00888 , const bool isPEDecl
00889 , const bool isIgnored
00890 );
00891
00896 virtual void resetDocType();
00897
00910 virtual void notationDecl
00911 (
00912 const XMLNotationDecl& notDecl
00913 , const bool isIgnored
00914 );
00915
00926 virtual void startAttList
00927 (
00928 const DTDElementDecl& elemDecl
00929 );
00930
00937 virtual void startIntSubset();
00938
00945 virtual void startExtSubset();
00946
00959 virtual void TextDecl
00960 (
00961 const XMLCh* const versionStr
00962 , const XMLCh* const encodingStr
00963 );
00965
00966
00967
00968
00969
00970
00973
00988 virtual void docCharacters
00989 (
00990 const XMLCh* const chars
00991 , const unsigned int length
00992 , const bool cdataSection
00993 );
00994
01004 virtual void docComment
01005 (
01006 const XMLCh* const comment
01007 );
01008
01028 virtual void docPI
01029 (
01030 const XMLCh* const target
01031 , const XMLCh* const data
01032 );
01033
01045 virtual void endDocument();
01046
01063 virtual void endElement
01064 (
01065 const XMLElementDecl& elemDecl
01066 , const unsigned int urlId
01067 , const bool isRoot
01068 );
01069
01080 virtual void endEntityReference
01081 (
01082 const XMLEntityDecl& entDecl
01083 );
01084
01104 virtual void ignorableWhitespace
01105 (
01106 const XMLCh* const chars
01107 , const unsigned int length
01108 , const bool cdataSection
01109 );
01110
01115 virtual void resetDocument();
01116
01127 virtual void startDocument();
01128
01155 virtual void startElement
01156 (
01157 const XMLElementDecl& elemDecl
01158 , const unsigned int urlId
01159 , const XMLCh* const elemPrefix
01160 , const RefVectorOf<XMLAttr>& attrList
01161 , const unsigned int attrCount
01162 , const bool isEmpty
01163 , const bool isRoot
01164 );
01165
01175 virtual void startEntityReference
01176 (
01177 const XMLEntityDecl& entDecl
01178 );
01179
01197 virtual void XMLDecl
01198 (
01199 const XMLCh* const versionStr
01200 , const XMLCh* const encodingStr
01201 , const XMLCh* const standaloneStr
01202 , const XMLCh* const actualEncodingStr
01203 );
01205
01206
01207
01208
01209
01210
01213
01236 virtual void error
01237 (
01238 const unsigned int errCode
01239 , const XMLCh* const msgDomain
01240 , const XMLErrorReporter::ErrTypes errType
01241 , const XMLCh* const errorText
01242 , const XMLCh* const systemId
01243 , const XMLCh* const publicId
01244 , const unsigned int lineNum
01245 , const unsigned int colNum
01246 );
01247
01256 virtual void resetErrors();
01258
01259
01260
01261
01262
01263
01266
01277 virtual void endInputSource(const InputSource& inputSource);
01278
01293 virtual bool expandSystemId
01294 (
01295 const XMLCh* const systemId
01296 , XMLBuffer& toFill
01297 );
01298
01306 virtual void resetEntities();
01307
01322 virtual InputSource* resolveEntity
01323 (
01324 const XMLCh* const publicId
01325 , const XMLCh* const systemId
01326 );
01327
01339 virtual void startInputSource(const InputSource& inputSource);
01341
01342
01345
01355 bool getDoValidation() const;
01356
01370 void setDoValidation(const bool newState);
01372
01373
01374 protected :
01375
01376
01377
01378 SAXParser(const SAXParser&);
01379 void operator=(const SAXParser&);
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
01428
01429 VecAttrListImpl fAttrList;
01430 DocumentHandler* fDocHandler;
01431 DTDHandler* fDTDHandler;
01432 unsigned int fElemDepth;
01433 EntityResolver* fEntityResolver;
01434 ErrorHandler* fErrorHandler;
01435 unsigned int fAdvDHCount;
01436 XMLDocumentHandler** fAdvDHList;
01437 unsigned int fAdvDHListSize;
01438 bool fParseInProgress;
01439 XMLScanner* fScanner;
01440 };
01441
01442
01443
01444
01445
01446 inline DocumentHandler* SAXParser::getDocumentHandler()
01447 {
01448 return fDocHandler;
01449 }
01450
01451 inline const DocumentHandler* SAXParser::getDocumentHandler() const
01452 {
01453 return fDocHandler;
01454 }
01455
01456 inline EntityResolver* SAXParser::getEntityResolver()
01457 {
01458 return fEntityResolver;
01459 }
01460
01461 inline const EntityResolver* SAXParser::getEntityResolver() const
01462 {
01463 return fEntityResolver;
01464 }
01465
01466 inline ErrorHandler* SAXParser::getErrorHandler()
01467 {
01468 return fErrorHandler;
01469 }
01470
01471 inline const ErrorHandler* SAXParser::getErrorHandler() const
01472 {
01473 return fErrorHandler;
01474 }
01475
01476 inline const XMLScanner& SAXParser::getScanner() const
01477 {
01478 return *fScanner;
01479 }
01480
01481 #endif