|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-12-06 08:11 UTC] anthony at ectrolinux dot com
[2022-04-08 08:07 UTC] ilutov@php.net
-Status: Open
+Status: Closed
-Package: Feature/Change Request
+Package: *General Issues
-Assigned To:
+Assigned To: ilutov
[2022-04-08 08:07 UTC] ilutov@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 05:00:01 2025 UTC |
Description: ------------ A lot can go wrong during schema validation: 1.) the schema cannot be opened 2.) the schema is not well-formed 3.) the schema itself is invalid 4.) the $dom in question is invalid Currently there is neither a way to distinguish between these four problems, nor a way to capture an actual validation error(4). Imho schemaValidate really needs some refinements. Here's an idea: schemaValidate (string file [, integer errType [, string errMsg]]) errType and errMsg would describe the error (if any) and schemaValidate would STOP triggering errors and return false instead. Usage: if (!$dom->schemaValidate($schema, $errType, $errMsg)) { switch ($errType) { case SCHEMA_NOT_FOUND: throw new Exception("$schema not found"); case SCHEMA_NOT_WELLFORMED: throw new Exception("$schema not well-formed"); case SCHEMA_INVALID: throw new Exception("$schema is invalid"); case SCHEMA_DOM_INVALID: throw new Exception("XML invalid: $errMsg"); } } or simply: if (!$dom->schemaValidate($schema, $errType, $errMsg)) { throw new Exception($errMsg ? $errMsg : "$schema not usable"); } Whether you like my idea or not, I hope you'll agree that: if (!@$dom->schemaValidate($schema)) { throw new Exception("cannot validate or invalid input"); } is not enough.