|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-04-15 14:06 UTC] rob dot eyre at gmail dot com
Description:
------------
After calling registerPHPFunctions() and including the php namespace on an XSL stylesheet, I can call global functions (eg date()), but not static class functions (ie testClass::testMethod()).
Reproduce code:
---------------
class testClass {
function testMethod() {
return 'testValue';
}
}
$xslt = new XSLTProcessor;
$xslt->registerPHPFunctions();
$xmlDoc = DOMDocument::loadXML('<root />');
$xslDoc = DOMDocument::loadXML('
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl">
<xsl:template match="/">
<div><xsl:value-of select="php:function(\'testClass::testMethod\')" /></div>
</xsl:template>
</xsl:stylesheet>');
$xslt->importStylesheet($xslDoc);
echo $xslt->transformToXML($xmlDoc);
Expected result:
----------------
<div>testValue</div>
Actual result:
--------------
Warning: XSLTProcessor::transformToXml() [function.transformToXml]: Unable to call handler testClass::testMethod() in /home/rob/Projects/sandbox/index.php on line 19
Warning: XSLTProcessor::transformToXml() [function.transformToXml]: xmlXPathCompiledEval: evaluation failed in /home/rob/Projects/sandbox/index.php on line 19
Warning: XSLTProcessor::transformToXml() [function.transformToXml]: runtime error: file /home/rob/Projects/sandbox/ line 4 element value-of in /home/rob/Projects/sandbox/index.php on line 19
Warning: XSLTProcessor::transformToXml() [function.transformToXml]: xsltValueOf: text copy failed in /home/rob/Projects/sandbox/index.php on line 19
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 09 07:00:01 2025 UTC |
It's not a static method :) Do static function testMethod() { and it works