Forum und email

XSL functions

Introdução

A extensão XSL implementa o padrão XSL, executando » transformações XSLT usando a » biblioteca libxslt

Dependências

Esta extensão usa libxslt que pode ser encontrada em » https://xmlsoft.org/XSLT/. Versão da libxslt 1.1.0 ou maior é requerido.

Instalação

PHP 5 inclue a extensão XSL por padrão e pode ser habilitada adicionando o argumento --with-xsl[=DIR] na linha de configuração. DIR é o diretório da instalação da libxslt.

Classes pré-definidas

XSLTProcessor

Construtor

Métodos

Exemplos

Muitos exemplos nesta referência requerem um arquivo XML e XSL. Nós iremos usar collection.xml e collection.xsl que contêm o seguinte:

Example#1 collection.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>

Example#2 collection.xsl

<xsl:stylesheet version="1.0" xmlns:xsl="https://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>

Constantes pré-definidas

As contantes abaixo são definidas por esta extensão e somente estarão disponíveis quando a extensão foi compilada com o PHP ou carregada dinamicamente durante a execução.

XSL_CLONE_AUTO (integer)
XSL_CLONE_NEVER (integer)
XSL_CLONE_ALWAYS (integer)
LIBXSLT_VERSION (integer)
versão da libxslt como 10117. Disponível no PHP 5.1.2.
LIBXSLT_DOTTED_VERSION (string)
versão da libxslt como like 1.1.17. Disponível no PHP 5.1.2.
LIBEXSLT_VERSION (integer)
versão da libexslt como 813. Disponível no PHP 5.1.2.
LIBEXSLT_DOTTED_VERSION (string)
versão da libexslt como 1.1.17. Disponível no PHP 5.1.2.

Índice