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
00248 int getErrorCount() const;
00249
00260 bool getDoNamespaces() const;
00261
00274 bool getExitOnFirstFatalError() const;
00275
00286 bool getValidationConstraintFatal() const;
00287
00299 bool getExpandEntityReferences() const;
00300
00318 bool getCreateEntityReferenceNodes()const;
00319
00330 bool getIncludeIgnorableWhitespace() const;
00331
00341 bool getToCreateXMLDeclTypeNode() const;
00342
00344
00345
00346
00347
00348
00349
00352
00366 void setErrorHandler(ErrorHandler* const handler);
00367
00383 void setEntityResolver(EntityResolver* const handler);
00384
00403 void setDoNamespaces(const bool newState);
00404
00421 void setExitOnFirstFatalError(const bool newState);
00422
00438 void setValidationConstraintFatal(const bool newState);
00439
00454 void setExpandEntityReferences(const bool expand);
00455
00472 void setCreateEntityReferenceNodes(const bool create);
00473
00495 void setIncludeIgnorableWhitespace(const bool include);
00496
00513 void setValidationScheme(const ValSchemes newScheme);
00514
00528 void setDoSchema(const bool newState);
00529
00540 void setToCreateXMLDeclTypeNode(const bool create);
00541
00543
00544
00545
00546
00547
00548
00551
00565 void parse(const InputSource& source, const bool reuseGrammar = false);
00566
00581 void parse(const XMLCh* const systemId, const bool reuseGrammar = false);
00582
00594 void parse(const char* const systemId, const bool reuseGrammar = false);
00595
00625 bool parseFirst
00626 (
00627 const XMLCh* const systemId
00628 , XMLPScanToken& toFill
00629 , const bool reuseGrammar = false
00630 );
00631
00662 bool parseFirst
00663 (
00664 const char* const systemId
00665 , XMLPScanToken& toFill
00666 , const bool reuseGrammar = false
00667 );
00668
00699 bool parseFirst
00700 (
00701 const InputSource& source
00702 , XMLPScanToken& toFill
00703 , const bool reuseGrammar = false
00704 );
00705
00728 bool parseNext(XMLPScanToken& token);
00729
00755 void parseReset(XMLPScanToken& token);
00756
00758
00759
00760
00761
00762
00763
00764
00767
00792 virtual void error
00793 (
00794 const unsigned int errCode
00795 , const XMLCh* const msgDomain
00796 , const XMLErrorReporter::ErrTypes errType
00797 , const XMLCh* const errorText
00798 , const XMLCh* const systemId
00799 , const XMLCh* const publicId
00800 , const unsigned int lineNum
00801 , const unsigned int colNum
00802 );
00803
00812 virtual void resetErrors();
00814
00815
00816
00817
00818
00819
00822
00835 virtual void endInputSource(const InputSource& inputSource);
00836
00852 virtual bool expandSystemId
00853 (
00854 const XMLCh* const systemId
00855 , XMLBuffer& toFill
00856 );
00857
00866 virtual void resetEntities();
00867
00883 virtual InputSource* resolveEntity
00884 (
00885 const XMLCh* const publicId
00886 , const XMLCh* const systemId
00887 );
00888
00901 virtual void startInputSource(const InputSource& inputSource);
00902
00904
00905
00906
00907
00908
00909
00910
00913
00926 virtual void docCharacters
00927 (
00928 const XMLCh* const chars
00929 , const unsigned int length
00930 , const bool cdataSection
00931 );
00932
00941 virtual void docComment
00942 (
00943 const XMLCh* const comment
00944 );
00945
00958 virtual void docPI
00959 (
00960 const XMLCh* const target
00961 , const XMLCh* const data
00962 );
00963
00968 virtual void endDocument();
00969
00983 virtual void endElement
00984 (
00985 const XMLElementDecl& elemDecl
00986 , const unsigned int urlId
00987 , const bool isRoot
00988 );
00989
00998 virtual void endEntityReference
00999 (
01000 const XMLEntityDecl& entDecl
01001 );
01002
01021 virtual void ignorableWhitespace
01022 (
01023 const XMLCh* const chars
01024 , const unsigned int length
01025 , const bool cdataSection
01026 );
01027
01034 virtual void resetDocument();
01035
01040 virtual void startDocument();
01041
01069 virtual void startElement
01070 (
01071 const XMLElementDecl& elemDecl
01072 , const unsigned int urlId
01073 , const XMLCh* const elemPrefix
01074 , const RefVectorOf<XMLAttr>& attrList
01075 , const unsigned int attrCount
01076 , const bool isEmpty
01077 , const bool isRoot
01078 );
01079
01089 virtual void startEntityReference
01090 (
01091 const XMLEntityDecl& entDecl
01092 );
01093
01112 virtual void XMLDecl
01113 (
01114 const XMLCh* const versionStr
01115 , const XMLCh* const encodingStr
01116 , const XMLCh* const standaloneStr
01117 , const XMLCh* const actualEncStr
01118 );
01120
01121
01124
01134 bool getDoValidation() const;
01135
01149 void setDoValidation(const bool newState);
01150
01154 virtual void attDef
01155 (
01156 const DTDElementDecl& elemDecl
01157 , const DTDAttDef& attDef
01158 , const bool ignoring
01159 );
01160
01161 virtual void doctypeComment
01162 (
01163 const XMLCh* const comment
01164 );
01165
01166 virtual void doctypeDecl
01167 (
01168 const DTDElementDecl& elemDecl
01169 , const XMLCh* const publicId
01170 , const XMLCh* const systemId
01171 , const bool hasIntSubset
01172 );
01173
01174 virtual void doctypePI
01175 (
01176 const XMLCh* const target
01177 , const XMLCh* const data
01178 );
01179
01180 virtual void doctypeWhitespace
01181 (
01182 const XMLCh* const chars
01183 , const unsigned int length
01184 );
01185
01186 virtual void elementDecl
01187 (
01188 const DTDElementDecl& decl
01189 , const bool isIgnored
01190 );
01191
01192 virtual void endAttList
01193 (
01194 const DTDElementDecl& elemDecl
01195 );
01196
01197 virtual void endIntSubset();
01198
01199 virtual void endExtSubset();
01200
01201 virtual void entityDecl
01202 (
01203 const DTDEntityDecl& entityDecl
01204 , const bool isPEDecl
01205 , const bool isIgnored
01206 );
01207
01208 virtual void resetDocType();
01209
01210 virtual void notationDecl
01211 (
01212 const XMLNotationDecl& notDecl
01213 , const bool isIgnored
01214 );
01215
01216 virtual void startAttList
01217 (
01218 const DTDElementDecl& elemDecl
01219 );
01220
01221 virtual void startIntSubset();
01222
01223 virtual void startExtSubset();
01224
01225 virtual void TextDecl
01226 (
01227 const XMLCh* const versionStr
01228 , const XMLCh* const encodingStr
01229 );
01230
01231
01233
01234
01235 protected :
01236
01237
01238
01239
01242
01247 DOM_Node getCurrentNode();
01248
01250
01251
01252
01253
01254
01255
01258
01266 void setCurrentNode(DOM_Node toSet);
01267
01274 void setDocument(DOM_Document toSet);
01276
01277
01278 private :
01279
01280
01281
01282
01283
01284
01285
01286
01287
01288
01289
01290
01291
01292
01293
01294
01295
01296
01297
01298
01299
01300
01301
01302
01303
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319
01320
01321
01322
01323
01324
01325
01326
01327
01328 DOM_Node fCurrentParent;
01329 DOM_Node fCurrentNode;
01330 DOM_Document fDocument;
01331 EntityResolver* fEntityResolver;
01332 ErrorHandler* fErrorHandler;
01333 bool fCreateEntityReferenceNodes;
01334 bool fIncludeIgnorableWhitespace;
01335 ValueStackOf<DOM_Node>* fNodeStack;
01336 bool fParseInProgress;
01337 XMLScanner* fScanner;
01338 bool fWithinElement;
01339 DocumentTypeImpl* fDocumentType;
01340 bool fToCreateXMLDeclTypeNode;
01341 };
01342
01343
01344
01345
01346
01347
01348 inline void DOMParser::endInputSource(const InputSource&)
01349 {
01350
01351 }
01352
01353 inline bool DOMParser::expandSystemId(const XMLCh* const, XMLBuffer&)
01354 {
01355
01356 return false;
01357 }
01358
01359 inline void DOMParser::resetEntities()
01360 {
01361
01362 }
01363
01364 inline void DOMParser::startInputSource(const InputSource&)
01365 {
01366
01367 }
01368
01369
01370
01371
01372
01373 inline DOM_Document DOMParser::getDocument()
01374 {
01375 return fDocument;
01376 }
01377
01378 inline ErrorHandler* DOMParser::getErrorHandler()
01379 {
01380 return fErrorHandler;
01381 }
01382
01383 inline const ErrorHandler* DOMParser::getErrorHandler() const
01384 {
01385 return fErrorHandler;
01386 }
01387
01388 inline EntityResolver* DOMParser::getEntityResolver()
01389 {
01390 return fEntityResolver;
01391 }
01392
01393 inline const EntityResolver* DOMParser::getEntityResolver() const
01394 {
01395 return fEntityResolver;
01396 }
01397
01398 inline bool DOMParser::getExpandEntityReferences() const
01399 {
01400 return fCreateEntityReferenceNodes;
01401 }
01402 inline bool DOMParser::getCreateEntityReferenceNodes() const
01403 {
01404 return fCreateEntityReferenceNodes;
01405 }
01406
01407 inline bool DOMParser::getIncludeIgnorableWhitespace() const
01408 {
01409 return fIncludeIgnorableWhitespace;
01410 }
01411
01412 inline const XMLScanner& DOMParser::getScanner() const
01413 {
01414 return *fScanner;
01415 }
01416
01417 inline bool DOMParser::getToCreateXMLDeclTypeNode() const
01418 {
01419 return fToCreateXMLDeclTypeNode;
01420 }
01421
01422
01423
01424
01425
01426 inline void DOMParser::setExpandEntityReferences(const bool expand)
01427 {
01428 fCreateEntityReferenceNodes = expand;
01429 }
01430
01431 inline void DOMParser::setCreateEntityReferenceNodes(const bool create)
01432 {
01433 fCreateEntityReferenceNodes = create;
01434 }
01435
01436 inline void DOMParser::setIncludeIgnorableWhitespace(const bool include)
01437 {
01438 fIncludeIgnorableWhitespace = include;
01439 }
01440
01441 inline void DOMParser::setToCreateXMLDeclTypeNode(const bool create)
01442 {
01443 fToCreateXMLDeclTypeNode = create;
01444 }
01445
01446
01447
01448
01449
01450 inline DOM_Node DOMParser::getCurrentNode()
01451 {
01452 return fCurrentNode;
01453 }
01454
01455
01456
01457
01458
01459 inline void DOMParser::setCurrentNode(DOM_Node toSet)
01460 {
01461 fCurrentNode = toSet;
01462 }
01463
01464 inline void DOMParser::setDocument(DOM_Document toSet)
01465 {
01466 fDocument = toSet;
01467 }
01468
01469 #endif