1--TEST--
2Test the basics to function XSLTProcessor::transformToXml().
3--CREDITS--
4Rodrigo Prado de Jesus <royopa [at] gmail [dot] com>
5--EXTENSIONS--
6xsl
7--FILE--
8<?php
9$xml = <<<EOB
10<allusers>
11 <user>
12  <uid>bob</uid>
13 </user>
14 <user>
15  <uid>joe</uid>
16 </user>
17</allusers>
18EOB;
19$xsl = <<<EOB
20<?xml version="1.0" encoding="UTF-8"?>
21<xsl:stylesheet version="1.0"
22     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
23     xmlns:php="http://php.net/xsl">
24<xsl:output method="html" encoding="utf-8" indent="yes"/>
25 <xsl:template match="allusers">
26  <html><body>
27    <h2>Users</h2>
28    <table>
29    <xsl:for-each select="user">
30      <tr><td>
31        <xsl:value-of
32             select="php:function('ucfirst',string(uid))"/>
33      </td></tr>
34    </xsl:for-each>
35    </table>
36  </body></html>
37 </xsl:template>
38</xsl:stylesheet>
39EOB;
40
41$xmldoc = new DOMDocument('1.0', 'utf-8');
42$xmldoc->loadXML($xml);
43
44$xsldoc = new DOMDocument('1.0', 'utf-8');
45$xsldoc->loadXML($xsl);
46
47$proc = new XSLTProcessor();
48$proc->registerPHPFunctions();
49$proc->importStyleSheet($xsldoc);
50
51var_dump($proc->transformToXML($xmldoc));
52?>
53--EXPECT--
54string(135) "<html xmlns:php="http://php.net/xsl"><body>
55<h2>Users</h2>
56<table>
57<tr><td>Bob</td></tr>
58<tr><td>Joe</td></tr>
59</table>
60</body></html>
61"
62