src/snac/util/EADParser.php
/**
     * Validate a Directory of XML
     *
     * Loads all XML files from the given directory into PHP's libxml parser to check
     * for well-formedness or EAD schema validation.
     *
     * @param $eaddir string The directory to parse through
     * @param $fullValidate boolean optional Whether or not to use full Schema validation
     * @return array[] An array of errors, or empty array if no error
     */
Validate a Directory of XML
Loads all XML files from the given directory into PHP's libxml parser to check
for well-formedness or EAD schema validation.

@param $eaddir string The directory to parse through
@param $fullValidate boolean optional Whether or not to use full Schema validation
@return array[] An array of errors, or empty array if no error
Validate a Directory of XML Loads all XML files from the given directory into PHP ' s libxml parser to check for well - formedness or EAD schema validation . @param $eaddir string The directory to parse through @param $fullValidate boolean optional Whether or not to use full Schema validation @return array [] An array of errors or empty array if no error
private function validateDirectory($eaddir, $fullValidate = true) {
        $errors = [];
        try {
            libxml_use_internal_errors(true);
            if (is_dir($eaddir)) {
                if ($dh = opendir($eaddir)) {
                    while (($file = readdir($dh)) !== false) {
                        if ($file == '.' || $file == '..')
                            continue;
                        $this->logger->addDebug("Validating: $eaddir$file");
                        $xml = new \DOMDocument();
                        $xml->load($eaddir . $file);
                        if ($this->eadVersion == null)
                            $this->getEADVersion($xml);
                        if ($fullValidate) {
                            if ($this->eadVersion)
                                @$xml->schemaValidate(\snac\Config::$EAD_PARSER_DIR."/{$this->eadVersion}.xsd");
                        }
                        $errors = array_merge($errors, $this->getXMLErrors());
                    }
                    closedir($dh);
                    if ($this->eadVersion === false) {
                        array_push($errors, [
                            "filename" => "",
                            "message" => "Unrecognized EAD Namespace",
                            "code" => "",
                            "line" => ""
                        ]);
                    }
                }
            }
            $this->logger->addDebug("EAD Validation Complete");
        } catch (\Exception $e) {
            $this->cleanup($tmpdir);
            throw new \snac\exceptions\SNACEADParserException($e);
        }
        return $errors;
    }
private function validateDirectory ( $ eaddir , $ fullValidate = true ) { $ errors = [ ] ; try { libxml_use_internal_errors ( true ) ; if ( is_dir ( $ eaddir ) ) { if ( $ dh = opendir ( $ eaddir ) ) { while ( ( $ file = readdir ( $ dh ) ) !== false ) { if ( $ file == '.' || $ file == '..' ) continue ; $ this -> logger -> addDebug ( " Validating:  $ eaddir $ file " ) ; $ xml = new \ DOMDocument ( ) ; $ xml -> load ( $ eaddir . $ file ) ; if ( $ this -> eadVersion == null ) $ this -> getEADVersion ( $ xml ) ; if ( $ fullValidate ) { if ( $ this -> eadVersion ) @ $ xml -> schemaValidate ( \ snac \ Config :: $ EAD_PARSER_DIR . " / { $ this -> eadVersion } .xsd " ) ; } $ errors = array_merge ( $ errors , $ this -> getXMLErrors ( ) ) ; } closedir ( $ dh ) ; if ( $ this -> eadVersion === false ) { array_push ( $ errors , [ " filename " => " " , " message " => " Unrecognized EAD Namespace " , " code " => " " , " line " => " " ] ) ; } } } $ this -> logger -> addDebug ( " EAD Validation Complete " ) ; } catch ( \ Exception $ e ) { $ this -> cleanup ( $ tmpdir ) ; throw new \ snac \ exceptions \ SNACEADParserException ( $ e ) ; } return $ errors ; }
Validate a Directory of XML
 Loads all XML files from the given directory into PHP's libxml parser to check
 for well-formedness or EAD schema validation.
Validate a Directory of XML Loads all XML files from the given directory into PHP ' s libxml parser to check for well - formedness or EAD schema validation .
// Enable user error handling