class XMLValidationHandler

This abstract class defines the validation handler API's

Inheritance:


Public

Class specific constants.
enum EConstants
Success is the value returned from the validateContent methods when successful
Constructors and Destructor.
XMLValidationHandler ()
Default Constructor
virtual ~XMLValidationHandler ()
Destructor
The pure virtual functions defining the validation interface.
virtual bool checkRootElement (const ElementDecl& rootDecl)
This method checks the validity of the content of the specified root element
virtual bool checkAttributes ( const ElementDecl& element, const XMLAttr** attributes, const unsigned int attrCount )
This method allows the validator to check the attributes for the specified element
virtual int checkContent ( ElementDecl& element, const unsigned int* childIds, const unsigned int childCount )
This method checks whether its legal for the given element to have the specified children
virtual void postParseValidation ( RefHashTableOf& idRefList )
This method allows the validator to do whatever is required once the scanner gets through to the end of the document
virtual void resetValidation ()
This method gives the validator a chance to reset its state, so that it is ready to validate another document
virtual void validatePoolInfo ( NameBasedPool& elemDeclPool, NameBasedPool& elemNotationPool )
This method is used to validate the information extracted from the DTD
Validation support provided at this level.
int checkContentByName ( const XMLCh* const elemName, const XMLCh** childNames, const unsigned int childCount )
This method checks whether its legal for the given element to have the specified children
void setScanner (XMLScanner* const srcScanner)
This setter method allows the validation handler object to store the scanner object

Protected

getters.
const XMLScanner& getScanner () const
Returns the scanner object
getters.
const XMLScanner& getScanner () const
Returns the scanner object
getters.
const XMLScanner& getScanner () const
Returns the scanner object
getters.
const XMLScanner& getScanner () const
Returns the scanner object

Documentation

This abstract class defines the validation handler API's. which can be installed in a validating parser configuration. The parser uses this handler to verify whether the XML data that it is parsing conforms to the rules specified in the DTD.

The class XMLScanner defines the interface which allows a validation handler to be installed. The only difference between a validating and non-validating parser is the presence of one these validation handlers.

Class specific constants.

enum EConstants
Success is the value returned from the validateContent methods when successful. If calling the 'by name' version, then it has to look up the names. If it cannot look up the parent, it returns BadParent. If it cannot look up a child, it returns BadChild. Otherwise, they return the zero based index of the first child that failed to match the content model.

Constructors and Destructor.

XMLValidationHandler()
Default Constructor

virtual ~XMLValidationHandler()
Destructor

Validation support provided at this level.

int checkContentByName( const XMLCh* const elemName, const XMLCh** childNames, const unsigned int childCount )
This method checks whether its legal for the given element to have the specified children. It is a convenience method which takes string arguments. These strings represent element names. The implementation looks up the names of these elements in the element decl. pool and creates a list of id's. It then calls the pure virtual 'checkContent', which takes integer parameters, to do the actual validation.

Returns:
The enum EConstants indicating a bad parameter values or success. It can also return a value of 0 or greater, which indicates the index of the first bad child in the list of given children names.
Parameters:
elemName - The name of the element whose contents have to be verified.
childNames - The list of names of child element names.
childCount - The count of names specified in the childNames parameter.
See Also:
checkContent(ElementDecl, unsigned int*, unsigned int)
EConstants

void setScanner(XMLScanner* const srcScanner)
This setter method allows the validation handler object to store the scanner object
Parameters:
srcScanner -

The pure virtual functions defining the validation interface.

virtual bool checkRootElement(const ElementDecl& rootDecl)
This method checks the validity of the content of the specified root element. This should be the root element of the document being scanned. It provides a default implementations, but for safety reasons its marked as pure virtual, which forces the derived classes to explicitly call this implementation.

If the root element found in the DTD does not match the element specified, it returns false.

Returns:
true, if the root element contents were found to be valid, else false indicating invalid content or no DOCTYPE declaration.
Parameters:
rootDecl - The element decl entry of the root element.

virtual bool checkAttributes( const ElementDecl& element, const XMLAttr** attributes, const unsigned int attrCount )
This method allows the validator to check the attributes for the specified element.

Returns:
true, if specified attributes are legal for the element, false otherwise.
Parameters:
element - The element whose attributes have to be validated.
attributes - The list of attributes to be validated.
attrCount - The count of attributes in the attributes list.

virtual int checkContent( ElementDecl& element, const unsigned int* childIds, const unsigned int childCount )
This method checks whether its legal for the given element to have the specified children. The children are specified by their indexes in the element decl pool.

Returns:
The enum EConstants indicating a bad parameter values or success. It can also return a value of 0 or greater, which indicates the index of the first bad child in the list of given children names.
Parameters:
element - The element whose content model needs to be verified.
childIds - The list of indexes representing child elements.
childCount - The count of indexes in the childIds parameter.
See Also:
checkContent(XMLCh*, XMLCh**, unsigned int)
EConstants

virtual void postParseValidation( RefHashTableOf& idRefList )
This method allows the validator to do whatever is required once the scanner gets through to the end of the document.

For example checks like, all the ID references encountered should refer to some element with that id. Any errors found are reported back via the scanners 'emitError' method.

Parameters:
idRefList - The list of #IDREFs encountered.
See Also:
XMLScanner

virtual void resetValidation()
This method gives the validator a chance to reset its state, so that it is ready to validate another document

virtual void validatePoolInfo( NameBasedPool& elemDeclPool, NameBasedPool& elemNotationPool )
This method is used to validate the information extracted from the DTD. It gets called only if a validating parser is being used. A default implementation is provided for this pure virtual method, which checks whether all element names encountered were defined or not. Derived classes have to explicitly call this default implementation.

All errors found are reported back using the scanner's emitError method.

Parameters:
elemDeclPool - The element declaration pool which will be checked for any undeclared elements.
elemNotationPool - The pool containing all notation declaration. This parameter is currently not ignored.

getters.

const XMLScanner& getScanner() const
Returns the scanner object.
Returns:
A reference to the scanner object.

XMLValidationHandler(const XMLValidationHandler&)
The copy constructor, you cannot call this directly

void operator=(const XMLValidationHandler&)
The assignment operator, you cannot call this directly


This class has no child classes.
Version:
Revision: 06 1.18.1.1 src/com/ibm/xml/framework/XMLValidationHandler.hpp, xml4c2Framework, xml4c2_2_x
See Also:
XMLScanner

alphabetic index hierarchy of classes


XML Parser for C++ 2.0
Copyright © IBM Corp, 1999
Center for Java Technology
10275 N. De Anza Blvd.
Cupertino CA 95014 USA
Email: xml4c@us.ibm.com

IBM Logo