Location: PHPKode > scripts > XSLT Transform > xslt-transform/XSLTTransform.php
<?php
	/**
	* class XSLTTransform
	*
	* { Description :- 
	*	
	* }
	*/

	class XSLTTransform
	{
		var $xmlfile;
		var $xslfile;
		var $xmldata;
		var $xsldata;
		var $resulttree;
		
		/**
		* Method XSLTTransform::XSLTTransform()
		*
		* { Description :- 
		*	This method resizes the image.
		* }
		*/
		
		function XSLTTransform($xmlfile, $xslfile)
		{
			$this->xmlfile = $xmlfile;
			$this->xslfile = $xslfile;
			$this->readFiles();
		}
		
		/**
		* Method XSLTTransform::readFiles()
		*
		* { Description :- 
		*	This method resizes the image.
		* }
		*/
		
		function readFiles()
		{
			$fp = fopen($this->xmlfile, "r");
			$this->xmldata = fread($fp, filesize($this->xmlfile));
			fclose($fp);
			$fp = fopen($this->xslfile, "r");
			$this->xsldata = fread($fp, filesize($this->xslfile));
			fclose($fp);
			$this->transform();
		}
		
		/**
		* Method XSLTTransform::transform()
		*
		* { Description :- 
		*	This method resizes the image.
		* }
		*/
		
		function transform()
		{
			$arguments = array(
						"/_xml" => $this->xmldata,
						"/_xsl" => $this->xsldata);
						
			$xh = xslt_create();
			
			$this->resulttree = xslt_process($xh, "arg:/_xml", "arg:/_xsl", null, $arguments);
			if(!$this->resulttree)
			{
				echo "Error $this->xmlfile cannot be transformed ";
				echo "Error: " . xslt_error($xh) . " Error No: " . xslt_errno($xh);
			}
		}
		
		/**
		* Method XSLTTransform::getResultTree()
		*
		* { Description :- 
		*	This method resizes the image.
		* }
		*/
		
		function getResultTree()
		{
			return $this->resulttree;
		}
	}
?>
Return current item: XSLT Transform