XML
  Home arrow XML arrow Page 6 - XSL Transformation With PHP And Sablot...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML

XSL Transformation With PHP And Sablotron
By: Harish Kamath, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 6
    2001-11-30

    Table of Contents:
  • XSL Transformation With PHP And Sablotron
  • Getting Down To Business
  • Start It Up
  • Handling Things Better
  • An Evening At The Moulin Rouge
  • Mistakes Happen
  • Publish Or Die!
  • Endzone

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    XSL Transformation With PHP And Sablotron - Mistakes Happen


    (Page 6 of 8 )

    Like any good API, PHP's Sablotron extension comes with an excellent error-handling mechanism. I'll modify one of the examples above to illustrate:

    <?php




    // the files
    $xmlfile = "person.xml";
    $xslfile = "person.xsl";




    // create the XSLT processor
    $xslthandler = xslt_create() or die("Houston, we
    have a problem. No XSLT
    handler available. Mission aborted.");




    // process the two files to get the desired output
    if(xslt_run($xslthandler,
    $xslfile, $xmlfile))
    {
    // get and print the result
    echo xslt_fetch_result($xslthandler);
    }
    else
    {
    //
    error
    echo "Something bad just happened.n";
    echo "Error code: " . xslt_errno($xslthandler)
    . "n";
    echo "Error string: " . xslt_error($xslthandler) . "n";
    exit;
    }




    // free the resources occupied by the handlers
    xslt_free($xslthandler);




    ?>

    Much of the code here has been culled from the previous examples. The difference: this script includes a primitive error-handling mechanism, which checks whether or not the processing was successful, and returns an error code and message if not.

    Both the xslt_errno() and xslt_error() functions accept a handle for the XSLT processor, and return the last error code and message generated by the processor. At least that's the theory - in my experiments with PHP 4.0.6, these functions failed to work as advertised.

    More XML Articles
    More By Harish Kamath, (c) Melonfire


     

       

    XML ARTICLES

    - How to Set Up Podcasting and Vodcasting
    - Creating an RSS Reader Application
    - Building an RSS File
    - An Introduction to XUL Part 6
    - An Introduction to XUL Part 5
    - An Introduction to XUL Part 4
    - An Introduction to XUL Part 3
    - An Introduction to XUL Part 2
    - An Introduction to XUL Part 1
    - XML Matters: Practical XML Data Design and M...
    - Practical XML Data Design and Manipulation f...
    - SimpleXML
    - XForms Basics, Part 3
    - XForms Basics, Part 2
    - XForms Basics





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway