Login   Register  
PHP Classes
elePHPant
Icontem

File: xslt_transform.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Urs Gehrig  >  xslt_transform  >  xslt_transform.php  >  Download  
File: xslt_transform.php
Role: ???
Content type: text/plain
Description: XSLT transform class
Class: xslt_transform
Author: By
Last change:
Date: 13 years ago
Size: 1,152 bytes
 

Contents

Class file image Download
<?php 

/* 
* Subject:  XSLT class using PHP4 Sablotron extension 
* Author:   Urs Gehrig <urs@circle.ch> 
* Date:     11-10-2000 
* Version:  0.1 
* 
* URL:      http://www.circle.ch/projects/ 
*/ 

class xsl_transform { 

    var $xsl_file; 
    var $xml_file; 
    var $filename; 

    // {{{ xsl_transform(), constructor of xsl_transform class 

    function xsl_transform($xsl_file = '', $xml_file = ''){ 
        $this->xsl_string = $this->read_file($xsl_file); 
        $this->xml_string = $this->read_file($xml_file); 
    } 

    // }}} 
    // {{{ read_file() 

    function read_file($filename) { 
        // get contents of a file into a string 
        $fd = fopen( $filename, "r" ); 
        $content = fread( $fd, filesize( $filename ) ); 
        fclose( $fd ); 
        return $content; 
    } 

    // }}} 
    // {{{ apply() 

    function apply() { 
        $this->result = ''; 

        $this->msg = xslt_process($this->xsl_string, $this->xml_string, $this->result); 
        if(!$this->msg) print ("Transformation failed."); 
        return $this->result; 
    } 

    // }}} 
} 
?>