Syfmony2 developers have solved this problem. It is not freakin 'clean, but will do:
function validateSchema(\DOMDocument $dom) { $tmpfiles = array(); $imports = ''; foreach ($this->schemaLocations as $namespace => $location) { $parts = explode('/', $location); if (preg_match('#^phar://#i', $location)) { $tmpfile = tempnam(sys_get_temp_dir(), 'sf2'); if ($tmpfile) { file_put_contents($tmpfile, file_get_contents($location)); $tmpfiles[] = $tmpfile; $parts = explode('/', str_replace('\\', '/', $tmpfile)); } } $drive = '\\' === DIRECTORY_SEPARATOR ? array_shift($parts).'/' : ''; $location = 'file:///'.$drive.implode('/', array_map('rawurlencode', $parts)); $imports .= sprintf(' <xsd:import namespace="%s" schemaLocation="%s" />' . PHP_EOL, $namespace, $location); } $source = <<<EOF <?xml version="1.0" encoding="utf-8" ?> <xsd:schema xmlns="http://symfony.com/schema" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://symfony.com/schema" elementFormDefault="qualified"> <xsd:import namespace="http://www.w3.org/XML/1998/namespace"/> $imports </xsd:schema> EOF ; $current = libxml_use_internal_errors(true); $valid = $dom->schemaValidateSource($source); foreach ($tmpfiles as $tmpfile) { @unlink($tmpfile); } if (!$valid) { throw new \InvalidArgumentException(implode("\n", $this->getXmlErrors())); } libxml_use_internal_errors($current); }
source share