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
00145
00146
00147
00148
00149
00152
00162 IDOM_Document* getDocument();
00163
00171 ErrorHandler* getErrorHandler();
00172
00180 const ErrorHandler* getErrorHandler() const;
00181
00189 EntityResolver* getEntityResolver();
00190
00198 const EntityResolver* getEntityResolver() const;
00199
00207 const XMLValidator& getValidator() const;
00208
00216 ValSchemes getValidationScheme() const;
00217
00228 bool getDoSchema() const;
00229
00241 int getErrorCount() const;
00242
00253 bool getDoNamespaces() const;
00254
00267 bool getExitOnFirstFatalError() const;
00268
00279 bool getValidationConstraintFatal() const;
00280
00292 bool getExpandEntityReferences() const;
00293
00311 bool getCreateEntityReferenceNodes()const;
00312
00323 bool getIncludeIgnorableWhitespace() const;
00324
00326
00327
00328
00329
00330
00331
00334
00348 void setErrorHandler(ErrorHandler* const handler);
00349
00365 void setEntityResolver(EntityResolver* const handler);
00366
00385 void setDoNamespaces(const bool newState);
00386
00403 void setExitOnFirstFatalError(const bool newState);
00404
00420 void setValidationConstraintFatal(const bool newState);
00421
00436 void setExpandEntityReferences(const bool expand);
00437
00454 void setCreateEntityReferenceNodes(const bool create);
00455
00477 void setIncludeIgnorableWhitespace(const bool include);
00478
00495 void setValidationScheme(const ValSchemes newScheme);
00496
00510 void setDoSchema(const bool newState);
00511
00513
00514
00515
00516
00517
00518
00521
00542 void parse(const InputSource& source, const bool reuseGrammar = false);
00543
00563 void parse(const XMLCh* const systemId, const bool reuseGrammar = false);
00564
00583 void parse(const char* const systemId, const bool reuseGrammar = false);
00584
00614 bool parseFirst
00615 (
00616 const XMLCh* const systemId
00617 , XMLPScanToken& toFill
00618 , const bool reuseGrammar = false
00619 );
00620
00651 bool parseFirst
00652 (
00653 const char* const systemId
00654 , XMLPScanToken& toFill
00655 , const bool reuseGrammar = false
00656 );
00657
00688 bool parseFirst
00689 (
00690 const InputSource& source
00691 , XMLPScanToken& toFill
00692 , const bool reuseGrammar = false
00693 );
00694
00717 bool parseNext(XMLPScanToken& token);
00718
00744 void parseReset(XMLPScanToken& token);
00745
00747
00748
00749
00750
00751
00752
00753
00756
00781 virtual void error
00782 (
00783 const unsigned int errCode
00784 , const XMLCh* const msgDomain
00785 , const XMLErrorReporter::ErrTypes errType
00786 , const XMLCh* const errorText
00787 , const XMLCh* const systemId
00788 , const XMLCh* const publicId
00789 , const unsigned int lineNum
00790 , const unsigned int colNum
00791 );
00792
00801 virtual void resetErrors();
00803
00804
00805
00806
00807
00808
00811
00824 virtual void endInputSource(const InputSource& inputSource);
00825
00841 virtual bool expandSystemId
00842 (
00843 const XMLCh* const systemId
00844 , XMLBuffer& toFill
00845 );
00846
00855 virtual void resetEntities();
00856
00872 virtual InputSource* resolveEntity
00873 (
00874 const XMLCh* const publicId
00875 , const XMLCh* const systemId
00876 );
00877
00890 virtual void startInputSource(const InputSource& inputSource);
00891
00893
00894
00895
00896
00897
00898
00899
00902
00915 virtual void docCharacters
00916 (
00917 const XMLCh* const chars
00918 , const unsigned int length
00919 , const bool cdataSection
00920 );
00921
00930 virtual void docComment
00931 (
00932 const XMLCh* const comment
00933 );
00934
00947 virtual void docPI
00948 (
00949 const XMLCh* const target
00950 , const XMLCh* const data
00951 );
00952
00957 virtual void endDocument();
00958
00972 virtual void endElement
00973 (
00974 const XMLElementDecl& elemDecl
00975 , const unsigned int urlId
00976 , const bool isRoot
00977 );
00978
00987 virtual void endEntityReference
00988 (
00989 const XMLEntityDecl& entDecl
00990 );
00991
01010 virtual void ignorableWhitespace
01011 (
01012 const XMLCh* const chars
01013 , const unsigned int length
01014 , const bool cdataSection
01015 );
01016
01023 virtual void resetDocument();
01024
01029 virtual void startDocument();
01030
01058 virtual void startElement
01059 (
01060 const XMLElementDecl& elemDecl
01061 , const unsigned int urlId
01062 , const XMLCh* const elemPrefix
01063 , const RefVectorOf<XMLAttr>& attrList
01064 , const unsigned int attrCount
01065 , const bool isEmpty
01066 , const bool isRoot
01067 );
01068
01078 virtual void startEntityReference
01079 (
01080 const XMLEntityDecl& entDecl
01081 );
01082
01101 virtual void XMLDecl
01102 (
01103 const XMLCh* const versionStr
01104 , const XMLCh* const encodingStr
01105 , const XMLCh* const standaloneStr
01106 , const XMLCh* const actualEncStr
01107 );
01109
01110
01113
01123 bool getDoValidation() const;
01124
01138 void setDoValidation(const bool newState);
01139
01143 virtual void attDef
01144 (
01145 const DTDElementDecl& elemDecl
01146 , const DTDAttDef& attDef
01147 , const bool ignoring
01148 );
01149
01150 virtual void doctypeComment
01151 (
01152 const XMLCh* const comment
01153 );
01154
01155 virtual void doctypeDecl
01156 (
01157 const DTDElementDecl& elemDecl
01158 , const XMLCh* const publicId
01159 , const XMLCh* const systemId
01160 , const bool hasIntSubset
01161 );
01162
01163 virtual void doctypePI
01164 (
01165 const XMLCh* const target
01166 , const XMLCh* const data
01167 );
01168
01169 virtual void doctypeWhitespace
01170 (
01171 const XMLCh* const chars
01172 , const unsigned int length
01173 );
01174
01175 virtual void elementDecl
01176 (
01177 const DTDElementDecl& decl
01178 , const bool isIgnored
01179 );
01180
01181 virtual void endAttList
01182 (
01183 const DTDElementDecl& elemDecl
01184 );
01185
01186 virtual void endIntSubset();
01187
01188 virtual void endExtSubset();
01189
01190 virtual void entityDecl
01191 (
01192 const DTDEntityDecl& entityDecl
01193 , const bool isPEDecl
01194 , const bool isIgnored
01195 );
01196
01197 virtual void resetDocType();
01198
01199 virtual void notationDecl
01200 (
01201 const XMLNotationDecl& notDecl
01202 , const bool isIgnored
01203 );
01204
01205 virtual void startAttList
01206 (
01207 const DTDElementDecl& elemDecl
01208 );
01209
01210 virtual void startIntSubset();
01211
01212 virtual void startExtSubset();
01213
01214 virtual void TextDecl
01215 (
01216 const XMLCh* const versionStr
01217 , const XMLCh* const encodingStr
01218 );
01219
01220
01222
01223
01224 protected :
01225
01226
01227
01228
01231
01236 IDOM_Node* getCurrentNode();
01237
01239
01240
01241
01242
01243
01244
01247
01255 void setCurrentNode(IDOM_Node* toSet);
01256
01263 void setDocument(IDOM_Document* toSet);
01265
01266
01267 private :
01268
01269
01270
01271
01272
01273
01274
01275
01276
01277
01278
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 IDOM_Node* fCurrentParent;
01314 IDOM_Node* fCurrentNode;
01315 IDDocumentImpl* fDocument;
01316 EntityResolver* fEntityResolver;
01317 ErrorHandler* fErrorHandler;
01318 bool fCreateEntityReferenceNodes;
01319 bool fIncludeIgnorableWhitespace;
01320 ValueStackOf<IDOM_Node*>* fNodeStack;
01321 bool fParseInProgress;
01322 XMLScanner* fScanner;
01323 bool fWithinElement;
01324 IDDocumentTypeImpl* fDocumentType;
01325 };
01326
01327
01328
01329
01330
01331
01332 inline void IDOMParser::endInputSource(const InputSource&)
01333 {
01334
01335 }
01336
01337 inline bool IDOMParser::expandSystemId(const XMLCh* const, XMLBuffer&)
01338 {
01339
01340 return false;
01341 }
01342
01343 inline void IDOMParser::resetEntities()
01344 {
01345
01346 }
01347
01348 inline void IDOMParser::startInputSource(const InputSource&)
01349 {
01350
01351 }
01352
01353
01354
01355
01356
01357 inline ErrorHandler* IDOMParser::getErrorHandler()
01358 {
01359 return fErrorHandler;
01360 }
01361
01362 inline const ErrorHandler* IDOMParser::getErrorHandler() const
01363 {
01364 return fErrorHandler;
01365 }
01366
01367 inline EntityResolver* IDOMParser::getEntityResolver()
01368 {
01369 return fEntityResolver;
01370 }
01371
01372 inline const EntityResolver* IDOMParser::getEntityResolver() const
01373 {
01374 return fEntityResolver;
01375 }
01376
01377 inline bool IDOMParser::getExpandEntityReferences() const
01378 {
01379 return fCreateEntityReferenceNodes;
01380 }
01381 inline bool IDOMParser::getCreateEntityReferenceNodes() const
01382 {
01383 return fCreateEntityReferenceNodes;
01384 }
01385
01386 inline bool IDOMParser::getIncludeIgnorableWhitespace() const
01387 {
01388 return fIncludeIgnorableWhitespace;
01389 }
01390
01391
01392
01393
01394
01395 inline void IDOMParser::setExpandEntityReferences(const bool expand)
01396 {
01397 fCreateEntityReferenceNodes = expand;
01398 }
01399
01400 inline void IDOMParser::setCreateEntityReferenceNodes(const bool create)
01401 {
01402 fCreateEntityReferenceNodes = create;
01403 }
01404
01405 inline void IDOMParser::setIncludeIgnorableWhitespace(const bool include)
01406 {
01407 fIncludeIgnorableWhitespace = include;
01408 }
01409
01410
01411
01412
01413
01414 inline IDOM_Node* IDOMParser::getCurrentNode()
01415 {
01416 return fCurrentNode;
01417 }
01418
01419
01420
01421
01422
01423 inline void IDOMParser::setCurrentNode(IDOM_Node* toSet)
01424 {
01425 fCurrentNode = toSet;
01426 }
01427
01428 inline void IDOMParser::setDocument(IDOM_Document* toSet)
01429 {
01430 fDocument = (IDDocumentImpl *)toSet;
01431 }
01432
01433 #endif