Changeset 842
- Timestamp:
- 08/15/07 18:10:27 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/websites/xml/stubXMLPostInterceptor.php
r839 r842 72 72 $xslProcessor->setXMLDocument($this->createXMLSkinDocument($skin)); 73 73 $resultXSL = $xslProcessor->transformToDoc(); 74 $resultXSL->xinclude();74 @$resultXSL->xinclude(); 75 75 76 76 // now we use the created xsl to transform the xml document created by the application trunk/src/main/php/net/stubbles/xml/stubXMLXIncludeStreamWrapper.php
r837 r842 7 7 * @subpackage xml 8 8 */ 9 stubClassLoader::load('net.stubbles.xml.xsl.stubXSLProcessor'); 9 stubClassLoader::load('net.stubbles.xml.stubXMLException', 10 'net.stubbles.xml.xsl.stubXSLProcessor' 11 ); 10 12 /** 11 13 * Class to wrap xincludes transparently as stream wrapper. … … 21 23 * @var bool 22 24 */ 23 private static $registered = false;25 private static $registered = false; 24 26 /** 25 27 * the xsl processor to use for the transformation … … 67 69 /** 68 70 * registers the class as stream wrapper for the sml protocol 71 * 72 * @throws stubXMLException 69 73 */ 70 74 public static function register() … … 94 98 * sets the cache path to use 95 99 * 96 * @param string $cachePath 100 * @param string $cachePath 101 * @throws stubException 97 102 */ 98 103 public static function setCachePath($cachePath) … … 124 129 * @param string $opened_path full path that was actually opened 125 130 * @return bool 131 * @throws stubXMLException 126 132 */ 127 133 public function stream_open($path, $mode, $options, $opened_path) … … 165 171 /** 166 172 * processes the file and creates a cached version of it 173 * 174 * @throws stubXMLException 167 175 */ 168 176 protected function processFile() … … 170 178 $previousErrorHandling = libxml_use_internal_errors(true); 171 179 $xslProcessor = clone self::$xslProcessor; 172 $xslProcessor->setXMLDocument(DOMDocument::load($this->fileName)); 180 $domDocument = DOMDocument::load($this->fileName); 181 if (false === $domDocument) { 182 $this->handleErrors(libxml_get_errors(), $previousErrorHandling); 183 libxml_clear_errors(); 184 } 185 186 $xslProcessor->setXMLDocument($domDocument); 173 187 $resultDoc = $xslProcessor->transformToDoc(); 174 188 // we save first to prevent a infinite loop in case of recursions … … 179 193 unlink($this->cachedFileName); 180 194 libxml_clear_errors(); 181 foreach ($errors as $error) { 182 $message = trim($error->message) . (($error->file) ? (' in file ' . $error->file) : ('')) . ' on line ' . $error->line . ' in column ' . $error->column; 183 switch ($error->level) { 184 case LIBXML_ERR_WARNING: 185 $this->appendError($resultDoc, 'warning', $message); 186 break; 187 case LIBXML_ERR_ERROR: 188 $this->appendError($resultDoc, 'error', $message); 189 break; 190 case LIBXML_ERR_FATAL: 191 throw new stubXMLException('Fatal error: ' . $message); 192 } 193 } 195 $this->handleErrors($errors, $previousErrorHandling); 194 196 } 195 197 … … 199 201 } 200 202 $resultDoc->save($this->cachedFileName); 203 } 204 205 /** 206 * handles libxml errors 207 * 208 * @param array $errors 209 * @throws stubXMLException 210 */ 211 protected function handleErrors(array $errors, $previousErrorHandling) 212 { 213 foreach ($errors as $error) { 214 $message = trim($error->message) . (($error->file) ? (' in file ' . $error->file) : ('')) . ' on line ' . $error->line . ' in column ' . $error->column; 215 switch ($error->level) { 216 case LIBXML_ERR_WARNING: 217 $this->appendError($resultDoc, 'warning', $message); 218 break; 219 case LIBXML_ERR_ERROR: 220 $this->appendError($resultDoc, 'error', $message); 221 break; 222 case LIBXML_ERR_FATAL: 223 libxml_use_internal_errors($previousErrorHandling); 224 throw new stubXMLException('Fatal error: ' . $message); 225 } 226 } 201 227 } 202 228
