PhpDig.net

What is PhpDig?
PhpDig is a PHP MySQL based
Web Spider & Search Engine.




xslt_transform

Name

xslt_transform — Applies a stylesheet to an XML document with one function call.

Synopsis

boolean xslt_transform(xslt_URI, xml_URI, result_URI[, xslt_parameters][, xslt_arguments][, result]);
string xslt_URI: Location of stylesheet file
string xml_URI: Location of XML document file
string result_URI: Location of file in which to place results
array xslt_parameters (optional): Array of top-level XSLT parameters to pass to the stylesheet
array xslt_arguments (optional): Array of named document buffers to pass to the stylesheet
string result (optional): String which will contain the result when complete

Returns

TRUE if successful; FALSE otherwise.

Description

This function applies the stylesheet contained in the file named by xslt_URI to the XML document named by xml_URI . The results of the transformation are then placed into the internal buffer named by result_URI , which must use the 'arg:' URI scheme. xslt_parameters , if given, should contain a list of variables to be passed to the stylesheet. The xslt_arguments array, if given, is a list of named document buffers to be passed to the stylesheet.

Example

Example 1147. Using xslt_transform() in different ways

<?php
echo "<h3>Straight & simple processing</h3>\n";
$result = '';
if (xslt_transform('slashdot.xsl', 'slashdot.xml', 'arg:/_result', 0, 0, $result)) {
    echo $result;
} else {
    echo xslt_error();
}

echo "<h3>Using named buffers</h3>\n";
$result = '';
$arglist = array('xslbuffer' => join('', file('slashdot.xsl')), 
                 'xmlbuffer' => join('', file('slashdot.xml')));
if (xslt_transform('arg:/xslbuffer',
                   'arg:/xmlbuffer',
                   'arg:/_result', 
                   0, $arglist,
                   $result)) {
    echo $result;
} else {
    echo xslt_error();
}

echo "<h3>Providing parameters</h3>\n";
$result = '';
$params = array('generated-for' => 'Torben Wilson');
if (xslt_transform('slashdot.xsl', 'slashdot.xml',
                   'arg:/_result', $params, 0, $result)) {
    echo $result;
} else {
    echo xslt_error();
}
?>



PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing (Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch). This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/). The authors of this book have elected not to choose any options under the OPL. This online book was obtained from http://www.fooassociates.com/phpfer/ and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4 for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All persons and entities shall have neither liability nor responsibility to any person or entity with respect to any loss or damage arising from the information contained in this book.

Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.