Validation Processor
- 1. Rationale
- 2. Usage
- 2.1. Config Input
- 2.2. Schema Input
- 2.3. Data Input
- 2.4. Data Output
1. Rationale
The validation processor can be inserted in a pipeline to validatate data against a specified schema. The current implementation supports W3C Schema and Relax NG.
The validator functions in two distinct mode. The decorating mode adds
attribute to the document where errors occur. The non-decorating mode throws
a org.orbeon.oxf.common.ValidationException
if the data doesn't
conform to the schema.
2. Usage
Processor Name | oxf:validation |
---|---|
config input | The configuration of this validator. |
schema input | The schema (W3C Schema or Relax NG). |
data input | The document to validate. |
data output | This output mirrors the data input. |
2.1. Config Input
The configuration input selects the mode of the validator. The validator can
either be in the decorating mode or the non-decorating mode. The
decorating
element contains a boolean (true
or
false
) indicating if the validator is decorating or not. The
following example shows a configuration for a decorating validator.
2.2. Schema Input
The validation processor's schema input contains a supported XML schema (W3C or Relax NG). The schema type is automatically recognized. The following example shows a simple Relax NG schema for an arbitrary address book.
For more information about Relax NG syntax, read the Relax NG specification and Relax NG tutorial. The W3C Schema Primer provides a good introduction to the language.
2.3. Data Input
The data input contains the xml data to be validated. The following document is valid against the address book schema defined above.
2.4. Data Output
If the input data is valid against the specified schema, this output mirrors
the input data, i.e. the validation processor is invisible in the pipeline.
However, when validation errors occur, a ValidationException
is
thrown and the pipeline processing is interrupted if the validator is in the
non-decorating mode. When in decorating mode, the validator
annotates the output document in the following way:
For each validation error, the validator inserts an additional element after
the error-causing element. This element is in the
http://orbeon.org/oxf/xml/validation
namespace URI and contains the
following information:
- The message of the validator
- The system ID of the document, if available
- The location (line and column) within the document, if available.