downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

xslt_set_log> <xslt_set_encoding
[edit] Last updated: Fri, 17 May 2013

view this page in

xslt_set_error_handler

(PHP 4 >= 4.0.4)

xslt_set_error_handlerEstablecer un manejador de error para un procesador XSLT

Descripción

void xslt_set_error_handler ( resource $xh , mixed $handler )

Establece una función de manejador de error para el procesador XSLT dado por xh, Esta función se llamará cuando se produce un error en la transformación XSLT (esta función también es llamada para avisos).

Parámetros

xh

El identificador de enlace del procesador XSLT, creado con xslt_create().

handler

La función de usuario necesita aceptar cuatro parámetros: el procesador XSLT, el nivel de error, el código de error y un array de mensajes. La función se puede mostrar como:

error_handler ( resource $xh , int $error_level , int $error_code , array $messages )

Valores devueltos

No devuelve ningún valor.

Ejemplos

Ejemplo #1 Ejemplo de xslt_set_error_handler()

<?php

// Nuestro manejador de errores XSLT
function xslt_error_handler($handler$errno$level$info)
{
  
// por ahora, vamos a ver sólo los argumentos
  
var_dump(func_get_args());
}

// Contenido XML :
$xml='<?xml version="1.0"?>
<para>
 oops, escrita mal la etiqueta de cierre
</pata>'
;

// Contenido XSL :
$xsl='<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
   <strong><xsl:value-of select="para"/></strong>
</xsl:template>
</xsl:stylesheet>'
;

$xh xslt_create();

xslt_set_error_handler($xh"xslt_error_handler");

echo 
xslt_process($xh'arg:/_xml''arg:/_xsl',
                  
NULL, array("/_xml" => $xml"/_xsl" => $xsl));

?>

El resultado del ejemplo sería algo similar a:

array(4) {
  [0]=>
  resource(1) of type (XSLT Processor)
  [1]=>
  int(3)
  [2]=>
  int(0)
  [3]=>
  array(6) {
    ["msgtype"]=>
    string(5) "error"
    ["code"]=>
    string(1) "2"
    ["module"]=>
    string(9) "Sablotron"
    ["URI"]=>
    string(9) "arg:/_xml"
    ["line"]=>
    string(1) "4"
    ["msg"]=>
    string(34) "XML parser error 7: mismatched tag"
  }
}

Ver también

  • xslt_set_object() - Establece el objeto en que resolver funciones de devolución de llamada Si desea utilizar un método de objeto como manejador



add a note add a note User Contributed Notes xslt_set_error_handler - [2 notes]
up
0
jocke n0spam at selincite dot com
10 years ago
Addition to the last note. in the array I have used array($this, "myMethod") to make it use an internal function in a class.
I reckon this is how it is meant to work (not tested)
$myObj = new MyObj()
xslt_set_error_handler_($xh, array($myObj, "myErrorMethod"));
up
0
Anonymous
10 years ago
To set the error handler to the instance of an object, use the:

xslt_set_error_handler($xh, array($obj, $method))

syntax.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites