Bug #15845: xslt_process() errors...
| From: | jessenig at chello dot at | Date: | Sun, 03 Mar 2002 16:08:48 +0000 |
| Subject: | Bug #15845: xslt_process() errors... | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-1554@lists.php.net to get a copy of this message | ||
From: jessenig@chello.at
Operating system: Linux
PHP version: 4.0.6
PHP Bug Type: Sablotron XSL
Bug description: xslt_process() errors...
I tried to do some transformations using sablotron and
the PHP xslt functions.
After running into troubles from the first moment, I tried
some example scripts, but all of them won't work.
To get an idea of what i did i will post the xml-file content, the
xsl-file content and the script...
THE XSL FILE
------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<table border="2" bgcolor="yellow">
<tr>
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
------------------------------------------------------
THE XML FILE
------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
</catalog>
------------------------------------------------------
THE SCRIP (taken from the php-online-documentation for
xslt_process())
------------------------------------------------------
<?
$xsl = implode('',file("xml/cedists/cedist_news.xsl"));
$xml = implode('',file("xml/cedefts/cedeft_news.xml"));
// $xml and $xsl contain the XML and XSL data
$arguments = array(
'/_xml' => $xml,
'/_xsl' => $xsl
);
// Allocate a new XSLT processor
$xh = xslt_create();
// Process the document
$result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments);
if ($result) {
print "<pre>\n";
print $result;
print "</pre>\n";
}
else {
print xslt_error($xh);
print xslt_errno($xh);
}
xslt_free($xh);
?>
------------------------------------------------------
THE PROBLEM
******************************************************
Running the script produces the following error:
"Only variables can be passed by reference"
So i tried the following:
...................................
$result = xslt_process($xh,$xml,$xsl,NULL,$output);
echo $output;
...................................
Running the script with this xslt_process line produces
the following error:
"Wrong parameter count for xslt_process()"
So i changed the thing again and again and again until i
got a call of xslt_process which worked:
...................................
$result = xslt_process($xsl,$xml,$output);
echo $output;
...................................
As you can see, i DO NOT pass the reference to the created processor
($xh), and i also did not pass the other stuff, and !! the ORDER OF $xsl
and $xml WAS CHANGED.
This works! But why???
It even works, if i don't use xslt_create() function.
Why is that???
The whole xslt_ stuff seems to be a bit tricky...
******************************************************
ADDITIONAL INFORMATION
======================================================
PHP Version 4.0.6
------------------------------------------------------
Linux Kernel 2.4.16
------------------------------------------------------'./configure'
'--with-apxs=/usr/local/apache/bin/apxs' '--with-mysql=/usr/local/mysql'
'--enable-track-vars' '--enable-sysvsem' '--disable-debug'
'--enable-ftp'
'--enable-bcmath' '--with-gd' '--with-jpeg-dir'
'--with-png-dir=/usr/lib'
'--with-zlib-dir=/usr/include' '--with-pdflib' '--with-ttf'
'--with-ming=/usr/src/ming-0.2a' '--with-imap=/usr/src/imap-4.7c'
'--with-swf=/usr/src/dist' '--with-dom' '--with-curl'
'--with-sablot'
'--enable-memory-limit'
------------------------------------------------------
NO INFORMATION ABOUT SABLOTRON AVAILABLE, BUT SABLTRON
HAS BEEN INSTALLED BY THE PROVIDER ON MY REQUEST, SO I
THINK IT SHOULD BE THE LATEST VERSION
======================================================
--
Edit bug report at http://bugs.php.net/?id=15845&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=15845&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=15845&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=15845&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=15845&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=15845&r=support
Expected behavior: http://bugs.php.net/fix.php?id=15845&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=15845&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=15845&r=submittedtwice