Mam taki kod, ktory ma wykonac konwersję:
<?php
class bigXslt {
var $xsltproc;
function bigXslt () {
if (PHP_VERSION >= 5) {
$this->xsltproc = new XsltProcessor();
} else {
$this->xsltproc = xslt_create();
}
}
function createHtml ($xml, $xsl) {
return false;
}
$arguments = array('/_xml' => $xml,'/_xsl' =>$xsl);
$html = $this->_xsltProcess ('arg:/_xml', 'arg:/_xsl', null, $arguments);
$this->_xsltFree();
return $html;
}
function _xsltProcess($xml_arg,$xsl_arg,$xslcontainer = null,$args = null,$params = null) {
// Start with preparing the arguments
// Create instances of the DomDocument class
$xml = new DomDocument;
$xsl = new DomDocument;
// Load the xml document and the xsl template
$xml->loadXML($args[$xml_arg]);
$xsl->loadXML($args[$xsl_arg]);
// Load the xsl template
$this->xsltproc->importStyleSheet($xsl);
// Set parameters when defined
if ($params) {
foreach ($params as $param => $value) {
$xsltproc->setParameter("", $param, $value);
}
}
// Start the transformation
$processed = $this->xsltproc->transformToXML($xml);
// Put the result in a file when specified
if ($xslcontainer) {
return @file_put_contents($xslcontainer, $processed);
} else {
return $processed;
}
}
function _xsltFree() {
}
}
$parser = new bigXslt ();
$html = $parser->createHtml ("file.xml", "file.xsl");
?>
Jednakze wyrzuca bledy:
Kod
Warning: DOMDocument::loadXML() [function.loadXML]: XML declaration allowed only at the start of the document in Entity, line: 2 in /home/pawel/public_html/konw.php on line 41
Warning: Invalid or inclomplete context in /home/pawel/public_html/konw.php on line 55
W czym jest problem?