php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37091 Unable to call static php class functions from xsl
Submitted: 2006-04-15 14:06 UTC Modified: 2006-04-18 05:24 UTC
From: rob dot eyre at gmail dot com Assigned:
Status: Not a bug Package: XSLT related
PHP Version: 5.1.2 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: rob dot eyre at gmail dot com
New email:
PHP Version: OS:

 

 [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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-18 05:24 UTC] chregu@php.net
It's not a static method :)

Do

  static function testMethod() {

and it works


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 12:01:29 2024 UTC