www.alphaworks.ibm.comwww.ibm.com/developerwww.ibm.com

Home

Readme
Download

Build







Migration

Releases

Feedback

Y2K Compliance


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.14  2001/06/05 16:51:17  knoaman
00060   * Add 'const' to getGrammar - submitted by Peter A. Volchek.
00061   *
00062   * Revision 1.13  2001/05/11 13:25:33  tng
00063   * Copyright update.
00064   *
00065   * Revision 1.12  2001/05/03 20:34:22  tng
00066   * Schema: SchemaValidator update
00067   *
00068   * Revision 1.11  2001/04/19 18:16:53  tng
00069   * Schema: SchemaValidator update, and use QName in Content Model
00070   *
00071   * Revision 1.10  2001/03/21 21:56:03  tng
00072   * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
00073   *
00074   * Revision 1.9  2001/02/26 19:21:33  tng
00075   * Schema: add parameter prefix in findElem and findAttr.
00076   *
00077   * Revision 1.8  2000/12/14 18:49:58  tng
00078   * Fix API document generation warning: "Warning: end of member group without matching begin"
00079   *
00080   * Revision 1.7  2000/08/09 22:09:09  jpolast
00081   * added const XMLCh* getURIText()
00082   * allows parsers to use const URIs instead of appending
00083   * to a XMLBuffer.
00084   *
00085   * Revision 1.6  2000/03/02 19:54:25  roddey
00086   * This checkin includes many changes done while waiting for the
00087   * 1.1.0 code to be finished. I can't list them all here, but a list is
00088   * available elsewhere.
00089   *
00090   * Revision 1.5  2000/02/24 20:00:24  abagchi
00091   * Swat for removing Log from API docs
00092   *
00093   * Revision 1.4  2000/02/15 23:59:07  roddey
00094   * More updated documentation of Framework classes.
00095   *
00096   * Revision 1.3  2000/02/15 01:21:31  roddey
00097   * Some initial documentation improvements. More to come...
00098   *
00099   * Revision 1.2  2000/02/06 07:47:49  rahulj
00100   * Year 2K copyright swat.
00101   *
00102   * Revision 1.1.1.1  1999/11/09 01:08:38  twl
00103   * Initial checkin
00104   *
00105   * Revision 1.4  1999/11/08 20:44:41  rahul
00106   * Swat for adding in Product name and CVS comment log variable.
00107   *
00108   */
00109 
00110 
00111 #if !defined(XMLVALIDATOR_HPP)
00112 #define XMLVALIDATOR_HPP
00113 
00114 #include <util/XercesDefs.hpp>
00115 #include <framework/XMLAttr.hpp>
00116 #include <framework/XMLValidityCodes.hpp>
00117 #include <framework/XMLRefInfo.hpp>
00118 
00119 class ReaderMgr;
00120 class XMLBuffer;
00121 class XMLBufferMgr;
00122 class XMLElementDecl;
00123 class XMLEntityHandler;
00124 class XMLErrorReporter;
00125 class XMLMsgLoader;
00126 class XMLScanner;
00127 class Grammar;
00128 
00129 
00145 class  XMLValidator
00146 {
00147 public:
00148     // -----------------------------------------------------------------------
00149     //  Constructors are hidden, just the virtual destructor is exposed
00150     // -----------------------------------------------------------------------
00151 
00154 
00159     virtual ~XMLValidator()
00160     {
00161     }
00163 
00164 
00165     // -----------------------------------------------------------------------
00166     //  The virtual validator interface
00167     // -----------------------------------------------------------------------
00168 
00171 
00192     virtual int checkContent
00193     (
00194         XMLElementDecl* const   elemDecl
00195         , QName** const         children
00196         , const unsigned int    childCount
00197     ) = 0;
00198 
00204     virtual bool checkRootElement
00205     (
00206         const   unsigned int    elemId
00207     ) = 0;
00208 
00217     virtual void faultInAttr
00218     (
00219                 XMLAttr&    toFill
00220         , const XMLAttDef&  attDef
00221     )   const = 0;
00222 
00226     virtual void preContentValidation(bool reuseGrammar) = 0;
00227 
00235     virtual void postParseValidation() = 0;
00236 
00242     virtual void reset() = 0;
00243 
00250     virtual bool requiresNamespaces() const = 0;
00251 
00262     virtual void validateAttrValue
00263     (
00264         const   XMLAttDef*                  attDef
00265         , const XMLCh* const                attrValue
00266     ) = 0;
00267 
00275     virtual void validateElement
00276     (
00277         const   XMLElementDecl*             elemDef
00278     ) = 0;
00279 
00283     virtual Grammar* getGrammar() const =0;
00284 
00288     virtual void setGrammar(Grammar* aGrammar) =0;
00289 
00290 
00292 
00293     // -----------------------------------------------------------------------
00294     //  Virtual DTD handler interface.
00295     // -----------------------------------------------------------------------
00296 
00299 
00304     virtual bool handlesDTD() const = 0;
00305 
00306     // -----------------------------------------------------------------------
00307     //  Virtual Schema handler interface.
00308     // -----------------------------------------------------------------------
00309 
00311 
00316     virtual bool handlesSchema() const = 0;
00317 
00319 
00320     // -----------------------------------------------------------------------
00321     //  Setter methods
00322     //
00323     //  setScannerInfo() is called by the scanner to tell the validator
00324     //  about the stuff it needs to have access to.
00325     // -----------------------------------------------------------------------
00326 
00329 
00343     void setScannerInfo
00344     (
00345         XMLScanner* const           owningScanner
00346         , ReaderMgr* const          readerMgr
00347         , XMLBufferMgr* const       bufMgr
00348     );
00349 
00359     void setErrorReporter
00360     (
00361         XMLErrorReporter* const errorReporter
00362     );
00363 
00365 
00366 
00367     // -----------------------------------------------------------------------
00368     //  Error emitter methods
00369     // -----------------------------------------------------------------------
00370 
00373 
00391     void emitError(const XMLValid::Codes toEmit);
00392     void emitError
00393     (
00394         const   XMLValid::Codes toEmit
00395         , const XMLCh* const    text1
00396         , const XMLCh* const    text2 = 0
00397         , const XMLCh* const    text3 = 0
00398         , const XMLCh* const    text4 = 0
00399     );
00400     void emitError
00401     (
00402         const   XMLValid::Codes toEmit
00403         , const char* const     text1
00404         , const char* const     text2 = 0
00405         , const char* const     text3 = 0
00406         , const char* const     text4 = 0
00407     );
00408 
00410 
00411 
00412 protected :
00413     // -----------------------------------------------------------------------
00414     //  Hidden constructors
00415     // -----------------------------------------------------------------------
00416     XMLValidator
00417     (
00418         XMLErrorReporter* const errReporter = 0
00419     );
00420 
00421 
00422     // -----------------------------------------------------------------------
00423     //  Protected getters
00424     // -----------------------------------------------------------------------
00425     const XMLBufferMgr* getBufMgr() const;
00426     XMLBufferMgr* getBufMgr();
00427     const ReaderMgr* getReaderMgr() const;
00428     ReaderMgr* getReaderMgr();
00429     const XMLScanner* getScanner() const;
00430     XMLScanner* getScanner();
00431 
00432 
00433 private :
00434     // -----------------------------------------------------------------------
00435     //  Unimplemented Constructors and Operators
00436     // -----------------------------------------------------------------------
00437     XMLValidator(const XMLValidator&);
00438     void operator=(const XMLValidator&);
00439 
00440 
00441     // -----------------------------------------------------------------------
00442     //  Private data members
00443     //
00444     //  fErrorReporter
00445     //      The error reporter we are to use, if any.
00446     //
00447     // -----------------------------------------------------------------------
00448     XMLBufferMgr*       fBufMgr;
00449     XMLErrorReporter*   fErrorReporter;
00450     ReaderMgr*          fReaderMgr;
00451     XMLScanner*         fScanner;
00452 
00453 };
00454 
00455 
00456 // -----------------------------------------------------------------------
00457 //  Setter methods
00458 // -----------------------------------------------------------------------
00459 inline void
00460 XMLValidator::setScannerInfo(XMLScanner* const      owningScanner
00461                             , ReaderMgr* const      readerMgr
00462                             , XMLBufferMgr* const   bufMgr)
00463 {
00464     // We don't own any of these, we just reference them
00465     fScanner = owningScanner;
00466     fReaderMgr = readerMgr;
00467     fBufMgr = bufMgr;
00468 }
00469 
00470 inline void
00471 XMLValidator::setErrorReporter(XMLErrorReporter* const errorReporter)
00472 {
00473     fErrorReporter = errorReporter;
00474 }
00475 
00476 
00477 // ---------------------------------------------------------------------------
00478 //  XMLValidator: Protected getter
00479 // ---------------------------------------------------------------------------
00480 inline const XMLBufferMgr* XMLValidator::getBufMgr() const
00481 {
00482     return fBufMgr;
00483 }
00484 
00485 inline XMLBufferMgr* XMLValidator::getBufMgr()
00486 {
00487     return fBufMgr;
00488 }
00489 
00490 inline const ReaderMgr* XMLValidator::getReaderMgr() const
00491 {
00492     return fReaderMgr;
00493 }
00494 
00495 inline ReaderMgr* XMLValidator::getReaderMgr()
00496 {
00497     return fReaderMgr;
00498 }
00499 
00500 inline const XMLScanner* XMLValidator::getScanner() const
00501 {
00502     return fScanner;
00503 }
00504 
00505 inline XMLScanner* XMLValidator::getScanner()
00506 {
00507     return fScanner;
00508 }
00509 
00510 
00511 #endif


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