I would like to update to give details on the fix to help others since I saw many posts that are specific to a custom extension or a 3rd party extension, but nothing generic to find and fix root cause for any extensions and other XML files that may used in di-compile/merge process. I am positive that will approach will identify any XML valuation errors since all XML files are validated against respective schema files when the site is in developer mode.
First hint was from Alan Strom's post here. I used similar code for the most part but it didn't work in Magento 2.3.4
version Dom.php
, so had to change the code and function location as well to make it work.
2nd clue is from a PHP post on SO here.
Working code sample that will save merged xml file to root of your site(/var/www/html/<my_site>
) so that you can look at the line numbers pointed in the errors to identify the root cause within minutes. This will work for any out of box, or 3rd party extension code as well.
Add this code to your version of Dom.php in
public static function validateDomDocument(\DOMDocument $dom, $schema, $errorFormat = self::ERROR_FORMAT_DEFAULT)
function before the return statement.
if(count($errors) > 0) {
var_dump($errors);
var_dump("schema_name");
var_dump($schema);
$dom->save('merged_xml_file.xml');
exit;
}
Make sure to comment/document any changes not to lose during upgrade and repeating this issue all over again!