This package was developed to validate Mets files for the DFG-Viewer. It is possible to validate only parts of a xml-file. Validation is possible with xsd
, rng
and xsl
(Schematron). To validate only parts of an XML file, specify the root element of that part. In the tests folder is a copy of dmj/dfgviewer-schema.
composer require ottosmops/xmlvalidator
There is the one and only method validate
:
<?php
require('vendor/autoload.php');
use Ottosmops\XmlValidator\XmlValidator;
class test {
public static function index() {
$option = ['file' => 'tests/data/valid/mets_001.xml',
'ns' => 'mets',
'nsuri' => 'https://www.loc.gov/METS/',
'root' => 'mets',
'schema' => 'https://www.loc.gov/standards/mets/mets.xsd'];
$validator = new XmlValidator($option);
if (!$validator->validate()) {
print("validated mets: is not valid".PHP_EOL);
print($validator->getErrors());
} else {
print("validated mets: is valid".PHP_EOL);
}
}
}
test::index();
You can find more examples in the tests folder.
The MIT License (MIT). Please see License File for more information.