Abbey Workshop | ||||||||||
This module covers how to perform an XSLT transformation using PHP. The Sablotron XSLT Processor (http://www.gingerall.com/) has been included with PHP since version 4.1. For XSLT to work, PHP must be configured with the --enable-xslt and the --with-xslt-sablot options set. To see if the modules are included in your PHP executable, type php -m at a command prompt. This gives you a list of the included modules.
This example is pretty simple and is useful for quick XSLT testing from the command line. The details of which are covered in the PHP Cookbook from O'Reilly (see link below). In addition, the book includes an example of transforming XML data read from a URL and stored in memory. You would use this technique if you are using a REST web service like Amazon.com. Here is the source code. The comments pretty much explain what is going on.
Download source for: transform.php
Here is the XML source file used in the tranformation.
Download source for: student_directory.xml
Here is the XSLT stylesheet used to perform the tranformation.
Download source for: student_html.xsl
Copyright © Abbey Workshop 2006