mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-19 02:18:56 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@164874 c90b9560-bf6c-de11-be94-00142212c4b1
148 lines
3.4 KiB
XML
148 lines
3.4 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.6 $ -->
|
|
<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 <ulink url="&url.libxslt;">
|
|
libxslt library</ulink>
|
|
</para>
|
|
</section>
|
|
|
|
<section id="xsl.requirements">
|
|
&reftitle.required;
|
|
<para>
|
|
This extension uses <productname>libxslt</productname> which can be
|
|
found at <ulink url="&url.libxslt;">&url.libxslt;</ulink>. libxslt
|
|
version 1.0.18 or greater is required.
|
|
</para>
|
|
</section>
|
|
|
|
&reference.xsl.configure;
|
|
|
|
<section id="xsl.examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
In this small tutorial we will learn how to transform an XML
|
|
document into HTML.
|
|
</para>
|
|
<para>
|
|
<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>
|
|
</para>
|
|
<para>
|
|
<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>
|
|
</para>
|
|
<para>
|
|
<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>
|
|
</para>
|
|
</section>
|
|
|
|
&reference.xsl.constants;
|
|
|
|
</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
|
|
-->
|