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 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087
00088
00089
00090 #if !defined(XMLVALIDATOR_HPP)
00091 #define XMLVALIDATOR_HPP
00092
00093 #include <util/XercesDefs.hpp>
00094 #include <util/XMLEnumerator.hpp>
00095 #include <util/RefHashTableOf.hpp>
00096 #include <framework/XMLAttr.hpp>
00097 #include <framework/XMLValidityCodes.hpp>
00098 #include <framework/XMLRefInfo.hpp>
00099
00100 class ReaderMgr;
00101 class XMLBuffer;
00102 class XMLBufferMgr;
00103 class XMLElementDecl;
00104 class XMLEntityDecl;
00105 class XMLEntityHandler;
00106 class XMLErrorReporter;
00107 class XMLNotationDecl;
00108 class XMLMsgLoader;
00109 class XMLScanner;
00110
00111
00127 class XMLValidator
00128 {
00129 public:
00130
00131
00132
00133 enum Constants
00134 {
00135 Success = -1
00136 , BadParent = -2
00137 , BadChild = -3
00138 };
00139
00140
00141 enum LookupOpts
00142 {
00143 AddIfNotFound
00144 , FailIfNotFound
00145 };
00146
00147
00148
00149
00150
00151
00153
00154
00159 virtual ~XMLValidator()
00160 {
00161 }
00162
00163
00164
00165
00166
00167
00168
00170
00171
00180 unsigned int getEmptyNamespaceId() const;
00181
00190 unsigned int getGlobalNamespaceId() const;
00191
00201 unsigned int getUnknownNamespaceId() const;
00202
00210 unsigned int getXMLNamespaceId() const;
00211
00219 unsigned int getXMLNSNamespaceId() const;
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00232
00233
00247 void setScannerInfo
00248 (
00249 XMLScanner* const owningScanner
00250 , ReaderMgr* const readerMgr
00251 , XMLBufferMgr* const bufMgr
00252 );
00253
00263 void setErrorReporter
00264 (
00265 XMLErrorReporter* const errorReporter
00266 );
00267
00268
00269
00270
00271
00272
00273
00274
00276
00277
00283 virtual int addOrFindNSId
00284 (
00285 const XMLCh* const uriText
00286 ) = 0;
00287
00308 virtual int checkContent
00309 (
00310 const unsigned int elemId
00311 , const unsigned int* childIds
00312 , const unsigned int childCount
00313 ) = 0;
00314
00320 virtual bool checkRootElement
00321 (
00322 const unsigned int elemId
00323 ) = 0;
00324
00333 virtual void faultInAttr
00334 (
00335 XMLAttr& toFill
00336 , const XMLAttDef& attDef
00337 ) const = 0;
00338
00352 virtual const XMLElementDecl* findElemDecl
00353 (
00354 const unsigned int uriId
00355 , const XMLCh* const baseName
00356 , const XMLCh* const qName
00357 , const LookupOpts options
00358 , bool& wasAdded
00359 ) const = 0;
00360
00361 00362 00363 00364
00365 virtual XMLElementDecl* findElemDecl
00366 (
00367 const unsigned int uriId
00368 , const XMLCh* const baseName
00369 , const XMLCh* const qName
00370 , const LookupOpts options
00371 , bool& wasAdded
00372 ) = 0;
00373
00387 virtual const XMLEntityDecl* findEntityDecl
00388 (
00389 const XMLCh* const entName
00390 , const bool isPE
00391 ) const = 0;
00392
00405 virtual XMLEntityDecl* findEntityDecl
00406 (
00407 const XMLCh* const entName
00408 , const bool isPE
00409 ) = 0;
00410
00418 virtual unsigned int findElemId
00419 (
00420 const unsigned int uriId
00421 , const XMLCh* const baseName
00422 , const XMLCh* const qName
00423 ) const = 0;
00424
00431 virtual const XMLNotationDecl* findNotationDecl
00432 (
00433 const XMLCh* const notName
00434 ) const = 0;
00435
00440 virtual XMLNotationDecl* findNotationDecl
00441 (
00442 const XMLCh* const notName
00443 ) = 0;
00444
00450 virtual unsigned int findNSId
00451 (
00452 const XMLCh* const nsName
00453 ) const = 0;
00454
00461 virtual const XMLElementDecl* getElemDecl
00462 (
00463 const unsigned int elemId
00464 ) const = 0;
00465
00470 virtual XMLElementDecl* getElemDecl
00471 (
00472 const unsigned int elemId
00473 ) = 0;
00474
00481 virtual bool getURIText
00482 (
00483 const unsigned int uriId
00484 , XMLBuffer& uriBufToFill
00485 ) const = 0;
00486
00487 virtual const XMLCh* getURIText
00488 (
00489 const unsigned int uriId
00490 ) const = 0;
00491
00499 virtual void postParseValidation() = 0;
00500
00506 virtual void reset() = 0;
00507
00514 virtual bool requiresNamespaces() const = 0;
00515
00526 virtual void validateAttrValue
00527 (
00528 const XMLAttDef& attDef
00529 , const XMLCh* const attrValue
00530 ) = 0;
00531
00532
00533
00534
00535
00536
00537
00538
00540
00541
00546 virtual bool handlesDTD() const = 0;
00547
00561 virtual void scanDTD(const bool reuseValidator) = 0;
00562
00563
00564
00565
00566
00567
00568
00569
00571
00572
00590 void emitError(const XMLValid::Codes toEmit);
00591 void emitError
00592 (
00593 const XMLValid::Codes toEmit
00594 , const XMLCh* const text1
00595 , const XMLCh* const text2 = 0
00596 , const XMLCh* const text3 = 0
00597 , const XMLCh* const text4 = 0
00598 );
00599 void emitError
00600 (
00601 const XMLValid::Codes toEmit
00602 , const char* const text1
00603 , const char* const text2 = 0
00604 , const char* const text3 = 0
00605 , const char* const text4 = 0
00606 );
00607
00608
00609
00610
00611 protected :
00612
00613
00614
00615 XMLValidator
00616 (
00617 XMLErrorReporter* const errReporter = 0
00618 );
00619
00620
00621
00622
00623
00624 const XMLBufferMgr* getBufMgr() const;
00625 XMLBufferMgr* getBufMgr();
00626 const ReaderMgr* getReaderMgr() const;
00627 ReaderMgr* getReaderMgr();
00628 const XMLScanner* getScanner() const;
00629 XMLScanner* getScanner();
00630
00631
00632
00633
00634
00635 void setBaseFields
00636 (
00637 const unsigned int emptyNamespaceId
00638 , const unsigned int globalNamespaceId
00639 , const unsigned int unknownNamespaceId
00640 , const unsigned int xmlNamespaceId
00641 , const unsigned int xmlNSNamespaceId
00642 );
00643
00644
00645 private :
00646
00647
00648
00649 XMLValidator(const XMLValidator&);
00650 void operator=(const XMLValidator&);
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681 XMLBufferMgr* fBufMgr;
00682 unsigned int fEmptyNamespaceId;
00683 XMLErrorReporter* fErrorReporter;
00684 unsigned int fGlobalNamespaceId;
00685 ReaderMgr* fReaderMgr;
00686 XMLScanner* fScanner;
00687 unsigned int fUnknownNamespaceId;
00688 unsigned int fXMLNamespaceId;
00689 unsigned int fXMLNSNamespaceId;
00690
00691 };
00692
00693
00694
00695
00696
00697 inline unsigned int XMLValidator::getEmptyNamespaceId() const
00698 {
00699 return fEmptyNamespaceId;
00700 }
00701
00702 inline unsigned int XMLValidator::getGlobalNamespaceId() const
00703 {
00704 return fGlobalNamespaceId;
00705 }
00706
00707 inline unsigned int XMLValidator::getUnknownNamespaceId() const
00708 {
00709 return fUnknownNamespaceId;
00710 }
00711
00712 inline unsigned int XMLValidator::getXMLNamespaceId() const
00713 {
00714 return fXMLNamespaceId;
00715 }
00716
00717 inline unsigned int XMLValidator::getXMLNSNamespaceId() const
00718 {
00719 return fXMLNSNamespaceId;
00720 }
00721
00722
00723
00724
00725
00726 inline void
00727 XMLValidator::setScannerInfo(XMLScanner* const owningScanner
00728 , ReaderMgr* const readerMgr
00729 , XMLBufferMgr* const bufMgr)
00730 {
00731
00732 fScanner = owningScanner;
00733 fReaderMgr = readerMgr;
00734 fBufMgr = bufMgr;
00735 }
00736
00737 inline void
00738 XMLValidator::setErrorReporter(XMLErrorReporter* const errorReporter)
00739 {
00740 fErrorReporter = errorReporter;
00741 }
00742
00743
00744
00745
00746
00747 inline const XMLBufferMgr* XMLValidator::getBufMgr() const
00748 {
00749 return fBufMgr;
00750 }
00751
00752 inline XMLBufferMgr* XMLValidator::getBufMgr()
00753 {
00754 return fBufMgr;
00755 }
00756
00757 inline const ReaderMgr* XMLValidator::getReaderMgr() const
00758 {
00759 return fReaderMgr;
00760 }
00761
00762 inline ReaderMgr* XMLValidator::getReaderMgr()
00763 {
00764 return fReaderMgr;
00765 }
00766
00767 inline const XMLScanner* XMLValidator::getScanner() const
00768 {
00769 return fScanner;
00770 }
00771
00772 inline XMLScanner* XMLValidator::getScanner()
00773 {
00774 return fScanner;
00775 }
00776
00777
00778
00779
00780
00781 inline void
00782 XMLValidator::setBaseFields(const unsigned int emptyNamespaceId
00783 , const unsigned int globalNamespaceId
00784 , const unsigned int unknownNamespaceId
00785 , const unsigned int xmlNamespaceId
00786 , const unsigned int xmlNSNamespaceId)
00787 {
00788 fEmptyNamespaceId = emptyNamespaceId;
00789 fGlobalNamespaceId = globalNamespaceId;
00790 fUnknownNamespaceId = unknownNamespaceId;
00791 fXMLNamespaceId = xmlNamespaceId;
00792 fXMLNSNamespaceId = xmlNSNamespaceId;
00793 }
00794
00795 #endif