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 XMLScanner& getScanner() const;
00208
00216 const XMLValidator& getValidator() const;
00217
00225 ValSchemes getValidationScheme() const;
00226
00237 bool getDoSchema() const;
00238
00250 int getErrorCount() const;
00251
00262 bool getDoNamespaces() const;
00263
00276 bool getExitOnFirstFatalError() const;
00277
00288 bool getValidationConstraintFatal() const;
00289
00301 bool getExpandEntityReferences() const;
00302
00320 bool getCreateEntityReferenceNodes()const;
00321
00332 bool getIncludeIgnorableWhitespace() const;
00333
00335
00336
00337
00338
00339
00340
00343
00357 void setErrorHandler(ErrorHandler* const handler);
00358
00374 void setEntityResolver(EntityResolver* const handler);
00375
00394 void setDoNamespaces(const bool newState);
00395
00412 void setExitOnFirstFatalError(const bool newState);
00413
00429 void setValidationConstraintFatal(const bool newState);
00430
00445 void setExpandEntityReferences(const bool expand);
00446
00463 void setCreateEntityReferenceNodes(const bool create);
00464
00486 void setIncludeIgnorableWhitespace(const bool include);
00487
00504 void setValidationScheme(const ValSchemes newScheme);
00505
00519 void setDoSchema(const bool newState);
00520
00522
00523
00524
00525
00526
00527
00530
00544 void parse(const InputSource& source, const bool reuseGrammar = false);
00545
00560 void parse(const XMLCh* const systemId, const bool reuseGrammar = false);
00561
00573 void parse(const char* const systemId, const bool reuseGrammar = false);
00574
00604 bool parseFirst
00605 (
00606 const XMLCh* const systemId
00607 , XMLPScanToken& toFill
00608 , const bool reuseGrammar = false
00609 );
00610
00641 bool parseFirst
00642 (
00643 const char* const systemId
00644 , XMLPScanToken& toFill
00645 , const bool reuseGrammar = false
00646 );
00647
00678 bool parseFirst
00679 (
00680 const InputSource& source
00681 , XMLPScanToken& toFill
00682 , const bool reuseGrammar = false
00683 );
00684
00707 bool parseNext(XMLPScanToken& token);
00708
00734 void parseReset(XMLPScanToken& token);
00735
00737
00738
00739
00740
00741
00742
00743
00746
00771 virtual void error
00772 (
00773 const unsigned int errCode
00774 , const XMLCh* const msgDomain
00775 , const XMLErrorReporter::ErrTypes errType
00776 , const XMLCh* const errorText
00777 , const XMLCh* const systemId
00778 , const XMLCh* const publicId
00779 , const unsigned int lineNum
00780 , const unsigned int colNum
00781 );
00782
00791 virtual void resetErrors();
00793
00794
00795
00796
00797
00798
00801
00814 virtual void endInputSource(const InputSource& inputSource);
00815
00831 virtual bool expandSystemId
00832 (
00833 const XMLCh* const systemId
00834 , XMLBuffer& toFill
00835 );
00836
00845 virtual void resetEntities();
00846
00862 virtual InputSource* resolveEntity
00863 (
00864 const XMLCh* const publicId
00865 , const XMLCh* const systemId
00866 );
00867
00880 virtual void startInputSource(const InputSource& inputSource);
00881
00883
00884
00885
00886
00887
00888
00889
00892
00905 virtual void docCharacters
00906 (
00907 const XMLCh* const chars
00908 , const unsigned int length
00909 , const bool cdataSection
00910 );
00911
00920 virtual void docComment
00921 (
00922 const XMLCh* const comment
00923 );
00924
00937 virtual void docPI
00938 (
00939 const XMLCh* const target
00940 , const XMLCh* const data
00941 );
00942
00947 virtual void endDocument();
00948
00962 virtual void endElement
00963 (
00964 const XMLElementDecl& elemDecl
00965 , const unsigned int urlId
00966 , const bool isRoot
00967 );
00968
00977 virtual void endEntityReference
00978 (
00979 const XMLEntityDecl& entDecl
00980 );
00981
01000 virtual void ignorableWhitespace
01001 (
01002 const XMLCh* const chars
01003 , const unsigned int length
01004 , const bool cdataSection
01005 );
01006
01013 virtual void resetDocument();
01014
01019 virtual void startDocument();
01020
01048 virtual void startElement
01049 (
01050 const XMLElementDecl& elemDecl
01051 , const unsigned int urlId
01052 , const XMLCh* const elemPrefix
01053 , const RefVectorOf<XMLAttr>& attrList
01054 , const unsigned int attrCount
01055 , const bool isEmpty
01056 , const bool isRoot
01057 );
01058
01068 virtual void startEntityReference
01069 (
01070 const XMLEntityDecl& entDecl
01071 );
01072
01091 virtual void XMLDecl
01092 (
01093 const XMLCh* const versionStr
01094 , const XMLCh* const encodingStr
01095 , const XMLCh* const standaloneStr
01096 , const XMLCh* const actualEncStr
01097 );
01099
01100
01103
01113 bool getDoValidation() const;
01114
01128 void setDoValidation(const bool newState);
01129
01133 virtual void attDef
01134 (
01135 const DTDElementDecl& elemDecl
01136 , const DTDAttDef& attDef
01137 , const bool ignoring
01138 );
01139
01140 virtual void doctypeComment
01141 (
01142 const XMLCh* const comment
01143 );
01144
01145 virtual void doctypeDecl
01146 (
01147 const DTDElementDecl& elemDecl
01148 , const XMLCh* const publicId
01149 , const XMLCh* const systemId
01150 , const bool hasIntSubset
01151 );
01152
01153 virtual void doctypePI
01154 (
01155 const XMLCh* const target
01156 , const XMLCh* const data
01157 );
01158
01159 virtual void doctypeWhitespace
01160 (
01161 const XMLCh* const chars
01162 , const unsigned int length
01163 );
01164
01165 virtual void elementDecl
01166 (
01167 const DTDElementDecl& decl
01168 , const bool isIgnored
01169 );
01170
01171 virtual void endAttList
01172 (
01173 const DTDElementDecl& elemDecl
01174 );
01175
01176 virtual void endIntSubset();
01177
01178 virtual void endExtSubset();
01179
01180 virtual void entityDecl
01181 (
01182 const DTDEntityDecl& entityDecl
01183 , const bool isPEDecl
01184 , const bool isIgnored
01185 );
01186
01187 virtual void resetDocType();
01188
01189 virtual void notationDecl
01190 (
01191 const XMLNotationDecl& notDecl
01192 , const bool isIgnored
01193 );
01194
01195 virtual void startAttList
01196 (
01197 const DTDElementDecl& elemDecl
01198 );
01199
01200 virtual void startIntSubset();
01201
01202 virtual void startExtSubset();
01203
01204 virtual void TextDecl
01205 (
01206 const XMLCh* const versionStr
01207 , const XMLCh* const encodingStr
01208 );
01209
01210
01212
01213
01214 protected :
01215
01216
01217
01218
01221
01226 IDOM_Node* getCurrentNode();
01227
01229
01230
01231
01232
01233
01234
01237
01245 void setCurrentNode(IDOM_Node* toSet);
01246
01253 void setDocument(IDOM_Document* toSet);
01255
01256
01257 private :
01258
01259
01260
01261
01262
01263
01264
01265
01266
01267
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 IDOM_Node* fCurrentParent;
01304 IDOM_Node* fCurrentNode;
01305 IDDocumentImpl* fDocument;
01306 EntityResolver* fEntityResolver;
01307 ErrorHandler* fErrorHandler;
01308 bool fCreateEntityReferenceNodes;
01309 bool fIncludeIgnorableWhitespace;
01310 ValueStackOf<IDOM_Node*>* fNodeStack;
01311 bool fParseInProgress;
01312 XMLScanner* fScanner;
01313 bool fWithinElement;
01314 IDDocumentTypeImpl* fDocumentType;
01315 };
01316
01317
01318
01319
01320
01321
01322 inline void IDOMParser::endInputSource(const InputSource&)
01323 {
01324
01325 }
01326
01327 inline bool IDOMParser::expandSystemId(const XMLCh* const, XMLBuffer&)
01328 {
01329
01330 return false;
01331 }
01332
01333 inline void IDOMParser::resetEntities()
01334 {
01335
01336 }
01337
01338 inline void IDOMParser::startInputSource(const InputSource&)
01339 {
01340
01341 }
01342
01343
01344
01345
01346
01347 inline ErrorHandler* IDOMParser::getErrorHandler()
01348 {
01349 return fErrorHandler;
01350 }
01351
01352 inline const ErrorHandler* IDOMParser::getErrorHandler() const
01353 {
01354 return fErrorHandler;
01355 }
01356
01357 inline EntityResolver* IDOMParser::getEntityResolver()
01358 {
01359 return fEntityResolver;
01360 }
01361
01362 inline const EntityResolver* IDOMParser::getEntityResolver() const
01363 {
01364 return fEntityResolver;
01365 }
01366
01367 inline bool IDOMParser::getExpandEntityReferences() const
01368 {
01369 return fCreateEntityReferenceNodes;
01370 }
01371 inline bool IDOMParser::getCreateEntityReferenceNodes() const
01372 {
01373 return fCreateEntityReferenceNodes;
01374 }
01375
01376 inline bool IDOMParser::getIncludeIgnorableWhitespace() const
01377 {
01378 return fIncludeIgnorableWhitespace;
01379 }
01380
01381 inline const XMLScanner& IDOMParser::getScanner() const
01382 {
01383 return *fScanner;
01384 }
01385
01386
01387
01388
01389
01390 inline void IDOMParser::setExpandEntityReferences(const bool expand)
01391 {
01392 fCreateEntityReferenceNodes = expand;
01393 }
01394
01395 inline void IDOMParser::setCreateEntityReferenceNodes(const bool create)
01396 {
01397 fCreateEntityReferenceNodes = create;
01398 }
01399
01400 inline void IDOMParser::setIncludeIgnorableWhitespace(const bool include)
01401 {
01402 fIncludeIgnorableWhitespace = include;
01403 }
01404
01405
01406
01407
01408
01409 inline IDOM_Node* IDOMParser::getCurrentNode()
01410 {
01411 return fCurrentNode;
01412 }
01413
01414
01415
01416
01417
01418 inline void IDOMParser::setCurrentNode(IDOM_Node* toSet)
01419 {
01420 fCurrentNode = toSet;
01421 }
01422
01423 inline void IDOMParser::setDocument(IDOM_Document* toSet)
01424 {
01425 fDocument = (IDDocumentImpl *)toSet;
01426 }
01427
01428 #endif