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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2020 The PHP Group
All rights reserved.
Last updated: Wed Oct 28 18:01:24 2020 UTC