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 #if !defined(ABSTRACTDOMPARSER_HPP)
00062 #define ABSTRACTDOMPARSER_HPP
00063
00064 #include <xercesc/dom/DOMDocument.hpp>
00065 #include <xercesc/framework/XMLDocumentHandler.hpp>
00066 #include <xercesc/framework/XMLErrorReporter.hpp>
00067 #include <xercesc/framework/XMLEntityHandler.hpp>
00068 #include <xercesc/util/SecurityManager.hpp>
00069 #include <xercesc/util/ValueStackOf.hpp>
00070 #include <xercesc/validators/DTD/DocTypeHandler.hpp>
00071 #include <xercesc/dom/DOMDocumentType.hpp>
00072 #include <xercesc/validators/DTD/DTDElementDecl.hpp>
00073 #include <xercesc/framework/XMLBufferMgr.hpp>
00074
00075 XERCES_CPP_NAMESPACE_BEGIN
00076
00077 class XMLPScanToken;
00078 class XMLScanner;
00079 class XMLValidator;
00080 class DOMDocumentImpl;
00081 class DOMDocumentTypeImpl;
00082 class DOMElement;
00083 class GrammarResolver;
00084 class XMLGrammarPool;
00085 class PSVIHandler;
00086
00091 class AbstractDOMParser :
00092
00093 public XMemory
00094 , public XMLDocumentHandler
00095 , public XMLErrorReporter
00096 , public XMLEntityHandler
00097 , public DocTypeHandler
00098 {
00099 public :
00100
00101
00102
00105
00113 enum ValSchemes
00114 {
00115 Val_Never
00116 , Val_Always
00117 , Val_Auto
00118 };
00120
00121
00122
00123
00124
00127
00131 virtual ~AbstractDOMParser();
00132
00134
00135
00136
00137
00138
00146 void reset();
00147
00161 DOMDocument* adoptDocument();
00162
00164
00165
00166
00167
00168
00169
00172
00184 DOMDocument* getDocument();
00185
00193 const XMLValidator& getValidator() const;
00194
00202 ValSchemes getValidationScheme() const;
00203
00214 bool getDoSchema() const;
00215
00226 bool getValidationSchemaFullChecking() const;
00227
00239 int getErrorCount() const;
00240
00251 bool getDoNamespaces() const;
00252
00265 bool getExitOnFirstFatalError() const;
00266
00277 bool getValidationConstraintFatal() const;
00278
00288 bool getCreateEntityReferenceNodes()const;
00289
00300 bool getIncludeIgnorableWhitespace() const;
00301
00321 XMLCh* getExternalSchemaLocation() const;
00322
00342 XMLCh* getExternalNoNamespaceSchemaLocation() const;
00343
00359 SecurityManager* getSecurityManager() const;
00360
00372 bool getLoadExternalDTD() const;
00373
00382 bool getCreateCommentNodes()const;
00383
00395 bool getCalculateSrcOfs() const;
00396
00407 bool getStandardUriConformant() const;
00408
00415 PSVIHandler* getPSVIHandler();
00416
00423 const PSVIHandler* getPSVIHandler() const;
00424
00426
00427
00428
00429
00430
00431
00434
00449 void setDoNamespaces(const bool newState);
00450
00467 void setExitOnFirstFatalError(const bool newState);
00468
00488 void setValidationConstraintFatal(const bool newState);
00489
00508 void setCreateEntityReferenceNodes(const bool create);
00509
00531 void setIncludeIgnorableWhitespace(const bool include);
00532
00549 void setValidationScheme(const ValSchemes newScheme);
00550
00566 void setDoSchema(const bool newState);
00567
00584 void setValidationSchemaFullChecking(const bool schemaFullChecking);
00585
00606 void setExternalSchemaLocation(const XMLCh* const schemaLocation);
00607
00616 void setExternalSchemaLocation(const char* const schemaLocation);
00617
00632 void setExternalNoNamespaceSchemaLocation(const XMLCh* const noNamespaceSchemaLocation);
00633
00642 void setExternalNoNamespaceSchemaLocation(const char* const noNamespaceSchemaLocation);
00643
00659 void setSecurityManager(SecurityManager* const securityManager);
00660
00677 void setLoadExternalDTD(const bool newState);
00678
00689 void setCreateCommentNodes(const bool create);
00690
00703 void setCalculateSrcOfs(const bool newState);
00704
00715 void setStandardUriConformant(const bool newState);
00716
00724 void useScanner(const XMLCh* const scannerName);
00725
00733 void useImplementation(const XMLCh* const implementationFeatures);
00734
00743 virtual void setPSVIHandler(PSVIHandler* const handler);
00744
00746
00747
00748
00749
00750
00751
00754
00770 void parse(const InputSource& source);
00771
00788 void parse(const XMLCh* const systemId);
00789
00805 void parse(const char* const systemId);
00806
00833 bool parseFirst
00834 (
00835 const XMLCh* const systemId
00836 , XMLPScanToken& toFill
00837 );
00838
00866 bool parseFirst
00867 (
00868 const char* const systemId
00869 , XMLPScanToken& toFill
00870 );
00871
00899 bool parseFirst
00900 (
00901 const InputSource& source
00902 , XMLPScanToken& toFill
00903 );
00904
00927 bool parseNext(XMLPScanToken& token);
00928
00954 void parseReset(XMLPScanToken& token);
00955
00957
00958
00959
00960
00961
00964
00977 virtual void docCharacters
00978 (
00979 const XMLCh* const chars
00980 , const unsigned int length
00981 , const bool cdataSection
00982 );
00983
00992 virtual void docComment
00993 (
00994 const XMLCh* const comment
00995 );
00996
01009 virtual void docPI
01010 (
01011 const XMLCh* const target
01012 , const XMLCh* const data
01013 );
01014
01019 virtual void endDocument();
01020
01037 virtual void endElement
01038 (
01039 const XMLElementDecl& elemDecl
01040 , const unsigned int urlId
01041 , const bool isRoot
01042 , const XMLCh* const elemPrefix
01043 );
01044
01053 virtual void endEntityReference
01054 (
01055 const XMLEntityDecl& entDecl
01056 );
01057
01076 virtual void ignorableWhitespace
01077 (
01078 const XMLCh* const chars
01079 , const unsigned int length
01080 , const bool cdataSection
01081 );
01082
01089 virtual void resetDocument();
01090
01095 virtual void startDocument();
01096
01124 virtual void startElement
01125 (
01126 const XMLElementDecl& elemDecl
01127 , const unsigned int urlId
01128 , const XMLCh* const elemPrefix
01129 , const RefVectorOf<XMLAttr>& attrList
01130 , const unsigned int attrCount
01131 , const bool isEmpty
01132 , const bool isRoot
01133 );
01134
01144 virtual void startEntityReference
01145 (
01146 const XMLEntityDecl& entDecl
01147 );
01148
01167 virtual void XMLDecl
01168 (
01169 const XMLCh* const versionStr
01170 , const XMLCh* const encodingStr
01171 , const XMLCh* const standaloneStr
01172 , const XMLCh* const actualEncStr
01173 );
01174
01194 virtual void elementTypeInfo
01195 (
01196 const XMLCh* const typeName
01197 , const XMLCh* const typeURI
01198 );
01200
01201
01202
01203
01204
01207 virtual void attDef
01208 (
01209 const DTDElementDecl& elemDecl
01210 , const DTDAttDef& attDef
01211 , const bool ignoring
01212 );
01213
01214 virtual void doctypeComment
01215 (
01216 const XMLCh* const comment
01217 );
01218
01219 virtual void doctypeDecl
01220 (
01221 const DTDElementDecl& elemDecl
01222 , const XMLCh* const publicId
01223 , const XMLCh* const systemId
01224 , const bool hasIntSubset
01225 , const bool hasExtSubset = false
01226 );
01227
01228 virtual void doctypePI
01229 (
01230 const XMLCh* const target
01231 , const XMLCh* const data
01232 );
01233
01234 virtual void doctypeWhitespace
01235 (
01236 const XMLCh* const chars
01237 , const unsigned int length
01238 );
01239
01240 virtual void elementDecl
01241 (
01242 const DTDElementDecl& decl
01243 , const bool isIgnored
01244 );
01245
01246 virtual void endAttList
01247 (
01248 const DTDElementDecl& elemDecl
01249 );
01250
01251 virtual void endIntSubset();
01252
01253 virtual void endExtSubset();
01254
01255 virtual void entityDecl
01256 (
01257 const DTDEntityDecl& entityDecl
01258 , const bool isPEDecl
01259 , const bool isIgnored
01260 );
01261
01262 virtual void resetDocType();
01263
01264 virtual void notationDecl
01265 (
01266 const XMLNotationDecl& notDecl
01267 , const bool isIgnored
01268 );
01269
01270 virtual void startAttList
01271 (
01272 const DTDElementDecl& elemDecl
01273 );
01274
01275 virtual void startIntSubset();
01276
01277 virtual void startExtSubset();
01278
01279 virtual void TextDecl
01280 (
01281 const XMLCh* const versionStr
01282 , const XMLCh* const encodingStr
01283 );
01284
01285
01287
01288
01289
01290
01291
01304 bool getDoValidation() const;
01305
01319 void setDoValidation(const bool newState);
01320
01334 bool getExpandEntityReferences() const;
01335
01352 void setExpandEntityReferences(const bool expand);
01353
01355
01356 protected :
01357
01358
01359
01378 AbstractDOMParser
01379 (
01380 XMLValidator* const valToAdopt = 0
01381 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
01382 , XMLGrammarPool* const gramPool = 0
01383 );
01384
01386
01387
01388
01389
01397 DOMNode* getCurrentNode();
01398
01403 XMLScanner* getScanner() const;
01404
01409 GrammarResolver* getGrammarResolver() const;
01410
01416 bool getParseInProgress() const;
01417
01418 MemoryManager* getMemoryManager() const;
01419
01421
01422
01423
01424
01425
01426
01429
01437 void setCurrentNode(DOMNode* toSet);
01438
01445 void setDocument(DOMDocument* toSet);
01446
01453 void setParseInProgress(const bool toSet);
01455
01456
01457
01458
01461 virtual DOMElement* createElementNSNode(const XMLCh *fNamespaceURI,
01462 const XMLCh *qualifiedName);
01463
01464 void resetPool();
01465
01469 bool isDocumentAdopted() const;
01470
01472
01473
01474 private :
01475
01476
01477
01478 void initialize();
01479 void cleanUp();
01480
01481
01482
01483
01484 AbstractDOMParser(const AbstractDOMParser&);
01485 AbstractDOMParser& operator=(const AbstractDOMParser&);
01486
01487 protected:
01488
01489
01490
01491
01492
01493
01494
01495
01496
01497
01498
01499
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515
01516
01517
01518
01519
01520
01521
01522
01523
01524
01525
01526
01527
01528
01529
01530
01531
01532
01533
01534
01535
01536
01537
01538
01539
01540
01541
01542
01543
01544
01545
01546
01547
01548
01549
01550
01551
01552
01553
01554
01555
01556
01557 bool fCreateEntityReferenceNodes;
01558 bool fIncludeIgnorableWhitespace;
01559 bool fWithinElement;
01560 bool fParseInProgress;
01561 bool fCreateCommentNodes;
01562 bool fDocumentAdoptedByUser;
01563 XMLScanner* fScanner;
01564 XMLCh* fImplementationFeatures;
01565 DOMNode* fCurrentParent;
01566 DOMNode* fCurrentNode;
01567 DOMEntity* fCurrentEntity;
01568 DOMDocumentImpl* fDocument;
01569 ValueStackOf<DOMNode*>* fNodeStack;
01570 DOMDocumentTypeImpl* fDocumentType;
01571 RefVectorOf<DOMDocumentImpl>* fDocumentVector;
01572 GrammarResolver* fGrammarResolver;
01573 XMLStringPool* fURIStringPool;
01574 XMLValidator* fValidator;
01575 MemoryManager* fMemoryManager;
01576 XMLGrammarPool* fGrammarPool;
01577 XMLBufferMgr fBufMgr;
01578 XMLBuffer& fInternalSubset;
01579 PSVIHandler* fPSVIHandler;
01580 };
01581
01582
01583
01584
01585
01586
01587 inline bool AbstractDOMParser::getExpandEntityReferences() const
01588 {
01589 return !fCreateEntityReferenceNodes;
01590 }
01591 inline bool AbstractDOMParser::getCreateEntityReferenceNodes() const
01592 {
01593 return fCreateEntityReferenceNodes;
01594 }
01595
01596 inline bool AbstractDOMParser::getIncludeIgnorableWhitespace() const
01597 {
01598 return fIncludeIgnorableWhitespace;
01599 }
01600
01601 inline bool AbstractDOMParser::getParseInProgress() const
01602 {
01603 return fParseInProgress;
01604 }
01605
01606 inline XMLScanner* AbstractDOMParser::getScanner() const
01607 {
01608 return fScanner;
01609 }
01610
01611 inline GrammarResolver* AbstractDOMParser::getGrammarResolver() const
01612 {
01613 return fGrammarResolver;
01614 }
01615
01616 inline bool AbstractDOMParser::getCreateCommentNodes() const
01617 {
01618 return fCreateCommentNodes;
01619 }
01620
01621 inline PSVIHandler* AbstractDOMParser::getPSVIHandler()
01622 {
01623 return fPSVIHandler;
01624 }
01625
01626 inline const PSVIHandler* AbstractDOMParser::getPSVIHandler() const
01627 {
01628 return fPSVIHandler;
01629 }
01630
01631
01632
01633 inline void AbstractDOMParser::setExpandEntityReferences(const bool expand)
01634 {
01635 fCreateEntityReferenceNodes = !expand;
01636 }
01637
01638 inline void AbstractDOMParser::setCreateEntityReferenceNodes(const bool create)
01639 {
01640 fCreateEntityReferenceNodes = create;
01641 }
01642
01643 inline void AbstractDOMParser::setIncludeIgnorableWhitespace(const bool include)
01644 {
01645 fIncludeIgnorableWhitespace = include;
01646 }
01647
01648 inline void AbstractDOMParser::setCreateCommentNodes(const bool create)
01649 {
01650 fCreateCommentNodes = create;
01651 }
01652
01653 inline void AbstractDOMParser::useImplementation(const XMLCh* const implementationFeatures)
01654 {
01655 fMemoryManager->deallocate(fImplementationFeatures);
01656 fImplementationFeatures = XMLString::replicate(implementationFeatures, fMemoryManager);
01657 }
01658
01659
01660
01661
01662 inline DOMNode* AbstractDOMParser::getCurrentNode()
01663 {
01664 return fCurrentNode;
01665 }
01666
01667 inline MemoryManager* AbstractDOMParser::getMemoryManager() const
01668 {
01669 return fMemoryManager;
01670 }
01671
01672
01673
01674
01675 inline void AbstractDOMParser::setCurrentNode(DOMNode* toSet)
01676 {
01677 fCurrentNode = toSet;
01678 }
01679
01680 inline void AbstractDOMParser::setDocument(DOMDocument* toSet)
01681 {
01682 fDocument = (DOMDocumentImpl *)toSet;
01683 }
01684
01685 inline void AbstractDOMParser::setParseInProgress(const bool toSet)
01686 {
01687 fParseInProgress = toSet;
01688 }
01689
01690 XERCES_CPP_NAMESPACE_END
01691
01692 #endif
01693
01694
01695