php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29590 XSLT select syntax
Submitted: 2004-08-09 18:38 UTC Modified: 2004-08-09 20:37 UTC
From: x-penguin at tut dot by Assigned:
Status: Not a bug Package: XSLT related
PHP Version: 5CVS-2004-08-09 (dev) OS: Linux
Private report: No CVE-ID: None
 [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? 


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-09 18:42 UTC] chregu@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.


please provide a self running example.
 [2004-08-09 20:11 UTC] x-penguin at tut dot by
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"?>
 [2004-08-09 20:37 UTC] chregu@php.net
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...)
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Oct 28 18:01:24 2020 UTC