SunQuest
 
       XML
  Home arrow XML arrow Page 2 - 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 - Getting Down To Business


    (Page 2 of 8 )

    Before we get into the nitty-gritty of XSLT processing with PHP, I'd like to take some time to explain how all the pieces fit together.

    In case you don't already know, XML is a markup language created to help document authors describe the data contained within a document. This description is accomplished by means of tags, very similar in appearance to regular HTML markup. However, where HTML depends on pre-defined tags, XML allows document authors to create their own tags, immediately making it more powerful and flexible. There are some basic rules to be followed when creating an XML file, and a file can only be processed if these rules are followed to the letter.

    Once a file has been created, it needs to be converted, or "transformed", from pure data into something a little more readable. XSLT, the Extensible Style Language (Transformations), is typically used for such transformations; it's a powerful language that allows you to generate different output from the same XML data source. For example, you could use different XSL transformations to create an HTML Web page, a WML deck, and an ASCII text file...all from the same source XML.

    There's only one problem here: most browsers don't come with an XML parser or an XSL processor. The latest versions of Internet Explorer and Netscape Gecko do support XML, but older versions don't, and none of them have an XSL processor. And this brings up an obvious problem: how do you use an XML data source to generate HTML for these older browsers?

    The solution is to insert an additional layer between the client and the server, which takes care of processing the XML with XSLT and returning the rendered output to the browser. And that's where PHP comes in - PHP4 supports XML parsing, through its DOM and XML extensions, and includes an XSL processor, through its Sablotron extension.

    Sablotron, you say. Sounds scary. What's that?

    Sablotron is, according to its creators, "...a fast, compact and portable XML toolkit implementing XSLT, DOM and XPath". Developed by Ginger Alliance (http://www.gingerall.com), the Sablotron engine is a powerful, standards-compliant XSLT processor, with support for most common XSLT constructs.

    The latest version of PHP comes with an implementation of this engine, allowing PHP developers to perform XSLT transformations using regular PHP functions. Note, however, that you may need to recompile your PHP binary with the "--with-sablot" parameter to activate XML support (Windows users get a pre-built binary with their distribution.)

    Over the course of this article, I'll be demonstrating how you can use PHP's Sablotron extension to perform XSLT transformations of XML data on the server. I'll be assuming you know the basics of PHP, XML, XSLT and XPath; if you don't, you should take a look at the links at the end of the article before proceeding further.

    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 2 hosted by Hostway