Permalink
Browse files

fixed XSD local paths

  • Loading branch information...
1 parent 73db693 commit 269651235ae830fe8d93800f3fc70c6142b8bbc4 @fabpot committed May 21, 2010
@@ -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);
}
@@ -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);
}
/**
@@ -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()

0 comments on commit 2696512

Please sign in to comment.