| @@ 16-27 (lines=12) @@ | ||
| 13 | { |
|
| 14 | protected $contentTypes = array('text/xml', 'application/xml'); |
|
| 15 | ||
| 16 | public function doValidation(Response $response) |
|
| 17 | { |
|
| 18 | $domDocument = new \DOMDocument(); |
|
| 19 | $success = @$domDocument->loadXML((string) $response->getBody()); |
|
| 20 | ||
| 21 | if (!$success) { |
|
| 22 | $lastError = libxml_get_last_error(); |
|
| 23 | ||
| 24 | throw new ValidationFailedException('The xml file ' . $response->getUri() . ' is not well formed (last error: ' . |
|
| 25 | str_replace("\n", '', $lastError->message) . ').'); |
|
| 26 | } |
|
| 27 | } |
|
| 28 | } |
|
| 29 | ||
| @@ 42-53 (lines=12) @@ | ||
| 39 | } |
|
| 40 | } |
|
| 41 | ||
| 42 | private function validateBody($body, $filename, $isIndex = true) |
|
| 43 | { |
|
| 44 | $dom = new \DOMDocument(); |
|
| 45 | @$dom->loadXML($body); |
|
| 46 | ||
| 47 | $valid = @$dom->schemaValidate($this->getSchema($isIndex)); |
|
| 48 | ||
| 49 | if (!$valid) { |
|
| 50 | $lastError = libxml_get_last_error(); |
|
| 51 | throw new ValidationFailedException( |
|
| 52 | 'The given sitemap file (' . $filename . ') did not validate against the sitemap schema (last error: ' . str_replace("\n", '', $lastError->message) . ').'); |
|
| 53 | } |
|
| 54 | } |
|
| 55 | ||
| 56 | protected function doValidation(Response $response) |
|