XMLValidator.hpp
Go to the documentation of this file.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id$
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLVALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_XMLVALIDATOR_HPP
#include <xercesc/framework/XMLAttr.hpp>
#include <xercesc/framework/XMLValidityCodes.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class ReaderMgr;
class XMLBufferMgr;
class XMLElementDecl;
class XMLScanner;
class Grammar;
class XMLPARSER_EXPORT XMLValidator : public XMemory
{
public:
// -----------------------------------------------------------------------
// Constructors are hidden, just the virtual destructor is exposed
// -----------------------------------------------------------------------
virtual ~XMLValidator()
{
}
// -----------------------------------------------------------------------
// The virtual validator interface
// -----------------------------------------------------------------------
virtual bool checkContent
(
XMLElementDecl* const elemDecl
, QName** const children
, XMLSize_t childCount
, XMLSize_t* indexFailingChild
) = 0;
virtual void faultInAttr
(
XMLAttr& toFill
, const XMLAttDef& attDef
) const = 0;
virtual void preContentValidation(bool reuseGrammar,
bool validateDefAttr = false) = 0;
virtual void postParseValidation() = 0;
virtual void reset() = 0;
virtual bool requiresNamespaces() const = 0;
virtual void validateAttrValue
(
const XMLAttDef* attDef
, const XMLCh* const attrValue
, bool preValidation = false
, const XMLElementDecl* elemDecl = 0
) = 0;
virtual void validateElement
(
const XMLElementDecl* elemDef
) = 0;
virtual Grammar* getGrammar() const =0;
virtual void setGrammar(Grammar* aGrammar) =0;
// -----------------------------------------------------------------------
// Virtual DTD handler interface.
// -----------------------------------------------------------------------
virtual bool handlesDTD() const = 0;
// -----------------------------------------------------------------------
// Virtual Schema handler interface.
// -----------------------------------------------------------------------
virtual bool handlesSchema() const = 0;
// -----------------------------------------------------------------------
// Setter methods
//
// setScannerInfo() is called by the scanner to tell the validator
// about the stuff it needs to have access to.
// -----------------------------------------------------------------------
void setScannerInfo
(
XMLScanner* const owningScanner
, ReaderMgr* const readerMgr
, XMLBufferMgr* const bufMgr
);
void setErrorReporter
(
XMLErrorReporter* const errorReporter
);
// -----------------------------------------------------------------------
// Error emitter methods
// -----------------------------------------------------------------------
void emitError(const XMLValid::Codes toEmit);
void emitError
(
const XMLValid::Codes toEmit
, const XMLCh* const text1
, const XMLCh* const text2 = 0
, const XMLCh* const text3 = 0
, const XMLCh* const text4 = 0
);
void emitError
(
const XMLValid::Codes toEmit
, const char* const text1
, const char* const text2 = 0
, const char* const text3 = 0
, const char* const text4 = 0
);
void emitError
(
const XMLValid::Codes toEmit
, const XMLExcepts::Codes originalErrorCode
, const XMLCh* const text1 = 0
, const XMLCh* const text2 = 0
, const XMLCh* const text3 = 0
, const XMLCh* const text4 = 0
);
protected :
// -----------------------------------------------------------------------
// Hidden constructors
// -----------------------------------------------------------------------
XMLValidator
(
XMLErrorReporter* const errReporter = 0
);
// -----------------------------------------------------------------------
// Protected getters
// -----------------------------------------------------------------------
const XMLBufferMgr* getBufMgr() const;
XMLBufferMgr* getBufMgr();
const ReaderMgr* getReaderMgr() const;
ReaderMgr* getReaderMgr();
const XMLScanner* getScanner() const;
XMLScanner* getScanner();
private :
// -----------------------------------------------------------------------
// Unimplemented Constructors and Operators
// -----------------------------------------------------------------------
XMLValidator(const XMLValidator&);
XMLValidator& operator=(const XMLValidator&);
// -----------------------------------------------------------------------
// Private data members
//
// fErrorReporter
// The error reporter we are to use, if any.
//
// -----------------------------------------------------------------------
XMLBufferMgr* fBufMgr;
XMLErrorReporter* fErrorReporter;
ReaderMgr* fReaderMgr;
XMLScanner* fScanner;
};
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
inline void
XMLValidator::setScannerInfo(XMLScanner* const owningScanner
, ReaderMgr* const readerMgr
, XMLBufferMgr* const bufMgr)
{
// We don't own any of these, we just reference them
fScanner = owningScanner;
fReaderMgr = readerMgr;
fBufMgr = bufMgr;
}
inline void
XMLValidator::setErrorReporter(XMLErrorReporter* const errorReporter)
{
fErrorReporter = errorReporter;
}
// ---------------------------------------------------------------------------
// XMLValidator: Protected getter
// ---------------------------------------------------------------------------
inline const XMLBufferMgr* XMLValidator::getBufMgr() const
{
return fBufMgr;
}
inline XMLBufferMgr* XMLValidator::getBufMgr()
{
return fBufMgr;
}
inline const ReaderMgr* XMLValidator::getReaderMgr() const
{
return fReaderMgr;
}
inline ReaderMgr* XMLValidator::getReaderMgr()
{
return fReaderMgr;
}
inline const XMLScanner* XMLValidator::getScanner() const
{
return fScanner;
}
inline XMLScanner* XMLValidator::getScanner()
{
return fScanner;
}
XERCES_CPP_NAMESPACE_END
#endif
XMLAttr.hpp
XMLValidityCodes.hpp
XMLPARSER_EXPORT
#define XMLPARSER_EXPORT
Definition XercesDefs.hpp:163
XERCES_CPP_NAMESPACE_BEGIN
#define XERCES_CPP_NAMESPACE_BEGIN
Definition XercesDefs.hpp:112
XERCES_CPP_NAMESPACE_END
#define XERCES_CPP_NAMESPACE_END
Definition XercesDefs.hpp:113
XMLSize_t
size_t XMLSize_t
Definition Xerces_autoconf_config.hpp:112
XMLCh
char16_t XMLCh
Definition Xerces_autoconf_config.hpp:120
QName
Definition QName.hpp:35
XMLAttDef
Represents the core information of an attribute definition.
Definition XMLAttDef.hpp:53
XMLAttr
This class defines the information about an attribute that will come out of the scanner during parsin...
Definition XMLAttr.hpp:54
XMLElementDecl
This class defines the core information of an element declaration.
Definition XMLElementDecl.hpp:52
XMLErrorReporter
This abstract class defines a callback mechanism for the scanner.
Definition XMLErrorReporter.hpp:43
XMLValid::Codes
Codes
Definition XMLValidityCodes.hpp:16
XMLValidator
This abstract class provides the interface for all validators.
Definition XMLValidator.hpp:53
XMLValidator::emitError
void emitError(const XMLValid::Codes toEmit, const char *const text1, const char *const text2=0, const char *const text3=0, const char *const text4=0)
XMLValidator::getGrammar
virtual Grammar * getGrammar() const =0
Retrieve the Grammar used.
XMLValidator::setGrammar
virtual void setGrammar(Grammar *aGrammar)=0
Set the Grammar.
XMLValidator::setErrorReporter
void setErrorReporter(XMLErrorReporter *const errorReporter)
This method is called to set an error reporter on the validator via which it will report any errors i...
Definition XMLValidator.hpp:385
XMLValidator::preContentValidation
virtual void preContentValidation(bool reuseGrammar, bool validateDefAttr=false)=0
This method is called by the scanner after a Grammar is scanned.
XMLValidator::handlesSchema
virtual bool handlesSchema() const =0
This method allows the scanner to ask the validator if it handles Schema or not.
XMLValidator::setScannerInfo
void setScannerInfo(XMLScanner *const owningScanner, ReaderMgr *const readerMgr, XMLBufferMgr *const bufMgr)
Definition XMLValidator.hpp:374
XMLValidator::checkContent
virtual bool checkContent(XMLElementDecl *const elemDecl, QName **const children, XMLSize_t childCount, XMLSize_t *indexFailingChild)=0
The derived class should look up its declaration of the passed element from its element pool.
XMLValidator::getScanner
const XMLScanner * getScanner() const
Definition XMLValidator.hpp:414
XMLValidator::XMLValidator
XMLValidator(XMLErrorReporter *const errReporter=0)
XMLValidator::validateElement
virtual void validateElement(const XMLElementDecl *elemDef)=0
The derived class should apply any rules to the passed element decl that are above and beyond those d...
XMLValidator::emitError
void emitError(const XMLValid::Codes toEmit, const XMLCh *const text1, const XMLCh *const text2=0, const XMLCh *const text3=0, const XMLCh *const text4=0)
XMLValidator::faultInAttr
virtual void faultInAttr(XMLAttr &toFill, const XMLAttDef &attDef) const =0
The derived class should fault in the passed XMLAttr value.
XMLValidator::getReaderMgr
const ReaderMgr * getReaderMgr() const
Definition XMLValidator.hpp:404
XMLValidator::validateAttrValue
virtual void validateAttrValue(const XMLAttDef *attDef, const XMLCh *const attrValue, bool preValidation=false, const XMLElementDecl *elemDecl=0)=0
The derived class should apply any rules to the passed attribute value that are above and beyond thos...
XMLValidator::requiresNamespaces
virtual bool requiresNamespaces() const =0
The derived class should return a boolean that indicates whether it requires namespace processing or ...
XMLValidator::getBufMgr
const XMLBufferMgr * getBufMgr() const
Definition XMLValidator.hpp:394
XMLValidator::~XMLValidator
virtual ~XMLValidator()
The derived class should clean up its allocated data, then this class will do the same for data alloc...
Definition XMLValidator.hpp:66
XMLValidator::postParseValidation
virtual void postParseValidation()=0
This method is called by the scanner after the parse has completed.
XMLValidator::emitError
void emitError(const XMLValid::Codes toEmit)
This call is a convenience by which validators can emit errors.
XMLValidator::reset
virtual void reset()=0
This method is called by the scanner before a new document is about to start.
XMLValidator::handlesDTD
virtual bool handlesDTD() const =0
This method allows the scanner to ask the validator if it handles DTDs or not.
XMLValidator::emitError
void emitError(const XMLValid::Codes toEmit, const XMLExcepts::Codes originalErrorCode, const XMLCh *const text1=0, const XMLCh *const text2=0, const XMLCh *const text3=0, const XMLCh *const text4=0)
XMemory
This class makes it possible to override the C++ memory management by adding new/delete operators to ...
Definition XMemory.hpp:41