using:  RedHat ; PHP 5.1.2 ; libxml 2.6.22

How do I return a node-set to an xsl stylesheet via php:function?

I've had no difficulty returning strings, but so far xsl refuses to see the result as something I can iterate as real XML.


php fragment:
-----------------------------
// return String
function getNodesOne()
{
   return '<RESULT><NODE>foo</NODE><NODE>bar</NODE></RESULT>';
}

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

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

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

expected result: cnt=2

actual result:
   cnt=0

Same result calling php:function('getNodesOne') or php:function('getNodesTwo'). In both case, the xsl variable $nodes contains a string, not an actual node-set that can be iterated and otherwise worked with. $nodes/RESULT, like $nodes/RESULT/NODE, doesn't exist.


I also tried this, but it returns an empty node-set and not even a string:
-----------------------------
<xsl:copy-of select="document(php:function('getNodes'))" />
-----------------------------


Finally, I've also tried this, but libxml2 evidently does not support the inline-data URI form:
-----------------------------
<xsl:variable name="tmp">
   <xsl:value-of select="php:function('getNodes')" />
</xsl:variable>
<xsl:variable name="nodes">
   <xsl:copy-of select="document(concat('data:text/xml,',$tmp))" />
</xsl:variable>
-----------------------------

So, in all cases/combos of the above code, I get a string or an empty node-set.

Clearly, there should be a way to get a node-set via php:function, without creating a temporary xml file and without making a full request to apache.

Am I missing something?  Is something broken or, worse, broken by design?

Any help would be greatly appreciated.
thanks

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to