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 #if !defined(XMLVALIDATOR_HPP)
00086 #define XMLVALIDATOR_HPP
00087
00088 #include <util/XercesDefs.hpp>
00089 #include <util/XMLEnumerator.hpp>
00090 #include <util/RefHashTableOf.hpp>
00091 #include <framework/XMLAttr.hpp>
00092 #include <framework/XMLValidityCodes.hpp>
00093 #include <framework/XMLRefInfo.hpp>
00094
00095 class ReaderMgr;
00096 class XMLBuffer;
00097 class XMLBufferMgr;
00098 class XMLElementDecl;
00099 class XMLEntityDecl;
00100 class XMLEntityHandler;
00101 class XMLErrorReporter;
00102 class XMLNotationDecl;
00103 class XMLMsgLoader;
00104 class XMLScanner;
00105
00106
00122 class XMLValidator
00123 {
00124 public:
00125
00126
00127
00128 enum Constants
00129 {
00130 Success = -1
00131 , BadParent = -2
00132 , BadChild = -3
00133 };
00134
00135
00136 enum LookupOpts
00137 {
00138 AddIfNotFound
00139 , FailIfNotFound
00140 };
00141
00142
00143
00144
00145
00146
00148
00149
00154 virtual ~XMLValidator()
00155 {
00156 }
00157
00158
00159
00160
00161
00162
00163
00165
00166
00175 unsigned int getEmptyNamespaceId() const;
00176
00185 unsigned int getGlobalNamespaceId() const;
00186
00196 unsigned int getUnknownNamespaceId() const;
00197
00205 unsigned int getXMLNamespaceId() const;
00206
00214 unsigned int getXMLNSNamespaceId() const;
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00227
00228
00242 void setScannerInfo
00243 (
00244 XMLScanner* const owningScanner
00245 , ReaderMgr* const readerMgr
00246 , XMLBufferMgr* const bufMgr
00247 );
00248
00258 void setErrorReporter
00259 (
00260 XMLErrorReporter* const errorReporter
00261 );
00262
00263
00264
00265
00266
00267
00268
00269
00271
00272
00278 virtual int addOrFindNSId
00279 (
00280 const XMLCh* const uriText
00281 ) = 0;
00282
00303 virtual int checkContent
00304 (
00305 const unsigned int elemId
00306 , const unsigned int* childIds
00307 , const unsigned int childCount
00308 ) = 0;
00309
00315 virtual bool checkRootElement
00316 (
00317 const unsigned int elemId
00318 ) = 0;
00319
00328 virtual void faultInAttr
00329 (
00330 XMLAttr& toFill
00331 , const XMLAttDef& attDef
00332 ) const = 0;
00333
00347 virtual const XMLElementDecl* findElemDecl
00348 (
00349 const unsigned int uriId
00350 , const XMLCh* const baseName
00351 , const XMLCh* const qName
00352 , const LookupOpts options
00353 , bool& wasAdded
00354 ) const = 0;
00355
00356 00357 00358 00359
00360 virtual XMLElementDecl* findElemDecl
00361 (
00362 const unsigned int uriId
00363 , const XMLCh* const baseName
00364 , const XMLCh* const qName
00365 , const LookupOpts options
00366 , bool& wasAdded
00367 ) = 0;
00368
00382 virtual const XMLEntityDecl* findEntityDecl
00383 (
00384 const XMLCh* const entName
00385 , const bool isPE
00386 ) const = 0;
00387
00400 virtual XMLEntityDecl* findEntityDecl
00401 (
00402 const XMLCh* const entName
00403 , const bool isPE
00404 ) = 0;
00405
00413 virtual unsigned int findElemId
00414 (
00415 const unsigned int uriId
00416 , const XMLCh* const baseName
00417 , const XMLCh* const qName
00418 ) const = 0;
00419
00426 virtual const XMLNotationDecl* findNotationDecl
00427 (
00428 const XMLCh* const notName
00429 ) const = 0;
00430
00435 virtual XMLNotationDecl* findNotationDecl
00436 (
00437 const XMLCh* const notName
00438 ) = 0;
00439
00445 virtual unsigned int findNSId
00446 (
00447 const XMLCh* const nsName
00448 ) const = 0;
00449
00456 virtual const XMLElementDecl* getElemDecl
00457 (
00458 const unsigned int elemId
00459 ) const = 0;
00460
00465 virtual XMLElementDecl* getElemDecl
00466 (
00467 const unsigned int elemId
00468 ) = 0;
00469
00476 virtual bool getURIText
00477 (
00478 const unsigned int uriId
00479 , XMLBuffer& uriBufToFill
00480 ) const = 0;
00481
00489 virtual void postParseValidation() = 0;
00490
00496 virtual void reset() = 0;
00497
00504 virtual bool requiresNamespaces() const = 0;
00505
00516 virtual void validateAttrValue
00517 (
00518 const XMLAttDef& attDef
00519 , const XMLCh* const attrValue
00520 ) = 0;
00521
00522
00523
00524
00525
00526
00527
00528
00530
00531
00536 virtual bool handlesDTD() const = 0;
00537
00551 virtual void scanDTD(const bool reuseValidator) = 0;
00552
00553
00554
00555
00556
00557
00558
00559
00561
00562
00580 void emitError(const XMLValid::Codes toEmit);
00581 void emitError
00582 (
00583 const XMLValid::Codes toEmit
00584 , const XMLCh* const text1
00585 , const XMLCh* const text2 = 0
00586 , const XMLCh* const text3 = 0
00587 , const XMLCh* const text4 = 0
00588 );
00589 void emitError
00590 (
00591 const XMLValid::Codes toEmit
00592 , const char* const text1
00593 , const char* const text2 = 0
00594 , const char* const text3 = 0
00595 , const char* const text4 = 0
00596 );
00597
00598
00599
00600
00601 protected :
00602
00603
00604
00605 XMLValidator
00606 (
00607 XMLErrorReporter* const errReporter = 0
00608 );
00609
00610
00611
00612
00613
00614 const XMLBufferMgr* getBufMgr() const;
00615 XMLBufferMgr* getBufMgr();
00616 const ReaderMgr* getReaderMgr() const;
00617 ReaderMgr* getReaderMgr();
00618 const XMLScanner* getScanner() const;
00619 XMLScanner* getScanner();
00620
00621
00622
00623
00624
00625 void setBaseFields
00626 (
00627 const unsigned int emptyNamespaceId
00628 , const unsigned int globalNamespaceId
00629 , const unsigned int unknownNamespaceId
00630 , const unsigned int xmlNamespaceId
00631 , const unsigned int xmlNSNamespaceId
00632 );
00633
00634
00635 private :
00636
00637
00638
00639 XMLValidator(const XMLValidator&);
00640 void operator=(const XMLValidator&);
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671 XMLBufferMgr* fBufMgr;
00672 unsigned int fEmptyNamespaceId;
00673 XMLErrorReporter* fErrorReporter;
00674 unsigned int fGlobalNamespaceId;
00675 ReaderMgr* fReaderMgr;
00676 XMLScanner* fScanner;
00677 unsigned int fUnknownNamespaceId;
00678 unsigned int fXMLNamespaceId;
00679 unsigned int fXMLNSNamespaceId;
00680
00681 };
00682
00683
00684
00685
00686
00687 inline unsigned int XMLValidator::getEmptyNamespaceId() const
00688 {
00689 return fEmptyNamespaceId;
00690 }
00691
00692 inline unsigned int XMLValidator::getGlobalNamespaceId() const
00693 {
00694 return fGlobalNamespaceId;
00695 }
00696
00697 inline unsigned int XMLValidator::getUnknownNamespaceId() const
00698 {
00699 return fUnknownNamespaceId;
00700 }
00701
00702 inline unsigned int XMLValidator::getXMLNamespaceId() const
00703 {
00704 return fXMLNamespaceId;
00705 }
00706
00707 inline unsigned int XMLValidator::getXMLNSNamespaceId() const
00708 {
00709 return fXMLNSNamespaceId;
00710 }
00711
00712
00713
00714
00715
00716 inline void
00717 XMLValidator::setScannerInfo(XMLScanner* const owningScanner
00718 , ReaderMgr* const readerMgr
00719 , XMLBufferMgr* const bufMgr)
00720 {
00721
00722 fScanner = owningScanner;
00723 fReaderMgr = readerMgr;
00724 fBufMgr = bufMgr;
00725 }
00726
00727 inline void
00728 XMLValidator::setErrorReporter(XMLErrorReporter* const errorReporter)
00729 {
00730 fErrorReporter = errorReporter;
00731 }
00732
00733
00734
00735
00736
00737 inline const XMLBufferMgr* XMLValidator::getBufMgr() const
00738 {
00739 return fBufMgr;
00740 }
00741
00742 inline XMLBufferMgr* XMLValidator::getBufMgr()
00743 {
00744 return fBufMgr;
00745 }
00746
00747 inline const ReaderMgr* XMLValidator::getReaderMgr() const
00748 {
00749 return fReaderMgr;
00750 }
00751
00752 inline ReaderMgr* XMLValidator::getReaderMgr()
00753 {
00754 return fReaderMgr;
00755 }
00756
00757 inline const XMLScanner* XMLValidator::getScanner() const
00758 {
00759 return fScanner;
00760 }
00761
00762 inline XMLScanner* XMLValidator::getScanner()
00763 {
00764 return fScanner;
00765 }
00766
00767
00768
00769
00770
00771 inline void
00772 XMLValidator::setBaseFields(const unsigned int emptyNamespaceId
00773 , const unsigned int globalNamespaceId
00774 , const unsigned int unknownNamespaceId
00775 , const unsigned int xmlNamespaceId
00776 , const unsigned int xmlNSNamespaceId)
00777 {
00778 fEmptyNamespaceId = emptyNamespaceId;
00779 fGlobalNamespaceId = globalNamespaceId;
00780 fUnknownNamespaceId = unknownNamespaceId;
00781 fXMLNamespaceId = xmlNamespaceId;
00782 fXMLNSNamespaceId = xmlNSNamespaceId;
00783 }
00784
00785 #endif