Magento 2 validates most, if not all, of its XML configuration files via a schema document. If you’re dealing with someone else’s code and you need to jump to the source of a schema problems, here’s a debugging snippet.
#File: vendor/magento/framework/Config/Dom.php
public function validate($schemaFileName, &$errors = [])
{
if ($this->validationState->isValidationRequired()) {
$errors = $this->validateDomDocument($this->dom, $schemaFileName, $this->errorFormat);
//start debug
if(count($errors) > 0)
{
header('Content-Type: text/plain');
var_dump($errors);
var_dump($schemaFileName);
echo($this->dom->saveXml());
exit;
}
//end debug
return !count($errors);
}
return true;
}
Magento 2 validates the merged dom tree – this will output the error, the schema file that’s being violated, and the entire merged tree. With this, you should be able to pinpoint the problem node, and from there search your codebase for the incorrect XML file.