Dear all
A friend of mine has a simple content-creation system using XML/XSLT and ASP. The file litesite.xml is transformed to HTML by the file litesite.xsl. The transformation is set in motion by the file default.aspx. What the ASPX file does is pass arguments to the XSLT file so that the different pages in the website can be chosen and displayed. The whole thing looks like this: http://www.tanguay.info/litesite.
My friend and I would like to offer the same functionality in PHP for PHP users. So I've written/borrowed some PHP that looks like this:
<?php
/* litesite.php: transform litesite using PHP instead of ASP */
// set the filenames
$xml_file = "litesite_php.xml";
$xslt_file = "litesite_php.xsl";
// convert the xml and xslt to a string
$xml_string = join(' ', file($xml_file));
$xslt_string = join(' ', file($xslt_file));
$arguments = array("/xml" => $xml_string, "/xslt" => $xsl_string);
// Allocate a new XSLT processor
$xh = xslt_create();
// Process the document
$result = xslt_process($xh, "arg:/xml", "arg:/xslt", NULL, $arguments);
if ($result) {
print $result;
}
else {
print "Sorry, litesite_php.xml could not be transformed by litesite_php.xsl into";
print " the \$result variable. The reason for this is:<br />" . xslt_error($xh) .
print "<br />The error code for this error is:< >" . xslt_errno($xh);
print "</p></span></body></html>";
}
xslt_free($xh);
?>
There are obviously some fundamental errors in this. The error message I get is this:
Warning: Sablotron error on line 1: unknown encoding '' in /home/www/einsweb/_md/scotreal.info/experiment/litesite.php on line 24
Sorry, litesite_php.xml could not be transformed by litesite_php.xsl into
The error code for this error is:< >69 the $result variable. The reason for this is:
unknown encoding ''1
My problem is that I am somewhat out of my depth - I don't really know much about XSLT and I find the PHP code that I've borrowed a little strange at points. I'm attaching the XML/XSLT files. If anyone would like to give me some hints as to what my basic error is, I'd be very grateful.
Thank you for your help
Norman