Skip to content

Commit

Permalink
Document and complement XInclude failures as warnings on translations (
Browse files Browse the repository at this point in the history
  • Loading branch information
alfsb authored Dec 5, 2024
1 parent 9d68f54 commit dfcbb86
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions configure.php
Original file line number Diff line number Diff line change
Expand Up @@ -814,10 +814,16 @@ function getFileModificationHistory(): array {
}
}

{ # Automatic xi:include / xi:fallback fixups
if ( $ac['LANG'] != 'en' )
{
// XInclude failures are soft errors on translations, so remove
// residual XInclude tags on translations to keep them building.

$explain = false;

$xpath = new DOMXPath( $dom );
$nodes = $xpath->query( "//*[local-name()='include']" );
$xpath->registerNamespace( "xi" , "http://www.w3.org/2001/XInclude" );
$nodes = $xpath->query( "//xi:include" );
foreach( $nodes as $node )
{
$fixup = null;
Expand All @@ -831,8 +837,15 @@ function getFileModificationHistory(): array {
case "refsect1":
$fixup = "<title></title>";
break;
case "tbody":
$fixup = "<row><entry></entry></row>";
break;
// case "variablelist":
// $fixup = "<varlistentry><term>></term><listitem><simpara></simpara></listitem></varlistentry>";
// break;
default:
echo "Unknown parent element, validation may fail: $tagName\n";
echo "Unknown parent element of failed XInclude: $tagName\n";
$explain = true;
continue 2;
}
if ( $fixup != "" )
Expand All @@ -844,6 +857,18 @@ function getFileModificationHistory(): array {
}
$node->parentNode->removeChild( $node );
}

if ( $explain )
{
echo <<<MSG
\nIf you are seeing this message on a translation, this means that
XInclude/XPointers failures reported above are so many or unknown,
that configure.php cannot patch the translated manual into a validating
state. Please report any "Unknown parent" messages on the doc-base
repository, and focus on fixing XInclude/XPointers failures above.\n\n
MSG;
exit(-1); // stop here, do not let more messages further confuse the matter
}
}

echo "Validating {$ac["INPUT_FILENAME"]}... ";
Expand Down

0 comments on commit dfcbb86

Please sign in to comment.