cvs: pear /XML_DTD DTD_Validator.php
| From: | Thomas V.V.Cox | Date: | Sun, 24 Feb 2002 16:41:17 +0000 |
| Subject: | cvs: pear /XML_DTD DTD_Validator.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-2599@lists.php.net to get a copy of this message | ||
cox Sun Feb 24 11:41:17 2002 EDT
Modified files:
/pear/XML_DTD DTD_Validator.php
Log:
Tree changes and #FIXED attributes validation
Index: pear/XML_DTD/DTD_Validator.php
diff -u pear/XML_DTD/DTD_Validator.php:1.2 pear/XML_DTD/DTD_Validator.php:1.3
--- pear/XML_DTD/DTD_Validator.php:1.2 Sat Feb 23 23:37:22 2002
+++ pear/XML_DTD/DTD_Validator.php Sun Feb 24 11:41:16 2002
@@ -17,7 +17,7 @@
// | |
// +----------------------------------------------------------------------+
//
-// $Id: DTD_Validator.php,v 1.2 2002/02/24 04:37:22 cox Exp $
+// $Id: DTD_Validator.php,v 1.3 2002/02/24 16:41:16 cox Exp $
//
require_once 'XML/DTD_Parser.php';
@@ -95,13 +95,20 @@
if (isset($this->dtd['elements'][$name]['attributes'])) {
$atts = $this->dtd['elements'][$name]['attributes'];
foreach ($atts as $attname => $attvalue) {
- $opts = $attvalue['opts'];
- $prop = $attvalue['prop'];
- if ($prop == '#REQUIRED' && !isset($node_atts[$attname])) {
+ $opts = $attvalue['opts'];
+ $default = $attvalue['defaults'];
+ if ($default == '#REQUIRED' && !isset($node_atts[$attname])) {
$this->errors("missing required '$attname' attribute in
<$name>");
}
+ if ($default == '#FIXED') {
+ if (isset($node_atts[$attname]) && $node_atts[$attname] !=
$attvalue['fixed']) {
+ $this->errors("The value '{$node_atts[$attname]}' for
attribute '$attname' ".
+ "in <$name> can only be
'{$attvalue['fixed']}'");
+ }
+ }
if (isset($node_atts[$attname])) {
$node_val = $node_atts[$attname];
+ // Enumerated type validation
if (is_array($opts)) {
if (!in_array($node_val, $opts)) {
$this->errors("'$node_val' value for attribute
'$attname' under <$name> ".