Adding a bit of documentation for /ext/xsl.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@154729 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Ken 2004-03-28 06:42:32 +00:00
parent 498e7101b0
commit 24e65da400

139
reference/xsl/reference.xml Normal file
View file

@ -0,0 +1,139 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<reference id="ref.xsl">
<title>XSL functions</title>
<titleabbrev>XSL</titleabbrev>
<partintro>
<section id="xsl.intro">
&reftitle.intro;
&warn.experimental;
<para>
The XSL extension implements the XSL standard, performing
XSLT transformations using the libxslt library.
</para>
</section>
<section id="xsl.installation">
&reftitle.install;
<para>
PHP 5 includes XSL by default, but it can be enabled
explicitly by adding the argument
<option role="configure">--enable-xsl[=DIR]</option>.
<literal>DIR</literal> is the libxslt installation directory.
</para>
</section>
<section id="xsl.examples">
&reftitle.examples;
<para>
In this small tutorial we will learn how to transform an XML
document into HTML.
</para>
<section id="xsl.examples.sources">
<example>
<title>A simple XSL tree</title>
<programlisting role="xml">
<![CDATA[
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="iso-8859-1" indent="no"/>
<xsl:template match="collection">
Hey! Welcome to my sweet CD collection!
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="cd">
<h1><xsl:value-of select="title"/></h1>
<h2>by <xsl:value-of select="artist"/></h2>
<h3> - <xsl:value-of select="year"/></h3>
</xsl:template>
</xsl:stylesheet>
]]>
</programlisting>
</example>
<example>
<title>Corresponding XML tree</title>
<programlisting role="xml">
<![CDATA[
<collection>
<cd>
<title>PHP Rock</title>
<artist>Joe Coder</artist>
<year>2003</year>
</cd>
<cd>
<title>Squashing Typos on a Winter's Eve</title>
<artist>kennyt</artist>
<year>2004</year>
</cd>
</collection>
]]>
</programlisting>
</example>
</section>
<example>
<title>Making XML into HTML</title>
<simpara>
The following PHP code uses the XML and XSL extensions to
transform XML into presentable HTML.
</simpara>
<programlisting role="php">
<![CDATA[
<?php
/* Load the two XML sources */
$xml = new DomDocument; // from /ext/dom
$xml->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
?>
]]>
</programlisting>
<simpara>
This should produce an HTML fragment similar to the following:
</simpara>
<screen>
<![CDATA[
Hey! Welcome to my sweet CD collection!
<h1>PHP Rock</h1>
<h2>by Joe Coder</h2>
<h3> - 2003</h3>
<h1>Squashing Typos on a Winter's Eve</h1>
<h2> by kennyt</h2>
<h3> - 2004</h3>
]]>
</screen>
</example>
</section>
</partintro>
&reference.xsl.functions;
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->