XSL functions
XSL
&reftitle.intro;
&warn.experimental;
The XSL extension implements the XSL standard, performing
XSLT transformations using the
libxslt library
&reftitle.required;
This extension uses libxslt which can be
found at &url.libxslt;. libxslt
version 1.0.18 or greater is required.
&reference.xsl.configure;
&reftitle.examples;
In this small tutorial we will learn how to transform an XML
document into HTML.
A simple XSL tree
Hey! Welcome to my sweet CD collection!
by
-
]]>
Corresponding XML tree
PHP Rock
Joe Coder
2003
Squashing Typos on a Winter's Eve
kennyt
2004
]]>
Making XML into HTML
The following PHP code uses the XML and XSL extensions to
transform XML into presentable HTML.
load('example.xml');
$xsl = new DomDocument;
$xsl->load('example.xsl');
/* Configure the transformer */
$proc = new xsltprocessor;
$proc->importStyleSheet($xsl); // attach the xsl rules
echo $proc->transformToXML($xml); // actual transformation
?>
]]>
This should produce an HTML fragment similar to the following:
PHP Rock
by Joe Coder
- 2003
Squashing Typos on a Winter's Eve
by kennyt
- 2004
]]>
&reference.xsl.functions;