I`m need hanling XSLT errors in my script,
before I`m use Sablotron, that has nice
interface for it:
------------8<------------------
function ProduceXHTML($x ml, $xsl){
$xh = xslt_create();
xslt_set_encodi ng ($xh, CODE_PAGE);
$arguments = array('/_xml' => $xml, '/_xsl' => $xsl);
$result = @xslt_process($ xh, 'arg:/_xml', 'arg:/_xsl', NULL,
$arguments);
$this->error = (int)xslt_errno ($xh);
if($this->error){
$errorMessage = sprintf("Cannot process XSLT document
[code %d]: %s",
xslt_errno($xh) , xslt_error($xh) );
$this->AddErrorMessag e(5, $errorMessage);
}
xslt_free($xh);
}
------------8<------------------
but now I`m ported my project
in PHP5 and use XSLlib like this:
------------8<------------------
function ProduceXHTML($x sltemplate){
$xh = new XSLTProcessor() ;
$xml = new DOMDocument();
$xsl = new DOMDocument();
$xsl->loadXML($thi s->LoadXSLT(TEMPL ATES_ROOT.$xslt emplate));
$xml->loadXML($thi s->xml);
$xh->importStyleShe et($xsl);
$xhtml=$xh->transformToXML ($xml);
if($this->IsDebug()){
header('Content-type: text/xml');
die($this->xml);
}
if ($xhtml) {
$xhtml = str_replace("&a mp;", "&", $xhtml);
echo $xhtml;
} else {
/* commented, because PHPv5 used
printf("Cannot process XSLT document [code %d]: %s",
xslt_errno($xh) , xslt_error($xh) );
*/
return false; // invalid XSL
}
unset($xh);
}
------------8<------------------
anybody know how I can track errors now?
thanks and sorry for my English 2 3129
I solved this problem years ago:
1) Have a standard error handler which can be invoked using trigger_error() ;
I call mine 'errorHandler'.
2) Create an alternative error handler for XML/XSL processing in PHP 5. I
call mine 'XML_errorHandl er'
function XML_errorHandle r ($errno, $errstr, $errfile, $errline,
$errcontext)
// deal with errors from XML or XSL functions.
{
// pass these details to the standard error handler
errorHandler (E_USER_ERROR, $errstr, $errfile, $errline,
$errcontext);
} // XML_errorHandle r
3) Just before performing and XML/XSL processing switch to the alternative
error handler:
set_error_handl er('XML_errorHa ndler');
4) Don't forget to switch back again afterwards:
set_error_handl er('errorHandle r');
All this code can be downloaded from my website in my sample application at http://www.tonymarston.net/php-mysql...plication.html
--
Tony Marston http://www.tonymarston.net http://www.radicore.org
<al*******@gmai l.com> wrote in message
news:11******** **************@ v46g2000cwv.goo glegroups.com.. . I`m need hanling XSLT errors in my script, before I`m use Sablotron, that has nice interface for it: ------------8<------------------ function ProduceXHTML($x ml, $xsl){ $xh = xslt_create(); xslt_set_encodi ng ($xh, CODE_PAGE); $arguments = array('/_xml' => $xml, '/_xsl' => $xsl); $result = @xslt_process($ xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments); $this->error = (int)xslt_errno ($xh); if($this->error){ $errorMessage = sprintf("Cannot process XSLT document [code %d]: %s", xslt_errno($xh) , xslt_error($xh) ); $this->AddErrorMessag e(5, $errorMessage); }
xslt_free($xh); }
------------8<------------------
but now I`m ported my project in PHP5 and use XSLlib like this:
------------8<------------------ function ProduceXHTML($x sltemplate){ $xh = new XSLTProcessor() ; $xml = new DOMDocument(); $xsl = new DOMDocument();
$xsl->loadXML($thi s->LoadXSLT(TEMPL ATES_ROOT.$xslt emplate)); $xml->loadXML($thi s->xml);
$xh->importStyleShe et($xsl); $xhtml=$xh->transformToXML ($xml);
if($this->IsDebug()){ header('Content-type: text/xml'); die($this->xml); } if ($xhtml) { $xhtml = str_replace("&a mp;", "&", $xhtml); echo $xhtml; } else { /* commented, because PHPv5 used printf("Cannot process XSLT document [code %d]: %s", xslt_errno($xh) , xslt_error($xh) ); */ return false; // invalid XSL } unset($xh);
} ------------8<------------------ anybody know how I can track errors now?
thanks and sorry for my English
Tony Marston wrote: I solved this problem years ago:
1) Have a standard error handler which can be invoked using trigger_error() ; I call mine 'errorHandler'.
2) Create an alternative error handler for XML/XSL processing in PHP 5. I call mine 'XML_errorHandl er'
function XML_errorHandle r ($errno, $errstr, $errfile, $errline, $errcontext) // deal with errors from XML or XSL functions. { // pass these details to the standard error handler errorHandler (E_USER_ERROR, $errstr, $errfile, $errline, $errcontext); } // XML_errorHandle r
3) Just before performing and XML/XSL processing switch to the alternative error handler:
set_error_handl er('XML_errorHa ndler');
4) Don't forget to switch back again afterwards:
set_error_handl er('errorHandle r');
All this code can be downloaded from my website in my sample application at http://www.tonymarston.net/php-mysql...plication.html
-- Tony Marston http://www.tonymarston.net http://www.radicore.org
thank you very match!
it`s cool way!
I`m tested it and find it very nice! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Chung Leong |
last post by:
Help me here. I've become a bitconfused about how PHP4 deals with
objects after reading this description of PHP5:
"PHP's handling of objects has been completely rewritten, allowing for
better performance and more features. In previous versions of PHP,
objects were handled like primitive types (for instance integers and
strings). The drawback of this method was that semantically the whole
object was copied when a variable was assigned, or...
|
by: neur0maniak |
last post by:
Hi,
I've been eager to try out PHP5, so I've dumped it on my little dev
machine. It's running WinXP with IIS5. I've put the php-cgi.exe in the
"mappings" page as I'm used to doing with PHP4. I've got my php.ini all
set in C:\Windows.
I created an index.php containing: <?php phpinfo(); ?>
When I try to view the page, I get "HTTP 400 - Bad Request".
|
by: Darek |
last post by:
Hello,
I'm trying to install PHP5. My configure is
../configure --with-apxs=/usr/local/sbin/apxs --
prefix=PREFIX=/usr/local/php5/ --with-mysql --disable-pear
then make and make install
The error that I get is:
|
by: Mike |
last post by:
Last weekend I decided to install
Apache 2.0.53-win32-x86-no_ssl
PHP 5.0.3
Smarty 2.6.7
MySQL essential-4.1.10-win32
I have Apache up (Port 80 blocked at the router and firewall!) and I
have got
Smarty working. I haven't got around to installing MySQL. I am now in
chapter 8 'Error and Exception Handling' of
|
by: lawrence k |
last post by:
I've never before written a PHP script to run on my home Ubuntu
machine (though I've written dozens of PHP cron jobs for my web
server), so I thought I'd start off with a very simple test:
#!/usr/share/php5
<?php
echo "hello";
?>
| |
by: MikeB |
last post by:
I'm messing around with some sample code that I downloaded from a
website (http://odnal.com/prosper-bid-sniper) that uses PHP objects
and web services.
When I upload it to my server, I get a weird error in a particular
class. I'm posting 3 functions from that class. The error is
Parse error: syntax error, unexpected '{' in /home/public_html/
prosperapi/prosper.class.php on line 164.
Line 164 is the try-block in the call-function. I'm...
|
by: simon m |
last post by:
Hi All, I have a script sitting on my web server called
auto_mail.php5. I would like this to be used two different ways.
One way would be for a web form to call it as submit action on a form.
I have got this working great.
However, to get this to work I had to comment out the first line of
the script which is #!/usr/bin/php -q
Now the other way the script is called doesn't work any more! This
|
by: john6630 |
last post by:
Coming from the .Net world, I am used to the try...catch...finally
approach to error handling. And PHP 5 now supports this approach. But
I am not clear what happens to unhandled errors/exceptioins? Do I
define a default error handler as well as do my try/catch? Can I mix
error handling with the exceptions? Is one approach better than the
other?
TIA
John
|
by: kellygreer1 |
last post by:
I think I'm not quite understanding something about error handling in
PHP5. I have written some PHP code to index the contents of C drive
on a Windows machine. When it gets to certain special folders (fake
folders) it runs into errors. Directories it can not read from. I
have tried wrapping the code in a Try / Catch and the error still
comes through. What am I missing?
<?php
// Here is the code:
function indexFiles($path, $handle) {
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |