Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 63 additions & 15 deletions configure.php
Original file line number Diff line number Diff line change
Expand Up @@ -774,29 +774,77 @@ function getFileModificationHistory(): array {
}
echo "done.\n";

echo "Running XInclude/XPointer... ";
$status = $dom->xinclude();
if ($status === -1) {
echo "failed.\n";
} else {
/* For some dumb reason when no substitution are made it returns false instead of 0... */
$status = (int) $status;
echo "done. Performed $status XIncludes\n";
}
flush();

if ( $ac['XPOINTER_REPORTING'] == 'yes' || $ac['LANG'] == 'en' )
{
{ // XInclide/XPointer

echo "Running XInclude/XPointer... ";

// xinclides 1.1 capture

$beforeIdPaths = [];

$xpath = new DOMXPath( $dom );
$nodes = $xpath->query( "//*[@xml:id]" );

foreach( $nodes as $node )
{
$id = $node->getAttribute( "xml:id" );
$path = $node->getNodePath();

if ( isset( $beforeIdPaths[ $id ] ) )
{
echo "failed.\nDuplicated xml:id '$id' before XInclude!\n";
errors_are_bad( 1 );
}
$beforeIdPaths[ $id ] = $path;
}

// main

$ret = $dom->xinclude();

$errors = libxml_get_errors();
$output = ( $ac['STDERR_TO_STDOUT'] == 'yes' ) ? STDOUT : STDERR;
if ( count( $errors ) > 0 )
libxml_clear_errors();

if ( $ret === -1 )
echo "failed.\n";
else
{
$countOk = (int) $ret;
$countErr = count( $errors );
echo "done. Performed $countOk XIncludes, $countErr failures.\n";
}

// failures

if ( $countErr && ( $ac['XPOINTER_REPORTING'] == 'yes' || $ac['LANG'] == 'en' ) )
{
// Always report failures on doc-en.
// Failures on doc-en are fatal.

$output = $ac['STDERR_TO_STDOUT'] == 'yes' ? STDOUT : STDERR;
fprintf( $output , "\n");

foreach( $errors as $error )
fprintf( $output , "{$error->message}\n");

if ( $ac['LANG'] == 'en' )
errors_are_bad(1);
errors_are_bad( 1 );
}

// xinclides 1.1 fix up

$nodes = $xpath->query( "//*[@xml:id]" );
foreach( $nodes as $node )
{
$id = $node->getAttribute( "xml:id" );
$path = $node->getNodePath();

if ( $beforeIdPaths[ $id ] != $path )
$node->removeAttribute( "xml:id" );
}

flush();
}

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