original_string: public function validate($schemaFile) {
          if (!$this->xmlString)
              throw new XmlParserException("attempting to validate before parsing");
              
          if (!extension_loaded("DOM")) {
              trigger_error("DOM extension not loaded, will not validate XML", E_USER_NOTICE);
              return $this;
          }
  
          libxml_use_internal_errors(true);
          $document = new \DOMDocument();
          $document->loadXML($this->xmlString);
          
          if (!$document->schemaValidate($schemaFile)) {
              $msg = "The following XML errors occurred while validating:";
              foreach (libxml_get_errors() as $error)
                  $msg .= "\n" . $error->message;
              throw new XmlParserException($msg);
          }
  
          return $this;
      }
code: public function validate($schemaFile) {
          if (!$this->xmlString)
              throw new XmlParserException("attempting to validate before parsing");
              
          if (!extension_loaded("DOM")) {
              trigger_error("DOM extension not loaded, will not validate XML", E_USER_NOTICE);
              return $this;
          }
  
          libxml_use_internal_errors(true);
          $document = new \DOMDocument();
          $document->loadXML($this->xmlString);
          
          if (!$document->schemaValidate($schemaFile)) {
              $msg = "The following XML errors occurred while validating:";
              foreach (libxml_get_errors() as $error)
                  $msg .= "\n" . $error->message;
              throw new XmlParserException($msg);
          }
  
          return $this;
      }
code_tokens: public function validate ( $ schemaFile ) { if ( ! $ this -> xmlString ) throw new XmlParserException ( "attempting to validate before parsing" ) ; if ( ! extension_loaded ( "DOM" ) ) { trigger_error ( "DOM extension not loaded, will not validate XML" , E_USER_NOTICE ) ; return $ this ; } libxml_use_internal_errors ( true ) ; $ document = new \ DOMDocument ( ) ; $ document -> loadXML ( $ this -> xmlString ) ; if ( ! $ document -> schemaValidate ( $ schemaFile ) ) { $ msg = "The following XML errors occurred while validating:" ; foreach ( libxml_get_errors ( ) as $ error ) $ msg .= "\n" . $ error -> message ; throw new XmlParserException ( $ msg ) ; } return $ this ; }
docstring: Validates XML using a schema.
  @param string $schemaFile
  @return XmlParser
docstring_tokens: Validates XML using a schema .