c'hai culoOriginariamente inviato da topolino
con xslt
Codice PHP:
/****************************************************
*** transformer class copyright: Mindexperiment
*** version: 1.0
*** this class let you load a correct xml document
*** with an xslt
*****************************************************/
class transformer {
private $xml;
private $xsl;
public $output;
public function __construct( $xmlSource, $xslSource ) {
$this->xml = new DOMDocument;
$this->xml->load( $xmlSource );
$this->xsl = new DOMDocument;
$this->xsl->load( $xslSource );
$this->output = $this->transform();
}
public function toHtml() {
return $this->output->saveHtml();
}
private function transform() {
$processor = new XSLTProcessor;
$processor->importStyleSheet( $this->xsl );
return $processor->transformToDoc( $this->xml );
}
}