ottosmops / xmlvalidator
Validate XML-Files, also parts
Installs: 128
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Language:XSLT
Requires
- php: >=8.1.0
Requires (Dev)
- laravel/dusk: ^7.8
- phpunit/phpunit: ^9
README
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.
Installation
composer require ottosmops/xmlvalidator
Usage
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.
License
The MIT License (MIT). Please see License File for more information.