protected static function conf_initialize () { if (!defined('COREN_CONFIGURATION_FILE')) throw new coren_exception_config_/*!!!*/("Config file is not set."); self::$conf_document = new DOMDocument(self::conf_xml_version, self::conf_xml_encoding); $old_errors = libxml_use_internal_errors(true); $loaded = self::$conf_document->load(COREN_CONFIGURATION_FILE, LIBXML_COMPACT | LIBXML_XINCLUDE); libxml_use_internal_errors($old_errors); if (!$loaded) { $error = libxml_get_last_error(); if (is_null($error)) throw new coren_exception_configuration_file("Failed to load configuration file with unknown error."); else throw new coren_exception_configuration_file("Failed to load configuration file: " . $error->message); } self::$conf_xpath = new DOMXPath(self::$conf_document); self::$conf_xpath->registerNamespace("coren", self::conf_xml_ns_uri); //!!!todo: 2. make node selectable for script via constants (maybe some special 'id/name' attribute?). //!!!todo: 3. make required(!) attribute coren:target, which must have value 'php'? $query = "//coren:configuration";//NB: it can be non-root.(???) $nodes = self::$conf_xpath->query($query); /*xcc*/ if ($nodes->length > 1) throw new coren_exception_configuration_element("Only one top-level element allowed, but there is {$nodes->length}."); if ($nodes->length < 1) throw new coren_exception_configuration_element("At least one top-level element required, but there are none."); self::$conf_element = $nodes->item(0); }