rasmus          Wed Feb 22 23:38:31 2006 UTC

  Modified files:              
    /phpdoc/en/reference/xsl/functions  
                                        
xsl-xsltprocessor-register-php-functions.xml 
  Log:
  Add an example here
  
  
http://cvs.php.net/viewcvs.cgi/phpdoc/en/reference/xsl/functions/xsl-xsltprocessor-register-php-functions.xml?r1=1.5&r2=1.6&diff_format=u
Index: 
phpdoc/en/reference/xsl/functions/xsl-xsltprocessor-register-php-functions.xml
diff -u 
phpdoc/en/reference/xsl/functions/xsl-xsltprocessor-register-php-functions.xml:1.5
 
phpdoc/en/reference/xsl/functions/xsl-xsltprocessor-register-php-functions.xml:1.6
--- 
phpdoc/en/reference/xsl/functions/xsl-xsltprocessor-register-php-functions.xml:1.5
  Wed Apr  6 15:34:59 2005
+++ 
phpdoc/en/reference/xsl/functions/xsl-xsltprocessor-register-php-functions.xml  
    Wed Feb 22 23:38:31 2006
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.5 $ -->
+<!-- $Revision: 1.6 $ -->
 <refentry id="function.xsl-xsltprocessor-register-php-functions">
  <refnamediv>
   <refname>XSLTProcessor->registerPHPFunctions()</refname>
@@ -46,6 +46,54 @@
    &return.void;
   </para>
  </refsect1>
+ <refsect1 role="examples">
+  &reftitle.examples;
+  <para>
+   <example>
+    <title>Simple PHP Function call from a stylesheet</title>
+    <programlisting role="php"><![CDATA[<?php
+$xml = <<<EOB
+<allusers>
+ <user>
+  <uid>bob</uid>
+ </user>
+ <user>
+  <uid>joe</uid>
+ </user>
+</allusers>
+EOB;
+$xsl = <<<EOB
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0" 
+     xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
+     xmlns:php="http://php.net/xsl";>
+<xsl:output method="html" encoding="utf-8" indent="yes"/>
+ <xsl:template match="allusers">
+  <html><body>
+    <h2>Users</h2>
+    <table>
+    <xsl:for-each select="user">
+      <tr><td>
+        <xsl:value-of
+             select="php:function('ucfirst',string(uid))"/>
+      </td></tr>
+    </xsl:for-each>
+    </table>
+  </body></html>
+ </xsl:template>
+</xsl:stylesheet>
+EOB;
+$xmldoc = DOMDocument::loadXML($xml);
+$xsldoc = DOMDocument::loadXML($xsl);
+
+$proc = new XSLTProcessor();
+$proc->registerPHPFunctions();
+$proc->importStyleSheet($xsldoc);
+echo $proc->transformToXML($xmldoc);
+?>]]></programlisting>
+    </example>
+  </para>
+ </refsect1>
  <refsect1 role="changelog">
   &reftitle.changelog;
   <para>

Reply via email to