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(DOMPARSER_HPP)
00063 #define DOMPARSER_HPP
00064
00065
00066 #include <dom/DOM_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 <dom/DOM_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
00082
00093 class DOMParser :
00094
00095 public XMLDocumentHandler
00096 , public XMLErrorReporter
00097 , public XMLEntityHandler
00098 , public DocTypeHandler
00099 {
00100 public :
00101
00102
00103
00104 enum ValSchemes
00105 {
00106 Val_Never
00107 , Val_Always
00108 , Val_Auto
00109 };
00110
00111
00112
00113
00114
00115
00118
00127 DOMParser(XMLValidator* const valToAdopt = 0);
00128
00132 ~DOMParser();
00133
00135
00141 void reset();
00142
00143
00144
00145
00146
00147
00150
00160 DOM_Document getDocument();
00161
00169 ErrorHandler* getErrorHandler();
00170
00178 const ErrorHandler* getErrorHandler() const;
00179
00187 EntityResolver* getEntityResolver();
00188
00196 const EntityResolver* getEntityResolver() const;
00197
00205 const XMLScanner& getScanner() const;
00206
00214 const XMLValidator& getValidator() const;
00215
00223 ValSchemes getValidationScheme() const;
00224
00235 bool getDoSchema() const;
00236
00247 bool getValidationSchemaFullChecking() const;
00248
00260 int getErrorCount() const;
00261
00272 bool getDoNamespaces() const;
00273
00286 bool getExitOnFirstFatalError() const;
00287
00298 bool getValidationConstraintFatal() const;
00299
00311 bool getExpandEntityReferences() const;
00312
00330 bool getCreateEntityReferenceNodes()const;
00331
00342 bool getIncludeIgnorableWhitespace() const;
00343
00353 bool getToCreateXMLDeclTypeNode() const;
00354
00356
00357
00358
00359
00360
00361
00364
00378 void setErrorHandler(ErrorHandler* const handler);
00379
00395 void setEntityResolver(EntityResolver* const handler);
00396
00415 void setDoNamespaces(const bool newState);
00416
00433 void setExitOnFirstFatalError(const bool newState);
00434
00450 void setValidationConstraintFatal(const bool newState);
00451
00466 void setExpandEntityReferences(const bool expand);
00467
00484 void setCreateEntityReferenceNodes(const bool create);
00485
00507 void setIncludeIgnorableWhitespace(const bool include);
00508
00525 void setValidationScheme(const ValSchemes newScheme);
00526
00540 void setDoSchema(const bool newState);
00541
00558 void setValidationSchemaFullChecking(const bool schemaFullChecking);
00559
00570 void setToCreateXMLDeclTypeNode(const bool create);
00571
00573
00574
00575
00576
00577
00578
00581
00602 void parse(const InputSource& source, const bool reuseGrammar = false);
00603
00623 void parse(const XMLCh* const systemId, const bool reuseGrammar = false);
00624
00642 void parse(const char* const systemId, const bool reuseGrammar = false);
00643
00673 bool parseFirst
00674 (
00675 const XMLCh* const systemId
00676 , XMLPScanToken& toFill
00677 , const bool reuseGrammar = false
00678 );
00679
00710 bool parseFirst
00711 (
00712 const char* const systemId
00713 , XMLPScanToken& toFill
00714 , const bool reuseGrammar = false
00715 );
00716
00747 bool parseFirst
00748 (
00749 const InputSource& source
00750 , XMLPScanToken& toFill
00751 , const bool reuseGrammar = false
00752 );
00753
00776 bool parseNext(XMLPScanToken& token);
00777
00803 void parseReset(XMLPScanToken& token);
00804
00806
00807
00808
00809
00810
00811
00812
00815
00840 virtual void error
00841 (
00842 const unsigned int errCode
00843 , const XMLCh* const msgDomain
00844 , const XMLErrorReporter::ErrTypes errType
00845 , const XMLCh* const errorText
00846 , const XMLCh* const systemId
00847 , const XMLCh* const publicId
00848 , const unsigned int lineNum
00849 , const unsigned int colNum
00850 );
00851
00860 virtual void resetErrors();
00862
00863
00864
00865
00866
00867
00870
00883 virtual void endInputSource(const InputSource& inputSource);
00884
00900 virtual bool expandSystemId
00901 (
00902 const XMLCh* const systemId
00903 , XMLBuffer& toFill
00904 );
00905
00914 virtual void resetEntities();
00915
00931 virtual InputSource* resolveEntity
00932 (
00933 const XMLCh* const publicId
00934 , const XMLCh* const systemId
00935 );
00936
00949 virtual void startInputSource(const InputSource& inputSource);
00950
00952
00953
00954
00955
00956
00957
00958
00961
00974 virtual void docCharacters
00975 (
00976 const XMLCh* const chars
00977 , const unsigned int length
00978 , const bool cdataSection
00979 );
00980
00989 virtual void docComment
00990 (
00991 const XMLCh* const comment
00992 );
00993
01006 virtual void docPI
01007 (
01008 const XMLCh* const target
01009 , const XMLCh* const data
01010 );
01011
01016 virtual void endDocument();
01017
01031 virtual void endElement
01032 (
01033 const XMLElementDecl& elemDecl
01034 , const unsigned int urlId
01035 , const bool isRoot
01036 );
01037
01046 virtual void endEntityReference
01047 (
01048 const XMLEntityDecl& entDecl
01049 );
01050
01069 virtual void ignorableWhitespace
01070 (
01071 const XMLCh* const chars
01072 , const unsigned int length
01073 , const bool cdataSection
01074 );
01075
01082 virtual void resetDocument();
01083
01088 virtual void startDocument();
01089
01117 virtual void startElement
01118 (
01119 const XMLElementDecl& elemDecl
01120 , const unsigned int urlId
01121 , const XMLCh* const elemPrefix
01122 , const RefVectorOf<XMLAttr>& attrList
01123 , const unsigned int attrCount
01124 , const bool isEmpty
01125 , const bool isRoot
01126 );
01127
01137 virtual void startEntityReference
01138 (
01139 const XMLEntityDecl& entDecl
01140 );
01141
01160 virtual void XMLDecl
01161 (
01162 const XMLCh* const versionStr
01163 , const XMLCh* const encodingStr
01164 , const XMLCh* const standaloneStr
01165 , const XMLCh* const actualEncStr
01166 );
01168
01169
01172
01182 bool getDoValidation() const;
01183
01197 void setDoValidation(const bool newState);
01198
01202 virtual void attDef
01203 (
01204 const DTDElementDecl& elemDecl
01205 , const DTDAttDef& attDef
01206 , const bool ignoring
01207 );
01208
01209 virtual void doctypeComment
01210 (
01211 const XMLCh* const comment
01212 );
01213
01214 virtual void doctypeDecl
01215 (
01216 const DTDElementDecl& elemDecl
01217 , const XMLCh* const publicId
01218 , const XMLCh* const systemId
01219 , const bool hasIntSubset
01220 );
01221
01222 virtual void doctypePI
01223 (
01224 const XMLCh* const target
01225 , const XMLCh* const data
01226 );
01227
01228 virtual void doctypeWhitespace
01229 (
01230 const XMLCh* const chars
01231 , const unsigned int length
01232 );
01233
01234 virtual void elementDecl
01235 (
01236 const DTDElementDecl& decl
01237 , const bool isIgnored
01238 );
01239
01240 virtual void endAttList
01241 (
01242 const DTDElementDecl& elemDecl
01243 );
01244
01245 virtual void endIntSubset();
01246
01247 virtual void endExtSubset();
01248
01249 virtual void entityDecl
01250 (
01251 const DTDEntityDecl& entityDecl
01252 , const bool isPEDecl
01253 , const bool isIgnored
01254 );
01255
01256 virtual void resetDocType();
01257
01258 virtual void notationDecl
01259 (
01260 const XMLNotationDecl& notDecl
01261 , const bool isIgnored
01262 );
01263
01264 virtual void startAttList
01265 (
01266 const DTDElementDecl& elemDecl
01267 );
01268
01269 virtual void startIntSubset();
01270
01271 virtual void startExtSubset();
01272
01273 virtual void TextDecl
01274 (
01275 const XMLCh* const versionStr
01276 , const XMLCh* const encodingStr
01277 );
01278
01279
01281
01282
01283 protected :
01284
01285
01286
01287
01290
01295 DOM_Node getCurrentNode();
01296
01298
01299
01300
01301
01302
01303
01306
01314 void setCurrentNode(DOM_Node toSet);
01315
01322 void setDocument(DOM_Document toSet);
01324
01325
01326 private :
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
01372
01373
01374
01375
01376 DOM_Node fCurrentParent;
01377 DOM_Node fCurrentNode;
01378 DOM_Document fDocument;
01379 EntityResolver* fEntityResolver;
01380 ErrorHandler* fErrorHandler;
01381 bool fCreateEntityReferenceNodes;
01382 bool fIncludeIgnorableWhitespace;
01383 ValueStackOf<DOM_Node>* fNodeStack;
01384 bool fParseInProgress;
01385 XMLScanner* fScanner;
01386 bool fWithinElement;
01387 DocumentTypeImpl* fDocumentType;
01388 bool fToCreateXMLDeclTypeNode;
01389 };
01390
01391
01392
01393
01394
01395
01396 inline void DOMParser::endInputSource(const InputSource&)
01397 {
01398
01399 }
01400
01401 inline bool DOMParser::expandSystemId(const XMLCh* const, XMLBuffer&)
01402 {
01403
01404 return false;
01405 }
01406
01407 inline void DOMParser::resetEntities()
01408 {
01409
01410 }
01411
01412 inline void DOMParser::startInputSource(const InputSource&)
01413 {
01414
01415 }
01416
01417
01418
01419
01420
01421 inline DOM_Document DOMParser::getDocument()
01422 {
01423 return fDocument;
01424 }
01425
01426 inline ErrorHandler* DOMParser::getErrorHandler()
01427 {
01428 return fErrorHandler;
01429 }
01430
01431 inline const ErrorHandler* DOMParser::getErrorHandler() const
01432 {
01433 return fErrorHandler;
01434 }
01435
01436 inline EntityResolver* DOMParser::getEntityResolver()
01437 {
01438 return fEntityResolver;
01439 }
01440
01441 inline const EntityResolver* DOMParser::getEntityResolver() const
01442 {
01443 return fEntityResolver;
01444 }
01445
01446 inline bool DOMParser::getExpandEntityReferences() const
01447 {
01448 return fCreateEntityReferenceNodes;
01449 }
01450 inline bool DOMParser::getCreateEntityReferenceNodes() const
01451 {
01452 return fCreateEntityReferenceNodes;
01453 }
01454
01455 inline bool DOMParser::getIncludeIgnorableWhitespace() const
01456 {
01457 return fIncludeIgnorableWhitespace;
01458 }
01459
01460 inline const XMLScanner& DOMParser::getScanner() const
01461 {
01462 return *fScanner;
01463 }
01464
01465 inline bool DOMParser::getToCreateXMLDeclTypeNode() const
01466 {
01467 return fToCreateXMLDeclTypeNode;
01468 }
01469
01470
01471
01472
01473
01474 inline void DOMParser::setExpandEntityReferences(const bool expand)
01475 {
01476 fCreateEntityReferenceNodes = expand;
01477 }
01478
01479 inline void DOMParser::setCreateEntityReferenceNodes(const bool create)
01480 {
01481 fCreateEntityReferenceNodes = create;
01482 }
01483
01484 inline void DOMParser::setIncludeIgnorableWhitespace(const bool include)
01485 {
01486 fIncludeIgnorableWhitespace = include;
01487 }
01488
01489 inline void DOMParser::setToCreateXMLDeclTypeNode(const bool create)
01490 {
01491 fToCreateXMLDeclTypeNode = create;
01492 }
01493
01494
01495
01496
01497
01498 inline DOM_Node DOMParser::getCurrentNode()
01499 {
01500 return fCurrentNode;
01501 }
01502
01503
01504
01505
01506
01507 inline void DOMParser::setCurrentNode(DOM_Node toSet)
01508 {
01509 fCurrentNode = toSet;
01510 }
01511
01512 inline void DOMParser::setDocument(DOM_Document toSet)
01513 {
01514 fDocument = toSet;
01515 }
01516
01517 #endif