Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Xslt_process in PHP4.1.2

Posted on 2002-06-10
13
Medium Priority
?
296 Views
Last Modified: 2013-11-18
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>
0
Comment
Question by:dsraja
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 3
  • 3
13 Comments
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 7069452
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
 

Expert Comment

by:ComTech
ID: 7069495
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
 

Author Comment

by:dsraja
ID: 7069537
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 40

Expert Comment

by:Richard Quadling
ID: 7069643
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
 

Author Comment

by:dsraja
ID: 7069746
Ya ,dumpmem() is giving proper xml output.
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 7069802
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
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 7069808
That is the PHP documentation doesn't say you can't use a singleplaceholder ;-)
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 7069813
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
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 7069853
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
 

Author Comment

by:dsraja
ID: 7069905
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
 
LVL 40

Accepted Solution

by:
Richard Quadling earned 200 total points
ID: 7069928
Glad to have helped.
0
 

Expert Comment

by:ComTech
ID: 7070056
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
 

Expert Comment

by:ComTech
ID: 7070161
btw-I though the grade should be an A.  This system will automatiacally gibe a B if no grade is chosen.


ComTech
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question