eZ\Publish\Core\FieldType\RichText\Validator::validateBySchema PHP Method

validateBySchema() protected method

Performs validation on given $document using given $schema file and returns validation errors.
protected validateBySchema ( DOMDocument $document, string $schema ) : string[]
$document DOMDocument
$schema string
return string[]
    protected function validateBySchema(DOMDocument $document, $schema)
    {
        if (!file_exists($schema) || !is_file($schema)) {
            throw new RuntimeException("Validation of XML document cannot be performed, file '{$schema}' does not exist.");
        }
        $additionalErrors = array();
        $pathInfo = pathinfo($schema);
        switch ($pathInfo['extension']) {
            case 'xsd':
                $document->schemaValidate($schema);
                break;
            case 'rng':
                $document->relaxNGValidate($schema);
                break;
            case 'xsl':
                $additionalErrors = $this->schematronValidate($document, $schema);
                break;
            default:
                throw new RuntimeException('Validator is capable of handling ISO Schematron (as XSLT stylesheet), ' . "XSD and RELAX NG schema files, ending in .xsl, .xsd or .rng.\n" . "File '{$schema}' does not seem to be either of these.");
        }
        return $additionalErrors;
    }