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 #if !defined(IDOMPARSER_HPP)
00063 #define IDOMPARSER_HPP
00064
00065
00066 #include <idom/IDOM_Document.hpp>
00067 #include <framework/XMLDocumentHandler.hpp>
00068 #include <framework/XMLErrorReporter.hpp>
00069 #include <framework/XMLEntityHandler.hpp>
00070 #include <util/ValueStackOf.hpp>
00071
00072 #include <validators/DTD/DocTypeHandler.hpp>
00073 #include <idom/IDOM_DocumentType.hpp>
00074 #include <validators/DTD/DTDElementDecl.hpp>
00075
00076 class EntityResolver;
00077 class ErrorHandler;
00078 class XMLPScanToken;
00079 class XMLScanner;
00080 class XMLValidator;
00081 class IDDocumentImpl;
00082 class IDDocumentTypeImpl;
00083
00084
00095 class IDOMParser :
00096
00097 public XMLDocumentHandler
00098 , public XMLErrorReporter
00099 , public XMLEntityHandler
00100 , public DocTypeHandler
00101 {
00102 public :
00103
00104
00105
00106 enum ValSchemes
00107 {
00108 Val_Never
00109 , Val_Always
00110 , Val_Auto
00111 };
00112
00113
00114
00115
00116
00117
00120
00129 IDOMParser(XMLValidator* const valToAdopt = 0);
00130
00134 ~IDOMParser();
00135
00137
00143 void reset();
00144
00168 void resetDocumentPool();
00169
00170
00171
00172
00173
00174
00177
00187 IDOM_Document* getDocument();
00188
00196 ErrorHandler* getErrorHandler();
00197
00205 const ErrorHandler* getErrorHandler() const;
00206
00214 EntityResolver* getEntityResolver();
00215
00223 const EntityResolver* getEntityResolver() const;
00224
00232 const XMLValidator& getValidator() const;
00233
00241 ValSchemes getValidationScheme() const;
00242
00253 bool getDoSchema() const;
00254
00265 bool getValidationSchemaFullChecking() const;
00266
00278 int getErrorCount() const;
00279
00290 bool getDoNamespaces() const;
00291
00304 bool getExitOnFirstFatalError() const;
00305
00316 bool getValidationConstraintFatal() const;
00317
00329 bool getExpandEntityReferences() const;
00330
00348 bool getCreateEntityReferenceNodes()const;
00349
00360 bool getIncludeIgnorableWhitespace() const;
00361
00363
00364
00365
00366
00367
00368
00371
00385 void setErrorHandler(ErrorHandler* const handler);
00386
00402 void setEntityResolver(EntityResolver* const handler);
00403
00422 void setDoNamespaces(const bool newState);
00423
00440 void setExitOnFirstFatalError(const bool newState);
00441
00457 void setValidationConstraintFatal(const bool newState);
00458
00473 void setExpandEntityReferences(const bool expand);
00474
00491 void setCreateEntityReferenceNodes(const bool create);
00492
00514 void setIncludeIgnorableWhitespace(const bool include);
00515
00532 void setValidationScheme(const ValSchemes newScheme);
00533
00547 void setDoSchema(const bool newState);
00548
00565 void setValidationSchemaFullChecking(const bool schemaFullChecking);
00566
00568
00569
00570
00571
00572
00573
00576
00597 void parse(const InputSource& source, const bool reuseGrammar = false);
00598
00618 void parse(const XMLCh* const systemId, const bool reuseGrammar = false);
00619
00638 void parse(const char* const systemId, const bool reuseGrammar = false);
00639
00669 bool parseFirst
00670 (
00671 const XMLCh* const systemId
00672 , XMLPScanToken& toFill
00673 , const bool reuseGrammar = false
00674 );
00675
00706 bool parseFirst
00707 (
00708 const char* const systemId
00709 , XMLPScanToken& toFill
00710 , const bool reuseGrammar = false
00711 );
00712
00743 bool parseFirst
00744 (
00745 const InputSource& source
00746 , XMLPScanToken& toFill
00747 , const bool reuseGrammar = false
00748 );
00749
00772 bool parseNext(XMLPScanToken& token);
00773
00799 void parseReset(XMLPScanToken& token);
00800
00802
00803
00804
00805
00806
00807
00808
00811
00836 virtual void error
00837 (
00838 const unsigned int errCode
00839 , const XMLCh* const msgDomain
00840 , const XMLErrorReporter::ErrTypes errType
00841 , const XMLCh* const errorText
00842 , const XMLCh* const systemId
00843 , const XMLCh* const publicId
00844 , const unsigned int lineNum
00845 , const unsigned int colNum
00846 );
00847
00856 virtual void resetErrors();
00858
00859
00860
00861
00862
00863
00866
00879 virtual void endInputSource(const InputSource& inputSource);
00880
00896 virtual bool expandSystemId
00897 (
00898 const XMLCh* const systemId
00899 , XMLBuffer& toFill
00900 );
00901
00910 virtual void resetEntities();
00911
00927 virtual InputSource* resolveEntity
00928 (
00929 const XMLCh* const publicId
00930 , const XMLCh* const systemId
00931 );
00932
00945 virtual void startInputSource(const InputSource& inputSource);
00946
00948
00949
00950
00951
00952
00953
00954
00957
00970 virtual void docCharacters
00971 (
00972 const XMLCh* const chars
00973 , const unsigned int length
00974 , const bool cdataSection
00975 );
00976
00985 virtual void docComment
00986 (
00987 const XMLCh* const comment
00988 );
00989
01002 virtual void docPI
01003 (
01004 const XMLCh* const target
01005 , const XMLCh* const data
01006 );
01007
01012 virtual void endDocument();
01013
01027 virtual void endElement
01028 (
01029 const XMLElementDecl& elemDecl
01030 , const unsigned int urlId
01031 , const bool isRoot
01032 );
01033
01042 virtual void endEntityReference
01043 (
01044 const XMLEntityDecl& entDecl
01045 );
01046
01065 virtual void ignorableWhitespace
01066 (
01067 const XMLCh* const chars
01068 , const unsigned int length
01069 , const bool cdataSection
01070 );
01071
01078 virtual void resetDocument();
01079
01084 virtual void startDocument();
01085
01113 virtual void startElement
01114 (
01115 const XMLElementDecl& elemDecl
01116 , const unsigned int urlId
01117 , const XMLCh* const elemPrefix
01118 , const RefVectorOf<XMLAttr>& attrList
01119 , const unsigned int attrCount
01120 , const bool isEmpty
01121 , const bool isRoot
01122 );
01123
01133 virtual void startEntityReference
01134 (
01135 const XMLEntityDecl& entDecl
01136 );
01137
01156 virtual void XMLDecl
01157 (
01158 const XMLCh* const versionStr
01159 , const XMLCh* const encodingStr
01160 , const XMLCh* const standaloneStr
01161 , const XMLCh* const actualEncStr
01162 );
01164
01165
01168
01178 bool getDoValidation() const;
01179
01193 void setDoValidation(const bool newState);
01194
01198 virtual void attDef
01199 (
01200 const DTDElementDecl& elemDecl
01201 , const DTDAttDef& attDef
01202 , const bool ignoring
01203 );
01204
01205 virtual void doctypeComment
01206 (
01207 const XMLCh* const comment
01208 );
01209
01210 virtual void doctypeDecl
01211 (
01212 const DTDElementDecl& elemDecl
01213 , const XMLCh* const publicId
01214 , const XMLCh* const systemId
01215 , const bool hasIntSubset
01216 );
01217
01218 virtual void doctypePI
01219 (
01220 const XMLCh* const target
01221 , const XMLCh* const data
01222 );
01223
01224 virtual void doctypeWhitespace
01225 (
01226 const XMLCh* const chars
01227 , const unsigned int length
01228 );
01229
01230 virtual void elementDecl
01231 (
01232 const DTDElementDecl& decl
01233 , const bool isIgnored
01234 );
01235
01236 virtual void endAttList
01237 (
01238 const DTDElementDecl& elemDecl
01239 );
01240
01241 virtual void endIntSubset();
01242
01243 virtual void endExtSubset();
01244
01245 virtual void entityDecl
01246 (
01247 const DTDEntityDecl& entityDecl
01248 , const bool isPEDecl
01249 , const bool isIgnored
01250 );
01251
01252 virtual void resetDocType();
01253
01254 virtual void notationDecl
01255 (
01256 const XMLNotationDecl& notDecl
01257 , const bool isIgnored
01258 );
01259
01260 virtual void startAttList
01261 (
01262 const DTDElementDecl& elemDecl
01263 );
01264
01265 virtual void startIntSubset();
01266
01267 virtual void startExtSubset();
01268
01269 virtual void TextDecl
01270 (
01271 const XMLCh* const versionStr
01272 , const XMLCh* const encodingStr
01273 );
01274
01275
01277
01278
01279 protected :
01280
01281
01282
01283
01286
01291 IDOM_Node* getCurrentNode();
01292
01294
01295
01296
01297
01298
01299
01302
01310 void setCurrentNode(IDOM_Node* toSet);
01311
01318 void setDocument(IDOM_Document* toSet);
01320
01321
01322 private :
01323
01324
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334
01335
01336
01337
01338
01339
01340
01341
01342
01343
01344
01345
01346
01347
01348
01349
01350
01351
01352
01353
01354
01355
01356
01357
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367
01368
01369
01370
01371 IDOM_Node* fCurrentParent;
01372 IDOM_Node* fCurrentNode;
01373 IDDocumentImpl* fDocument;
01374 EntityResolver* fEntityResolver;
01375 ErrorHandler* fErrorHandler;
01376 bool fCreateEntityReferenceNodes;
01377 bool fIncludeIgnorableWhitespace;
01378 ValueStackOf<IDOM_Node*>* fNodeStack;
01379 bool fParseInProgress;
01380 XMLScanner* fScanner;
01381 bool fWithinElement;
01382 IDDocumentTypeImpl* fDocumentType;
01383 RefVectorOf<IDDocumentImpl>* fDocumentVector;
01384 };
01385
01386
01387
01388
01389
01390
01391 inline void IDOMParser::endInputSource(const InputSource&)
01392 {
01393
01394 }
01395
01396 inline bool IDOMParser::expandSystemId(const XMLCh* const, XMLBuffer&)
01397 {
01398
01399 return false;
01400 }
01401
01402 inline void IDOMParser::resetEntities()
01403 {
01404
01405 }
01406
01407 inline void IDOMParser::startInputSource(const InputSource&)
01408 {
01409
01410 }
01411
01412
01413
01414
01415
01416 inline ErrorHandler* IDOMParser::getErrorHandler()
01417 {
01418 return fErrorHandler;
01419 }
01420
01421 inline const ErrorHandler* IDOMParser::getErrorHandler() const
01422 {
01423 return fErrorHandler;
01424 }
01425
01426 inline EntityResolver* IDOMParser::getEntityResolver()
01427 {
01428 return fEntityResolver;
01429 }
01430
01431 inline const EntityResolver* IDOMParser::getEntityResolver() const
01432 {
01433 return fEntityResolver;
01434 }
01435
01436 inline bool IDOMParser::getExpandEntityReferences() const
01437 {
01438 return fCreateEntityReferenceNodes;
01439 }
01440 inline bool IDOMParser::getCreateEntityReferenceNodes() const
01441 {
01442 return fCreateEntityReferenceNodes;
01443 }
01444
01445 inline bool IDOMParser::getIncludeIgnorableWhitespace() const
01446 {
01447 return fIncludeIgnorableWhitespace;
01448 }
01449
01450
01451
01452
01453
01454 inline void IDOMParser::setExpandEntityReferences(const bool expand)
01455 {
01456 fCreateEntityReferenceNodes = expand;
01457 }
01458
01459 inline void IDOMParser::setCreateEntityReferenceNodes(const bool create)
01460 {
01461 fCreateEntityReferenceNodes = create;
01462 }
01463
01464 inline void IDOMParser::setIncludeIgnorableWhitespace(const bool include)
01465 {
01466 fIncludeIgnorableWhitespace = include;
01467 }
01468
01469
01470
01471
01472
01473 inline IDOM_Node* IDOMParser::getCurrentNode()
01474 {
01475 return fCurrentNode;
01476 }
01477
01478
01479
01480
01481
01482 inline void IDOMParser::setCurrentNode(IDOM_Node* toSet)
01483 {
01484 fCurrentNode = toSet;
01485 }
01486
01487 inline void IDOMParser::setDocument(IDOM_Document* toSet)
01488 {
01489 fDocument = (IDDocumentImpl *)toSet;
01490 }
01491
01492 #endif