Location: PHPKode > scripts > XML Sapiens Processor > xml-sapiens-processor/sample.php
<?PHP
/**
 * An example of how to use XML Sapiens Processor
 *
 * PHP versions 4 
 *
 * LICENSE: This source file is subject to version 3.0 of the PHP license
 * that is available through the world-wide-web at the following URI:
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
 * the PHP License and are unable to obtain it through the web, please
 * send a note to hide@address.com so we can mail you a copy immediately.
 *
 * @category   Processor
 * @package    SAPIPROCESSOR
 * @author     Max Baryshnikov <hide@address.com>
 * @author     Dmitry Sheiko <hide@address.com>
 * @copyright  2004-2005 XML Sapiens Team
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
 * @version    CVS: $Id:$
 * @link       http://pear.php.net/package/PackageName
 * @see        nothing
 * @since      File available since Release 1.0.0
 * @deprecated File deprecated in Release 1.0.0
 */

 /**
 * We are loading XML Sapiens expression functions
 */
 include("mvc/view/sapiexpressions.php");
 
 /**
 * We are loading XML Sapiens class
 */ 
 include("mvc/view/sapiprocessor.php");
 
 /**
 * We are loading our CMS functions
 */ 
 include("mvc/model/cmsapplications.php");
 

 /**
 * We are creating environment
 */ 
 $env = array( "name4" => "The value of Name4 variable from environment", "name5" => "It is title attribute of tag A from environment", );
	
/**
 * We are reference DATA and TEMPLATE sources 
 * Notice: sample.tpl includes a few SAPI-files
 */ 
 
	$template = 'examples/sample.tpl';
	$xmldata = "examples/datasample.xml";
	
/**
 * We are doing XML Sapiens Processor initilazation  
 * Syntax: 
 * obj sapi_core(string $DATA_filelink_or_code, string $Template_filelink_or_code[, array Environment_array]);
 */ 
	
	$sapi = new sapi_core($xmldata, $template, $env);

	//$sapi->access_mode="administration";
/**
 * We can switch on administrative mode of site
 * $sapi->access_mode="administration";
 */ 	

/**
 * We are processing XML Sapiens Transformation 
 */ 
	
	$result = $sapi->process();

	print $result;

/**
 * We are monitoring  transformation errors
 */ 	
	if($sapi->errors()) {
		print "<br /><br />Processing errors:<br /><br />";
		while(!$sapi->errors_eol()) {
	    print ("\tError : " . $sapi->error() . "<br />\n");
	    print ("\tIn file: " . $sapi->error_file() . "<br />\n");
	    print ("\tIn string: " . $sapi->error_string() . "<br /><br />\n");
	    $sapi->next_error();
		}
	} 
		
 ?>
Return current item: XML Sapiens Processor