Location: PHPKode > projects > Sourdough > sourdough/Sd_Xslt/Sd_Xslt_xalan.class.php
<?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 Xalan XSLT processor
*
* @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_xalan.class.php 3003 2007-12-08 11:05:17Z piezzi $
*/
class Sd_Xslt_xalan extends Sd_Xslt {
//[start] Constructor
	/**
	* Sd_Xslt_xalan constructor
	*
	* @param    Sourdough  $Sourd  Sourdough global object
	*/
	public function __construct(Sourdough $Sourd)
	{
		$this->Sourdough = $Sourd;
		parent::__construct();
	}
//[end]

//[start] Public Methods
	/**
	* Xalan XSL transformation
	*
	* @return    void
	*/
	public function transform()
	{
		$xml = $this->XML;
		$xsl = $this->XSL;
		
		if(file_exists($xml) && file_exists($xsl)) {
			$cmd = $this->conf['xalan_bin'].' -q -in '.$xml.' -xsl '.$xsl;
			
			if(is_array($this->params)) {
				foreach($this->params as $k => $v) {
					$cmd .= ' -param '.$k.' "\''.addslashes($v).'\'" ';
				}
			}
			
			if($this->conf['show_error'])
				$cmd .= ' 2>&1 ';
			else
				$cmd .= ' 2>/dev/null ';
			
			$output = array();
			exec($cmd, $output);
			$this->out = implode("\n", $output);
		} else {
			Sd_ErrorManager::raiseError(0, 'XSLT error: Xalan cannot handle files.');
		}
	}
	/**
	* Return Xalan output
	*
	* @return    string
	*/
	public function output()
	{
		return $this->out;
	}
//[end]
}
?>
Return current item: Sourdough