PHP Classes

XSLT PHP Template Engine: Process templates using XSLT

Recommend this page to a friend!
  Info   Example   Screenshots   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-01-09 (9 months ago) RSS 2.0 feedNot enough user ratingsTotal: 247 All time: 7,964 This week: 660Up
Version License PHP version Categories
xslt-php-template 1.6GNU General Publi...5.3.0XML, PHP 5, Templates
Description 

Author

This class can process templates using XSLT.

It can take parameter values and replace them in template files using XSLT to generate the processed template output when give XML style sheets.

Picture of Pierre-Henry Soria
  Performance   Level  
Name: Pierre-Henry Soria <contact>
Classes: 49 packages by
Country: United Kingdom
Age: 31
All time rank: 37316 in United Kingdom
Week rank: 1 Up
Innovation award
Innovation award
Nominee: 18x

Winner: 3x

Example

<?php
/**
 * @title Example file.
 *
 * @author Pierre-Henry Soria <ph7software@gmail.com>
 * @copyright (c) 2012, Pierre-Henry Soria. All Rights Reserved.
 * @license GNU General Public License.
 */

// Set a global namespace for the example file.
namespace PH7;
define('PH7', 1);

// Loading files necessary for the example with autoload file
require '../Library/_autoload.inc.php';

// Get the namespace
use PH7\Library\PH7Xsl\PH7Xsl;

try
{
   
$oXslTpl = new PH7Xsl(__DIR__ . '/persons.xsl');

   
$aVars = array(
       
'meta' => array(
           
'title' => 'Example to XSLT PHP Template Engine',
           
'description' => 'This is a simple but effective and powerful template engine running PHP with XSLT. With XSLT syntax, your template code and may be portable to virtually any programming language.',
           
'keywords' => 'PHP, XSLT, template',
        ),
       
'info' => array(
           
'lang' => 'en-US',
           
'heading1' => 'Simple XSLT PHP Engine',
           
'copyright-link' => 'http://ph-7.github.com',
           
'copyright-title-link' => 'pH7',
        )
    );

    foreach(
$aVars as $aStr)
       
$oXslTpl->setParam($aStr);

   
$aPersons = array(
       
1 => array('name' => 'Gayen', 'first-name' => 'Mark', 'description' => 'What are you doing tonight?, I go out with friends ;-)'),
       
2 => array('name' => 'Roksen', 'first-name' => 'Katin', 'description' => 'Hi, I\'m a nice person, and you?'),
       
3 => array('name' => 'Gansen', 'first-name' => 'Matthew', 'description' => 'Looking for nothing ...'),
       
4 => array('name' => 'Korsan', 'first-name' => 'Alexander', 'description' => 'I love spaghetti!'),
       
5 => array('name' => 'Frey', 'first-name' => 'Matt', 'description' => 'It seems that tomorrow I would be happy ...'),
       
6 => array('name' => 'Admin', 'first-name' => 'Gayen', 'description' => 'I\'m the king ... :D')
    );

    foreach(
$aPersons as $aPerson)
       
$oXslTpl->generateXMLNode($aPerson, 'persons');

   
$oXslTpl->render(); // Display

}
catch(\
Exception $oE)
{
    echo
'<p><b>Exception launched!</b><br /><br />' .
   
'Message: ' . $oE->getMessage() . '<br />' .
   
'File: ' . $oE->getFile() . '<br />' .
   
'Line: ' . $oE->getLine() . '<br />' .
   
'Trace: <p/><pre>' . $oE->getTraceAsString() . '</pre>';
}


Details

XSLT PHP Template Engine

This is a simple but effective and powerful template engine running PHP with XSLT (Extensible Stylesheet Language Transformations). With XSLT syntax, your template code and may be portable to virtually any programming language.

It also allows for the separation of PHP code and template code to have a much more professional software and template much more clean and clear.

Server Requirements

PHP 5.3.0 or newer.

Author

Pierre-Henry Soria

Contact

Contact me at ph7software@gmail.com

License

General Public License 3 or later; See the LICENSE.txt file.


Screenshots (1)  
  • example-of-PH7Xsl-XSLT-PHP-template-engine.png
  Files folder image Files (12)  
File Role Description
Files folder imageExample (5 files, 1 directory)
Files folder imageLibrary (1 file, 1 directory)
Accessible without login Plain text file LICENSE.txt Lic. License
Accessible without login Plain text file README.md Doc. Doc

  Files folder image Files (12)  /  Example  
File Role Description
Files folder imagescreenshot (1 file)
  Accessible without login Plain text file head.inc.xsl Data Auxiliary data
  Accessible without login Plain text file index.php Example Example script
  Accessible without login Plain text file persons.xsl Data Auxiliary data
  Accessible without login Plain text file style.css Data Auxiliary data
  Accessible without login Plain text file _layout.xsl Data Auxiliary data

  Files folder image Files (12)  /  Example  /  screenshot  
File Role Description
  Accessible without login Image file demo-of-PH7Xsl-XSL...template-engine.png Data Auxiliary data

  Files folder image Files (12)  /  Library  
File Role Description
Files folder imagePH7Xsl (2 files)
  Plain text file _autoload.inc.php Class Class source

  Files folder image Files (12)  /  Library  /  PH7Xsl  
File Role Description
  Plain text file Exception.class.php Class Class source
  Plain text file PH7Xsl.class.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 91%
Total:247
This week:0
All time:7,964
This week:660Up