Skip to content
Extraits de code Groupes Projets
Valider a7e01c3b rédigé par esj's avatar esj
Parcourir les fichiers

On ne reproche plus à un élément d'avoir un père inconnu, il n'y peut rien.

En revanche, si le père est connu mais ne reconnait pas cet élément comme fils, on donne la liste des pères possibles. Au passage, on voit tout ceux qui sont effectivement acceptés par la DTD, le validateur du W3C ne montrant que ceux politiquement corrects. Il faut les voir pour le croire.

Suite à mon ignorance de la triple accolade dans le Wiki lors des dépots [8061] et [8067], je redonne les globales qu'il faut affecter dans mes_options.php pour utiliser ce validateur (et, en cas de réussite, aussi indenteur fiable depuique que [8090] a trouvé comment contourner le bug de conception de SAX):

{{{
$GLOBALS['xml_indent'] = 'sax'; // pour seulement le validateur XML
$GLOBALS['xml_validation'] = true; // pour le validateur selon la DTD
}}}

et je mets en commentaire dans inc/utils ligne 994 de quoi essayer XHTML 1.0 strict pour voir ce que ça donne  (pour la non stricte, on ne voit plus grand chose maintenant).
parent dc5702ad
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -188,6 +188,7 @@ function xml_parsestring($phraseur, $data) ...@@ -188,6 +188,7 @@ function xml_parsestring($phraseur, $data)
var $ouvrant = array(); var $ouvrant = array();
var $reperes = array(); var $reperes = array();
var $elements = array(); var $elements = array();
var $peres = array();
var $entites = array(); var $entites = array();
var $attributs = array(); var $attributs = array();
var $ids = array(); var $ids = array();
......
...@@ -989,8 +989,9 @@ function spip_initialisation($pi=NULL, $pa=NULL, $ti=NULL, $ta=NULL) { ...@@ -989,8 +989,9 @@ function spip_initialisation($pi=NULL, $pa=NULL, $ti=NULL, $ta=NULL) {
define('_SPIP_DUMP', 'dump@stamp@.xml'); define('_SPIP_DUMP', 'dump@stamp@.xml');
define('_DOCTYPE_ECRIRE', define('_DOCTYPE_ECRIRE',
// "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>\n"); // "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>\n");
"<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>"); "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>");
// "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd'>\n");
define('_DOCTYPE_AIDE', define('_DOCTYPE_AIDE',
"<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"); "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>");
......
...@@ -50,8 +50,9 @@ function inc_validateur_dist($data) ...@@ -50,8 +50,9 @@ function inc_validateur_dist($data)
} }
$phraseur_xml->entites = $res; $phraseur_xml->entites = $res;
// reperer pour chaque noeud ses fils potentiels, sans repetitions, // reperer pour chaque noeud ses fils potentiels.
// pour faire une analyse syntaxique sommaire // mais tant pis pour leur eventuel ordre de succession (, * +):
// les cas sont rares et si aberrants que interet/temps-de-calcul -> 0
$res = array(); $res = array();
if (preg_match_all('/<!ELEMENT\s+(\w+)([^>]*)>/', $dtd, $r, PREG_SET_ORDER)) { if (preg_match_all('/<!ELEMENT\s+(\w+)([^>]*)>/', $dtd, $r, PREG_SET_ORDER)) {
foreach($r as $m) { foreach($r as $m) {
...@@ -59,8 +60,13 @@ function inc_validateur_dist($data) ...@@ -59,8 +60,13 @@ function inc_validateur_dist($data)
$val = expanserEntite($val, $phraseur_xml->entites); $val = expanserEntite($val, $phraseur_xml->entites);
$val = array_values(preg_split('/\W+/', $val,-1,PREG_SPLIT_NO_EMPTY)); $val = array_values(preg_split('/\W+/', $val,-1,PREG_SPLIT_NO_EMPTY));
$res[$nom]= $val; $res[$nom]= $val;
foreach ($val as $k) {
if (!isset($phraseur_xml->peres[$k])
OR !in_array($nom, $phraseur_xml->peres[$k]))
$phraseur_xml->peres[$k][]= $nom;
}
} }
} }
$phraseur_xml->elements = $res; $phraseur_xml->elements = $res;
$res = array(); $res = array();
...@@ -113,13 +119,18 @@ function validerElement($parser, $name, $attrs) ...@@ -113,13 +119,18 @@ function validerElement($parser, $name, $attrs)
if (isset($ouvrant[$depth])) { if (isset($ouvrant[$depth])) {
if (preg_match('/^\s*(\w+)/', $ouvrant[$depth], $r)) { if (preg_match('/^\s*(\w+)/', $ouvrant[$depth], $r)) {
$pere = $r[1]; $pere = $r[1];
if (!@in_array($name, $phraseur_xml->elements[$pere])) if (isset($phraseur_xml->elements[$pere]))
$phraseur_xml->err[]= " <b>$name</b>" if (!@in_array($name, $phraseur_xml->elements[$pere])) {
. _L(" n'est pas un fils de ") $bons_peres = @join ('</b>, <b>', $phraseur_xml->peres[$name]);
. '<b>' $phraseur_xml->err[]= " <b>$name</b>"
. $pere . _L(" n'est pas un fils de ")
. '</b>' . '<b>'
. coordonnees_erreur($parser); . $pere
. '</b>'
. (!$bons_peres ? ''
: (_L( '<p style="font-size: 80%"> mais de <b>') . $bons_peres . '</b></p>'))
. coordonnees_erreur($parser);
}
} }
} }
foreach ($phraseur_xml->attributs[$name] as $n => $v) foreach ($phraseur_xml->attributs[$name] as $n => $v)
......
...@@ -538,7 +538,7 @@ function emboite_texte($texte, $fonc='',$self='') ...@@ -538,7 +538,7 @@ function emboite_texte($texte, $fonc='',$self='')
$GLOBALS['xhtml_error'], $GLOBALS['xhtml_error'],
$regs, $regs,
PREG_SET_ORDER); PREG_SET_ORDER);
$err = '<tr><th>#</th><th>Occ.</th><th>Msg</th><th>L</th><th>Col</th></tr>'; $err = '<tr><th>#</th><th>Occ.</th><th>Li.</th><th>Col.</th><th>Err.</th></tr>';
$fautifs = array(); $fautifs = array();
$i = 0; $i = 0;
$encore = array(); $encore = array();
...@@ -560,14 +560,14 @@ function emboite_texte($texte, $fonc='',$self='') ...@@ -560,14 +560,14 @@ function emboite_texte($texte, $fonc='',$self='')
. "'><td style='text-align: right'>" . "'><td style='text-align: right'>"
. $i . $i
. "</td><td style='text-align: right'>" . "</td><td style='text-align: right'>"
. "$ref/$encore[$msg]</td><td>$msg</td>" . "$ref/$encore[$msg]</td>"
. "<td style='text-align: right'><a href='#L" . "<td style='text-align: right'><a href='#L"
. $ligne . $ligne
. "' id='T$i'>" . "' id='T$i'>"
. $ligne . $ligne
. "</a></td><td style='text-align: right'>" . "</a></td><td style='text-align: right'>"
. $fin . $fin
. "</td></tr>\n"; . "</td><td>$msg</td></tr>\n";
$fautifs[]= array($ligne, $col, $i); $fautifs[]= array($ligne, $col, $i);
} }
return array(ancre_texte($texte, $fautifs), return array(ancre_texte($texte, $fautifs),
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter