# Validation

The Validator is a component in this architecture since it implements the Component interface and any class that implements the Component Manager interface can manage it. E.g. a parser would configure the components that it needs through this interface by adhering to the guideline spelled out in the Setting Management section of this architecture overview.

The Component Manager is in charge of setting up the following internal Validator fields: SymbolTable, GrammarPool and ErrorFormatter.

The Validator is universal since it is both a filter and a source of document events regardless of the other components connected to in the pipeline architecture. See figure 1.

Figure 1- Pipeline Architecture - Sources & Filters

The following is an outline of the validation process used by the Validator:

1. The Validator uses the Grammar pool set by the Component Manager to acquire Grammars. See Grammar pool and Grammars for more details
2. The Validator uses Grammar’s getter methods to gain access to Element, Attribute, Notation, and Entity declarations.
3. When a document event (through the Document Handler of the Validator) is received the respective declaration is obtained from the Grammar.
4. These declarations are used to validate content and content model. See Data type and Content model validators.
5. If no validation errors are caught or returned. Then we generate a document event using the registered Document handler of the next component in the pipeline.
6. If a validation error is caught or returned then the error information is formatted using the Error Formatter which in turn may call the Error Handler.
7. The Validator component reset method allows setting a new component manager.

##

# Data type and Content model validators

##

## Datatype validators

Datatype Validators are based on the XML Schema Datatype draft. They are used by the Validator to validate attribute content in the case of a DTD or XML Schema grammars and to validate element content in the case of XML Schema grammars. Datatype validators implement the DatatypeValidator interface.

The Validator uses a factory method than implements the DatatypeValidatorFactory to get datatypes instances.

Datatype validator’s references are attached to the Element and Attribute declaration in the internal implementation of Grammars. See Grammar pools and Grammars

## Content model validators

Content model validators are used to check elements against the content model defined in an Element Declaration for those elements. Content model validators implement the ContentModelValidator interface.

#

# Grammar pool and Grammars

A GrammarPool is a registry of Grammars. Grammars are keyed using a “grammar name” which could be a name space. Grammars are classes derived from the Grammar class. Grammars contain internal array structures, and public getter methods that can be used by the Validator to access grammar information. These getter methods provide access to different Declaration constructs.

These Declaration constructs are: XMLElementDecl, XMLAttributeDecl, and XMLEntityDecl, and XMLNotationDecl.

Other constructs available through the Grammars are: XMLSimpleType, ContentModelValidator, and DatatypeValidator.

XMLSimpleType (Simple type) declarations are a special type of Element Declaration, which contains additional information beyond the one provided by XMLElementDecl such as data type validator references.

#

# Internal Grammar Structures

Bach to Architecture Overview