diff --git a/ecrire/inc/sax.php b/ecrire/inc/sax.php index a8cbd819338bab30505dcd36543f0f1c941bd046..ba7359d5733ecc8559c9ab931e661b3181b4e5a9 100644 --- a/ecrire/inc/sax.php +++ b/ecrire/inc/sax.php @@ -181,6 +181,7 @@ function xml_parsestring($xml_parser, $data) var $elements = array(); var $entites = array(); var $attributs = array(); + var $ids = array(); var $err = array(); } diff --git a/ecrire/inc/validateur.php b/ecrire/inc/validateur.php index 4a9623c371f91eeefad7a891dece518dcc85dd0d..11ded21c14a4e5974a492da7e7f3d24ac28d5e79 100644 --- a/ecrire/inc/validateur.php +++ b/ecrire/inc/validateur.php @@ -71,7 +71,7 @@ function inc_validateur_dist($data) $att = array(); if (preg_match_all("/\s*(\S+)\s+(([(][^)]*[)])|(\S+))\s+(\S+)(\s*'[^']*')?/", $val, $r2, PREG_SET_ORDER)) { foreach($r2 as $m2) { - $v = preg_match('/^\w+$/', $m2[2]) ? '' + $v = preg_match('/^\w+$/', $m2[2]) ? $m2[2] : ('/^' . preg_replace('/\s+/', '', $m2[2]) . '$/'); $att[$m2[1]] = array($v, $m2[5]); } @@ -146,17 +146,37 @@ function validerAttribut($parser, $name, $val, $bal) . _L(' attribut inconnu de ') . "<b>$bal</b>" . coordonnees_erreur($parser); - elseif ($a[$name][0][0]=='/') { - if (!preg_match($a[$name][0], $val)) { - $phraseur_xml->err[]= " <p><b>$val</b>" - . _L(" valeur de l'attribut ") - . "<b>$name</b>" - . _L(' de ') - . "<b>$bal</b>" - . _L(" n'est pas conforme au motif</p><p>") - . "<b>" . $a[$name][0] . "</b></p>" - . coordonnees_erreur($parser); - } + else{ + $type = $a[$name][0]; + if ($type[0]=='/') { + if (!preg_match($a[$name][0], $val)) { + $phraseur_xml->err[]= " <p><b>$val</b>" + . _L(" valeur de l'attribut ") + . "<b>$name</b>" + . _L(' de ') + . "<b>$bal</b>" + . _L(" n'est pas conforme au motif</p><p>") + . "<b>" . $a[$name][0] . "</b></p>" + . coordonnees_erreur($parser); + } + } elseif ($type == 'ID') { + if (isset($phraseur_xml->ids[$val])) { + $phraseur_xml->err[]= " <p><b>$val</b>" + . _L(" valeur de l'attribut ") + . "<b>$name</b>" + . _L(' de ') + . "<b>$bal</b>" + . _L(" incorrect ") + . coordonnees_erreur($parser); + list($l,$c) = $phraseur_xml->ids[$val]; + $phraseur_xml->err[]= " <p><b>$val</b>" + . _L(" vu auparavant ligne ") + . $l + . _L(" colonne ") + . $c; + } + else $phraseur_xml->ids[$val] = array(xml_get_current_line_number($parser), xml_get_current_column_number($parser)); + } } } ?>