note 32388 deleted from function.xslt-set-error-handler by didou

From: Date: Wed, 19 May 2004 19:46:36 +0000
Subject: note 32388 deleted from function.xslt-set-error-handler by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-69845@lists.php.net to get a copy of this message
Note Submitter: simen@NODAMNSPAM.bleed.no ---- I've been trying to create a consistent way of handling xslt errors, and I've come up with a simple solution: (Note: the messages array is not a normal array so a simple conversion is performed) function xslt_trap_error($parser, $num, $level, $messages) { global $xslt_trapped_errors; if (is_array($messages)) { foreach ($messages as $key => $value) { $data[$key] = $value; } $xslt_trapped_errors = sprintf("%s in %s on line %d", $data['msg'], $data['URI'], $data['line']); } else { $xslt_trapped_errors = $messages; } } Then in your parsing function: global $xslt_trapped_errors; @$result = xslt_process($xh, $xml, $xsl, null); if (!$result) { echo $xslt_trapped_errors; } else { return $result; }

« previous php.notes (#69845) next »