mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
added docs for xslt_backend_XXX,
see also for err(no|or) improved the documentation about the error handler function added an example about passing PHP variables to XSL sheets # thanks to all the notes submitters # I'm under win, I'll make test soon after the commit git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@159074 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
a285c00fcd
commit
448bb6c1f9
7 changed files with 217 additions and 20 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version='1.0' encoding='iso-8859-1'?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.xslt-backend-info">
|
||||
<refnamediv>
|
||||
<refname>xslt_backend_info</refname>
|
||||
|
@ -13,9 +13,16 @@
|
|||
<type>string</type><methodname>xslt_backend_info</methodname>
|
||||
<void/>
|
||||
</methodsynopsis>
|
||||
|
||||
&warn.undocumented.func;
|
||||
|
||||
<para>
|
||||
<function>xslt_backend_info</function> returns a string with
|
||||
information about the compilation setting of the backend
|
||||
or an error string when no information available.
|
||||
</para>
|
||||
<para>
|
||||
See also
|
||||
<function>xslt_backend_name</function> and
|
||||
<function>xslt_backend_version</function>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<?xml version='1.0' encoding='iso-8859-1'?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.xslt-backend-name">
|
||||
<refnamediv>
|
||||
<refname>xslt_backend_name</refname>
|
||||
<refpurpose>
|
||||
Returns the name of the Backend
|
||||
Returns the name of the backend
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
|
@ -13,9 +13,29 @@
|
|||
<type>string</type><methodname>xslt_backend_name</methodname>
|
||||
<void/>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
<function>xslt_backend_name</function> will always return
|
||||
<productname>Sablotron</productname>.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>xslt_backend_name</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
&warn.undocumented.func;
|
||||
echo xslt_backend_name(); // Sablotron
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
See also
|
||||
<function>xslt_backend_info</function> and
|
||||
<function>xslt_backend_version</function>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<?xml version='1.0' encoding='iso-8859-1'?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.xslt-backend-version">
|
||||
<refnamediv>
|
||||
<refname>xslt_backend_version</refname>
|
||||
<refpurpose>
|
||||
Returns the version number of Sablotron (if available)
|
||||
Returns the version number of Sablotron
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
|
@ -13,9 +13,30 @@
|
|||
<type>string</type><methodname>xslt_backend_version</methodname>
|
||||
<void/>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
<function>xslt_backend_version</function> returns the version
|
||||
number of <productname>Sablotron</productname> if available,
|
||||
&false otherwise.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>xslt_backend_version</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
&warn.undocumented.func;
|
||||
echo xslt_backend_version(); // 0.98 for example
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
See also
|
||||
<function>xslt_backend_name</function> and
|
||||
<function>xslt_backend_info</function>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<!-- splitted from ./en/functions/xslt.xml, last change in rev 1.3 -->
|
||||
<refentry id="function.xslt-errno">
|
||||
<refnamediv>
|
||||
|
@ -16,6 +16,9 @@
|
|||
Returns an error code describing the last error that occurred on the
|
||||
passed XSLT processor.
|
||||
</para>
|
||||
<para>
|
||||
See also <function>xslt_error</function>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
|
|
@ -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.3 -->
|
||||
<refentry id="function.xslt-error">
|
||||
<refnamediv>
|
||||
|
@ -41,6 +41,9 @@ xslt_free($xh);
|
|||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
See also <function>xslt_errno</function>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.12 $ -->
|
||||
<!-- $Revision: 1.13 $ -->
|
||||
<!-- splitted from ./en/functions/xslt.xml, last change in rev 1.3 -->
|
||||
<refentry id="function.xslt-process">
|
||||
<refnamediv>
|
||||
|
@ -168,11 +168,67 @@ xslt_free($xh);
|
|||
<para>
|
||||
Finally, the last argument to the <function>xslt_process</function>
|
||||
function represents an array for any top-level parameters that you want to
|
||||
pass to the XSLT document. These parameters can then be accessed within
|
||||
pass to the XSLT document. These parameters can then be accessed within
|
||||
your XSL files using the <xsl:param name="parameter_name">
|
||||
instruction. The parameters must be UTF-8 encoded and their values will be
|
||||
interpreted as strings by the Sablotron processor. In other words - you
|
||||
cannot pass node-sets as parameters to the XSLT document.
|
||||
interpreted as strings by the <productname>Sablotron</productname> processor.
|
||||
In other words - you cannot pass node-sets as parameters to the XSLT document.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title></title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
// XML string
|
||||
$xml = '<?xml version="1.0"?>
|
||||
<para>
|
||||
change me
|
||||
</para>';
|
||||
|
||||
// XSL string
|
||||
$xsl = '
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
<xsl:output method="html" encoding="ISO-8859-1" indent="no"
|
||||
omit-xml-declaration="yes" media-type="text/html"/>
|
||||
<xsl:param name="myvar"/>
|
||||
<xsl:param name="mynode"/>
|
||||
<xsl:template match="/">
|
||||
My PHP variable : <xsl:value-of select="$myvar"/><br />
|
||||
My node set : <xsl:value-of select="$mynode"/>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>';
|
||||
|
||||
|
||||
$xh = xslt_create();
|
||||
|
||||
// the second parameter will be interpreted as a string
|
||||
$parameters = array (
|
||||
'myvar' => 'test',
|
||||
'mynode' => '<foo>bar</foo>'
|
||||
);
|
||||
|
||||
$arguments = array (
|
||||
'/_xml' => $xml,
|
||||
'/_xsl' => $xsl
|
||||
);
|
||||
|
||||
echo xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments, $parameters);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
this will produce:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
My PHP variable : test<br>
|
||||
My node set : <foo>bar</foo>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
¬e.xslt.windows;
|
||||
</refsect1>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<!-- $Revision: 1.3 $ -->
|
||||
<!-- splitted from ./en/functions/xslt.xml, last change in rev 1.1 -->
|
||||
<refentry id="function.xslt-set-error-handler">
|
||||
<refnamediv>
|
||||
|
@ -14,9 +14,96 @@
|
|||
<methodparam><type>mixed</type><parameter>handler</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Set an error handler function for the XSLT processor given by <parameter>xh</parameter>,
|
||||
this function will be called whenever an error occurs in the XSLT transformation
|
||||
(this function is also called for notices).
|
||||
Set an error handler function for the XSLT processor given by
|
||||
<parameter>xh</parameter>, this function will be called whenever an
|
||||
error occurs in the XSLT transformation (this function is also called
|
||||
for notices).
|
||||
</para>
|
||||
<para>
|
||||
The user function needs to accept four parameters: the XSLT processor,
|
||||
the error level, the error code and an array of messages. The function
|
||||
can be shown as:
|
||||
<methodsynopsis>
|
||||
<methodname><replaceable>error_handler</replaceable></methodname>
|
||||
<methodparam><type>resource</type><parameter>xh</parameter></methodparam>
|
||||
<methodparam><type>int</type><parameter>error_level</parameter></methodparam>
|
||||
<methodparam><type>int</type><parameter>error_code</parameter></methodparam>
|
||||
<methodparam><type>array</type><parameter>messages</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>xslt_set_error_handler</function> Example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
// Our XSLT error handler
|
||||
function xslt_error_handler($handler, $errno, $level, $info)
|
||||
{
|
||||
// for now, let's just see the arguments
|
||||
var_dump(func_get_args());
|
||||
}
|
||||
|
||||
// XML content :
|
||||
$xml='<?xml version="1.0"?>
|
||||
<para>
|
||||
oops, I misspelled the closing tag
|
||||
</pata>';
|
||||
|
||||
// XSL content :
|
||||
$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));
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
This example will output something similar to:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
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"
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
Instead of a function name, an array containing an object reference and
|
||||
a method name can also be supplied.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
|
Loading…
Reference in a new issue