<?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 Sablotron 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_sablot.class.php 3003 2007-12-08 11:05:17Z piezzi $
*/
class Sd_Xslt_sablot extends Sd_Xslt {
//[start] Local Variables
/**
* XSLT handle
*
* @var resource $xh
*/
protected $xh;
//[end]
//[start] Constructor
/**
* Sd_Xslt_sablot constructor
*
* @param Sourdough $Sourd Sourdough global object
*/
public function __construct(Sourdough $Sourd)
{
$this->Sourdough = $Sourd;
parent::__construct();
}
//[end]
//[start] Public Methods
/**
* Sablot XSL transformation
*
* @return void
*/
public function transform()
{
$xml = $this->XML;
$xsl = $this->XSL;
$args = array();
if(!$this->is_content) {
$xml = Sd_File::getContent($xml);
$xsl = Sd_File::getContent($xsl);
}
$args['/_xml'] = $xml;
$args['/_xsl'] = $xsl;
if(!empty($this->params)) {
$this->out = @xslt_process($this->xh, 'arg:/_xml', 'arg:/_xsl', NULL, $args, $this->params);
} else {
$this->out = @xslt_process($this->xh, 'arg:/_xml', 'arg:/_xsl', NULL, $args);
}
if(!$this->out) {
Sd_ErrorManager::raiseError(0, 'XSLT error: '.xslt_errno($this->xh).' - '.xslt_error($this->xh));
}
}
/**
* Return Sablot output
*
* @return string
*/
public function output()
{
$this->close();
return $this->out;
}
//[end]
//[start] Protected/Private Methods
/**
* Sablot initialization
*
* @return void
*/
protected function init()
{
$this->xh = xslt_create();
}
/**
* Close Sablot XSLT process
*
* @return void
*/
protected function close()
{
xslt_free($this->xh);
}
//[end]
}
?>