function load($in_CSSML, $in_type = 'string') { if (parent::isError($load = parent::load())) { return $load; } if ($in_type == 'file' && @file_exists($in_CSSML)) { $this->CSSMLDoc = $in_CSSML; } elseif ($in_type == 'string' && is_string($in_CSSML)) { $this->CSSMLDoc = 'arg:/_xml'; $this->arguments = array('/_xml' => $in_CSSML); } else { return PEAR::raiseError(null, XML_CSSML_INVALID_DATA, null, E_USER_WARNING, "Request data: {$in_CSSML}", 'XML_CSSML_Error', true); } $this->loaded = true; }
function load($in_CSSML, $in_type = 'string') { if (parent::isError($load = parent::load())) { return $load; } // If the CSSML data is already a DOM object (can tell by checking for root) if ($in_type == 'object' && get_class($in_CSSML) == 'DomDocument') { $this->CSSMLDoc = $in_CSSML; } elseif ($in_type == 'file' && @file_exists($in_CSSML)) { $this->CSSMLDoc = domxml_open_file($in_CSSML); } elseif ($in_type == 'string' && is_string($in_CSSML)) { $this->CSSMLDoc = domxml_open_mem($in_CSSML); } else { return PEAR::raiseError(null, XML_CSSML_INVALID_DATA, null, E_USER_WARNING, "Request data: {$in_CSSML}", 'XML_CSSML_Error', true); } if (get_class($this->CSSMLDoc) != 'DomDocument') { return PEAR::raiseError(null, XML_CSSML_INVALID_DOCUMENT, null, E_USER_WARNING, "Request data: {$in_CSSML}", 'XML_CSSML_Error', true); } $this->loaded = true; }
/** * Return a textual error message for an XML_CSSML error code. * * @param int $in_value error code * * @access public * @return string error message, or false if not error code */ function errorMessage($in_value) { // make the variable static so that it only has to do the defining on the first call static $errorMessages; // define the varies error messages if (!isset($errorMessages)) { $errorMessages = array(XML_CSSML_OK => 'no error', XML_CSSML_ERROR => 'unknown error', XML_CSSML_ALREADY_EXISTS => 'cssml document already loaded', XML_CSSML_NOT_LOADED => 'cssml document has not been loaded', XML_CSSML_INVALID_DATA => 'invalid cssml data to parse', XML_CSSML_INVALID_DOCUMENT => 'cssml domdocument could not be created', XML_CSSML_INVALID_FILE => 'output file does not exist'); } // If this is an error object, then grab the corresponding error code if (XML_CSSML::isError($in_value)) { $in_value = $in_value->getCode(); } // return the textual error message corresponding to the code return isset($errorMessages[$in_value]) ? $errorMessages[$in_value] : $errorMessages[XML_CSSML_ERROR]; }