Xerces-C++ 3.3.0

List of all members
XMLValidator Class Referenceabstract

This abstract class provides the interface for all validators. More...

`#include <xercesc/framework/XMLValidator.hpp>`

Inheritance diagram for XMLValidator:

## Public Member Functions
Destructor
virtual | ~XMLValidator ()
| The derived class should clean up its allocated data, then this class will do the same for data allocated at this level.
Virtual validator interface
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.
virtual void | faultInAttr (XMLAttr &toFill, const XMLAttDef &attDef) const =0
| The derived class should fault in the passed XMLAttr value.
virtual void | preContentValidation (bool reuseGrammar, bool validateDefAttr=false)=0
| This method is called by the scanner after a Grammar is scanned.
virtual void | postParseValidation ()=0
| This method is called by the scanner after the parse has completed.
virtual void | reset ()=0
| This method is called by the scanner before a new document is about to start.
virtual bool | requiresNamespaces () const =0
| The derived class should return a boolean that indicates whether it requires namespace processing or not.
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 those defined by XML 1.0.
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 defined by XML 1.0.
virtual Grammar * | getGrammar () const =0
| Retrieve the Grammar used.
virtual void | setGrammar (Grammar *aGrammar)=0
| Set the Grammar.
Virtual DTD handler interface
virtual bool | handlesDTD () const =0
| This method allows the scanner to ask the validator if it handles DTDs or not.
Virtual Schema handler interface
virtual bool | handlesSchema () const =0
| This method allows the scanner to ask the validator if it handles Schema or not.
Setter methods
void | setScannerInfo (XMLScanner *const owningScanner, ReaderMgr *const readerMgr, XMLBufferMgr *const bufMgr)
void | setErrorReporter (XMLErrorReporter *const errorReporter)
| This method is called to set an error reporter on the validator via which it will report any errors it sees during parsing or validation.
Public Member Functions inherited from XMemory
void * | operator new (size_t size)
| This method overrides operator new.
void * | operator new (size_t size, MemoryManager *memMgr)
| This method defines a custom operator new, that will use the provided memory manager to perform the allocation.
void * | operator new (size_t size, void *ptr)
| This method overrides placement operator new.
void | operator delete (void *p)
| This method overrides operator delete.
void | operator delete (void *p, MemoryManager *memMgr)
| This method provides a matching delete for the custom operator new.
void | operator delete (void *p, void *ptr)
| This method provides a matching delete for the placement new.

## Error emittor methods
void | emitError (const XMLValid::Codes toEmit)
| This call is a convenience by which validators can emit errors.
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)
| XMLValidator (XMLErrorReporter *const errReporter=0)
const XMLBufferMgr * | getBufMgr () const
XMLBufferMgr * | getBufMgr ()
const ReaderMgr * | getReaderMgr () const
ReaderMgr * | getReaderMgr ()
const XMLScanner * | getScanner () const
XMLScanner * | getScanner ()

## Additional Inherited Members
Protected Member Functions inherited from XMemory
| XMemory ()
| Protected default constructor.

## Detailed Description

This abstract class provides the interface for all validators.

This is the simple amount of API that all validators must honor, in order for the scanner to use them to do validation. All validators will actually contain much more functionality than is accessible via this common API, but that functionality requires that you know what type of validator you are dealing with.

Basically, at this level, the primary concern is to be able to query core information about elements and attributes. Adding decls to the validator requires that you go through the derived interface because they all have their own decl types. At this level, we can return information via the base decl classes, from which each validator derives its own decl classes.

## Constructor & Destructor Documentation

## ◆ ~XMLValidator()

virtual XMLValidator::~XMLValidator | ( |  | ) |
| virtual

The derived class should clean up its allocated data, then this class will do the same for data allocated at this level.

## ◆ XMLValidator()

XMLValidator::XMLValidator | ( | XMLErrorReporter *const | errReporter = 0 | ) |
| protected

## Member Function Documentation

## ◆ checkContent()

virtual bool XMLValidator::checkContent | ( | XMLElementDecl *const | elemDecl,
|  | QName **const | children,
|  | XMLSize_t | childCount,
|  | XMLSize_t * | indexFailingChild )
| pure virtual

The derived class should look up its declaration of the passed element from its element pool.

It should then use the content model description contained in that element declaration to validate that the passed list of child elements are valid for that content model. The count can be zero, indicating no child elements.

Note that whitespace and text content are not validated here. Those are handled by the scanner. So only element ids are provided here.

Parameters

  elemDecl | The element whose content is to be checked.
  children | An array of element QName which represent the elements found within the parent element, i.e. the content to be validated.
  childCount | The number of elements in the childIds array. It can be zero if the element had none.
  indexFailingChild | On return, it will contain the index of the children failing validation, if the retun value is false

## ◆ emitError() [1/4]

void XMLValidator::emitError | ( | const XMLValid::Codes | toEmit | ) |

This call is a convenience by which validators can emit errors.

Most of the grunt work of loading the text, getting the current source location, ect... is handled here.

If the loaded text has replacement parameters, then text strings can be passed. These will be used to replace the tokens {0}, {1}, {2}, and {3} in the order passed. So text1 will replace {0}, text2 will replace {1}, and so forth.

textX Up to four replacement parameters. They can be provided as either XMLCh strings, or local code page strings which will be transcoded internally.

Parameters

  toEmit | The error code to emit. it must be one of the defined validator error codes.

## ◆ emitError() [2/4]

void XMLValidator::emitError | ( | const XMLValid::Codes | toEmit,
|  | const char *const | text1,
|  | const char *const | text2 = 0,
|  | const char *const | text3 = 0,
|  | const char *const | text4 = 0 )

## ◆ emitError() [3/4]

void XMLValidator::emitError | ( | const XMLValid::Codes | toEmit,
|  | const XMLCh *const | text1,
|  | const XMLCh *const | text2 = 0,
|  | const XMLCh *const | text3 = 0,
|  | const XMLCh *const | text4 = 0 )

## ◆ emitError() [4/4]

void XMLValidator::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 )

## ◆ faultInAttr()

virtual void XMLValidator::faultInAttr | ( | XMLAttr & | toFill,
|  | const XMLAttDef & | attDef ) const
| pure virtual

The derived class should fault in the passed XMLAttr value.

It should use the passeed attribute definition (which is passed via the base type so it must often be downcast to the appropriate type for the derived validator class), to fill in the passed attribute. This is done as a performance enhancement since the derived class has more direct access to the information.

## ◆ getBufMgr() [1/2]

XMLBufferMgr * XMLValidator::getBufMgr | ( |  | ) |
| protected

## ◆ getBufMgr() [2/2]

const XMLBufferMgr * XMLValidator::getBufMgr | ( |  | ) | const
| protected

## ◆ getGrammar()

virtual Grammar * XMLValidator::getGrammar | ( |  | ) | const
| pure virtual

Retrieve the Grammar used.

## ◆ getReaderMgr() [1/2]

ReaderMgr * XMLValidator::getReaderMgr | ( |  | ) |
| protected

## ◆ getReaderMgr() [2/2]

const ReaderMgr * XMLValidator::getReaderMgr | ( |  | ) | const
| protected

## ◆ getScanner() [1/2]

XMLScanner * XMLValidator::getScanner | ( |  | ) |
| protected

## ◆ getScanner() [2/2]

const XMLScanner * XMLValidator::getScanner | ( |  | ) | const
| protected

## ◆ handlesDTD()

virtual bool XMLValidator::handlesDTD | ( |  | ) | const
| pure virtual

This method allows the scanner to ask the validator if it handles DTDs or not.

## ◆ handlesSchema()

virtual bool XMLValidator::handlesSchema | ( |  | ) | const
| pure virtual

This method allows the scanner to ask the validator if it handles Schema or not.

## ◆ postParseValidation()

virtual void XMLValidator::postParseValidation | ( |  | ) |
| pure virtual

This method is called by the scanner after the parse has completed.

It gives the validator a chance to check certain things that can only be checked after the whole document has been parsed, such as referential integrity of ID/IDREF pairs and so forth. The validator should just issue errors for any problems it finds.

## ◆ preContentValidation()

virtual void XMLValidator::preContentValidation | ( | bool | reuseGrammar,
|  | bool | validateDefAttr = false )
| pure virtual

This method is called by the scanner after a Grammar is scanned.

## ◆ requiresNamespaces()

virtual bool XMLValidator::requiresNamespaces | ( |  | ) | const
| pure virtual

The derived class should return a boolean that indicates whether it requires namespace processing or not.

Some do and some allow it to be optional. This flag is used to control whether the client code's requests to disable namespace processing can be honored or not.

## ◆ reset()

virtual void XMLValidator::reset | ( |  | ) |
| pure virtual

This method is called by the scanner before a new document is about to start.

It gives the validator a change to reset itself in preparation for another validation pass.

## ◆ setErrorReporter()

void XMLValidator::setErrorReporter | ( | XMLErrorReporter *const | errorReporter | ) |

This method is called to set an error reporter on the validator via which it will report any errors it sees during parsing or validation.

This is generally called by the owning scanner.

Parameters

  errorReporter | A pointer to the error reporter to use. This is not adopted, just referenced so the caller remains responsible for its cleanup, if any.

## ◆ setGrammar()

virtual void XMLValidator::setGrammar | ( | Grammar * | aGrammar | ) |
| pure virtual

Set the Grammar.

## ◆ setScannerInfo()

void XMLValidator::setScannerInfo | ( | XMLScanner *const | owningScanner,
|  | ReaderMgr *const | readerMgr,
|  | XMLBufferMgr *const | bufMgr )

Parameters

  owningScanner | This is a pointer to the scanner to which the validator belongs. The validator will often need to query state data from the scanner.
  readerMgr | This is a pointer to the reader manager that is being used by the scanner.
  bufMgr | This is the buffer manager of the scanner. This is provided as a convenience so that the validator doesn't have to create its own buffer manager during the parse process.

## ◆ validateAttrValue()

virtual void XMLValidator::validateAttrValue | ( | const XMLAttDef * | attDef,
|  | const XMLCh *const | attrValue,
|  | bool | preValidation = false,
|  | const XMLElementDecl * | elemDecl = 0 )
| pure virtual

The derived class should apply any rules to the passed attribute value that are above and beyond those defined by XML 1.0.

The scanner itself will impose XML 1.0 rules, based on the type of the attribute. This will generally be used to check things such as range checks and other datatype related validation.

If the value breaks any rules as defined by the derived class, it should just issue errors as usual.

## ◆ validateElement()

virtual void XMLValidator::validateElement | ( | const XMLElementDecl * | elemDef | ) |
| pure virtual

The derived class should apply any rules to the passed element decl that are above and beyond those defined by XML 1.0.

If the value breaks any rules as defined by the derived class, it should just issue errors as usual.

The documentation for this class was generated from the following file:

- XMLValidator.hpp