Chapter 4. Package hvalidator

This chapter describes the package hvalidator which provides all functions for validating XML documents represented as XmlTree. The validation process basically consists of three phases. First the DTD is validated, after this the document is validated. In the last step the document is transformed: missing default values are added and attribute values are normalized. Unlike other popular XML validation tools the validation functions return a list of errors instead of aborting after the first error was found.

While the modules from package hparser use a monadic approach, these modules are written purely functional. Validation is done by filter functions of type XmlFilter. These filters return a list of errors or an empty list if no errors are detected.

4.1. Module hierarchy

The only public module for validating XML documents is the module Validation. It exports all functions for validating and transforming XML documents. Validation is basically a helper module, which combines the functionalities of the internal modules taking part at validation and transformation.

Internal modules

DTDValidation

Provides functions for validating the DTD of XML documents.

DocValidation

Provides functions for validating the elements and attributes of XML documents.

DocTransformation

Provides functions for transforming XML documents after they have been validated. The transformation phase is part of the validation process.

AttributeValueValidation

Provides functions to normalize attribute values and to check if the attribute value matches the lexical constraints of its type.

XmlRE and RE

Support DocValidation by validating the content model of an element. The algorithm used is based on derivatives of regular expressions.

Figure 4-1. Modules of package hvalidator