#30814 [NEW]: more detailed feedback from DOMDocument::schemaValidate

From: Date: Wed, 17 Nov 2004 15:55:15 +0000
Subject: #30814 [NEW]: more detailed feedback from DOMDocument::schemaValidate
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-69177@lists.php.net to get a copy of this message
From: pecoes at web dot de Operating system: windows xp PHP version: 5.0.2 PHP Bug Type: Feature/Change Request Bug description: more detailed feedback from DOMDocument::schemaValidate 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. -- Edit bug report at http://bugs.php.net/?id=30814&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30814&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30814&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30814&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=30814&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=30814&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=30814&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=30814&r=needscript Try newer version: http://bugs.php.net/fix.php?id=30814&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=30814&r=support Expected behavior: http://bugs.php.net/fix.php?id=30814&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=30814&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=30814&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=30814&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30814&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=30814&r=dst IIS Stability: http://bugs.php.net/fix.php?id=30814&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=30814&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=30814&r=float MySQL Configuration Error: http://bugs.php.net/fix.php?id=30814&r=mysqlcfg

« previous php.bugs (#69177) next »