<?php
//
// +--------------------------------------------------------------------+
// | Sourdough PHP Application Framework |
// +--------------------------------------------------------------------+
// | Copyright (c) 2001-2007 Philip Iezzi, phpee.com |
// | Web http://sourdough.phpee.com/ |
// | License GNU Lesser General Public License (LGPL) |
// +--------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// +--------------------------------------------------------------------+
//
/**
* Sourdough PHP Application Framework
* @package sourdough
* @subpackage xslt
*/
/**
* SOURDOUGH XSL transformation class for the DOMXML library
*
* @package sourdough
* @subpackage xslt
* @author Philip Iezzi <pipo at phpee dot com>
* @author based on XSLT class http://www.neokraft.net, original author: Olivier Meunier
* @copyright Copyright (c) 2001-2007 PHPEE.COM
* @license http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License
* @version $Id: Sd_Xslt_dom.class.php 3003 2007-12-08 11:05:17Z piezzi $
*/
class Sd_Xslt_dom extends Sd_Xslt {
//[start] Constructor
/**
* Sd_Xslt_dom constructor
*
* @param Sourdough $Sourd Sourdough global object
*/
public function __construct(Sourdough $Sourd)
{
$this->Sourdough = $Sourd;
parent::__construct();
}
//[end]
//[start] Public Methods
/**
* DOMXML XSL transformation
*
* @return void
*/
public function transform() {
$xml = $this->XML;
$xsl = $this->XSL;
if($this->is_content) {
$objXML = domxml_open_mem($xml);
$objXSL = domxml_xslt_stylesheet($xsl);
} else {
if (file_exists(getcwd().'/'.$xml)) {
$objXML = domxml_open_file(getcwd().'/'.$xml);
} elseif(file_exists($xml)) {
$objXML = domxml_open_file($xml);
} else {
$xml = Sd_File::getContent($xml);
$objXML = domxml_open_mem($xml);
}
if (file_exists(getcwd().'/'.$xsl)) {
$objXSL = domxml_xslt_stylesheet_file(getcwd().'/'.$xsl);
} elseif (file_exists($xsl)) {
$objXSL = domxml_xslt_stylesheet_file($xsl);
} else {
$xsl = Sd_File::getContent($xsl);
$objXSL = domxml_xslt_stylesheet($xsl);
}
}
if(!is_array($this->params))
$this->params = array();
$this->out = $objXSL->process($objXML,$this->params);
}
/**
* Return DOMXML output
*
* @return string
*/
public function output()
{
return $this->out->html_dump_mem();
}
//[end]
}
?>