didou Fri Jul 30 09:51:44 2004 EDT
Modified files:
/phpdoc/en/reference/xslt/functions xslt-set-error-handler.xml
xslt-set-object.xml
xslt-set-sax-handlers.xml
Log:
document xslt_set_option()
better OO example for xslt_set_sax_handlers() using xslt_set_option()
tell xslt_set_error_handler() users to use xslt_set_option() instead of passing an
array with a reference to the object
http://cvs.php.net/diff.php/phpdoc/en/reference/xslt/functions/xslt-set-error-handler.xml?r1=1.3&r2=1.4&ty=u
Index: phpdoc/en/reference/xslt/functions/xslt-set-error-handler.xml
diff -u phpdoc/en/reference/xslt/functions/xslt-set-error-handler.xml:1.3
phpdoc/en/reference/xslt/functions/xslt-set-error-handler.xml:1.4
--- phpdoc/en/reference/xslt/functions/xslt-set-error-handler.xml:1.3 Wed May 19
16:47:51 2004
+++ phpdoc/en/reference/xslt/functions/xslt-set-error-handler.xml Fri Jul 30
09:51:43 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/xslt.xml, last change in rev 1.1 -->
<refentry id="function.xslt-set-error-handler">
<refnamediv>
@@ -102,8 +102,8 @@
</example>
</para>
<para>
- Instead of a function name, an array containing an object reference and
- a method name can also be supplied.
+ See also <function>xslt_set_object</function> if you want to use an
+ object method as handler.
</para>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/xslt/functions/xslt-set-object.xml?r1=1.1&r2=1.2&ty=u
Index: phpdoc/en/reference/xslt/functions/xslt-set-object.xml
diff -u phpdoc/en/reference/xslt/functions/xslt-set-object.xml:1.1
phpdoc/en/reference/xslt/functions/xslt-set-object.xml:1.2
--- phpdoc/en/reference/xslt/functions/xslt-set-object.xml:1.1 Wed May 19 12:01:20
2004
+++ phpdoc/en/reference/xslt/functions/xslt-set-object.xml Fri Jul 30 09:51:43
2004
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='iso-8859-1'?>
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
<refentry id="function.xslt-set-object">
<refnamediv>
<refname>xslt_set_object</refname>
@@ -11,12 +11,55 @@
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>xslt_set_object</methodname>
- <methodparam><type>resource</type><parameter>parser</parameter></methodparam>
+ <methodparam><type>resource</type><parameter>processor</parameter></methodparam>
<methodparam><type>object</type><parameter>obj</parameter></methodparam>
</methodsynopsis>
+ <para>
+ This function allows to use the <parameter>processor</parameter> inside
+ an <parameter>object</parameter> and to resolve all callback functions
+ in it.
+ </para>
+ <para>
+ The callback functions can be declared with
+ <function>xml_set_sax_handlers</function>,
+ <function>xslt_set_scheme_handlers</function> or
+ <function>xslt_set_error_handler</function> and are assumed to be methods
+ of <parameter>object</parameter>.
+ </para>
+ <para>
+ <example>
+ <title>Using your own error handler as a method</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
- &warn.undocumented.func;
+class my_xslt_processor {
+
+ var $_xh; // our XSLT processor
+
+ function my_xslt_processor()
+ {
+ $this->_xh = xslt_create();
+ // Make $this object the callback resolver
+ xslt_set_object($this->_xh, $this);
+
+ // Let's handle the errors
+ xslt_set_error_handler($this->_xh, "my_xslt_error_handler");
+ }
+
+ function my_xslt_error_handler($handler, $errno, $level, $info)
+ {
+ // for now, let's just see the arguments
+ var_dump(func_get_args());
+ }
+}
+
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
</refsect1>
</refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/xslt/functions/xslt-set-sax-handlers.xml?r1=1.5&r2=1.6&ty=u
Index: phpdoc/en/reference/xslt/functions/xslt-set-sax-handlers.xml
diff -u phpdoc/en/reference/xslt/functions/xslt-set-sax-handlers.xml:1.5
phpdoc/en/reference/xslt/functions/xslt-set-sax-handlers.xml:1.6
--- phpdoc/en/reference/xslt/functions/xslt-set-sax-handlers.xml:1.5 Mon Jul 26
07:39:15 2004
+++ phpdoc/en/reference/xslt/functions/xslt-set-sax-handlers.xml Fri Jul 30
09:51:43 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.5 $ -->
+<!-- $Revision: 1.6 $ -->
<!-- splitted from ./en/functions/xslt.xml, last change in rev 1.29 -->
<refentry id='function.xslt-set-sax-handlers'>
<refnamediv>
@@ -237,9 +237,8 @@
</example>
</para>
<para>
- Every values of the <parameter>handlers</parameter> array is either a
- string containing the function name, or an array in the following format:
- <command>array(&$obj, "method")</command>.
+ You can also use <function>xslt_set_object</function> if you want to
+ implement your handlers in an object.
</para>
<para>
<example>
@@ -252,6 +251,30 @@
var $buffer, $tag, $attrs;
+ var $_xh;
+
+ function data_sax_handler($xml, $xsl)
+ {
+ // our xslt resource
+ $this->_xh = xslt_create();
+
+ xslt_set_object($this->_xs, $this);
+
+ // configure sax handlers
+ $handlers = array(
+ "document" => array('start_document', 'end_document'),
+ "element" => array('start_element', 'end_element'),
+ "character" => 'characters'
+ );
+
+ xslt_set_sax_handlers($this->_xh, $handlers);
+
+ xslt_process($this->_xh, 'arg:/_xml', 'arg:/_xsl', NULL, array("/_xml"=>$xml,
"/_xsl"=>$xsl));
+ xslt_free($this->_xh);
+
+
+ }
+
function start_document()
{
// start reading the document
@@ -287,27 +310,7 @@
}
-// our xsl handle
-$xh = xslt_create();
-
-$handler = new data_sax_handler();
-// configure sax handlers
-$handlers = array(
- "document" => array(
- array(&$handler, 'start_document'),
- array(&$handler, 'end_document')
-),
- "element" => array(
- array(&$handler, 'start_element'),
- array(&$handler, 'end_element')
-),
- "character" => array(&$handler, 'characters')
-);
-
-xslt_set_sax_handlers($xh, $handlers);
-
-xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, array("/_xml"=>$xml,
"/_xsl"=>$xsl));
-xslt_free($xh);
+$exec = new data_sax_handler($xml, $xsl);
?>
]]>