I'm using the php class XSLTProcessor to generate HTML from a xsl. Within the xsl, I'd like all my custom namespace elements to be processed by my own processor class.
So for example:
<xsl:for-each select="doc/elements/*">
<doc:renderElement element="." />
</xsl:for-each>
This should call the method renderElement of an instance of my custom processor class.
I know I can enable calling php functions by using the registerPHPFunctions function. However, this only seems to support calling static methods.
Yes, XSLTProcessor::registerPHPFunctions only supports static function calls of classes. However you can make use of those static calls to provide a factory or instance registry to provide actual objects. In your case probably based on the element name.
Existing code where this is done can be found in the PIWI - PHP Transformation Framework.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With