Processors - Validation


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.


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.

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.


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.

<element xmlns="" name="addressBook">
<element name="card">
<element name="name">
<attribute name="age">
<element name="email">

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.

Data input

The data input contains the xml data to be validated. The following document is valid against the address book schema defined above.

<name age="24">John Smith</name>
<name age="42">Fred Bloggs</name>

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 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.
For example, the following element could be generated:
<v:error xmlns:v="" message="Error bad character content for element near month (schema: oxf:/date.rng)" system-id="oxf:/date.xml" line="5" column="10"/>