Validation

Validators

DOMDocumentValidationStack

Kitodo\Dlf\Validation\DOMDocumentValidationStack implementation of Kitodo\Dlf\Validation\AbstractDlfValidationStack for validating DOMDocument against the configurable validators.

The configuration is an array validator configurations each with following entries:

Key

Description

title

Title of the validator

className

Fully qualified class name of validator class derived from Kitodo\Dlf\Validation\AbstractDlfValidator

breakOnError

Indicates whether the validation of the validation stack should be interrupted in case of errors.

configuration

Specific configuration of validator

XmlSchemesValidator

Kitodo\Dlf\Validation\XmlSchemesValidator combines the configured schemes into one schema and validates the provided DOMDocument against this.

The configuration is an array validator configurations each with following entries:

Key

Description

namespace

Specifies the URI of the namespace to import

schemaLocation

Specifies the URI to the schema for the imported namespace

SaxonXslToSvrlValidator

Kitodo\Dlf\Validation\SaxonXslToSvrlValidator validates the DOMDocument against an XSL Schematron and converts error output to validation errors.

To use the validator, the XSL Schematron must be available alongside the XSL processor as a JAR file, and the required Java version of the processor must be installed.

Key

Description

jar

Absolute path to the Saxon JAR file

xsl

Absolute path to the XSL Schematron

DOMDocumentValidation Middleware

Kitodo\Dlf\Validation\DOMDocumentValidation middleware can be used via the parameter middleware with the value dlf/domDocumentValidation and the parameter url with the URL to the DOMDocument content to validate.

Configuration

The validation middleware can be configured through the plugin settings in TypoScript with the block called domDocumentValidationValidators.

plugin.tx_dlf {
    settings {
        domDocumentValidationValidators {
            validator {
               ...
            },
            validatorStack {
               ...
            },
            ...
Copied!

Validators derived from Kitodo\Dlf\Validation\AbstractDlfValidator can be configured here. This also includes the use of validation stack implementations derived from Kitodo\Dlf\Validation\AbstractDlfValidationStack, which use DOMDocument as the valueClassName for validation. This allows for multiple levels of nesting.

In the background of the middleware, the Kitodo\Dlf\Validation\DOMDocumentValidationStack is used, to which the configured validators are assigned.

TypoScript Example

plugin.tx_dlf {
    settings {
        storagePid = {$config.storagePid}
        domDocumentValidationValidators {
           10 {
               title = XML-Schemes Validator
               className = Kitodo\Dlf\Validation\XmlSchemesValidator
               breakOnError = false
               configuration {
                   oai {
                       namespace = http://www.openarchives.org/OAI/2.0/
                       schemaLocation = https://www.openarchives.org/OAI/2.0/OAI-PMH.xsd
                   }
                   mets {
                       namespace = http://www.loc.gov/METS/
                       schemaLocation = http://www.loc.gov/standards/mets/mets.xsd
                   }
                   mods {
                       namespace = http://www.loc.gov/mods/v3
                       schemaLocation = http://www.loc.gov/standards/mods/mods.xsd
                   }
               }
           },
           ...
Copied!