Ok, so I get this error when trying to transform my XML with PHP:
Warning: Sablotron error on line 1: XML parser error 3: no element found in /home/httpd/vhosts/noctambus.com/httpdocs/reviews/xml/standardbrowser.php on line 85
Below is the PHP code I've been using:
<?php
$CONF_XSL_FILE = "/home/virtual/site4/fst/var/www/html/reviews/xsl/standardbrowser.xsl";
$CONF_XML_DIR = "/home/virtual/site4/fst/var/www/html/reviews/xml/";
$transformer = new XSLTransformer();
if ($transformer->setXsl($CONF_XSL_FILE) && $transformer->setXml($CONF_XML_DIR . $x)) { $transformer->transform(); echo $transformer->getOutput();
} else {
echo $transformer->getError(); }
/* XSLTranformer -- Class to transform XML files using XSL with the Sablotron libraries. */
class XSLTransformer { var $xsl, $xml, $output, $error ;
/* Constructor */
function XSLTransformer() { $this->processor = xslt_create(); }
/* Destructor */
function destroy() { xslt_destroy_processor($this->processor); }
/* output methods */
function setOutput($string) { $this->output = $string; }
function getOutput() { return $this->output; }
/* set methods */
function setXml($uri) { if($doc = new docReader($uri)) { $this->xml = $doc->getString(); return true; } else { $this->setError("Could not open $xml"); return false; } }
function setXsl($uri) { if($doc = new docReader($uri)) { $this->xsl = $doc->getString(); return true; } else { $this->setError("Could not open $uri"); return false; } }
/* transform method */
function transform() {
$arguments = array( '/_xml' => $this->xml, '/_xsl' => $this->xsl );
$this->setOutput( xslt_process($this->processor, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments) );
$this->setError($err); }
/* Error Handling */
function setError($string) { $this->error = $string; }
function getError() { return $this->error; } }
/* docReader -- read a file or URL as a string */
class docReader { var $string; // public string representation of file var $type; // private URI type: 'file','url' var $bignum = 1000000; var $uri;
/* public constructor */
function docReader($uri) { // returns integer $this->setUri($uri); $this->setType();
$fp = fopen($this->getUri(),"r");
if($fp) { // get length if ($this->getType() == 'file') { $length = filesize($this->getUri()); } else { $length = $this->bignum; } $this->setString(fread($fp,$length)); return 1; } else { return 0; } }
/* determine if a URI is a filename or URL */
function isFile($uri) { // returns boolean if (strstr($uri,'http://') == $uri) { return false; } else { return true; } }
/* set and get methods */
function setUri($string) { $this->uri = $string; }
function getUri() { return $this->uri; }
function setString($string) { $this->string = $string; }
function getString() { return $this->string; }
function setType() { if ($this->isFile($this->uri)) { $this->type = 'file'; } else { $this->type = 'url'; } }
function getType() { return $this->type; } }
?>
Why am I getting this error? My XMl document, as well as my XSlL see to be ok. My PHP 4.3.3 never gave me a problem like this. What's going on?
Thanks!!!
"The superior man seeks [room for improvement or occasion to blame] in himself; the inferior man seeks it in others."
-K'ung Fu-Tzu, 'Great Learning', Ch. 9, v. 15:20
"Conscience is the chamber of justice." -Origen
Got Ragnar?
http://www.TerribleMovies.Com
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.620 / Virus Database: 399 - Release Date: 3/11/2004