note 85390 added to function.xslt-create
| From: | LW at osu1 dot php dot net | Date: | Thu, 28 Aug 2008 08:41:30 +0000 |
| Subject: | note 85390 added to function.xslt-create | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-143909@lists.php.net to get a copy of this message | ||
Hello,
I changed the function from myadzel (?) a little bit, so that it now correctly uses either a file OR
a string as parameter - WITHOUT producing PHP warnings. See here:
<?php
function xslt ($xml, $xsl) {
$xh = @xslt_create();
$args['xml'] = ( file_exists( $xml ) )?join ('', file ($xml)):$xml;
$args['xsl'] = ( file_exists( $xsl ) )?join ('', file ($xsl)):$xsl;
// try with a string
$result = @xslt_process ($xh, 'arg:/xml', 'arg:/xsl', NULL, $args);
// try with resource
if (!$result) { $result = @xslt_process ($xh, $xml, $xsl); }
@xslt_free ($xh);
return $result;
}
?>
Examples:
echo xslt ('./index.xml', './index.xsl');
echo xslt ('<test><example>An example!</example></test>',
'./index.xsl');
----
Server IP: 212.124.37.9
Probable Submitter: 80.137.36.165
----
Manual Page -- http://www.php.net/manual/en/function.xslt-create.php
Edit -- https://master.php.net/note/edit/85390
Del: integrated -- https://master.php.net/note/delete/85390/integrated
Del: useless -- https://master.php.net/note/delete/85390/useless
Del: bad code -- https://master.php.net/note/delete/85390/bad+code
Del: spam -- https://master.php.net/note/delete/85390/spam
Del: non-english -- https://master.php.net/note/delete/85390/non-english
Del: in docs -- https://master.php.net/note/delete/85390/in+docs
Del: other reasons-- https://master.php.net/note/delete/85390
Reject -- https://master.php.net/note/reject/85390
Search -- https://master.php.net/manage/user-notes.php