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 <xercesc/dom/DOM_Document.hpp>
00067 #include <xercesc/framework/XMLDocumentHandler.hpp>
00068 #include <xercesc/framework/XMLErrorReporter.hpp>
00069 #include <xercesc/framework/XMLEntityHandler.hpp>
00070 #include <xercesc/util/ValueStackOf.hpp>
00071
00072 #include <xercesc/validators/DTD/DocTypeHandler.hpp>
00073 #include <xercesc/dom/DOM_DocumentType.hpp>
00074 #include <xercesc/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
00317 bool getCreateEntityReferenceNodes()const;
00318
00329 bool getIncludeIgnorableWhitespace() const;
00330
00340 bool getToCreateXMLDeclTypeNode() const;
00341
00361 XMLCh* getExternalSchemaLocation() const;
00362
00382 XMLCh* getExternalNoNamespaceSchemaLocation() const;
00383
00385
00386
00387
00388
00389
00390
00393
00407 void setErrorHandler(ErrorHandler* const handler);
00408
00424 void setEntityResolver(EntityResolver* const handler);
00425
00444 void setDoNamespaces(const bool newState);
00445
00462 void setExitOnFirstFatalError(const bool newState);
00463
00479 void setValidationConstraintFatal(const bool newState);
00480
00497 void setCreateEntityReferenceNodes(const bool create);
00498
00520 void setIncludeIgnorableWhitespace(const bool include);
00521
00538 void setValidationScheme(const ValSchemes newScheme);
00539
00553 void setDoSchema(const bool newState);
00554
00571 void setValidationSchemaFullChecking(const bool schemaFullChecking);
00572
00583 void setToCreateXMLDeclTypeNode(const bool create);
00584
00604
00605 void setExternalSchemaLocation(const XMLCh* const schemaLocation);
00606
00615 void setExternalSchemaLocation(const char* const schemaLocation);
00616
00631 void setExternalNoNamespaceSchemaLocation(const XMLCh* const noNamespaceSchemaLocation);
00632
00641 void setExternalNoNamespaceSchemaLocation(const char* const noNamespaceSchemaLocation);
00642
00644
00645
00646
00647
00648
00649
00652
00673 void parse(const InputSource& source, const bool reuseGrammar = false);
00674
00694 void parse(const XMLCh* const systemId, const bool reuseGrammar = false);
00695
00713 void parse(const char* const systemId, const bool reuseGrammar = false);
00714
00744 bool parseFirst
00745 (
00746 const XMLCh* const systemId
00747 , XMLPScanToken& toFill
00748 , const bool reuseGrammar = false
00749 );
00750
00781 bool parseFirst
00782 (
00783 const char* const systemId
00784 , XMLPScanToken& toFill
00785 , const bool reuseGrammar = false
00786 );
00787
00818 bool parseFirst
00819 (
00820 const InputSource& source
00821 , XMLPScanToken& toFill
00822 , const bool reuseGrammar = false
00823 );
00824
00847 bool parseNext(XMLPScanToken& token);
00848
00874 void parseReset(XMLPScanToken& token);
00875
00877
00878
00879
00880
00881
00882
00883
00886
00911 virtual void error
00912 (
00913 const unsigned int errCode
00914 , const XMLCh* const msgDomain
00915 , const XMLErrorReporter::ErrTypes errType
00916 , const XMLCh* const errorText
00917 , const XMLCh* const systemId
00918 , const XMLCh* const publicId
00919 , const unsigned int lineNum
00920 , const unsigned int colNum
00921 );
00922
00931 virtual void resetErrors();
00933
00934
00935
00936
00937
00938
00941
00954 virtual void endInputSource(const InputSource& inputSource);
00955
00971 virtual bool expandSystemId
00972 (
00973 const XMLCh* const systemId
00974 , XMLBuffer& toFill
00975 );
00976
00985 virtual void resetEntities();
00986
01002 virtual InputSource* resolveEntity
01003 (
01004 const XMLCh* const publicId
01005 , const XMLCh* const systemId
01006 );
01007
01020 virtual void startInputSource(const InputSource& inputSource);
01021
01023
01024
01025
01026
01027
01028
01029
01032
01045 virtual void docCharacters
01046 (
01047 const XMLCh* const chars
01048 , const unsigned int length
01049 , const bool cdataSection
01050 );
01051
01060 virtual void docComment
01061 (
01062 const XMLCh* const comment
01063 );
01064
01077 virtual void docPI
01078 (
01079 const XMLCh* const target
01080 , const XMLCh* const data
01081 );
01082
01087 virtual void endDocument();
01088
01102 virtual void endElement
01103 (
01104 const XMLElementDecl& elemDecl
01105 , const unsigned int urlId
01106 , const bool isRoot
01107 );
01108
01117 virtual void endEntityReference
01118 (
01119 const XMLEntityDecl& entDecl
01120 );
01121
01140 virtual void ignorableWhitespace
01141 (
01142 const XMLCh* const chars
01143 , const unsigned int length
01144 , const bool cdataSection
01145 );
01146
01153 virtual void resetDocument();
01154
01159 virtual void startDocument();
01160
01188 virtual void startElement
01189 (
01190 const XMLElementDecl& elemDecl
01191 , const unsigned int urlId
01192 , const XMLCh* const elemPrefix
01193 , const RefVectorOf<XMLAttr>& attrList
01194 , const unsigned int attrCount
01195 , const bool isEmpty
01196 , const bool isRoot
01197 );
01198
01208 virtual void startEntityReference
01209 (
01210 const XMLEntityDecl& entDecl
01211 );
01212
01231 virtual void XMLDecl
01232 (
01233 const XMLCh* const versionStr
01234 , const XMLCh* const encodingStr
01235 , const XMLCh* const standaloneStr
01236 , const XMLCh* const actualEncStr
01237 );
01239
01240
01243
01257 void setExpandEntityReferences(const bool expand);
01258
01270 bool getExpandEntityReferences() const;
01271
01285 bool getDoValidation() const;
01286
01303 void setDoValidation(const bool newState);
01304
01308 virtual void attDef
01309 (
01310 const DTDElementDecl& elemDecl
01311 , const DTDAttDef& attDef
01312 , const bool ignoring
01313 );
01314
01315 virtual void doctypeComment
01316 (
01317 const XMLCh* const comment
01318 );
01319
01320 virtual void doctypeDecl
01321 (
01322 const DTDElementDecl& elemDecl
01323 , const XMLCh* const publicId
01324 , const XMLCh* const systemId
01325 , const bool hasIntSubset
01326 );
01327
01328 virtual void doctypePI
01329 (
01330 const XMLCh* const target
01331 , const XMLCh* const data
01332 );
01333
01334 virtual void doctypeWhitespace
01335 (
01336 const XMLCh* const chars
01337 , const unsigned int length
01338 );
01339
01340 virtual void elementDecl
01341 (
01342 const DTDElementDecl& decl
01343 , const bool isIgnored
01344 );
01345
01346 virtual void endAttList
01347 (
01348 const DTDElementDecl& elemDecl
01349 );
01350
01351 virtual void endIntSubset();
01352
01353 virtual void endExtSubset();
01354
01355 virtual void entityDecl
01356 (
01357 const DTDEntityDecl& entityDecl
01358 , const bool isPEDecl
01359 , const bool isIgnored
01360 );
01361
01362 virtual void resetDocType();
01363
01364 virtual void notationDecl
01365 (
01366 const XMLNotationDecl& notDecl
01367 , const bool isIgnored
01368 );
01369
01370 virtual void startAttList
01371 (
01372 const DTDElementDecl& elemDecl
01373 );
01374
01375 virtual void startIntSubset();
01376
01377 virtual void startExtSubset();
01378
01379 virtual void TextDecl
01380 (
01381 const XMLCh* const versionStr
01382 , const XMLCh* const encodingStr
01383 );
01384
01385
01387
01388
01389 protected :
01390
01391
01392
01393
01396
01401 DOM_Node getCurrentNode();
01402
01404
01405
01406
01407
01408
01409
01412
01420 void setCurrentNode(DOM_Node toSet);
01421
01428 void setDocument(DOM_Document toSet);
01430
01431
01432 private :
01433
01434
01435
01436
01437
01438
01439
01440
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461
01462
01463
01464
01465
01466
01467
01468
01469
01470
01471
01472
01473
01474
01475
01476
01477
01478
01479
01480
01481
01482 DOM_Node fCurrentParent;
01483 DOM_Node fCurrentNode;
01484 DOM_Document fDocument;
01485 EntityResolver* fEntityResolver;
01486 ErrorHandler* fErrorHandler;
01487 bool fCreateEntityReferenceNodes;
01488 bool fIncludeIgnorableWhitespace;
01489 ValueStackOf<DOM_Node>* fNodeStack;
01490 bool fParseInProgress;
01491 XMLScanner* fScanner;
01492 bool fWithinElement;
01493 DocumentTypeImpl* fDocumentType;
01494 bool fToCreateXMLDeclTypeNode;
01495 };
01496
01497
01498
01499
01500
01501
01502 inline void DOMParser::endInputSource(const InputSource&)
01503 {
01504
01505 }
01506
01507 inline bool DOMParser::expandSystemId(const XMLCh* const, XMLBuffer&)
01508 {
01509
01510 return false;
01511 }
01512
01513 inline void DOMParser::resetEntities()
01514 {
01515
01516 }
01517
01518 inline void DOMParser::startInputSource(const InputSource&)
01519 {
01520
01521 }
01522
01523
01524
01525
01526
01527 inline DOM_Document DOMParser::getDocument()
01528 {
01529 return fDocument;
01530 }
01531
01532 inline ErrorHandler* DOMParser::getErrorHandler()
01533 {
01534 return fErrorHandler;
01535 }
01536
01537 inline const ErrorHandler* DOMParser::getErrorHandler() const
01538 {
01539 return fErrorHandler;
01540 }
01541
01542 inline EntityResolver* DOMParser::getEntityResolver()
01543 {
01544 return fEntityResolver;
01545 }
01546
01547 inline const EntityResolver* DOMParser::getEntityResolver() const
01548 {
01549 return fEntityResolver;
01550 }
01551
01552 inline bool DOMParser::getExpandEntityReferences() const
01553 {
01554 return fCreateEntityReferenceNodes;
01555 }
01556 inline bool DOMParser::getCreateEntityReferenceNodes() const
01557 {
01558 return fCreateEntityReferenceNodes;
01559 }
01560
01561 inline bool DOMParser::getIncludeIgnorableWhitespace() const
01562 {
01563 return fIncludeIgnorableWhitespace;
01564 }
01565
01566 inline const XMLScanner& DOMParser::getScanner() const
01567 {
01568 return *fScanner;
01569 }
01570
01571 inline bool DOMParser::getToCreateXMLDeclTypeNode() const
01572 {
01573 return fToCreateXMLDeclTypeNode;
01574 }
01575
01576
01577
01578
01579
01580 inline void DOMParser::setExpandEntityReferences(const bool expand)
01581 {
01582 fCreateEntityReferenceNodes = expand;
01583 }
01584
01585 inline void DOMParser::setCreateEntityReferenceNodes(const bool create)
01586 {
01587 fCreateEntityReferenceNodes = create;
01588 }
01589
01590 inline void DOMParser::setIncludeIgnorableWhitespace(const bool include)
01591 {
01592 fIncludeIgnorableWhitespace = include;
01593 }
01594
01595 inline void DOMParser::setToCreateXMLDeclTypeNode(const bool create)
01596 {
01597 fToCreateXMLDeclTypeNode = create;
01598 }
01599
01600
01601
01602
01603
01604 inline DOM_Node DOMParser::getCurrentNode()
01605 {
01606 return fCurrentNode;
01607 }
01608
01609
01610
01611
01612
01613 inline void DOMParser::setCurrentNode(DOM_Node toSet)
01614 {
01615 fCurrentNode = toSet;
01616 }
01617
01618 inline void DOMParser::setDocument(DOM_Document toSet)
01619 {
01620 fDocument = toSet;
01621 }
01622
01623 #endif