Skip to content

Commit 81d0ed5

Browse files
compromise on validation (#284)
1 parent 2d122f3 commit 81d0ed5

1 file changed

Lines changed: 18 additions & 31 deletions

File tree

configure.php

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ function usage() // {{{
6565
[{$acd['ROOTDIR']}]
6666
6767
Package-specific:
68-
--enable-force-dom-save Force .manual.xml to be saved in a full build
69-
even if it fails validation [{$acd['FORCE_DOM_SAVE']}]
7068
--enable-chm Enable Windows HTML Help Edition pages [{$acd['CHMENABLED']}]
7169
--enable-xml-details Enable detailed XML error messages [{$acd['DETAILED_ERRORMSG']}]
7270
--disable-version-files Do not merge the extension specific
@@ -304,7 +302,6 @@ function find_xml_files($path) // {{{
304302
'LANG' => 'en',
305303
'LANGDIR' => "{$rootdir}/en",
306304
'ENCODING' => 'utf-8',
307-
'FORCE_DOM_SAVE' => 'no',
308305
'PARTIAL' => 'no',
309306
'DETAILED_ERRORMSG' => 'no',
310307
'VERSION_FILES' => 'yes',
@@ -377,10 +374,6 @@ function find_xml_files($path) // {{{
377374
$ac['srcdir'] = $v;
378375
break;
379376

380-
case 'force-dom-save':
381-
$ac['FORCE_DOM_SAVE'] = $v;
382-
break;
383-
384377
case 'chm':
385378
$ac['CHMENABLED'] = $v;
386379
break;
@@ -637,13 +630,9 @@ function xml_configure()
637630
$ac["GENERATE"] = str_replace($ac["ROOTDIR"].$ac["LANGDIR"], "", $tmp);
638631
$str = "\n<!ENTITY developer.include.file SYSTEM 'file:///{$ac["GENERATE"]}'>";
639632
file_put_contents("{$ac["basedir"]}/entities/file-entities.ent", $str, FILE_APPEND);
640-
$ac["FORCE_DOM_SAVE"] = "yes";
641633
}
642634
checkvalue($ac["GENERATE"]);
643635

644-
checking('whether to save an invalid .manual.xml');
645-
checkvalue($ac['FORCE_DOM_SAVE']);
646-
647636
function dom_load( DOMDocument $dom , string $filename , string $baseURI = "" ) : bool
648637
{
649638
$filename = realpath( $filename );
@@ -951,27 +940,25 @@ function xinclude_residual_list( DOMDocument $dom ) : DOMNodeList
951940
echo "done.\n";
952941
} else {
953942
echo "failed.\n";
954-
echo "\nThe document didn't validate\n";
955-
956-
/**
957-
* TODO: Integrate jing to explain schema violations as libxml is *useless*
958-
* And this is not going to change for a while as the maintainer of libxml2 even acknowledges:
959-
* > As it stands, libxml2's Relax NG validator doesn't seem suitable for production.
960-
* cf. https://gitlab.gnome.org/GNOME/libxml2/-/issues/448
961-
*/
962-
$output = shell_exec('java -jar ' . $srcdir . '/docbook/jing.jar ' . RNG_SCHEMA_FILE. ' ' . $acd['OUTPUT_FILENAME']);
963-
if ($output === null) {
964-
echo "Command failed do you have Java installed?";
943+
echo "\nThe document didn't validate.\n";
944+
945+
if ($ac['DETAILED_ERRORMSG'] === 'yes') {
946+
/**
947+
* TODO: Integrate jing to explain schema violations as libxml is *useless*
948+
* And this is not going to change for a while as the maintainer of libxml2 even acknowledges:
949+
* > As it stands, libxml2's Relax NG validator doesn't seem suitable for production.
950+
* cf. https://gitlab.gnome.org/GNOME/libxml2/-/issues/448
951+
*/
952+
$output = shell_exec('java -jar ' . $srcdir . '/docbook/jing.jar ' . RNG_SCHEMA_FILE. ' ' . $acd['OUTPUT_FILENAME']);
953+
if ($output === null) {
954+
echo "Command failed do you have Java installed?";
955+
} else {
956+
echo $output;
957+
}
965958
} else {
966-
echo $output;
967-
}
968-
//echo 'Please use Jing and the:' . PHP_EOL
969-
// . 'java -jar ./build/jing.jar /path/to/doc-base/docbook/docbook-v5.2-os/rng/docbookxi.rng /path/to/doc-base/.manual.xml' . PHP_EOL
970-
// . 'command to check why the RelaxNG schema failed.' . PHP_EOL;
971-
972-
// Exit normally when don't care about validation
973-
if ($ac["FORCE_DOM_SAVE"] == "yes") {
974-
exit(0);
959+
echo "Here are the errors I got:\n";
960+
echo "(If this isn't enough information, try again with --enable-xml-details)\n";
961+
print_xml_errors(false);
975962
}
976963

977964
errors_are_bad(1); // Tell the shell that this script finished with an error.

0 commit comments

Comments
 (0)