Sophie

Sophie

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

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
>XSLTProcessor::registerPHPFunctions</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="XSL functions"
HREF="ref.xsl.html"><LINK
REL="PREVIOUS"
TITLE="XSLTProcessor::importStylesheet"
HREF="function.xsl-xsltprocessor-import-stylesheet.html"><LINK
REL="NEXT"
TITLE="XSLTProcessor::removeParameter"
HREF="function.xsl-xsltprocessor-remove-parameter.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.xsl-xsltprocessor-import-stylesheet.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.xsl-xsltprocessor-remove-parameter.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.xsl-xsltprocessor-register-php-functions"
></A
>XSLTProcessor::registerPHPFunctions</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN246228"
></A
><P
>    (no version information, might be only in CVS)</P
>XSLTProcessor::registerPHPFunctions&nbsp;--&nbsp;Enables the ability to use PHP functions as XSLT functions</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN246231"
></A
><H2
>说明</H2
>class <B
CLASS="classname"
>XSLTProcessor</B
> { <BR
></BR
>void <B
CLASS="methodname"
>registerPHPFunctions</B
> ( [mixed restrict] )<BR
></BR
>}<P
>&#13;   This method enables the ability to use PHP functions as XSLT functions
   within XSL stylesheets.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN246243"
></A
><H2
>参数</H2
><P
>&#13;   <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><CODE
CLASS="parameter"
>restrict</CODE
></DT
><DD
><P
>&#13;       Use this parameter to only allow certain functions to be called from 
       XSLT.
      </P
><P
>&#13;       This parameter can be either a string (a function name) or an array of
       functions.
      </P
></DD
></DL
></DIV
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN246253"
></A
><H2
>返回值</H2
><P
>&#13;   无返回值。
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN246256"
></A
><H2
>范例</H2
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN246259"
></A
><P
><B
>例 1. Simple PHP Function call from a stylesheet</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$xml </font><font color="#007700">= &lt;&lt;&lt;EOB<br /></font><font color="#0000BB">&lt;allusers&gt;<br /> &lt;user&gt;<br />&nbsp;&nbsp;&lt;uid&gt;bob&lt;/uid&gt;<br /> &lt;/user&gt;<br /> &lt;user&gt;<br />&nbsp;&nbsp;&lt;uid&gt;joe&lt;/uid&gt;<br /> &lt;/user&gt;<br />&lt;/allusers&gt;<br /></font><font color="#007700">EOB;<br /></font><font color="#0000BB">$xsl </font><font color="#007700">= &lt;&lt;&lt;EOB<br /></font><font color="#0000BB">&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br />&lt;xsl:stylesheet version="1.0" <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xmlns:xsl="http://www.w3.org/1999/XSL/Transform"<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xmlns:php="http://php.net/xsl"&gt;<br />&lt;xsl:output method="html" encoding="utf-8" indent="yes"/&gt;<br /> &lt;xsl:template match="allusers"&gt;<br />&nbsp;&nbsp;&lt;html&gt;&lt;body&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;h2&gt;Users&lt;/h2&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;table&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;xsl:for-each select="user"&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&gt;&lt;td&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xsl:value-of<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;select="php:function('ucfirst',string(uid))"/&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/td&gt;&lt;/tr&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;/xsl:for-each&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;/table&gt;<br />&nbsp;&nbsp;&lt;/body&gt;&lt;/html&gt;<br /> &lt;/xsl:template&gt;<br />&lt;/xsl:stylesheet&gt;<br /></font><font color="#007700">EOB;<br /></font><font color="#0000BB">$xmldoc </font><font color="#007700">= </font><font color="#0000BB">DOMDocument</font><font color="#007700">::</font><font color="#0000BB">loadXML</font><font color="#007700">(</font><font color="#0000BB">$xml</font><font color="#007700">);<br /></font><font color="#0000BB">$xsldoc </font><font color="#007700">= </font><font color="#0000BB">DOMDocument</font><font color="#007700">::</font><font color="#0000BB">loadXML</font><font color="#007700">(</font><font color="#0000BB">$xsl</font><font color="#007700">);<br /><br /></font><font color="#0000BB">$proc </font><font color="#007700">= new </font><font color="#0000BB">XSLTProcessor</font><font color="#007700">();<br /></font><font color="#0000BB">$proc</font><font color="#007700">-&gt;</font><font color="#0000BB">registerPHPFunctions</font><font color="#007700">();<br /></font><font color="#0000BB">$proc</font><font color="#007700">-&gt;</font><font color="#0000BB">importStyleSheet</font><font color="#007700">(</font><font color="#0000BB">$xsldoc</font><font color="#007700">);<br />echo </font><font color="#0000BB">$proc</font><font color="#007700">-&gt;</font><font color="#0000BB">transformToXML</font><font color="#007700">(</font><font color="#0000BB">$xmldoc</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN246262"
></A
><H2
>更新日志</H2
><P
>&#13;   <DIV
CLASS="informaltable"
><P
></P
><A
NAME="AEN246265"
></A
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><THEAD
><TR
><TH
>版本</TH
><TH
>说明</TH
></TR
></THEAD
><TBODY
><TR
><TD
>5.1.0</TD
><TD
>&#13;        The <CODE
CLASS="parameter"
>restrict</CODE
> parameter was added.
       </TD
></TR
></TBODY
></TABLE
><P
></P
></DIV
>
  </P
></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.xsl-xsltprocessor-import-stylesheet.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.xsl-xsltprocessor-remove-parameter.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>XSLTProcessor::importStylesheet</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.xsl.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>XSLTProcessor::removeParameter</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>