node-set via php:function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kwmccabe
Forum Newbie
Posts: 1
Joined: Thu Feb 23, 2006 3:36 pm
Location: NYC

node-set via php:function

Post 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
Post Reply