error or simply return */ $GLOBALS['DOMIT_DOMException_mode'] = DOMIT_ONERROR_CONTINUE; /** * @global string Log file for errors */ $GLOBALS['DOMIT_DOMException_log'] = null; /** * A DOMIT! exception handling class * * @package domit-xmlparser * @author John Heinstein */ class DOMIT_DOMException { /** * Raises the specified exception * @param int The error number * @param string A string explanation of the error */ function raiseException($errorNum, $errorString) { if ($GLOBALS['DOMIT_DOMException_errorHandler'] != null) { call_user_func($GLOBALS['DOMIT_DOMException_errorHandler'], $errorNum, $errorString); } else { $errorMessageText = $errorNum . ' ' . $errorString; $errorMessage = 'Error: ' . $errorMessageText; if ((!isset($GLOBALS['DOMIT_ERROR_FORMATTING_HTML'])) || ($GLOBALS['DOMIT_ERROR_FORMATTING_HTML'] == true)) { $errorMessage = "

" . $errorMessage . "

"; } //log error to file if ((isset($GLOBALS['DOMIT_DOMException_log'])) && ($GLOBALS['DOMIT_DOMException_log'] != null)) { require_once(DOMIT_INCLUDE_PATH . 'php_file_utilities.php'); $logItem = "\n" . date('Y-m-d H:i:s') . 'DOMIT! Error ' . $errorMessageText; php_file_utilities::putDataToFile($GLOBALS['DOMIT_DOMException_log'], $logItem, 'a'); } switch ($GLOBALS['DOMIT_DOMException_mode']) { case DOMIT_ONERROR_CONTINUE: return; break; case DOMIT_ONERROR_DIE: die($errorMessage); break; } } } //raiseException /** * custom handler for DOM errors * @param object A reference to the custom error handler */ function setErrorHandler($method) { $GLOBALS['DOMIT_DOMException_errorHandler'] =& $method; } //setErrorHandler /** * Set error mode * @param int The DOM error mode */ function setErrorMode($mode) { $GLOBALS['DOMIT_DOMException_mode'] = $mode; } //setErrorMode /** * Set error mode * @param boolean True if errors should be logged * @param string Absolute or relative path to log file */ function setErrorLog($doLogErrors, $logfile) { if ($doLogErrors) { $GLOBALS['DOMIT_DOMException_log'] = $logfile; } else { $GLOBALS['DOMIT_DOMException_log'] = null; } } //setErrorLog } //DOMIT_DOMException /** * A class representing the DOM Implementation node * * @package domit-xmlparser * @author John Heinstein */ class DOMIT_DOMImplementation { function hasFeature($feature, $version = null) { if (strtoupper($feature) == 'XML') { if (($version == '1.0') || ($version == '2.0') || ($version == null)) { return true; } } return false; } //hasFeature /** * Creates a new DOMIT_Document node and appends a documentElement with the specified info * @param string The namespaceURI of the documentElement * @param string The $qualifiedName of the documentElement * @param Object A document type node * @return Object The new document fragment node */ function &createDocument($namespaceURI, $qualifiedName, &$docType) { $xmldoc = new DOMIT_Document(); $documentElement =& $xmldoc->createElementNS($namespaceURI, $qualifiedName); $xmldoc->setDocumentElement($documentElement); if ($docType != null) { $xmldoc->doctype =& $docType; } return $xmldoc; } //createDocument /** * Creates a new DOMIT_DocumentType node (not yet implemented!) * @param string The $qualifiedName * @param string The $publicID * @param string The $systemID * @return Object The new document type node */ function &createDocumentType($qualifiedName, $publicID, $systemID) { //not yet implemented DOMIT_DOMException::raiseException(DOMIT_NOT_SUPPORTED_ERROR, ('Method createDocumentType is not yet implemented.')); } //createDocumentType } //DOMIT_DOMImplementation ?>