XML
  Home arrow XML arrow Page 2 - XSL Transformation With PHP And Sablotron
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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? 
Google.com  
XML

XSL Transformation With PHP And Sablotron
By: Harish Kamath, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    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

    - Flex Array Collection Sort and Filtering
    - The Flex Tree Control
    - Flex List Controls
    - Working with Flex and Datagrids
    - 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...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek