PHP: xslt_create - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

xslt_errno xslt_backend_version

Last updated: Sat, 27 Jan 2007

view this page in

# xslt_create

(PHP 4 >= 4.0.3, PECL)

xslt_create -- Create a new XSLT processor

## Description

resource xslt_create ( void )

Create and return a new XSLT processor resource for manipulation by the other XSLT functions.

## Примеры

Пример 1. xslt_create() example

`<?php
function xml2html($xmldata, $xsl)
{
/* $xmldata -> your XML */
/* $xsl -> XSLT file */
$path = 'include';
$arguments = array('/_xml' => $xmldata);
$xsltproc = xslt_create();
xslt_set_encoding($xsltproc, 'ISO-8859-1');
$html =
xslt_process($xsltproc, 'arg:/_xml', "$path/$xsl", NULL, $arguments);
if (empty($html)) {
die('XSLT processing error: '. xslt_error($xsltproc));
}
xslt_free($xsltproc);
return $html;
}
?>`

## Смотрите также

xslt_free().

add a note User Contributed Notes
xslt_create
Kerry Kobashi
28-Mar-2005 07:29
`It should be noted that xslt_create() will return FALSE in the case of failure (Sablotron processor could not be created).
This, obtained from looking at the source code extension.`
garth at webconexion dot net
18-Sep-2003 05:23
`In order to pass PHP variables into an XSL document you need to do the following:
Firstly I created the following function to use:
function GetXHTML($sXML, $sXSL, $aParameters)
{
$hXML = xslt_create();
$aArguments = array('/_xml' => $sXML, '/_xsl' => $sXSL);
$sXHTML = xslt_process($hXML, 'arg:/_xml', 'arg:/_xsl', NULL, $aArguments, $aParameters);
xslt_free($hXML);
return $sXHTML;
}
Then call it like thus, passing the XML and XSL as a string with the final parameter being an array which can contain as many values as you wish to pass in:
$sXHTML = GetXHTML($sXML, $sXSL, array("age"=>"26"));
Then in the XSL document you need the following:
<xsl:param name="age" />
Then where you want to display the value of age you do this:
<xsl:value-of select="$age" />
Thanks now.`
add a note
xslt_errno xslt_backend_version

Last updated: Sat, 27 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 10:36:09 2007 PST