1--TEST-- 2Test the basics to function XSLTProcessor::transformToURI(). 3--CREDITS-- 4Rodrigo Prado de Jesus <royopa [at] gmail [dot] com> 5--SKIPIF-- 6<?php extension_loaded('xsl') or die('skip xsl extension is not available'); ?> 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 <table> 28 <xsl:for-each select="user"> 29 <tr><td> 30 <xsl:value-of 31 select="php:function('ucfirst',string(uid))"/> 32 </td></tr> 33 </xsl:for-each> 34 </table> 35 </body></html> 36 </xsl:template> 37</xsl:stylesheet> 38EOB; 39 40$xmldoc = new DOMDocument('1.0', 'utf-8'); 41$xmldoc->loadXML($xml); 42 43$xsldoc = new DOMDocument('1.0', 'utf-8'); 44$xsldoc->loadXML($xsl); 45 46$proc = new XSLTProcessor(); 47$proc->registerPHPFunctions(); 48$proc->importStyleSheet($xsldoc); 49 50var_dump($proc->transformToURI($xsldoc, 'php://output')); 51?> 52--EXPECTF-- 53int(56) 54