Solved

Xslt_process in PHP4.1.2

Posted on 2002-06-10
13
292 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 50 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

733 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