There may be cases where a null $result is legitimate, in this case add a test for non-zero xlst_errno:
<?php
$xh = xslt_create();
$result = xslt_process($xh, 'dog.xml', 'pets.xsl');
if (!$result && xslt_errno($xh) > 0) {
die(sprintf("Cannot process XSLT document [%d]: %s",
xslt_errno($xh), xslt_error($xh)));
}
echo $result;
xslt_free($xh);
?>
xslt_error
(PHP 4 >= 4.0.3)
xslt_error — Restituisce una stringa di errore
Descrizione
string xslt_error
( resource
$xh
)Restituisce una stringa che descrive l'ultimo errore che si รจ verificato sul processore XSLT passato.
Valori restituiti
Restituisce il messaggio di errore, come una stringa.
Esempi
Example #1 Gestione degli errori utilizzando le funzioni xslt_error() e xslt_errno().
<?php
$xh = xslt_create();
$result = xslt_process($xh, 'dog.xml', 'pets.xsl');
if (!$result) {
die(sprintf("Impossibile elaborare il documento XSLT [%d]: %s",
xslt_errno($xh), xslt_error($xh)));
}
echo $result;
xslt_free($xh);
?>
mikes at ayeltd dot biz ¶
9 years ago
