Esempio n. 1
0
File: odt.php Progetto: bmdevel/ezc
 /**
  * Performs the actual validation on the given $document.
  *
  * Returns true on success, an array of errors otherwise.
  * 
  * @param DOMDocument $document 
  * @return array(ezcDocumentValidationError)|true
  */
 private function performValidation(DOMDocument $document)
 {
     $document->relaxNGValidate(dirname(__FILE__) . '/odt/data/odf_1.2.rng');
     // Get all errors
     $xmlErrors = libxml_get_errors();
     $errors = array();
     foreach ($xmlErrors as $error) {
         $errors[] = ezcDocumentValidationError::createFromLibXmlError($error);
     }
     libxml_clear_errors();
     return count($errors) ? $errors : true;
 }
Esempio n. 2
0
 /**
  * Validate the input string
  *
  * Validate the input string against the specification of the current
  * document format.
  *
  * Returns true, if the validation succeded, and an array with
  * ezcDocumentValidationError objects otherwise.
  *
  * @param string $string
  * @return mixed
  */
 public function validateString($string)
 {
     $oldSetting = libxml_use_internal_errors(true);
     libxml_clear_errors();
     $document = new DOMDocument();
     $document->loadXml($string);
     $document->relaxNGValidate($this->options->relaxNgSchema);
     // Get all errors
     $xmlErrors = libxml_get_errors();
     $errors = array();
     foreach ($xmlErrors as $error) {
         $errors[] = ezcDocumentValidationError::createFromLibXmlError($error);
     }
     libxml_clear_errors();
     libxml_use_internal_errors($oldSetting);
     return count($errors) ? $errors : true;
 }
Esempio n. 3
0
 /**
  * Validate the input string
  *
  * Validate the input string against the specification of the current
  * document format.
  *
  * Returns true, if the validation succeded, and an array with
  * ezcDocumentValidationError objects otherwise.
  *
  * @param string $string
  * @return mixed
  */
 public function validateString($string)
 {
     $oldSetting = libxml_use_internal_errors(true);
     libxml_clear_errors();
     $document = new DOMDocument();
     $document->loadXml($string);
     $document->schemaValidate(dirname(__FILE__) . '/xhtml/schema/xhtml1-transitional.xsd');
     // Get all errors
     $xmlErrors = libxml_get_errors();
     $errors = array();
     foreach ($xmlErrors as $error) {
         $errors[] = ezcDocumentValidationError::createFromLibXmlError($error);
     }
     libxml_clear_errors();
     libxml_use_internal_errors($oldSetting);
     return count($errors) ? $errors : true;
 }