<?php

// Get Variables

$XML $_GET['xml'];
$XSL $_GET['xsl'];
$format $_GET['format'];

// Validate

if (!$XML || !$XSL) {
echo 
"<h2>Directions: <br>";
echo 
"Example: http://www.rationalmind.net/?file=XSLT&xml=david/bookmarks.xml&xsl=david/bookmarks.xsl<br>";
echo 
"Optionally, add &format=xml<br>";
echo 
"For more, see my blog.</h2>";
die(); }


// What to do?

if ($format == xml) {
header('Content-type: text/xml'true);
//echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">";

} else {
echo 
"<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">";
}

// Allocate a new XSLT processor
$xh xslt_create();

// Process the document, returning the result into the $result variable
$result xslt_process($xh$XML$XSL);
if (
$result) {
    print 
$result;

}
else {
    print 
"Sorry, sample.xml could not be transformed by sample.xsl into";
    print 
"  the \$result variable the reason is that " xslt_error($xh) .
    print 
" and the error code is " xslt_errno($xh);
}

xslt_free($xh);

?>