php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15845 xslt_process() errors...
Submitted: 2002-03-03 11:08 UTC Modified: 2002-03-03 18:00 UTC
From: jessenig at chello dot at Assigned:
Status: Not a bug Package: Sablotron XSL
PHP Version: 4.0.6 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jessenig at chello dot at
New email:
PHP Version: OS:

 

 [2002-03-03 11:08 UTC] jessenig at chello dot at
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
======================================================

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-03-03 13:27 UTC] cmk@php.net
This is not a bug. It is intended to work that way.

You are using the old ext/sablot and there xslt_process does not need a sablotron processor handle.

Please ask further questions on php-general.
 [2002-03-03 14:42 UTC] jessenig at chello dot at
when you say "does not need a handle" you wanna say "won't take one", right?
and... what version of php uses the new ext/sablot, if this is the old?
is the old version documented somewhere? could not find anything...

jj
 [2002-03-03 18:00 UTC] cmk@php.net
The new extension for xslt processing is called ext/xslt and was released first with PHP 4.1.0

You have to ask around if someone can send you an old version of the documentation or check it out via cvs.

And yes, xslt_process won't take a handle as an argument, but you already found that out.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 17:01:30 2024 UTC