public function convert(DOMDocument $document)
{
if (!file_exists($this->stylesheet)) {
throw new InvalidArgumentException('stylesheetPath', "Conversion of XML document cannot be performed, file '{$this->stylesheet}' does not exist.");
}
$processor = $this->getXSLTProcessor();
$this->startRecordingErrors();
$document = $processor->transformToDoc($document);
$errors = $this->collectErrors();
if (!empty($errors)) {
throw new InvalidArgumentException('$xmlDoc', 'Transformation of XML content failed: ' . implode("\n", $errors));
}
return $document;
}