Skip to content

Commit

Permalink
fixed XSD local paths
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed May 21, 2010
1 parent 73db693 commit 2696512
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Expand Up @@ -250,6 +250,10 @@ protected function validateSchema($dom, $file)

$imports = '';
foreach ($schemaLocations as $namespace => $location) {
$parts = explode('/', $location);
$drive = '\\' === DIRECTORY_SEPARATOR ? array_shift($parts) : '';
$location = 'file:///'.$drive.implode('/', array_map('rawurlencode', $parts));

$imports .= sprintf(' <xsd:import namespace="%s" schemaLocation="%s" />'."\n", $namespace, $location);
}

Expand All @@ -266,11 +270,11 @@ protected function validateSchema($dom, $file)
EOF
;

libxml_use_internal_errors(true);
$current = libxml_use_internal_errors(true);
if (!$dom->schemaValidateSource($source)) {
throw new \InvalidArgumentException(implode("\n", $this->getXmlErrors()));
}
libxml_use_internal_errors(false);
libxml_use_internal_errors($current);
}

/**
Expand Down
10 changes: 7 additions & 3 deletions src/Symfony/Components/Routing/Loader/XmlFileLoader.php
Expand Up @@ -138,11 +138,15 @@ protected function loadFile($path)
*/
protected function validate($dom, $file)
{
libxml_use_internal_errors(true);
if (!$dom->schemaValidate(__DIR__.'/schema/routing/routing-1.0.xsd')) {
$parts = explode('/', str_replace('\\', '/', __DIR__.'/schema/routing/routing-1.0.xsd'));
$drive = '\\' === DIRECTORY_SEPARATOR ? array_shift($parts) : '';
$location = 'file:///'.$drive.implode('/', array_map('rawurlencode', $parts));

$current = libxml_use_internal_errors(true);
if (!$dom->schemaValidate($location)) {
throw new \InvalidArgumentException(implode("\n", $this->getXmlErrors()));
}
libxml_use_internal_errors(false);
libxml_use_internal_errors($current);
}

protected function getXmlErrors()
Expand Down

0 comments on commit 2696512

Please sign in to comment.