I am using PHP with XSL and registerPHPfunctions.
It is ok for return PHP string values with xsl:value-of, but I not know how to return XML fragments from PHP.
Example at XSLT:
<xsl:template match="table">
<xsl:copy-of select="php:function('myfunc',.)"/>
</xsl:template>
Example at PHP:
function myfunc($x) {return '<table><tr><td>ok</td></tr></table>';}
Result is not XML but a "lt/gt/amp enconded XML". Use of copy-of or value-of at XSL, not modify the return behaviour. It is a cast problem?
PS: even with identity function, I tested, it not returns the XML node,
function myfunc($x) {return $x;}