Solved

Xslt_process in PHP4.1.2

Posted on 2002-06-10
13
287 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
  • 7
  • 3
  • 3
13 Comments
 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
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
Comment Utility
Ya ,dumpmem() is giving proper xml output.
0
 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
That is the PHP documentation doesn't say you can't use a singleplaceholder ;-)
0
 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
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:RQuadling
Comment Utility
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
Comment Utility
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:
RQuadling earned 50 total points
Comment Utility
Glad to have helped.
0
 

Expert Comment

by:ComTech
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
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.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now