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

Home

Readme
Download
Installation
Build

API Docs
Samples
Schema

FAQs
Programming
Migration

Releases
Bug-Reporting
Feedback

Y2K Compliance
PDF Document

CVS Repository
Mail Archive

API Docs for SAX and DOM
 

Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

XMLValidator.hpp

Go to the documentation of this file.
00001 /*
00002  * The Apache Software License, Version 1.1
00003  *
00004  * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
00005  * reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions
00009  * are met:
00010  *
00011  * 1. Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  *
00014  * 2. Redistributions in binary form must reproduce the above copyright
00015  *    notice, this list of conditions and the following disclaimer in
00016  *    the documentation and/or other materials provided with the
00017  *    distribution.
00018  *
00019  * 3. The end-user documentation included with the redistribution,
00020  *    if any, must include the following acknowledgment:
00021  *       "This product includes software developed by the
00022  *        Apache Software Foundation (http://www.apache.org/)."
00023  *    Alternately, this acknowledgment may appear in the software itself,
00024  *    if and wherever such third-party acknowledgments normally appear.
00025  *
00026  * 4. The names "Xerces" and "Apache Software Foundation" must
00027  *    not be used to endorse or promote products derived from this
00028  *    software without prior written permission. For written
00029  *    permission, please contact apache\@apache.org.
00030  *
00031  * 5. Products derived from this software may not be called "Apache",
00032  *    nor may "Apache" appear in their name, without prior written
00033  *    permission of the Apache Software Foundation.
00034  *
00035  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
00036  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00037  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00038  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
00039  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00040  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00041  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
00042  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00043  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00044  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00045  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00046  * SUCH DAMAGE.
00047  * ====================================================================
00048  *
00049  * This software consists of voluntary contributions made by many
00050  * individuals on behalf of the Apache Software Foundation, and was
00051  * originally based on software copyright (c) 1999, International
00052  * Business Machines, Inc., http://www.ibm.com .  For more information
00053  * on the Apache Software Foundation, please see
00054  * <http://www.apache.org/>.
00055  */
00056 
00057  /*
00058   * $Log: XMLValidator.hpp,v $
00059   * Revision 1.2  2002/02/20 18:17:01  tng
00060   * [Bug 5977] Warnings on generating apiDocs.
00061   *
00062   * Revision 1.1.1.1  2002/02/01 22:21:52  peiyongz
00063   * sane_include
00064   *
00065   * Revision 1.17  2001/11/30 22:18:18  peiyongz
00066   * cleanUp function made member function
00067   * cleanUp object moved to file scope
00068   * double mutex lock removed
00069   *
00070   * Revision 1.16  2001/11/13 13:24:46  tng
00071   * Deprecate function XMLValidator::checkRootElement.
00072   *
00073   * Revision 1.15  2001/10/24 23:46:52  peiyongz
00074   * [Bug 4342] fix the leak.
00075   *
00076   * Revision 1.14  2001/06/05 16:51:17  knoaman
00077   * Add 'const' to getGrammar - submitted by Peter A. Volchek.
00078   *
00079   * Revision 1.13  2001/05/11 13:25:33  tng
00080   * Copyright update.
00081   *
00082   * Revision 1.12  2001/05/03 20:34:22  tng
00083   * Schema: SchemaValidator update
00084   *
00085   * Revision 1.11  2001/04/19 18:16:53  tng
00086   * Schema: SchemaValidator update, and use QName in Content Model
00087   *
00088   * Revision 1.10  2001/03/21 21:56:03  tng
00089   * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
00090   *
00091   * Revision 1.9  2001/02/26 19:21:33  tng
00092   * Schema: add parameter prefix in findElem and findAttr.
00093   *
00094   * Revision 1.8  2000/12/14 18:49:58  tng
00095   * Fix API document generation warning: "Warning: end of member group without matching begin"
00096   *
00097   * Revision 1.7  2000/08/09 22:09:09  jpolast
00098   * added const XMLCh* getURIText()
00099   * allows parsers to use const URIs instead of appending
00100   * to a XMLBuffer.
00101   *
00102   * Revision 1.6  2000/03/02 19:54:25  roddey
00103   * This checkin includes many changes done while waiting for the
00104   * 1.1.0 code to be finished. I can't list them all here, but a list is
00105   * available elsewhere.
00106   *
00107   * Revision 1.5  2000/02/24 20:00:24  abagchi
00108   * Swat for removing Log from API docs
00109   *
00110   * Revision 1.4  2000/02/15 23:59:07  roddey
00111   * More updated documentation of Framework classes.
00112   *
00113   * Revision 1.3  2000/02/15 01:21:31  roddey
00114   * Some initial documentation improvements. More to come...
00115   *
00116   * Revision 1.2  2000/02/06 07:47:49  rahulj
00117   * Year 2K copyright swat.
00118   *
00119   * Revision 1.1.1.1  1999/11/09 01:08:38  twl
00120   * Initial checkin
00121   *
00122   * Revision 1.4  1999/11/08 20:44:41  rahul
00123   * Swat for adding in Product name and CVS comment log variable.
00124   *
00125   */
00126 
00127 
00128 #if !defined(XMLVALIDATOR_HPP)
00129 #define XMLVALIDATOR_HPP
00130 
00131 #include <xercesc/util/XercesDefs.hpp>
00132 #include <xercesc/framework/XMLAttr.hpp>
00133 #include <xercesc/framework/XMLValidityCodes.hpp>
00134 #include <xercesc/framework/XMLRefInfo.hpp>
00135 
00136 class ReaderMgr;
00137 class XMLBuffer;
00138 class XMLBufferMgr;
00139 class XMLElementDecl;
00140 class XMLEntityHandler;
00141 class XMLErrorReporter;
00142 class XMLMsgLoader;
00143 class XMLScanner;
00144 class Grammar;
00145 
00146 
00162 class  XMLValidator
00163 {
00164 public:
00165     // -----------------------------------------------------------------------
00166     //  Constructors are hidden, just the virtual destructor is exposed
00167     // -----------------------------------------------------------------------
00168 
00171 
00176     virtual ~XMLValidator()
00177     {
00178     }
00180 
00181 
00182     // -----------------------------------------------------------------------
00183     //  The virtual validator interface
00184     // -----------------------------------------------------------------------
00185 
00188 
00208     virtual int checkContent
00209     (
00210         XMLElementDecl* const   elemDecl
00211         , QName** const         children
00212         , const unsigned int    childCount
00213     ) = 0;
00214 
00223     virtual void faultInAttr
00224     (
00225                 XMLAttr&    toFill
00226         , const XMLAttDef&  attDef
00227     )   const = 0;
00228 
00232     virtual void preContentValidation(bool reuseGrammar) = 0;
00233 
00241     virtual void postParseValidation() = 0;
00242 
00248     virtual void reset() = 0;
00249 
00256     virtual bool requiresNamespaces() const = 0;
00257 
00268     virtual void validateAttrValue
00269     (
00270         const   XMLAttDef*                  attDef
00271         , const XMLCh* const                attrValue
00272     ) = 0;
00273 
00281     virtual void validateElement
00282     (
00283         const   XMLElementDecl*             elemDef
00284     ) = 0;
00285 
00289     virtual Grammar* getGrammar() const =0;
00290 
00294     virtual void setGrammar(Grammar* aGrammar) =0;
00295 
00296 
00298 
00299     // -----------------------------------------------------------------------
00300     //  Virtual DTD handler interface.
00301     // -----------------------------------------------------------------------
00302 
00305 
00310     virtual bool handlesDTD() const = 0;
00311 
00312     // -----------------------------------------------------------------------
00313     //  Virtual Schema handler interface.
00314     // -----------------------------------------------------------------------
00315 
00317 
00322     virtual bool handlesSchema() const = 0;
00323 
00325 
00326     // -----------------------------------------------------------------------
00327     //  Setter methods
00328     //
00329     //  setScannerInfo() is called by the scanner to tell the validator
00330     //  about the stuff it needs to have access to.
00331     // -----------------------------------------------------------------------
00332 
00335 
00349     void setScannerInfo
00350     (
00351         XMLScanner* const           owningScanner
00352         , ReaderMgr* const          readerMgr
00353         , XMLBufferMgr* const       bufMgr
00354     );
00355 
00365     void setErrorReporter
00366     (
00367         XMLErrorReporter* const errorReporter
00368     );
00369 
00371 
00372 
00373     // -----------------------------------------------------------------------
00374     //  Error emitter methods
00375     // -----------------------------------------------------------------------
00376 
00379 
00398     void emitError(const XMLValid::Codes toEmit);
00399     void emitError
00400     (
00401         const   XMLValid::Codes toEmit
00402         , const XMLCh* const    text1
00403         , const XMLCh* const    text2 = 0
00404         , const XMLCh* const    text3 = 0
00405         , const XMLCh* const    text4 = 0
00406     );
00407     void emitError
00408     (
00409         const   XMLValid::Codes toEmit
00410         , const char* const     text1
00411         , const char* const     text2 = 0
00412         , const char* const     text3 = 0
00413         , const char* const     text4 = 0
00414     );
00415 
00417 
00418     // -----------------------------------------------------------------------
00419     //  Deprecated XMLValidator interface
00420     // -----------------------------------------------------------------------
00428     bool checkRootElement
00429     (
00430         const   unsigned int    elemId
00431     ) { return true;};
00432 
00433     // -----------------------------------------------------------------------
00434     //  Notification that lazy data has been deleted
00435     // -----------------------------------------------------------------------
00436     static void reinitMsgMutex();
00437 
00438     static void reinitMsgLoader();
00439 
00440 protected :
00441     // -----------------------------------------------------------------------
00442     //  Hidden constructors
00443     // -----------------------------------------------------------------------
00444     XMLValidator
00445     (
00446         XMLErrorReporter* const errReporter = 0
00447     );
00448 
00449 
00450     // -----------------------------------------------------------------------
00451     //  Protected getters
00452     // -----------------------------------------------------------------------
00453     const XMLBufferMgr* getBufMgr() const;
00454     XMLBufferMgr* getBufMgr();
00455     const ReaderMgr* getReaderMgr() const;
00456     ReaderMgr* getReaderMgr();
00457     const XMLScanner* getScanner() const;
00458     XMLScanner* getScanner();
00459 
00460 
00461 private :
00462     // -----------------------------------------------------------------------
00463     //  Unimplemented Constructors and Operators
00464     // -----------------------------------------------------------------------
00465     XMLValidator(const XMLValidator&);
00466     void operator=(const XMLValidator&);
00467 
00468 
00469     // -----------------------------------------------------------------------
00470     //  Private data members
00471     //
00472     //  fErrorReporter
00473     //      The error reporter we are to use, if any.
00474     //
00475     // -----------------------------------------------------------------------
00476     XMLBufferMgr*       fBufMgr;
00477     XMLErrorReporter*   fErrorReporter;
00478     ReaderMgr*          fReaderMgr;
00479     XMLScanner*         fScanner;
00480 
00481 };
00482 
00483 
00484 // -----------------------------------------------------------------------
00485 //  Setter methods
00486 // -----------------------------------------------------------------------
00487 inline void
00488 XMLValidator::setScannerInfo(XMLScanner* const      owningScanner
00489                             , ReaderMgr* const      readerMgr
00490                             , XMLBufferMgr* const   bufMgr)
00491 {
00492     // We don't own any of these, we just reference them
00493     fScanner = owningScanner;
00494     fReaderMgr = readerMgr;
00495     fBufMgr = bufMgr;
00496 }
00497 
00498 inline void
00499 XMLValidator::setErrorReporter(XMLErrorReporter* const errorReporter)
00500 {
00501     fErrorReporter = errorReporter;
00502 }
00503 
00504 
00505 // ---------------------------------------------------------------------------
00506 //  XMLValidator: Protected getter
00507 // ---------------------------------------------------------------------------
00508 inline const XMLBufferMgr* XMLValidator::getBufMgr() const
00509 {
00510     return fBufMgr;
00511 }
00512 
00513 inline XMLBufferMgr* XMLValidator::getBufMgr()
00514 {
00515     return fBufMgr;
00516 }
00517 
00518 inline const ReaderMgr* XMLValidator::getReaderMgr() const
00519 {
00520     return fReaderMgr;
00521 }
00522 
00523 inline ReaderMgr* XMLValidator::getReaderMgr()
00524 {
00525     return fReaderMgr;
00526 }
00527 
00528 inline const XMLScanner* XMLValidator::getScanner() const
00529 {
00530     return fScanner;
00531 }
00532 
00533 inline XMLScanner* XMLValidator::getScanner()
00534 {
00535     return fScanner;
00536 }
00537 
00538 
00539 #endif


Copyright © 2000 The Apache Software Foundation. All Rights Reserved.