/** * Will validate a DOM document against a schema file. Will return TRUE if validation * passes, FALSE otherwise. * * @param \DOMDocument $domDocument DOM document to validate * @param string $schemaFile The specific schema file to validate against * @param boolean $failOnErrors If the validation should fail on error (optional) * * @return void * * @throws \AppserverIo\Configuration\ConfigurationException If $failOnErrors is set to true an exception will be thrown on errors */ public function validateXml(\DOMDocument $domDocument, $schemaFile, $failOnErrors = false) { // activate internal error handling, necessary to catch errors with libxml_get_errors() libxml_use_internal_errors(true); // prepare result and error messages $errorMessages = array(); // validate the configuration file with the schema if ($domDocument->schemaValidate($schemaFile) === false) { // collect the errors and return as a failure $errorMessages = ConfigurationUtils::singleton()->prepareErrorMessages(libxml_get_errors()); // if we have to fail on errors we might do so here if ($failOnErrors === true) { throw new ConfigurationException(reset($errorMessages)); } } }
/** * Initializes the configuration utils instance to test. * * @return void */ public function setUp() { $this->configurationUtils = ConfigurationUtils::singleton(); }