Xslt_process in PHP4.1.2

when I run my code through browser, it is
working properly. But when I run this php
code in linux shell using "php <filename>", it was showing this
error.

code:
----
$args=array('/_xml'=>$xmlobj->dumpmem());
$parser = xslt_create();
$resulthtml=xslt_process($parser, 'arg:/_xml', $this->mTemplate, NULL, $args);

$this->mTemplate variable is having the xsl file name.


Error message
^^^^^^^^^^^^^
<br>
Warning: Wrong parameter count for xslt_process() in abc.php on line 81<br>
dsrajaAsked:
Who is Participating?
 
Richard QuadlingConnect With a Mentor Senior Software DeveloperCommented:
Glad to have helped.
0
 
Richard QuadlingSenior Software DeveloperCommented:
Where does the warning appear?

Can you try adding

error_reporting(E_ALL);

to the top of yout script and see if it produces any other warnings or errors or anything?

The help on xslt_process shows an example with the NULL in it.

Out of interest, could you try breaking

$args=array('/_xml'=>$xmlobj->dumpmem());

into

$argvalue = $xmlobj->dumpmem();
$args=array('/_xml'=>$argvalue);

to see if there is something odd about the dumpmem() method or its output.

Hmm.

Not a lot of help.

Regards,

Richard Quadling.
0
 
ComTechCommented:
dsraja, I have added 30 of my own points as there is a 50 point minimum now, and has somehow got thrugh this.  These extra points will come from my pocket and not yours.

Regards,
ComTech
CS Admin @ EE
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
dsrajaAuthor Commented:
Thanks for your suggestions Richard.

Actually I am getting this warning message in the mail sent by the cron(backend script).

I have tried both of your suggestions.I didn't get much difference in the working.Same error is coming.

Regards,
Shanmugaraja
0
 
Richard QuadlingSenior Software DeveloperCommented:
Does dumpmem() produce something meaningful?

I'm not a xml expert, but can the script work without this parameter (the help says they are optional, so ...).
0
 
dsrajaAuthor Commented:
Ya ,dumpmem() is giving proper xml output.
0
 
Richard QuadlingSenior Software DeveloperCommented:
Try ...

$args=array('/_xml'=>$xmlobj->dumpmem(),'/_xsl'=>$this->mTemplate);
$parser = xslt_create();
$resulthtml=xslt_process($parser, 'arg:/_xml', 'arg:/_xsl', NULL, $args);


The document doesn't say you can't use a single placeholder, but the example is with both of them as placeholders.

Please correct any errors in this cutnpaste as I am guessing the code.

Richard.
0
 
Richard QuadlingSenior Software DeveloperCommented:
That is the PHP documentation doesn't say you can't use a singleplaceholder ;-)
0
 
Richard QuadlingSenior Software DeveloperCommented:
The example is ...

<?php
// $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 "SUCCESS, sample.xml was transformed by sample.xsl into the \$result";
    print " variable, the \$result variable has the following contents\n<br>\n";
    print "<pre>\n";
    print $result;
    print "</pre>\n";
}
else {
    print "Sorry, sample.xml could not be transformed by sample.xsl into";
    print "  the \$result variable the reason is that " . xslt_error($xh) .
    print " and the error code is " . xslt_errno($xh);
}
xslt_free($xh);
?>


Which uses 2 arguments.

Regards,
Richard.
0
 
Richard QuadlingSenior Software DeveloperCommented:
Is the Sabletron library installed correctly? Did you recently upgrade from a version of php prior to V4.1?


The PHP dox says ...

Installation
This extension uses Sablotron and expat, which can both be found at http://www.gingerall.com/. Binaries are provided as well as source.

On UNIX, run configure with the --enable-xslt --with-xslt-sablot options. The Sablotron library should be installed somewhere your compiler can find it.


About This Extension
This PHP extension provides a processor independent API to XSLT transformations. Currently this extension only supports the Sablotron library from the Ginger Alliance. Support is planned for other libraries, such as the Xalan library or the libxslt library.

Note: This extension is different than the sablotron extension distributed with versions of PHP prior to PHP 4.1, currently only the new XSLT extension in PHP 4.1 is supported. If you need support for the old extension, please ask your questions on the php-general@lists.php.net mailing list.

...


Richard.
0
 
dsrajaAuthor Commented:
Richard, Thanks a lot for your concern in this doubt.

****************************************************
Note: This extension is different than the sablotron extension distributed with versions of PHP prior
to PHP 4.1, currently only the new XSLT extension in PHP 4.1 is supported. If you need support for the
old extension, please ask your questions on the php-general@lists.php.net mailing list.
**************************************************

Ya, You are correct.Now I have found the problem.

Actually what happened is in our server in /usr/local/bin the binary php is of version 4.0.6.
But we have configured the apache with php 4.1.2.The problem is this particular extension has changed  a lot in the latest version.

So we need to upade in both /usr/local/bin/ and apache module with the same version.I don't how it happened in our server.

Now what I did is, I have checked for the php version and done the coding accordingly.

$minor = explode(".",phpversion());
          if($minor[1] >= 1) // PHP 4.1.x -- preferred
          {
               $args=array('/_xml'=>$xmlobj->dumpmem());
               $parser = xslt_create();
               $resulthtml=xslt_process($parser,'arg:/_xml',$this->mTemplate,NULL,$args);
          }
          else // PHP 4.0.6
          {
               $xsl_content = fread(fopen($this->mTemplate, "r"), filesize($this->mTemplate));
               $final_xml = $xmlobj->dumpmem();
               xslt_process($xsl_content, $final_xml,$resulthtml);
          }


Now this is working fine both in backend and front end.
Once again thanks a lot for your effort reg this doubt.


With regards,
Shanmugaraja
0
 
ComTechCommented:
As I was subcribed to this question, I have been following the flow of proposals, and ideas, and working it out.

You keeping with the flow RQuadling, and dsraja for working diligenly with each other.  I will point to this question when I need to show someone else how the process is supposed to work.

Thanks guys,
ComTech
CS Admin @ EE
0
 
ComTechCommented:
btw-I though the grade should be an A.  This system will automatiacally gibe a B if no grade is chosen.


ComTech
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.