|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-08-09 18:38 UTC] x-penguin at tut dot by
Description:
------------
In php5.0.0 I can use next select syntax:
<xsl:variable name="menus" select="php:function('Menu::createXML')/menus"/>
but in php5.1.0-dev I see this warning
>>>
Warning: XSLTProcessor::transformToDoc() [function.transformToDoc]: Invalid type in
/mnt/data/www/html/web/Includes/Theme.php on line 117
Warning: XSLTProcessor::transformToDoc() [function.transformToDoc]: runtime error: file
/mnt/data/www/html/linux.grodno.by/web/Themes/FreeWay/Templates/Modules/module.xsl line 22 element
variable in /mnt/data/www/html/web/Includes/Theme.php on line 117
Warning: XSLTProcessor::transformToDoc() [function.transformToDoc]: Evaluating global variable being
computed ... failed in /mnt/data/www/html/web/Includes/Theme.php on line 117
>>>
Menu::createXML() static method, returns XML document... in php5.0 all work fine,
but in 5.1.0-dev dasn't. How i can do this in php5.1... or it's a bug?
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 05:00:01 2025 UTC |
PHP Version 5.1.0-dev, configure with: './configure' '--prefix=/usr/' '--with-apxs2' '--with-gettext' '--with-iconv' '--with-mysql' '--enable-mbstring=ru' '--enable-mbregex' '--enable-mbstr-enc-trans' '--disable-short-tags' '--with-xsl' '--with-libxml' '--without-sqlite' '--enable-soap' libxslt Version 1.1.8 libxml Version 2.6.11 libexslt Version 1.1.8 apache 2.0.48 Reproduce code: --------------- <?php final class Menu { public static function createXML() { $xml = new DomDocument; $xml->loadXML('<?xml version="1.0" encoding="iso-8859-1" ?> <menus><menu>1</menu><menu>2</menu><menu>3</menu></menus>'); return $xml->saveXML(); } } $xsl = new DomDocument(); $xsl->loadXML( '<?xml version="1.0" encoding="iso-8859-1" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl"> <xsl:variable name="menus" select="php:function(\'Menu::createXML\')/menus"/> <xsl:template match="/"> <xsl:value-of select="$menus" /> </xsl:template> </xsl:stylesheet>' ); $xml = new DomDocument; $xml->loadXML('<?xml version="1.0" encoding="iso-8859-1" ?><null></null>'); $proc = new XSLTProcessor(); $proc->registerPhpFunctions(); $proc->importStylesheet($xsl); $dom = $proc->transformToDoc($xml); echo $dom->saveXML(); ?> Expected result: ---------------- <?xml version="1.0"?> 123 Actual result: -------------- <br /> <b>Warning</b>: XSLTProcessor::transformToDoc() [<a href='function.transformToDoc'>function.transformToDoc</a>]: Invalid type in <b>/mnt/data/www/html/linux.grodno.by/web/test.php</b> on line <b>30</b><br /> <br /> <b>Warning</b>: XSLTProcessor::transformToDoc() [<a href='function.transformToDoc'>function.transformToDoc</a>]: runtime error: file /mnt/data/www/html/linux.grodno.by/web/ element variable in <b>/mnt/data/www/html/linux.grodno.by/web/test.php</b> on line <b>30</b><br /> <br /> <b>Warning</b>: XSLTProcessor::transformToDoc() [<a href='function.transformToDoc'>function.transformToDoc</a>]: Evaluating global variable being computed ... failed in <b>/mnt/data/www/html/linux.grodno.by/web/test.php</b> on line <b>30</b><br /> <?xml version="1.0"?>I wonder, if that really worked in PHP 5.0.0 ... (doesn't here on 5.0.0-dev) but change return $xml->saveXML(); to return $xml; and it works (you have to return a DomDocument if you want to access the nodes later...)