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
00091
00092
00093 #if !defined(XMLVALIDATOR_HPP)
00094 #define XMLVALIDATOR_HPP
00095
00096 #include <util/XercesDefs.hpp>
00097 #include <util/XMLEnumerator.hpp>
00098 #include <util/RefHashTableOf.hpp>
00099 #include <framework/XMLAttr.hpp>
00100 #include <framework/XMLValidityCodes.hpp>
00101 #include <framework/XMLRefInfo.hpp>
00102
00103 class ReaderMgr;
00104 class XMLBuffer;
00105 class XMLBufferMgr;
00106 class XMLElementDecl;
00107 class XMLEntityDecl;
00108 class XMLEntityHandler;
00109 class XMLErrorReporter;
00110 class XMLNotationDecl;
00111 class XMLMsgLoader;
00112 class XMLScanner;
00113
00114
00130 class XMLValidator
00131 {
00132 public:
00133
00134
00135
00136 enum Constants
00137 {
00138 Success = -1
00139 , BadParent = -2
00140 , BadChild = -3
00141 };
00142
00143
00144 enum LookupOpts
00145 {
00146 AddIfNotFound
00147 , FailIfNotFound
00148 };
00149
00150
00151
00152
00153
00154
00157
00162 virtual ~XMLValidator()
00163 {
00164 }
00166
00167
00168
00169
00170
00171
00174
00183 unsigned int getEmptyNamespaceId() const;
00184
00193 unsigned int getGlobalNamespaceId() const;
00194
00204 unsigned int getUnknownNamespaceId() const;
00205
00213 unsigned int getXMLNamespaceId() const;
00214
00222 unsigned int getXMLNSNamespaceId() const;
00223
00225
00226
00227
00228
00229
00230
00231
00232
00233
00236
00250 void setScannerInfo
00251 (
00252 XMLScanner* const owningScanner
00253 , ReaderMgr* const readerMgr
00254 , XMLBufferMgr* const bufMgr
00255 );
00256
00266 void setErrorReporter
00267 (
00268 XMLErrorReporter* const errorReporter
00269 );
00270
00272
00273
00274
00275
00276
00277
00280
00286 virtual int addOrFindNSId
00287 (
00288 const XMLCh* const uriText
00289 ) = 0;
00290
00311 virtual int checkContent
00312 (
00313 const unsigned int elemId
00314 , const unsigned int* childIds
00315 , const unsigned int childCount
00316 ) = 0;
00317
00323 virtual bool checkRootElement
00324 (
00325 const unsigned int elemId
00326 ) = 0;
00327
00336 virtual void faultInAttr
00337 (
00338 XMLAttr& toFill
00339 , const XMLAttDef& attDef
00340 ) const = 0;
00341
00355 virtual const XMLElementDecl* findElemDecl
00356 (
00357 const unsigned int uriId
00358 , const XMLCh* const baseName
00359 , const XMLCh* const qName
00360 , const LookupOpts options
00361 , bool& wasAdded
00362 ) const = 0;
00363
00364
00365
00366
00367
00368 virtual XMLElementDecl* findElemDecl
00369 (
00370 const unsigned int uriId
00371 , const XMLCh* const baseName
00372 , const XMLCh* const qName
00373 , const LookupOpts options
00374 , bool& wasAdded
00375 ) = 0;
00376
00390 virtual const XMLEntityDecl* findEntityDecl
00391 (
00392 const XMLCh* const entName
00393 , const bool isPE
00394 ) const = 0;
00395
00408 virtual XMLEntityDecl* findEntityDecl
00409 (
00410 const XMLCh* const entName
00411 , const bool isPE
00412 ) = 0;
00413
00421 virtual unsigned int findElemId
00422 (
00423 const unsigned int uriId
00424 , const XMLCh* const baseName
00425 , const XMLCh* const qName
00426 ) const = 0;
00427
00434 virtual const XMLNotationDecl* findNotationDecl
00435 (
00436 const XMLCh* const notName
00437 ) const = 0;
00438
00443 virtual XMLNotationDecl* findNotationDecl
00444 (
00445 const XMLCh* const notName
00446 ) = 0;
00447
00453 virtual unsigned int findNSId
00454 (
00455 const XMLCh* const nsName
00456 ) const = 0;
00457
00464 virtual const XMLElementDecl* getElemDecl
00465 (
00466 const unsigned int elemId
00467 ) const = 0;
00468
00473 virtual XMLElementDecl* getElemDecl
00474 (
00475 const unsigned int elemId
00476 ) = 0;
00477
00484 virtual bool getURIText
00485 (
00486 const unsigned int uriId
00487 , XMLBuffer& uriBufToFill
00488 ) const = 0;
00489
00490 virtual const XMLCh* getURIText
00491 (
00492 const unsigned int uriId
00493 ) const = 0;
00494
00502 virtual void postParseValidation() = 0;
00503
00509 virtual void reset() = 0;
00510
00517 virtual bool requiresNamespaces() const = 0;
00518
00529 virtual void validateAttrValue
00530 (
00531 const XMLAttDef& attDef
00532 , const XMLCh* const attrValue
00533 ) = 0;
00534
00536
00537
00538
00539
00540
00541
00544
00549 virtual bool handlesDTD() const = 0;
00550
00564 virtual void scanDTD(const bool reuseValidator) = 0;
00565
00567
00568
00569
00570
00571
00572
00575
00593 void emitError(const XMLValid::Codes toEmit);
00594 void emitError
00595 (
00596 const XMLValid::Codes toEmit
00597 , const XMLCh* const text1
00598 , const XMLCh* const text2 = 0
00599 , const XMLCh* const text3 = 0
00600 , const XMLCh* const text4 = 0
00601 );
00602 void emitError
00603 (
00604 const XMLValid::Codes toEmit
00605 , const char* const text1
00606 , const char* const text2 = 0
00607 , const char* const text3 = 0
00608 , const char* const text4 = 0
00609 );
00610
00612
00613
00614 protected :
00615
00616
00617
00618 XMLValidator
00619 (
00620 XMLErrorReporter* const errReporter = 0
00621 );
00622
00623
00624
00625
00626
00627 const XMLBufferMgr* getBufMgr() const;
00628 XMLBufferMgr* getBufMgr();
00629 const ReaderMgr* getReaderMgr() const;
00630 ReaderMgr* getReaderMgr();
00631 const XMLScanner* getScanner() const;
00632 XMLScanner* getScanner();
00633
00634
00635
00636
00637
00638 void setBaseFields
00639 (
00640 const unsigned int emptyNamespaceId
00641 , const unsigned int globalNamespaceId
00642 , const unsigned int unknownNamespaceId
00643 , const unsigned int xmlNamespaceId
00644 , const unsigned int xmlNSNamespaceId
00645 );
00646
00647
00648 private :
00649
00650
00651
00652 XMLValidator(const XMLValidator&);
00653 void operator=(const XMLValidator&);
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
00682
00683
00684 XMLBufferMgr* fBufMgr;
00685 unsigned int fEmptyNamespaceId;
00686 XMLErrorReporter* fErrorReporter;
00687 unsigned int fGlobalNamespaceId;
00688 ReaderMgr* fReaderMgr;
00689 XMLScanner* fScanner;
00690 unsigned int fUnknownNamespaceId;
00691 unsigned int fXMLNamespaceId;
00692 unsigned int fXMLNSNamespaceId;
00693
00694 };
00695
00696
00697
00698
00699
00700 inline unsigned int XMLValidator::getEmptyNamespaceId() const
00701 {
00702 return fEmptyNamespaceId;
00703 }
00704
00705 inline unsigned int XMLValidator::getGlobalNamespaceId() const
00706 {
00707 return fGlobalNamespaceId;
00708 }
00709
00710 inline unsigned int XMLValidator::getUnknownNamespaceId() const
00711 {
00712 return fUnknownNamespaceId;
00713 }
00714
00715 inline unsigned int XMLValidator::getXMLNamespaceId() const
00716 {
00717 return fXMLNamespaceId;
00718 }
00719
00720 inline unsigned int XMLValidator::getXMLNSNamespaceId() const
00721 {
00722 return fXMLNSNamespaceId;
00723 }
00724
00725
00726
00727
00728
00729 inline void
00730 XMLValidator::setScannerInfo(XMLScanner* const owningScanner
00731 , ReaderMgr* const readerMgr
00732 , XMLBufferMgr* const bufMgr)
00733 {
00734
00735 fScanner = owningScanner;
00736 fReaderMgr = readerMgr;
00737 fBufMgr = bufMgr;
00738 }
00739
00740 inline void
00741 XMLValidator::setErrorReporter(XMLErrorReporter* const errorReporter)
00742 {
00743 fErrorReporter = errorReporter;
00744 }
00745
00746
00747
00748
00749
00750 inline const XMLBufferMgr* XMLValidator::getBufMgr() const
00751 {
00752 return fBufMgr;
00753 }
00754
00755 inline XMLBufferMgr* XMLValidator::getBufMgr()
00756 {
00757 return fBufMgr;
00758 }
00759
00760 inline const ReaderMgr* XMLValidator::getReaderMgr() const
00761 {
00762 return fReaderMgr;
00763 }
00764
00765 inline ReaderMgr* XMLValidator::getReaderMgr()
00766 {
00767 return fReaderMgr;
00768 }
00769
00770 inline const XMLScanner* XMLValidator::getScanner() const
00771 {
00772 return fScanner;
00773 }
00774
00775 inline XMLScanner* XMLValidator::getScanner()
00776 {
00777 return fScanner;
00778 }
00779
00780
00781
00782
00783
00784 inline void
00785 XMLValidator::setBaseFields(const unsigned int emptyNamespaceId
00786 , const unsigned int globalNamespaceId
00787 , const unsigned int unknownNamespaceId
00788 , const unsigned int xmlNamespaceId
00789 , const unsigned int xmlNSNamespaceId)
00790 {
00791 fEmptyNamespaceId = emptyNamespaceId;
00792 fGlobalNamespaceId = globalNamespaceId;
00793 fUnknownNamespaceId = unknownNamespaceId;
00794 fXMLNamespaceId = xmlNamespaceId;
00795 fXMLNSNamespaceId = xmlNSNamespaceId;
00796 }
00797
00798 #endif