Calling PHP functions from XSLT (evil...)
- You can call now any PHP functions as an XSLT-Function
function foo($id ) {
return $id;
}
function bar($id) {
return $id[0]->value;
}
function nodeSet($id = null) {
$dom = new domdocument;
$dom->loadXML("<root>this is from an external DomDocument</root>");
return $dom->documentElement;
}
$xslt = new xsltprocesser();
$xslt->registerPhpFunctions();
---
<xsl:value-of select="php:functionString('foo', /doc/@id)"/>
<xsl:value-of select="php:function('bar', /doc/@id)"/>
<xsl:value-of select="php:function('nodeSet')/root"/>
Some of the more advanced features of XML in PHP5
© copyright 2004 Bitflux GmbH