Flash Developer
Aquent
US-FL-Lake Mary

Justtechjobs.com Post A Job | Post A Resume

Transforming XML with XSL using Sablotron
In my last article I covered the use of the expat functions available to PHP for parsing XML documents using the SAX method. The sample code was a class that read the XML document and generated the HTML to present the data in a nice table. This example was far from perfect due to the fact that the presentation of the data was not separate from the class code that had to parse the XML document. This meant that a slight modification to the HTML generated by the class could break the actual parsing functionality of the class.
This is not the ideal way of doing things in a production environment, hence the purpose of this article in explaining how to parse XML documents using XSLT (eXtensible Stylesheet Language Transformations). XSLT is a language for transforming XML documents into other XML documents or HTML documents. I will not discuss XML, XSL or XSLT syntax in this article, for a good introduction to these please refer to the links at the end of this article.The focus of this article is on how to transform XML documents with XSLT using the Sablotron XSLT processor.
Sablotron is the result of a project to develop a fast, reliable, compact and portable XSLT processor conforming to the W3C specification. It currently supports Linux, Windows NT and, beginning with version 0.42, Solaris. It requires the expat XML Parser. In addition to these pieces of software the PHP4 sablotron extension wrapper is required to build an extension module that you can load with the PHP4 parser to give you access to the Sablotron API. This may sound a bit complex but it's really not and the result is well worth the power that these functions will provide you with. Some links to instructions on how to do all this are provided at the end of the article.
To demonstrate the use of these functions I have written an XSLT class that takes XML and XSL wether it be in the format of a file, a URL or a String and performs the transform. I use this class to to read an XML document from the web (the Slashdot news!) and transform it into an HTML page using an XSLT document on the local file system.
I'll do my best to explain how I've done this and welcome questions in the followup section, so here goes nothing ! ...
[ Next Page ]


Comments:
syntax-error in sablot 1.0 but not in 0,97Michael02/16/05 07:29
undefined function: xslt_create_processor() david11/12/04 18:49
RE: XML Fatal error: unknown encoding Wajee T.04/08/04 04:59
RE: Call to undefined function: xslt_create()Protorium02/27/04 12:41
the doc reader class is WRong !!!!nowhere01/20/04 18:50
RE: Working publishing platform XML/XSLJustin Grant07/22/03 23:11
XSL precompilingJakob Schwendner04/08/03 05:22
RE: official XSLT Support in PHPyohm03/31/03 08:40
Working publishing platform XML/XSLAlexandru COSTIN03/14/03 18:40
working application with xsltIlya02/20/03 00:17
RE: How can I use gb2312 diretorily in xsldavidliu09/25/02 00:22
How can I use gb2312 diretorily in xsldavidliu09/17/02 23:14
RE: Call to undefined function: xslt_create()Alexander Lang09/05/02 11:43
XSL function for validationSathya08/20/02 03:04
extension library xslRajeev08/16/02 12:22
php_sablot.dll with encoding supportyanhl07/27/02 19:07
parsing values from php to xslchristian Sorensen07/23/02 05:15
Subject: Error starting the sample script Z.Klindzic07/11/02 17:25
Error starting the sample scriptWoHu06/24/02 16:10
Passing a variable or parameter to xsl Niket Trivedi06/20/02 16:05
Passing a param to an xsl file from xsl Marine06/20/02 09:56
official XSLT Support in PHPStefan Reier06/17/02 09:18
Php & Sablotron 0.9 encoding UTF-16sylvain06/14/02 06:09
RE: can sablotron show spanish charactersJosé Zorrilla06/10/02 19:47
RE: undefined symbol: JS_PropertyStubAdam05/28/02 15:07
RE: Passing a variable to an xsl fileala05/28/02 05:31
Passing a variable to an xsl fileDesaraju05/03/02 16:30
can sablotron show spanish charactersErnesto moratal04/16/02 13:15
xml doumentaaa03/24/02 16:16
Installing Sabltron on Win 2000martin03/20/02 04:23
undefined symbol: JS_PropertyStubOliver Bott03/14/02 03:14
call to undefined function JS_PropertyStubOliver Bott03/14/02 03:09
SablotronChris Moore02/28/02 12:26
XML Fatal error: unknown encoding chicky02/27/02 02:10
XML Fatal error: unknown encoding chicky02/27/02 01:09
RE: Call to undefined function: xslt_create()TaQ01/29/02 12:03
Call to undefined function: xslt_create() Bart01/03/02 07:52
RE: expat/sablotron install problemsYasela Udawatte12/26/01 23:50
Concate XML ObjectSanthosh12/22/01 00:02
RE: accentuation problemsskysignature12/08/01 00:44
accentuation problemsGustavo10/29/01 15:52
LD_LIBRARY_PATHMatt Pritchard10/26/01 13:03
transformation an XML file jayakumar D10/22/01 04:17
XSL error for output comment generation?Xavier Outhier10/08/01 06:19
xslt-wml/sablotronbernd09/28/01 07:01
Modified XSLTransformer class for PHP4>=4.0.3Sandeep Khanna09/20/01 00:46
RE: Sablotron Apache1.3.12+PHP4.0.5+Win98Boris09/19/01 16:04
PHP-Versions, Win2k & SablotronBoris09/19/01 15:55
RE: include() problemJens Schriver09/14/01 11:43
Apache configurationAleksei08/28/01 05:24
RE: FYI: German 'Umlaute' with SablotronSalvatore08/28/01 02:15
PHP Sablotron extensionAleksei08/27/01 22:08
RE: xslt_process() dies, not returns falsechregu08/24/01 00:42
include() problemchris08/02/01 10:34
xml fileJoris Kluivers07/18/01 09:48
access to XSL filejan janssen07/17/01 02:55
Problems with 'not valid' HTML in XSLAlexey AK07/06/01 04:16
Sablotron & bad XML/XSLLehel07/05/01 02:26
RE: xslt_process() dies, not returns falseAlexandre Damiron07/04/01 05:26
RE: xslt_process() dies, not returns falseRoberto Shintani06/20/01 13:54
RE: sablotron + multiple XSL ?lsr06/05/01 09:35
RE: What about SQL->XMLpatbeau06/01/01 11:03
XSL with phpXML class?Tom05/20/01 10:34
RE: sablotron + multiple XSL ?Martynas Majeris05/20/01 00:37
sablotron + multiple XSL ?nono05/10/01 08:01
Modified version in Code LibraryMelvyn Sopacua05/05/01 10:17
RE: undefined functionradhak05/02/01 22:38
RE: --------------- COMPLETE STEPS FOR SABLOTRON Belka05/02/01 08:48
undefined function (Transforming radhak05/02/01 03:50
RE: expat/sablotron install problemsMelvyn Sopacua04/30/01 16:27
RE: How fast does it go mister?Jens Schriver04/27/01 12:29
RE: XSLT without Sablotron?Jens Schriver04/27/01 12:28
RE: Installation problem (yeah, again)E.deWolff04/26/01 08:38
expat/sablotron install problemsLehel04/24/01 08:50
RE: Installation problem (yeah, again)Jesper04/24/01 04:52
RE: Dinamic XML generation??? INSTALLING SABLOTRON ON LINUX RH704/20/01 06:42
XSLT without Sablotron?Thomas04/20/01 05:02
RE: Dinamic XML generation??? Bryan Brunton04/19/01 17:09
Installation problem (yeah, again)E.deWolff04/12/01 12:09
error in xsltNicolas04/12/01 04:54
RE: Dinamic XML generation??? Aki Sasaki04/04/01 20:55
--------------- COMPLETE STEPS FOR SABLOTRON Shashank Tripathi04/02/01 03:33
dinamic xsl ???Emanuele03/28/01 02:17
RE: sablotron under windowsquang03/13/01 11:11
RE: How fast does it go mister?Idan Sofer03/06/01 17:31
RE: xslt_process() dies, not returns falseEric Roth03/02/01 20:35
RE: InstalationGil03/01/01 23:55
RE: what W3C XSLT version does Sablotron supportsdaniele02/28/01 14:05
Updated version of classSander Westland02/28/01 12:21
PHPLIB, XSLT, and this ArticleBryan Brunton02/27/01 16:01
xslt_process() dies, not returns falseSergey Kanareykin02/27/01 14:14
RE: php_sablot.dllOla Strandberg02/26/01 02:25
why not libxslt (xslt parts of libxml)?olivier02/22/01 05:14
what W3C XSLT version does Sablotron supportsPatricia DiBenedetto02/20/01 12:28
RE: php_sablot.dllMatthew Peltzer02/18/01 17:09
php_sablot.dllMatthew Peltzer02/17/01 21:42
Sablotron XSLT_ERRORGeorge02/13/01 23:02
HTML tags in XML documentPeter Blum02/11/01 10:10
Dinamic XML generation??? Daniele02/09/01 02:17
Transform XML dinamically generated?Daniele02/09/01 01:26
RE: sablotron under windowsDanny Appaiah02/06/01 04:26
Sablotron Apache1.3.12+PHP4.0.5+Win98Danny Appaiah02/06/01 03:23
RE: HREFs embedded in XMLbeek01/30/01 13:59
RE: Installing an XSL parsersto01/30/01 01:04
RE: sablotron under windowssto01/30/01 01:00
Simple/Exact Steps for XSLT in WIN32wasti01/25/01 13:07
php_sablotn000b01/25/01 01:55
RE: sablotron under windowsDon Buchanan01/25/01 00:44
RE: Apache on W2000... & Sablotron futureTaco01/24/01 11:34
RE: Apache on W2000 php4.04 (rtfm)Peter01/24/01 07:32
RE: Apache on W2000 php4.04 (rtfm)Taco01/23/01 12:46
RE: HREFs embedded in XMLNam Xuan01/17/01 03:55
encoding problemDmitry Rud01/15/01 05:12
passing parameters - please helpJens01/15/01 04:08
RE: How can I use utf-16 or euc-kr encoding?Al Lin01/15/01 00:08
Apache on W2000 php4.04jan janssen01/11/01 06:20
Problems with sablotron...Andrew Nappin01/10/01 06:45
HREFs embedded in XMLCharles Dostale12/29/00 12:39
RE: Getting Sablotron with W32 PHPTim K12/08/00 15:02
Installing an XSL parserJay12/07/00 18:36
Using output buffering and XSLT transformNam Xuan12/06/00 22:30
RE: FYI: German 'Umlaute' with SablotronJustin Grant12/06/00 00:45
FYI: German 'Umlaute' with SablotronAxel Tietje12/01/00 08:00
Getting Sablotron with W32 PHPRonald TAO11/21/00 11:56
How can I use utf-16 or euc-kr encoding?Jaewook Ahn11/18/00 10:21
RE: modification to allow passing parametersGreg 11/15/00 14:39
modification to allow passing parametersdietrich11/09/00 15:29
New API in PHP 4.0.3pl1Nam Xuan11/09/00 02:50
undefined functionsiva11/09/00 00:54
RE: Getting Sablotron WorkingUrs Gehrig11/08/00 18:26
setting xml and xsl from stringsrowan11/08/00 17:45
RE: Error on shutdownrowan11/08/00 17:41
GEEZ the install is conveluted.Greg11/08/00 16:17
DLLs files for windowsBogdan11/08/00 10:47
Forgot to mention my config statement....Greg 11/07/00 12:12
Getting Sablotron WorkingGreg 11/07/00 11:48
How fast does it go mister?Alan Garfield11/07/00 05:49
RE: What about SQL->XMLTerence11/06/00 19:59
RE: InstalationMika11/04/00 22:25
RE: Output Buffering + Sablot Ext.Walter Jerusalinsky11/03/00 21:27
What about SQL->XMLseth banks11/03/00 14:52
RE: Output Buffering + Sablot Ext.Urs Gehrig11/03/00 06:58
Error on shutdownMichael Payne11/01/00 02:08
Output Buffering + Sablot Ext.Walter Jerusalinsky10/31/00 20:49
RE: InstalationVincent Vollers10/31/00 09:00
RE: InstalationOliver Kurz10/30/00 04:06
more columns like this please!Terence10/29/00 19:12
RE: Instalation (same here)M. Refky10/29/00 10:33
RE: InstalationM. Refky10/29/00 10:01
RE: Instalation (same here)Vincent Vollers10/28/00 11:31
RE: sablotron under windows [DISREGARD PREV]Walter10/27/00 18:29
RE: sablotron under windows - problemWalter10/27/00 18:18
InstalationLuis Argerich10/27/00 09:47
RE: Different API --- PHP 4.0.3 (XSL Parms)Jens Wabnitz10/27/00 03:09
RE: How do you compile this ?dietrich10/27/00 01:27
RE: Different API --- PHP 4.0.3 (XSL Parms)Justin Grant10/26/00 18:47
RE: Different API --- PHP 4.0.3Jens Wabnitz10/26/00 13:41
RE: Different API --- PHP 4.0.3Justin Grant10/26/00 12:32
trying to load sablotronw00g10/26/00 05:31
How do you compile this ?Oliver Kurz10/26/00 05:05
Different API --- PHP 4.0.3Mark Melvin10/25/00 18:40
RE: Bug in XSL File?Justin Grant10/25/00 15:43
sablotron under windowsPierre Kessler10/25/00 14:45
Bug in XSL File?Pat O'Neill10/25/00 10:07
 

If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly.

Add A Comment:

Name:

Email:

Subject:

Message:

To reduce spam posts, messages are now manually approved

You are not [logged in]. That means your account will not get credit for this post.