|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-06-10 16:13 UTC] clicknmix at gmail dot com
Description:
------------
When using a function with XSLTProcessor->registerPHPFunctions() to return a dom object, it no longer handles it as XML, and produces an error.
Reproduce code:
---------------
Function is:
function myxml ($Value="default")
{
$dom = new domdocument();
$dom->loadXML("<root>this is from an external DomDocument - $Value</root>");
return $dom;
}
and XSLT call is:
<xsl:value-of select="php:function('myxml','Hello World')/root" />
Full scripts at:
http://home.protocol80.co.uk/php5/collection.phps
http://home.protocol80.co.uk/php5/collection.xml
http://home.protocol80.co.uk/php5/collection.xml
Expected result:
----------------
In previous versions you could access the tree of the returned XML and print the output. (As if you were including a flat XML file)
Actual result:
--------------
Warning: XSLTProcessor::transformToXml() [function.transformToXml]: A PHP Object can not be converted to a XPath-string in /controlpanel/hosts/design/htdocs/test/collection.php on line 22
Warning: Invalid type in /controlpanel/hosts/design/htdocs/test/collection.php on line 22
Warning: runtime error: file /controlpanel/hosts/design/htdocs/test/collection.xsl element value-of in /controlpanel/hosts/design/htdocs/test/collection.php on line 22
Warning: xsltValueOf: text copy failed in /controlpanel/hosts/design/htdocs/test/collection.php on line 22
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 10:00:02 2025 UTC |
I've been working with Ritch on this one. He says the same code works with 5.0.3 but not with 5.0.4, so I've compared the two source files for the location of the bug, and nothing other than the "{{{ proto" lines in ext/xsl/xsltprocessor.c seems to be different. The warnings come about when you return a DOMDocument (rather than a string) from the php:function, and this causes retval->type == IS_OBJECT to be true. Now, I'm not that familiar with this code, but it seems to me that maybe the test on line 281 should be true if the object you're returning is a DOMDocument, and that this equality is true under 5.0.3 but false under 5.0.4, causing the equality on line 295 to be true and thus generating the first warning as reported above.The following code: function myxml ($Value="default") { $dom = new domdocument(); $dom->loadXML("<root>this is from an external DomDocument - $Value</root>"); return $dom; } print debug_zval_dump(myxml('')); yields: object(DOMDocument)#1 (0) refcount(1){ } I haven't yet managed to get gdb attached happily to this build of PHP; having trouble with loadable modules. It's worth noting that the stock PHP 5.0.4 that comes with Fedora Core 4 demonstrates this problem, if anyone's looking for basic install to test with.