server-php-xml-class-xslt-class-xslt.php / php
<?php //#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
###
// Title : class_xslt.php // Version : 1.1 // Author : Luis Argerich (lrargerich@yahoo.com) // Last modification date : 03-11-2002 // Description : An abstraction class for the XSLT extension // this one uses the Sablotron processor but we // may release classes based on other processors // later. //#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
###
// History: // 03-11-2001 Class modified to work with the new XSLT extension // 11-11-2001 Class created //#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
###
// To-Dos: //#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
###
// How to use it: // include_once("class_xslt.php"); // // xslt->setXml("applications.xml"); // or setXmlString( // xslt->setXsl("tr1.xsl"); // or setXslString( // if(xslt->transform()) { // xslt->getOutput(); // echo // } else { // print("Error:".xslt->getError()); // } //#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
###
// CHECK FOR DOUBLE DEFINITION HERE if(defined("_class_xslt_is_included")) { // do nothing since the class is already included } else { define("_class_xslt_is_included",1); class Xslt { var xml, error ; /* Constructor */ function xslt() { /* Destructor */ function destroy() { xslt_free(this->processor); } /* output methods */ function setOutput(this->output = this->output; } /* set methods */ function setXmlString(this->xml=xsl) { xsl; return true; } function setXml(doc = new docReader(this->xml = this->setError("Could not open uri) { if(uri)) { doc->getString(); return true; } else { uri"); return false; } } /* transform method */ function transform() { this->xml, '/_xsl' => ret = xslt_process(arguments); if(!this->setError(xslt_error(this->setOutput(/* Error Handling */ function setError(string) { string; } function getError() { return /* docReader -- read a file or URL as a string */ /* test */ /* docUri = new docReader('http://www.someurl.com/doc.html'); echo class docReader { var string; // public string representation of file var bignum = 1000000; var /* public constructor */ function docReader(uri) { // returns integer uri); uri; fp = fopen(fp) { // get length if (length = filesize(length = this->setString(fread(length)); return 1; } else { return 0; } } /* determine if a URI is a filename or URL */ function isFile(// returns boolean if (strstr(uri,'http://') == /* set and get methods */ function setUri(string) { string; } function getUri() { return string) { string; } function getString() { return this->isFile(this->type = 'file'; } else { this->type; } } } ?>
(C) Æliens 20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.