Location: PHPKode > projects > Entier Studio > entierstudio/framework/helpers/xslt.helper.php
<?php
/*
 Requires PHP5, uses included XSL extension (to be enabled).
 To be used in PHP4 scripts using XSLT extension.
 Allows PHP4/XSLT scripts to run on PHP5/XSL

 Typical use:
 {
  if (version_compare(PHP_VERSION,'5','>=')&&extension_loaded('xsl'))
   require_once('xslt.helper');
 }

 Version 0.5, 2006-08-06, http://alexandre.alapetite.net/doc-alex/xslt-php4-php5/

 ------------------------------------------------------------------
 Written by Alexandre Alapetite, http://alexandre.alapetite.net/cv/

Copyright 2004-2006, Licence: Creative Commons "Attribution-ShareAlike 2.0 France" BY-SA (FR),
 http://creativecommons.org/licenses/by-sa/2.0/fr/
 http://alexandre.alapetite.net/divers/apropos/#by-sa
 - Attribution. You must give the original author credit
 - Share Alike. If you alter, transform, or build upon this work,
   you may distribute the resulting work only under a license identical to this one
   (Can be included in GPL/LGPL projects)
 - The French law is authoritative
 - Any of these conditions can be waived if you get permission from Alexandre Alapetite
 - Please send to Alexandre Alapetite the modifications you make,
   in order to improve this file for the benefit of everybody

 If you want to distribute this code, please do it as a link to:
 http://alexandre.alapetite.net/doc-alex/xslt-php4-php5/
*/
if (@version_compare(PHP_VERSION, '5', '>=') && @extension_loaded('xsl')) {
    // Emulate the old xslt library functions
    /**
	 *
	 */
    function xslt_create() {
        return new XsltProcessor();
    }
	/**
	 *
	 */
	function xslt_errno($xh) {
		return 7;
	}
	/**
	 *
	 */
	function xslt_error($xh) {
		return '?';
	}
	/**
	 *
	 */
	function xslt_free($xh) {
		unset($xh);
	}
	/**
	 * See also: http://alexandre.alapetite.net/doc-alex/domxml-php4-php5/
     * Based on: http://www.php.net/manual/ref.xsl.php#45415
     */
    function xslt_process($xh, $xmlcontainer, $xslcontainer, $resultcontainer = null, $arguments = null, $parameters = null) {        
        // Start with preparing the arguments
        $xmlcontainer = str_replace('arg:', '', $xmlcontainer);
        $xslcontainer = str_replace('arg:', '', $xslcontainer);

        // Create instances of the DomDocument class
        $xml = new DomDocument;
        $xsl = new DomDocument;

        // Load the xml document and the xsl template
        $xml->loadXML($arguments[$xmlcontainer]);
        $xsl->loadXML($arguments[$xslcontainer]);

        // Load the xsl template
        $xh->registerPHPFunctions();
        $xh->importStyleSheet($xsl);

        // Set parameters when defined
        if ($parameters) {
            foreach ($parameters as $param => $value) {
                $xh->setParameter("", $param, $value);
            }
        }

        // Start the transformation
        $processed = $xh->transformToXML($xml);

        // Put the result in a file when specified
        if ($resultcontainer) {
            return @file_put_contents($resultcontainer, $processed);
        } else {
            return $processed;
        }

    }    
}
?>
Return current item: Entier Studio