http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Home

Readme
Charter
Release Info

Installation
Download
Build Instructions

FAQs
Samples
API Docs

DOM C++ Binding
Programming
Migration Guide

Feedback
Bug-Reporting
PDF Document

Source Repository
User Mail Archive
Devel Mail Archive

API Docs for SAX and DOM
 

XMLValidator.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 1999-2004 The Apache Software Foundation.
00003  * 
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  * 
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017  /*
00018  * $Id: XMLValidator.hpp 191054 2005-06-17 02:56:35Z jberry $
00019  */
00020 
00021 
00022 #if !defined(XMLVALIDATOR_HPP)
00023 #define XMLVALIDATOR_HPP
00024 
00025 #include <xercesc/framework/XMLAttr.hpp>
00026 #include <xercesc/framework/XMLValidityCodes.hpp>
00027 
00028 XERCES_CPP_NAMESPACE_BEGIN
00029 
00030 class ReaderMgr;
00031 class XMLBufferMgr;
00032 class XMLElementDecl;
00033 class XMLScanner;
00034 class Grammar;
00035 
00036 
00052 class  XMLValidator : public XMemory
00053 {
00054 public:
00055     // -----------------------------------------------------------------------
00056     //  Constructors are hidden, just the virtual destructor is exposed
00057     // -----------------------------------------------------------------------
00058 
00061 
00066     virtual ~XMLValidator()
00067     {
00068     }
00070 
00071 
00072     // -----------------------------------------------------------------------
00073     //  The virtual validator interface
00074     // -----------------------------------------------------------------------
00075 
00078 
00098     virtual int checkContent
00099     (
00100         XMLElementDecl* const   elemDecl
00101         , QName** const         children
00102         , const unsigned int    childCount
00103     ) = 0;
00104 
00113     virtual void faultInAttr
00114     (
00115                 XMLAttr&    toFill
00116         , const XMLAttDef&  attDef
00117     )   const = 0;
00118 
00122     virtual void preContentValidation(bool reuseGrammar,
00123                                       bool validateDefAttr = false) = 0;
00124 
00132     virtual void postParseValidation() = 0;
00133 
00139     virtual void reset() = 0;
00140 
00147     virtual bool requiresNamespaces() const = 0;
00148 
00159     virtual void validateAttrValue
00160     (
00161         const   XMLAttDef*                  attDef
00162         , const XMLCh* const                attrValue
00163         , bool                              preValidation = false
00164         , const XMLElementDecl*             elemDecl = 0
00165     ) = 0;
00166 
00174     virtual void validateElement
00175     (
00176         const   XMLElementDecl*             elemDef
00177     ) = 0;
00178 
00182     virtual Grammar* getGrammar() const =0;
00183 
00187     virtual void setGrammar(Grammar* aGrammar) =0;
00188 
00189 
00191 
00192     // -----------------------------------------------------------------------
00193     //  Virtual DTD handler interface.
00194     // -----------------------------------------------------------------------
00195 
00198 
00203     virtual bool handlesDTD() const = 0;
00204 
00205     // -----------------------------------------------------------------------
00206     //  Virtual Schema handler interface.
00207     // -----------------------------------------------------------------------
00208 
00215     virtual bool handlesSchema() const = 0;
00216 
00218 
00219     // -----------------------------------------------------------------------
00220     //  Setter methods
00221     //
00222     //  setScannerInfo() is called by the scanner to tell the validator
00223     //  about the stuff it needs to have access to.
00224     // -----------------------------------------------------------------------
00225 
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 
00264 
00265 
00266     // -----------------------------------------------------------------------
00267     //  Error emitter methods
00268     // -----------------------------------------------------------------------
00269 
00272 
00291     void emitError(const XMLValid::Codes toEmit);
00292     void emitError
00293     (
00294         const   XMLValid::Codes toEmit
00295         , const XMLCh* const    text1
00296         , const XMLCh* const    text2 = 0
00297         , const XMLCh* const    text3 = 0
00298         , const XMLCh* const    text4 = 0
00299     );
00300     void emitError
00301     (
00302         const   XMLValid::Codes toEmit
00303         , const char* const     text1
00304         , const char* const     text2 = 0
00305         , const char* const     text3 = 0
00306         , const char* const     text4 = 0
00307     );
00308 
00310 
00311     // -----------------------------------------------------------------------
00312     //  Deprecated XMLValidator interface
00313     // -----------------------------------------------------------------------
00321     bool checkRootElement
00322     (
00323         const   unsigned int
00324     ) { return true;};
00325 
00326     // -----------------------------------------------------------------------
00327     //  Notification that lazy data has been deleted
00328     // -----------------------------------------------------------------------
00329     static void reinitMsgMutex();
00330 
00331     static void reinitMsgLoader();
00332 
00333 protected :
00334     // -----------------------------------------------------------------------
00335     //  Hidden constructors
00336     // -----------------------------------------------------------------------
00337     XMLValidator
00338     (
00339         XMLErrorReporter* const errReporter = 0
00340     );
00341 
00342 
00343     // -----------------------------------------------------------------------
00344     //  Protected getters
00345     // -----------------------------------------------------------------------
00346     const XMLBufferMgr* getBufMgr() const;
00347     XMLBufferMgr* getBufMgr();
00348     const ReaderMgr* getReaderMgr() const;
00349     ReaderMgr* getReaderMgr();
00350     const XMLScanner* getScanner() const;
00351     XMLScanner* getScanner();
00352 
00353 
00354 private :
00355     // -----------------------------------------------------------------------
00356     //  Unimplemented Constructors and Operators
00357     // -----------------------------------------------------------------------
00358     XMLValidator(const XMLValidator&);
00359     XMLValidator& operator=(const XMLValidator&);
00360 
00361 
00362     // -----------------------------------------------------------------------
00363     //  Private data members
00364     //
00365     //  fErrorReporter
00366     //      The error reporter we are to use, if any.
00367     //
00368     // -----------------------------------------------------------------------
00369     XMLBufferMgr*       fBufMgr;
00370     XMLErrorReporter*   fErrorReporter;
00371     ReaderMgr*          fReaderMgr;
00372     XMLScanner*         fScanner;
00373 };
00374 
00375 
00376 // -----------------------------------------------------------------------
00377 //  Setter methods
00378 // -----------------------------------------------------------------------
00379 inline void
00380 XMLValidator::setScannerInfo(XMLScanner* const      owningScanner
00381                             , ReaderMgr* const      readerMgr
00382                             , XMLBufferMgr* const   bufMgr)
00383 {
00384     // We don't own any of these, we just reference them
00385     fScanner = owningScanner;
00386     fReaderMgr = readerMgr;
00387     fBufMgr = bufMgr;
00388 }
00389 
00390 inline void
00391 XMLValidator::setErrorReporter(XMLErrorReporter* const errorReporter)
00392 {
00393     fErrorReporter = errorReporter;
00394 }
00395 
00396 
00397 // ---------------------------------------------------------------------------
00398 //  XMLValidator: Protected getter
00399 // ---------------------------------------------------------------------------
00400 inline const XMLBufferMgr* XMLValidator::getBufMgr() const
00401 {
00402     return fBufMgr;
00403 }
00404 
00405 inline XMLBufferMgr* XMLValidator::getBufMgr()
00406 {
00407     return fBufMgr;
00408 }
00409 
00410 inline const ReaderMgr* XMLValidator::getReaderMgr() const
00411 {
00412     return fReaderMgr;
00413 }
00414 
00415 inline ReaderMgr* XMLValidator::getReaderMgr()
00416 {
00417     return fReaderMgr;
00418 }
00419 
00420 inline const XMLScanner* XMLValidator::getScanner() const
00421 {
00422     return fScanner;
00423 }
00424 
00425 inline XMLScanner* XMLValidator::getScanner()
00426 {
00427     return fScanner;
00428 }
00429 
00430 XERCES_CPP_NAMESPACE_END
00431 
00432 #endif


Copyright © 1994-2004 The Apache Software Foundation. All Rights Reserved.