Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 05cd670d8a02b2b4a0ffb1756f2e8308 > files > 5210

php-manual-zh-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>xslt_set_sax_handlers</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="XSLT Functions"
HREF="ref.xslt.html"><LINK
REL="PREVIOUS"
TITLE="xslt_set_sax_handler"
HREF="function.xslt-set-sax-handler.html"><LINK
REL="NEXT"
TITLE="xslt_set_scheme_handler"
HREF="function.xslt-set-scheme-handler.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP 手册</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.xslt-set-sax-handler.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.xslt-set-scheme-handler.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.xslt-set-sax-handlers"
></A
>xslt_set_sax_handlers</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN247065"
></A
><P
>    (PHP 4 &#62;= 4.0.6, PECL)</P
>xslt_set_sax_handlers&nbsp;--&nbsp;
     Set the SAX handlers to be called when the XML document gets processed
    </DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN247068"
></A
><H2
>Description</H2
>void <B
CLASS="methodname"
>xslt_set_sax_handlers</B
> ( resource processor, array handlers )<BR
></BR
><P
>&#13;     <B
CLASS="function"
>xslt_set_sax_handlers()</B
> registers the SAX 
     <CODE
CLASS="parameter"
>handlers</CODE
> for the document, given a XSLT 
     <CODE
CLASS="parameter"
>processor</CODE
> resource.
    </P
><P
>&#13;     <CODE
CLASS="parameter"
>handlers</CODE
> should be an array in the following format:
      <DIV
CLASS="informalexample"
><P
></P
><A
NAME="AEN247085"
></A
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /><br />$handlers </font><font color="#007700">= array(<br /><br />&nbsp;&nbsp;</font><font color="#DD0000">"document" </font><font color="#007700">=&gt; array(<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">"start_doc"</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">"end_doc"</font><font color="#007700">),<br /><br />&nbsp;&nbsp;</font><font color="#DD0000">"element"&nbsp;&nbsp;</font><font color="#007700">=&gt; array(<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">"start_element"</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">"end_element"</font><font color="#007700">),<br /><br />&nbsp;&nbsp;</font><font color="#DD0000">"namespace" </font><font color="#007700">=&gt; array(<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">"start_namespace"</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">"end_namespace"</font><font color="#007700">),<br /><br />&nbsp;&nbsp;</font><font color="#DD0000">"comment"&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&gt; </font><font color="#DD0000">"comment"</font><font color="#007700">,<br /><br />&nbsp;&nbsp;</font><font color="#DD0000">"pi"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&gt; </font><font color="#DD0000">"pi"</font><font color="#007700">,<br /><br />&nbsp;&nbsp;</font><font color="#DD0000">"character" </font><font color="#007700">=&gt; </font><font color="#DD0000">"characters"<br /><br /></font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
></P
></DIV
>
     Where the functions follow the syntax described for the scheme handler 
     functions.
    </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>注意: </B
>
      The given array does not need to contain all of the different sax
      handler elements (although it can), but it only needs to conform to 
      "handler" =&#62; "function" format described above.
     </P
></BLOCKQUOTE
></DIV
><P
>&#13;     Each of the individual SAX handler functions are in the format below:
     <P
></P
><UL
><LI
><P
>&#13;        <B
CLASS="methodname"
><TT
CLASS="replaceable"
><I
>start_doc</I
></TT
></B
> ( resource processor )<BR
></BR
>
       </P
></LI
><LI
><P
>&#13;        <B
CLASS="methodname"
><TT
CLASS="replaceable"
><I
>end_doc</I
></TT
></B
> ( resource processor )<BR
></BR
>
       </P
></LI
><LI
><P
>&#13;        <B
CLASS="methodname"
><TT
CLASS="replaceable"
><I
>start_element</I
></TT
></B
> ( resource processor, string name, array attributes )<BR
></BR
>
       </P
></LI
><LI
><P
>&#13;        <B
CLASS="methodname"
><TT
CLASS="replaceable"
><I
>end_element</I
></TT
></B
> ( resource processor, string name )<BR
></BR
>
       </P
></LI
><LI
><P
>&#13;        <B
CLASS="methodname"
><TT
CLASS="replaceable"
><I
>start_namespace</I
></TT
></B
> ( resource processor, string prefix, string uri )<BR
></BR
>
       </P
></LI
><LI
><P
>&#13;        <B
CLASS="methodname"
><TT
CLASS="replaceable"
><I
>end_namespace</I
></TT
></B
> ( resource processor, string prefix )<BR
></BR
>
       </P
></LI
><LI
><P
>&#13;        <B
CLASS="methodname"
><TT
CLASS="replaceable"
><I
>comment</I
></TT
></B
> ( resource processor, string contents )<BR
></BR
>
       </P
></LI
><LI
><P
>&#13;        <B
CLASS="methodname"
><TT
CLASS="replaceable"
><I
>pi</I
></TT
></B
> ( resource processor, string target, string contents )<BR
></BR
>
       </P
></LI
><LI
><P
>&#13;        <B
CLASS="methodname"
><TT
CLASS="replaceable"
><I
>characters</I
></TT
></B
> ( resource processor, string contents )<BR
></BR
>
       </P
></LI
></UL
>
    </P
><P
>&#13;     Using <B
CLASS="function"
>xslt_set_sax_handlers()</B
> doesn't look very different than
     running a SAX parser like <A
HREF="function.xml-parse.html"
><B
CLASS="function"
>xml_parse()</B
></A
> on the result of an 
     <A
HREF="function.xslt-process.html"
><B
CLASS="function"
>xslt_process()</B
></A
> transformation.
    </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN247197"
></A
><H2
>范例</H2
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN247199"
></A
><P
><B
>例 1. <B
CLASS="function"
>xslt_set_sax_handlers()</B
> Example</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#FF8000">// From ohlesbeauxjours at yahoo dot fr<br />// Here's a simple example that applies strtoupper() on <br />// the content of every &lt;auteur&gt; tag and then displays the <br />// resulting XML tree:<br /><br /></font><font color="#0000BB">$xml</font><font color="#007700">=</font><font color="#DD0000">'&lt;?xml version="1.0"?&gt;<br />&lt;books&gt;<br /> &lt;book&gt;<br />&nbsp;&nbsp;&lt;title&gt;Mme Bovary&lt;/title&gt;<br />&nbsp;&nbsp;&lt;author&gt;Gustave Flaubert&lt;/author&gt;<br /> &lt;/book&gt;<br /> &lt;book&gt;<br />&nbsp;&nbsp;&lt;title&gt;Mrs Dalloway&lt;/title&gt;<br />&nbsp;&nbsp;&lt;author&gt;Virginia Woolf&lt;/author&gt;<br /> &lt;/book&gt;<br />&lt;/books&gt;'</font><font color="#007700">;<br /><br /></font><font color="#0000BB">$xsl</font><font color="#007700">=</font><font color="#DD0000">'&lt;?xml version="1.0"?&gt;<br />&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;<br />&lt;xsl:output method="html" encoding="ISO-8859-1" indent="no" omit-xml-declaration="yes"/&gt;<br />&lt;xsl:template match="/"&gt;<br /> &lt;xsl:for-each select="books/book"&gt;<br />&nbsp;&nbsp;&lt;livre&gt;<br />&nbsp;&nbsp;&nbsp;&lt;auteur&gt;&lt;xsl:value-of select="author/text()"/&gt;&lt;/auteur&gt;<br />&nbsp;&nbsp;&lt;/livre&gt;<br /> &lt;/xsl:for-each&gt;<br />&lt;/xsl:template&gt;<br />&lt;/xsl:stylesheet&gt;'</font><font color="#007700">;<br /><br /></font><font color="#FF8000">// Handlers :<br /></font><font color="#007700">function </font><font color="#0000BB">start_document</font><font color="#007700">() <br />{<br />&nbsp;&nbsp;</font><font color="#FF8000">// start reading the document<br /></font><font color="#007700">}<br /><br />function </font><font color="#0000BB">end_document</font><font color="#007700">() <br />{<br />&nbsp;&nbsp;</font><font color="#FF8000">// end reading the document<br /></font><font color="#007700">}<br /><br />function </font><font color="#0000BB">start_element</font><font color="#007700">(</font><font color="#0000BB">$parser</font><font color="#007700">, </font><font color="#0000BB">$name</font><font color="#007700">, </font><font color="#0000BB">$attributes</font><font color="#007700">) <br />{<br />&nbsp;&nbsp;global </font><font color="#0000BB">$result</font><font color="#007700">,</font><font color="#0000BB">$tag</font><font color="#007700">;<br />&nbsp;&nbsp;</font><font color="#0000BB">$result </font><font color="#007700">.= </font><font color="#DD0000">"&lt;"</font><font color="#007700">. </font><font color="#0000BB">$name </font><font color="#007700">. </font><font color="#DD0000">"&gt;"</font><font color="#007700">;<br />&nbsp;&nbsp;</font><font color="#0000BB">$tag </font><font color="#007700">= </font><font color="#0000BB">$name</font><font color="#007700">;<br />}<br /><br />function </font><font color="#0000BB">end_element</font><font color="#007700">(</font><font color="#0000BB">$parser</font><font color="#007700">, </font><font color="#0000BB">$name</font><font color="#007700">) <br />{<br />&nbsp;&nbsp;global </font><font color="#0000BB">$result</font><font color="#007700">;<br />&nbsp;&nbsp;</font><font color="#0000BB">$result </font><font color="#007700">.= </font><font color="#DD0000">"&lt;/" </font><font color="#007700">. </font><font color="#0000BB">$name </font><font color="#007700">. </font><font color="#DD0000">"&gt;"</font><font color="#007700">;<br />}<br /><br />function </font><font color="#0000BB">characters</font><font color="#007700">(</font><font color="#0000BB">$parser</font><font color="#007700">, </font><font color="#0000BB">$data</font><font color="#007700">) <br />{<br />&nbsp;&nbsp;global </font><font color="#0000BB">$result</font><font color="#007700">,</font><font color="#0000BB">$tag</font><font color="#007700">;<br />&nbsp;&nbsp;if (</font><font color="#0000BB">$tag </font><font color="#007700">== </font><font color="#DD0000">"auteur" </font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$data </font><font color="#007700">= </font><font color="#0000BB">strtoupper</font><font color="#007700">(</font><font color="#0000BB">$data</font><font color="#007700">);<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;</font><font color="#0000BB">$result </font><font color="#007700">.= </font><font color="#0000BB">$data</font><font color="#007700">;<br />}<br /><br /></font><font color="#FF8000">// Transformation :<br /></font><font color="#0000BB">$xh </font><font color="#007700">= </font><font color="#0000BB">xslt_create</font><font color="#007700">();<br /></font><font color="#0000BB">$handlers </font><font color="#007700">= array(</font><font color="#DD0000">"document" </font><font color="#007700">=&gt; array(</font><font color="#DD0000">"start_document"</font><font color="#007700">,</font><font color="#DD0000">"end_document"</font><font color="#007700">),<br />&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">"element" </font><font color="#007700">=&gt; array(</font><font color="#DD0000">"start_element"</font><font color="#007700">,</font><font color="#DD0000">"end_element"</font><font color="#007700">),<br />&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">"character" </font><font color="#007700">=&gt; </font><font color="#DD0000">"characters"</font><font color="#007700">);<br /><br /></font><font color="#0000BB">xslt_set_sax_handlers</font><font color="#007700">(</font><font color="#0000BB">$xh</font><font color="#007700">, </font><font color="#0000BB">$handlers</font><font color="#007700">);<br /></font><font color="#0000BB">xslt_process</font><font color="#007700">(</font><font color="#0000BB">$xh</font><font color="#007700">, </font><font color="#DD0000">'arg:/_xml'</font><font color="#007700">, </font><font color="#DD0000">'arg:/_xsl'</font><font color="#007700">, </font><font color="#0000BB">NULL</font><font color="#007700">, array(</font><font color="#DD0000">"/_xml"</font><font color="#007700">=&gt;</font><font color="#0000BB">$xml</font><font color="#007700">, </font><font color="#DD0000">"/_xsl"</font><font color="#007700">=&gt;</font><font color="#0000BB">$xsl</font><font color="#007700">));<br /></font><font color="#0000BB">xslt_free</font><font color="#007700">(</font><font color="#0000BB">$xh</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
><P
>&#13;     You can also use <A
HREF="function.xslt-set-object.html"
><B
CLASS="function"
>xslt_set_object()</B
></A
> if you want to
     implement your handlers in an object.
    </P
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN247205"
></A
><P
><B
>例 2. Object oriented handler</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#FF8000">// This is the object oriented version of the previous example<br /></font><font color="#007700">class </font><font color="#0000BB">data_sax_handler </font><font color="#007700">{<br /><br />&nbsp;&nbsp;var </font><font color="#0000BB">$buffer</font><font color="#007700">, </font><font color="#0000BB">$tag</font><font color="#007700">, </font><font color="#0000BB">$attrs</font><font color="#007700">;<br /><br />&nbsp;&nbsp;var </font><font color="#0000BB">$_xh</font><font color="#007700">;<br /><br />&nbsp;&nbsp;function </font><font color="#0000BB">data_sax_handler</font><font color="#007700">(</font><font color="#0000BB">$xml</font><font color="#007700">, </font><font color="#0000BB">$xsl</font><font color="#007700">)<br />&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// our xslt resource<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$this</font><font color="#007700">-&gt;</font><font color="#0000BB">_xh </font><font color="#007700">= </font><font color="#0000BB">xslt_create</font><font color="#007700">();<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">xslt_set_object</font><font color="#007700">(</font><font color="#0000BB">$this</font><font color="#007700">-&gt;</font><font color="#0000BB">_xs</font><font color="#007700">, </font><font color="#0000BB">$this</font><font color="#007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// configure sax handlers<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$handlers </font><font color="#007700">= array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">"document" </font><font color="#007700">=&gt; array(</font><font color="#DD0000">'start_document'</font><font color="#007700">, </font><font color="#DD0000">'end_document'</font><font color="#007700">),<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">"element" </font><font color="#007700">=&gt; array(</font><font color="#DD0000">'start_element'</font><font color="#007700">, </font><font color="#DD0000">'end_element'</font><font color="#007700">),<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">"character" </font><font color="#007700">=&gt; </font><font color="#DD0000">'characters'<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">xslt_set_sax_handlers</font><font color="#007700">(</font><font color="#0000BB">$this</font><font color="#007700">-&gt;</font><font color="#0000BB">_xh</font><font color="#007700">, </font><font color="#0000BB">$handlers</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">xslt_process</font><font color="#007700">(</font><font color="#0000BB">$this</font><font color="#007700">-&gt;</font><font color="#0000BB">_xh</font><font color="#007700">, </font><font color="#DD0000">'arg:/_xml'</font><font color="#007700">, </font><font color="#DD0000">'arg:/_xsl'</font><font color="#007700">, </font><font color="#0000BB">NULL</font><font color="#007700">, array(</font><font color="#DD0000">"/_xml"</font><font color="#007700">=&gt;</font><font color="#0000BB">$xml</font><font color="#007700">, </font><font color="#DD0000">"/_xsl"</font><font color="#007700">=&gt;</font><font color="#0000BB">$xsl</font><font color="#007700">));<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">xslt_free</font><font color="#007700">(</font><font color="#0000BB">$this</font><font color="#007700">-&gt;</font><font color="#0000BB">_xh</font><font color="#007700">);<br /><br /><br />&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;function </font><font color="#0000BB">start_document</font><font color="#007700">() <br />&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// start reading the document<br />&nbsp;&nbsp;</font><font color="#007700">}<br /><br />&nbsp;&nbsp;function </font><font color="#0000BB">end_document</font><font color="#007700">() {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// complete reading the document<br />&nbsp;&nbsp;</font><font color="#007700">}<br /><br />&nbsp;&nbsp;function </font><font color="#0000BB">start_element</font><font color="#007700">(</font><font color="#0000BB">$parser</font><font color="#007700">, </font><font color="#0000BB">$name</font><font color="#007700">, </font><font color="#0000BB">$attributes</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$this</font><font color="#007700">-&gt;</font><font color="#0000BB">tag </font><font color="#007700">= </font><font color="#0000BB">$name</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$this</font><font color="#007700">-&gt;</font><font color="#0000BB">buffer </font><font color="#007700">.= </font><font color="#DD0000">"&lt;" </font><font color="#007700">. </font><font color="#0000BB">$name </font><font color="#007700">. </font><font color="#DD0000">"&gt;"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$this</font><font color="#007700">-&gt;</font><font color="#0000BB">attrs </font><font color="#007700">= </font><font color="#0000BB">$attributes</font><font color="#007700">;<br />&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;function </font><font color="#0000BB">end_element</font><font color="#007700">(</font><font color="#0000BB">$parser</font><font color="#007700">, </font><font color="#0000BB">$name</font><font color="#007700">)<br />&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$this</font><font color="#007700">-&gt;</font><font color="#0000BB">tag </font><font color="#007700">= </font><font color="#DD0000">''</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$this</font><font color="#007700">-&gt;</font><font color="#0000BB">buffer </font><font color="#007700">.= </font><font color="#DD0000">"&lt;/" </font><font color="#007700">. </font><font color="#0000BB">$name </font><font color="#007700">. </font><font color="#DD0000">"&gt;"</font><font color="#007700">;<br />&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;function </font><font color="#0000BB">characters</font><font color="#007700">(</font><font color="#0000BB">$parser</font><font color="#007700">, </font><font color="#0000BB">$data</font><font color="#007700">)<br />&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;if (</font><font color="#0000BB">$this</font><font color="#007700">-&gt;</font><font color="#0000BB">tag </font><font color="#007700">== </font><font color="#DD0000">'auteur'</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$data </font><font color="#007700">= </font><font color="#0000BB">strtoupper</font><font color="#007700">(</font><font color="#0000BB">$data</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$this</font><font color="#007700">-&gt;</font><font color="#0000BB">buffer </font><font color="#007700">.= </font><font color="#0000BB">$data</font><font color="#007700">;<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;function </font><font color="#0000BB">get_buffer</font><font color="#007700">() {<br />&nbsp;&nbsp;&nbsp;&nbsp;return </font><font color="#0000BB">$this</font><font color="#007700">-&gt;</font><font color="#0000BB">buffer</font><font color="#007700">;<br />&nbsp;&nbsp;}<br /><br />}<br /><br /></font><font color="#0000BB">$exec </font><font color="#007700">= new </font><font color="#0000BB">data_sax_handler</font><font color="#007700">(</font><font color="#0000BB">$xml</font><font color="#007700">, </font><font color="#0000BB">$xsl</font><font color="#007700">);<br /><br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
>&#13;      Both examples will output:
     </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="xml"
>&#60;livre&#62;
   &#60;auteur&#62;GUSTAVE FLAUBERT&#60;/auteur&#62;
&#60;/livre&#62;
&#60;livre&#62;
   &#60;auteur&#62;VIRGINIA WOOLF&#60;/auteur&#62;
&#60;/livre&#62;</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.xslt-set-sax-handler.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>起始页</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.xslt-set-scheme-handler.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>xslt_set_sax_handler</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.xslt.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>xslt_set_scheme_handler</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>