Page 1 of 1

node-set via php:function

Posted: Thu Feb 23, 2006 4:07 pm
by kwmccabe
RedHat 7.x ; PHP 5.1.2 ; libxml 2.6.22 ; libxslt 1.1.10

From what little I can find on the topic, the following code demonstrates using the XSLTProcessor::registerPHPFunctions() and select="php:function()" to return XML to and XSL stylesheet. All I get is a string. The result looks like XML but doesn't act XML, ie, subnodes can't be selected, counted or iterated.

Does anybody have this working?

Any help would be greatly appreciated.
thanks


see also:
http://us3.php.net/manual/en/function.x ... ctions.php

php:

Code: Select all

function getNodes()
{
    $xml = '<RESULT><NODE>foo</NODE><NODE>bar</NODE></RESULT>';
    $doc = DomDocument::loadXML($xml);
    return $doc;   // return DomDocument
}
xsl:

Code: Select all

<xsl:variable name="nodes">
    <xsl:copy-of select="php:function('getNodes')" />
</xsl:variable>

node cnt=<xsl:value-of select="count($nodes/RESULT/NODE)" />

expected result:

Code: Select all

node cnt=2
actual result:

Code: Select all

node cnt=0