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 PARSERS_EXPORT 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
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
00393 bool getURLEntityCaching() const;
00394
00404 XMLCh* getURLEntityCacheDir() const;
00405
00407
00408
00409
00410
00411
00412
00415
00429 void setErrorHandler(ErrorHandler* const handler);
00430
00446 void setEntityResolver(EntityResolver* const handler);
00447
00466 void setDoNamespaces(const bool newState);
00467
00484 void setExitOnFirstFatalError(const bool newState);
00485
00501 void setValidationConstraintFatal(const bool newState);
00502
00519 void setCreateEntityReferenceNodes(const bool create);
00520
00542 void setIncludeIgnorableWhitespace(const bool include);
00543
00560 void setValidationScheme(const ValSchemes newScheme);
00561
00575 void setDoSchema(const bool newState);
00576
00593 void setValidationSchemaFullChecking(const bool schemaFullChecking);
00594
00605 void setToCreateXMLDeclTypeNode(const bool create);
00606
00627 void setExternalSchemaLocation(const XMLCh* const schemaLocation);
00628
00637 void setExternalSchemaLocation(const char* const schemaLocation);
00638
00653 void setExternalNoNamespaceSchemaLocation(const XMLCh* const noNamespaceSchemaLocation);
00654
00663 void setExternalNoNamespaceSchemaLocation(const char* const noNamespaceSchemaLocation);
00664
00679 void setURLEntityCaching(const bool useCache);
00680
00696 void setURLEntityCacheDir(const XMLCh* const cachedir);
00697
00707 void setURLEntityCacheDir(const char* const cachedir);
00708
00710
00711
00712
00713
00714
00715
00718
00739 void parse(const InputSource& source, const bool reuseGrammar = false);
00740
00760 void parse(const XMLCh* const systemId, const bool reuseGrammar = false);
00761
00779 void parse(const char* const systemId, const bool reuseGrammar = false);
00780
00810 bool parseFirst
00811 (
00812 const XMLCh* const systemId
00813 , XMLPScanToken& toFill
00814 , const bool reuseGrammar = false
00815 );
00816
00847 bool parseFirst
00848 (
00849 const char* const systemId
00850 , XMLPScanToken& toFill
00851 , const bool reuseGrammar = false
00852 );
00853
00884 bool parseFirst
00885 (
00886 const InputSource& source
00887 , XMLPScanToken& toFill
00888 , const bool reuseGrammar = false
00889 );
00890
00913 bool parseNext(XMLPScanToken& token);
00914
00940 void parseReset(XMLPScanToken& token);
00941
00943
00944
00945
00946
00947
00948
00949
00952
00977 virtual void error
00978 (
00979 const unsigned int errCode
00980 , const XMLCh* const msgDomain
00981 , const XMLErrorReporter::ErrTypes errType
00982 , const XMLCh* const errorText
00983 , const XMLCh* const systemId
00984 , const XMLCh* const publicId
00985 , const unsigned int lineNum
00986 , const unsigned int colNum
00987 );
00988
00997 virtual void resetErrors();
00999
01000
01001
01002
01003
01004
01007
01020 virtual void endInputSource(const InputSource& inputSource);
01021
01037 virtual bool expandSystemId
01038 (
01039 const XMLCh* const systemId
01040 , XMLBuffer& toFill
01041 );
01042
01051 virtual void resetEntities();
01052
01068 virtual InputSource* resolveEntity
01069 (
01070 const XMLCh* const publicId
01071 , const XMLCh* const systemId
01072 );
01073
01086 virtual void startInputSource(const InputSource& inputSource);
01087
01089
01090
01091
01092
01093
01094
01095
01098
01111 virtual void docCharacters
01112 (
01113 const XMLCh* const chars
01114 , const unsigned int length
01115 , const bool cdataSection
01116 );
01117
01126 virtual void docComment
01127 (
01128 const XMLCh* const comment
01129 );
01130
01143 virtual void docPI
01144 (
01145 const XMLCh* const target
01146 , const XMLCh* const data
01147 );
01148
01153 virtual void endDocument();
01154
01168 virtual void endElement
01169 (
01170 const XMLElementDecl& elemDecl
01171 , const unsigned int urlId
01172 , const bool isRoot
01173 );
01174
01183 virtual void endEntityReference
01184 (
01185 const XMLEntityDecl& entDecl
01186 );
01187
01206 virtual void ignorableWhitespace
01207 (
01208 const XMLCh* const chars
01209 , const unsigned int length
01210 , const bool cdataSection
01211 );
01212
01219 virtual void resetDocument();
01220
01225 virtual void startDocument();
01226
01254 virtual void startElement
01255 (
01256 const XMLElementDecl& elemDecl
01257 , const unsigned int urlId
01258 , const XMLCh* const elemPrefix
01259 , const RefVectorOf<XMLAttr>& attrList
01260 , const unsigned int attrCount
01261 , const bool isEmpty
01262 , const bool isRoot
01263 );
01264
01274 virtual void startEntityReference
01275 (
01276 const XMLEntityDecl& entDecl
01277 );
01278
01297 virtual void XMLDecl
01298 (
01299 const XMLCh* const versionStr
01300 , const XMLCh* const encodingStr
01301 , const XMLCh* const standaloneStr
01302 , const XMLCh* const actualEncStr
01303 );
01305
01306
01323 void setExpandEntityReferences(const bool expand);
01324
01336 bool getExpandEntityReferences() const;
01337
01351 bool getDoValidation() const;
01352
01369 void setDoValidation(const bool newState);
01370
01374 virtual void attDef
01375 (
01376 const DTDElementDecl& elemDecl
01377 , const DTDAttDef& attDef
01378 , const bool ignoring
01379 );
01380
01381 virtual void doctypeComment
01382 (
01383 const XMLCh* const comment
01384 );
01385
01386 virtual void doctypeDecl
01387 (
01388 const DTDElementDecl& elemDecl
01389 , const XMLCh* const publicId
01390 , const XMLCh* const systemId
01391 , const bool hasIntSubset
01392 );
01393
01394 virtual void doctypePI
01395 (
01396 const XMLCh* const target
01397 , const XMLCh* const data
01398 );
01399
01400 virtual void doctypeWhitespace
01401 (
01402 const XMLCh* const chars
01403 , const unsigned int length
01404 );
01405
01406 virtual void elementDecl
01407 (
01408 const DTDElementDecl& decl
01409 , const bool isIgnored
01410 );
01411
01412 virtual void endAttList
01413 (
01414 const DTDElementDecl& elemDecl
01415 );
01416
01417 virtual void endIntSubset();
01418
01419 virtual void endExtSubset();
01420
01421 virtual void entityDecl
01422 (
01423 const DTDEntityDecl& entityDecl
01424 , const bool isPEDecl
01425 , const bool isIgnored
01426 );
01427
01428 virtual void resetDocType();
01429
01430 virtual void notationDecl
01431 (
01432 const XMLNotationDecl& notDecl
01433 , const bool isIgnored
01434 );
01435
01436 virtual void startAttList
01437 (
01438 const DTDElementDecl& elemDecl
01439 );
01440
01441 virtual void startIntSubset();
01442
01443 virtual void startExtSubset();
01444
01445 virtual void TextDecl
01446 (
01447 const XMLCh* const versionStr
01448 , const XMLCh* const encodingStr
01449 );
01450
01451
01453
01454
01455 protected :
01456
01457
01458
01459
01467 DOM_Node getCurrentNode();
01468
01470
01471
01472
01473
01474
01475
01478
01486 void setCurrentNode(DOM_Node toSet);
01487
01494 void setDocument(DOM_Document toSet);
01496
01497
01498 private :
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 DOM_Node fCurrentParent;
01549 DOM_Node fCurrentNode;
01550 DOM_Document fDocument;
01551 EntityResolver* fEntityResolver;
01552 ErrorHandler* fErrorHandler;
01553 bool fCreateEntityReferenceNodes;
01554 bool fIncludeIgnorableWhitespace;
01555 ValueStackOf<DOM_Node>* fNodeStack;
01556 bool fParseInProgress;
01557 XMLScanner* fScanner;
01558 bool fWithinElement;
01559 DocumentTypeImpl* fDocumentType;
01560 bool fToCreateXMLDeclTypeNode;
01561 };
01562
01563
01564
01565
01566
01567
01568 inline void DOMParser::endInputSource(const InputSource&)
01569 {
01570
01571 }
01572
01573 inline bool DOMParser::expandSystemId(const XMLCh* const, XMLBuffer&)
01574 {
01575
01576 return false;
01577 }
01578
01579 inline void DOMParser::resetEntities()
01580 {
01581
01582 }
01583
01584 inline void DOMParser::startInputSource(const InputSource&)
01585 {
01586
01587 }
01588
01589
01590
01591
01592
01593 inline DOM_Document DOMParser::getDocument()
01594 {
01595 return fDocument;
01596 }
01597
01598 inline ErrorHandler* DOMParser::getErrorHandler()
01599 {
01600 return fErrorHandler;
01601 }
01602
01603 inline const ErrorHandler* DOMParser::getErrorHandler() const
01604 {
01605 return fErrorHandler;
01606 }
01607
01608 inline EntityResolver* DOMParser::getEntityResolver()
01609 {
01610 return fEntityResolver;
01611 }
01612
01613 inline const EntityResolver* DOMParser::getEntityResolver() const
01614 {
01615 return fEntityResolver;
01616 }
01617
01618 inline bool DOMParser::getExpandEntityReferences() const
01619 {
01620 return fCreateEntityReferenceNodes;
01621 }
01622 inline bool DOMParser::getCreateEntityReferenceNodes() const
01623 {
01624 return fCreateEntityReferenceNodes;
01625 }
01626
01627 inline bool DOMParser::getIncludeIgnorableWhitespace() const
01628 {
01629 return fIncludeIgnorableWhitespace;
01630 }
01631
01632 inline const XMLScanner& DOMParser::getScanner() const
01633 {
01634 return *fScanner;
01635 }
01636
01637 inline bool DOMParser::getToCreateXMLDeclTypeNode() const
01638 {
01639 return fToCreateXMLDeclTypeNode;
01640 }
01641
01642
01643
01644
01645
01646 inline void DOMParser::setExpandEntityReferences(const bool expand)
01647 {
01648 fCreateEntityReferenceNodes = expand;
01649 }
01650
01651 inline void DOMParser::setCreateEntityReferenceNodes(const bool create)
01652 {
01653 fCreateEntityReferenceNodes = create;
01654 }
01655
01656 inline void DOMParser::setIncludeIgnorableWhitespace(const bool include)
01657 {
01658 fIncludeIgnorableWhitespace = include;
01659 }
01660
01661 inline void DOMParser::setToCreateXMLDeclTypeNode(const bool create)
01662 {
01663 fToCreateXMLDeclTypeNode = create;
01664 }
01665
01666
01667
01668
01669
01670 inline DOM_Node DOMParser::getCurrentNode()
01671 {
01672 return fCurrentNode;
01673 }
01674
01675
01676
01677
01678
01679 inline void DOMParser::setCurrentNode(DOM_Node toSet)
01680 {
01681 fCurrentNode = toSet;
01682 }
01683
01684 inline void DOMParser::setDocument(DOM_Document toSet)
01685 {
01686 fDocument = toSet;
01687 }
01688
01689 #endif