<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >XSL functions</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="PHP 手册" HREF="index.html"><LINK REL="UP" TITLE="函数参考" HREF="funcref.html"><LINK REL="PREVIOUS" TITLE="XMLWriter::writeRaw" HREF="function.xmlwriter-write-raw.html"><LINK REL="NEXT" TITLE="XSLTProcessor::__construct" HREF="function.xsl-xsltprocessor-construct.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="reference" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP 手册</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.xmlwriter-write-raw.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.xsl-xsltprocessor-construct.html" ACCESSKEY="N" >下一页</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.xsl" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >CLXXXIII. XSL functions</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN245987" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="xsl.intro" >简介</A ></H1 ><P > The XSL extension implements the XSL standard, performing <A HREF="http://www.w3.org/TR/xslt" TARGET="_top" >XSLT transformations</A > using the <A HREF="http://xmlsoft.org/XSLT/" TARGET="_top" >libxslt library</A > </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="xsl.requirements" >需求</A ></H1 ><P > This extension uses <SPAN CLASS="productname" >libxslt</SPAN > which can be found at <A HREF="http://xmlsoft.org/XSLT/" TARGET="_top" >http://xmlsoft.org/XSLT/</A >. libxslt version 1.1.0 or greater is required. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="xsl.installation" >安装</A ></H1 ><P > PHP 5 includes the XSL extension by default and can be enabled by adding the argument <CODE CLASS="option" >--with-xsl[=DIR]</CODE > to your configure line. <TT CLASS="literal" >DIR</TT > is the libxslt installation directory. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="xsl.classes" >预定义类</A ></H1 ><P > </P ><DIV CLASS="section" ><H2 CLASS="section" ><A NAME="xsl.class.xsltprocessor" ><B CLASS="classname" >XSLTProcessor</B ></A ></H2 ><P > </P ><DIV CLASS="section" ><H3 CLASS="section" ><A NAME="xsl.class.xsltprocessor.constructor" >构造函数</A ></H3 ><P ></P ><UL ><LI ><P ><A HREF="function.xsl-xsltprocessor-construct.html" >XSLTProcessor::__construct</A > - construct a new XSLTProcessor object</P ></LI ></UL ></DIV ><DIV CLASS="section" ><H3 CLASS="section" ><A NAME="xsl.class.xsltprocessor.methods" >方法</A ></H3 ><P ></P ><UL ><LI ><P ><A HREF="function.xsl-xsltprocessor-get-parameter.html" >XSLTProcessor::getParameter</A > - Get value of a parameter</P ></LI ><LI ><P ><A HREF="function.xsl-xsltprocessor-has-exslt-support.html" >XSLTProcessor::hasExsltSupport</A > - Determine if PHP has EXSLT support</P ></LI ><LI ><P ><A HREF="function.xsl-xsltprocessor-import-stylesheet.html" >XSLTProcessor::importStylesheet</A > - Import stylesheet</P ></LI ><LI ><P ><A HREF="function.xsl-xsltprocessor-register-php-functions.html" >XSLTProcessor::registerPHPFunctions</A > - Enables the ability to use PHP functions as XSLT functions</P ></LI ><LI ><P ><A HREF="function.xsl-xsltprocessor-remove-parameter.html" >XSLTProcessor::removeParameter</A > - Remove parameter</P ></LI ><LI ><P ><A HREF="function.xsl-xsltprocessor-set-parameter.html" >XSLTProcessor::setParameter</A > - Set value for a parameter</P ></LI ><LI ><P ><A HREF="function.xsl-xsltprocessor-transform-to-doc.html" >XSLTProcessor::transformToDoc</A > - Transform to DOMDocument</P ></LI ><LI ><P ><A HREF="function.xsl-xsltprocessor-transform-to-uri.html" >XSLTProcessor::transformToURI</A > - Transform to URI</P ></LI ><LI ><P ><A HREF="function.xsl-xsltprocessor-transform-to-xml.html" >XSLTProcessor::transformToXML</A > - Transform to XML</P ></LI ></UL ></DIV ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="xsl.examples" >范例</A ></H1 ><P > Many examples in this reference require both an XML and an XSL file. We will use <TT CLASS="filename" >collection.xml</TT > and <TT CLASS="filename" >collection.xsl</TT > that contains the following: </P ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN246052" ></A ><P ><B >例 1. collection.xml</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="xml" ><collection> <cd> <title>Fight for your mind</title> <artist>Ben Harper</artist> <year>1995</year> </cd> <cd> <title>Electric Ladyland</title> <artist>Jimi Hendrix</artist> <year>1997</year> </cd> </collection></PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN246055" ></A ><P ><B >例 2. collection.xsl</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="xml" ><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:param name="owner" select="'Nicolas Eliaszewicz'"/> <xsl:output method="html" encoding="iso-8859-1" indent="no"/> <xsl:template match="collection"> Hey! Welcome to <xsl:value-of select="$owner"/>'s 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"/> - <xsl:value-of select="year"/></h2> <hr /> </xsl:template> </xsl:stylesheet></PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="xsl.constants" >预定义常量</A ></H1 ><P >以下常量由本扩展模块定义,因此只有在本扩展模块被编译到 PHP 中,或者在运行时被动态加载后才有效。</P ><P ></P ><DIV CLASS="variablelist" ><DL ><DT ><TT CLASS="constant" ><B >XSL_CLONE_AUTO</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >XSL_CLONE_NEVER</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >XSL_CLONE_ALWAYS</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >LIBXSLT_VERSION</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > libxslt version like 10117. Available as of PHP 5.1.2. </P ></DD ><DT ><TT CLASS="constant" ><B >LIBXSLT_DOTTED_VERSION</B ></TT > (<A HREF="language.types.string.html" ><B CLASS="type" >string</B ></A >)</DT ><DD ><P > libxslt version like 1.1.17. Available as of PHP 5.1.2. </P ></DD ><DT ><TT CLASS="constant" ><B >LIBEXSLT_VERSION</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > libexslt version like 813. Available as of PHP 5.1.2. </P ></DD ><DT ><TT CLASS="constant" ><B >LIBEXSLT_DOTTED_VERSION</B ></TT > (<A HREF="language.types.string.html" ><B CLASS="type" >string</B ></A >)</DT ><DD ><P > libexslt version like 1.1.17. Available as of PHP 5.1.2. </P ></DD ></DL ></DIV ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >目录</B ></DT ><DT ><A HREF="function.xsl-xsltprocessor-construct.html" >XSLTProcessor::__construct</A > -- Creates a new XSLTProcessor object</DT ><DT ><A HREF="function.xsl-xsltprocessor-get-parameter.html" >XSLTProcessor::getParameter</A > -- Get value of a parameter</DT ><DT ><A HREF="function.xsl-xsltprocessor-has-exslt-support.html" >XSLTProcessor::hasExsltSupport</A > -- Determine if PHP has EXSLT support</DT ><DT ><A HREF="function.xsl-xsltprocessor-import-stylesheet.html" >XSLTProcessor::importStylesheet</A > -- Import stylesheet</DT ><DT ><A HREF="function.xsl-xsltprocessor-register-php-functions.html" >XSLTProcessor::registerPHPFunctions</A > -- Enables the ability to use PHP functions as XSLT functions</DT ><DT ><A HREF="function.xsl-xsltprocessor-remove-parameter.html" >XSLTProcessor::removeParameter</A > -- Remove parameter</DT ><DT ><A HREF="function.xsl-xsltprocessor-set-parameter.html" >XSLTProcessor::setParameter</A > -- Set value for a parameter</DT ><DT ><A HREF="function.xsl-xsltprocessor-transform-to-doc.html" >XSLTProcessor::transformToDoc</A > -- Transform to a DOMDocument</DT ><DT ><A HREF="function.xsl-xsltprocessor-transform-to-uri.html" >XSLTProcessor::transformToURI</A > -- Transform to URI</DT ><DT ><A HREF="function.xsl-xsltprocessor-transform-to-xml.html" >XSLTProcessor::transformToXML</A > -- Transform to XML</DT ></DL ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.xmlwriter-write-raw.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >起始页</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.xsl-xsltprocessor-construct.html" ACCESSKEY="N" >下一页</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >XMLWriter::writeRaw</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="funcref.html" ACCESSKEY="U" >上一级</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >XSLTProcessor::__construct</TD ></TR ></TABLE ></DIV ></BODY ></HTML >