diff --git a/src/SchemaValidatableElementTrait.php b/src/SchemaValidatableElementTrait.php index 0c79c0e..9a44b66 100644 --- a/src/SchemaValidatableElementTrait.php +++ b/src/SchemaValidatableElementTrait.php @@ -13,7 +13,9 @@ use function defined; use function file_exists; use function implode; +use function libxml_clear_errors; use function libxml_get_errors; +use function libxml_use_internal_errors; use function sprintf; use function trim; @@ -32,6 +34,9 @@ trait SchemaValidatableElementTrait */ public static function schemaValidate(DOMDocument $document): DOMDocument { + $internalErrors = libxml_use_internal_errors(true); + libxml_clear_errors(); + $schemaFile = self::getSchemaFile(); // Must suppress the warnings here in order to throw them as an error below. $result = @$document->schemaValidate($schemaFile); @@ -48,6 +53,9 @@ public static function schemaValidate(DOMDocument $document): DOMDocument )); } + libxml_use_internal_errors($internalErrors); + libxml_clear_errors(); + return $document; }