|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #38595 XSLTProcessor::registerPHPFunctions() should be able to register callbacks
Submitted: 2006-08-25 17:09 UTC Modified: 2011-02-21 21:22 UTC
Avg. Score:4.5 ± 0.9
Reproduced:9 of 9 (100.0%)
Same Version:2 (22.2%)
Same OS:7 (77.8%)
From: goliath dot mailinglist at gmx dot de Assigned:
Status: Open Package: XSLT related
PHP Version: 5.1.5 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-08-25 17:09 UTC] goliath dot mailinglist at gmx dot de
XSLTProcessor::registerPHPFunctions() has very limited use. It is only possible to register static callable functions.

Some nicer API would be:
$xslt = new XSLTProcessor()
	'func1' => 'functionblah',
	'func2' => array('class', 'method'),
	'func3' => array($obj, 'method') // this would be the real advantage

Or even better:
$xslt->registerPHPFunction('func1', 'functionblah');
$xslt->registerPHPFunction('func2', array('class', 'method'));
$xslt->registerPHPFunction('func3', array($obj, 'method'));

This would be similar to the set/get/removeParameter-API....

btw.: Your CAPCHA only works with cookies enabled, that really sucks.

Reproduce code:
None, not possible

Expected result:
Be able to have instance-methods as callbacks for the XSLTProcessor.
(Note: Not global accessibly objects)

Actual result:
Not possible


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-24 03:35 UTC] php at xmlnode dot com
I'm not sure how important this really is.  I too was disappointed at 
the lack of flexibility with registerPHPFunctions, but it was hard to 
be too upset about it because for us, the decision to use XSL as a 
template is an acknowledgment of standards and registerPHPFunctions is 
not standard...  

What we've done, if the value can't be passed as a parameter using 
XSLTProcessor::setParameter() is created a class with a bunch of 
static methods which are then called using something like this:

php:function('XSL::<function name>',0)

If objects need to be instantiated, that work is done inside of those 
respective methods -- not throughout the XSL.  The approach here has 
the added benefit of being able to periodically scrutinize what others 
on the team  are wanting access to within the XSL and make adjustments 
for security, performance, etc.

 [2011-02-21 21:22 UTC]
-Package: Feature/Change Request +Package: XSLT related
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Sep 19 00:03:39 2021 UTC