Source for file CSSML.php
Documentation is available at CSSML.php
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Dan Allen <dan@mojavelinux.com> |
// +----------------------------------------------------------------------+
// $Id: CSSML.php,v 1.8 2005/10/12 12:38:12 toggg Exp $
// XML_CSSML is a CSSML to CSS xslt parser
define('XML_CSSML_ERROR', -1 );
define('XML_CSSML_ALREADY_EXISTS', -2 );
define('XML_CSSML_NOT_LOADED', -3 );
define('XML_CSSML_INVALID_DATA', -4 );
define('XML_CSSML_INVALID_DOCUMENT', -5 );
define('XML_CSSML_INVALID_FILE', -6 );
require_once 'XML/CSSML/Error.php';
* Replace function is_a()
* @link http://php.net/function.is_a
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.8 $
* @require PHP 4.0.0 (user_error) (is_subclass_of)
function is_a($object, $class)
* The XML_CSSML class provides the xsl functions
* to parse a CSSML document into a stylesheet
* with the ability to output to a file or return
* @author Dan Allen <dan@mojavelinux.com>
* domxml object which holds the xml document with the css information
* domxml object which holds the xsl document which parses the cssml document
* @var object $stylesheetDoc
* Redirection method for the output of the cssml (file, stdout)
* If redirection is a file, it must be absolute
* @var string $outputMethod
* Code corresponding to the user agent of the browser,
* such as is generated with Net_UserAgentDetect
* Filter for the entries in the CSSML
* Comment to be used at the top of the stylesheet output
* Boolean which defines if the CSSML document has been loaded
* Class constructor, prepare the cssml document object from either a string, file or object
* @param mixed $in_cssml Optionally the CSSML data can be passed to the constructor
function XML_CSSML ($in_driver, $in_CSSML = null , $in_type = 'string', $in_params = null )
$this = $this->factory($in_driver, $in_CSSML, $in_type, $in_params);
function &factory($in_driver, $in_CSSML = null , $in_type = 'string', $in_params = null )
$interface_path = 'CSSML/' . $in_driver . '.php';
$interface_class = 'XML_CSSML_' . $in_driver;
@include_once $interface_path;
$obj = & new $interface_class($in_CSSML, $in_type, $in_params);
* Prepare the CSSML document object from either a string, file or object. This
* will set the CSSMLDoc class variable which will be parsed by the xsl stylesheet
* @param mixed $in_CSSML The CSSML document which contains the information for
* generating the CSS document
* Set the params (params) that will be used when calling the stylesheet parser.
* This pertains particularly to variables such as browser code, image path and
* the filter. It works by passing an associative array with any number of the
* possible parameters for the stylesheet. If a variable is not set, the default
* @param array $in_params Associative array of the params
if (isset ($in_params['browser'])) {
$this->browser = $in_params['browser'];
if (isset ($in_params['filter'])) {
$this->filter = $in_params['filter'];
if (isset ($in_params['comment'])) {
if (isset ($in_params['output'])) {
$this->output = $in_params['output'];
if ($in_params['output'] != 'STDOUT') {
// check to make sure this is a file...this needs work
return PEAR ::raiseError (null , XML_CSSML_INVALID_FILE, PEAR_ERROR_PRINT , E_USER_NOTICE , '', 'XML_CSSML_Error', true );
* Run the transformation on the CSSML document using the CSSML xsl stylesheet. If
* the output method is to a file, then the function will not return. If the output
* is set to STDOUT, the xml string will be returned (really the css document) after
* some clean up of entities and domxml bugs have been fixed
* @return css string if output method is STDOUT, else void
return PEAR ::raiseError (null , XML_CSSML_NOT_LOADED, null , E_USER_WARNING , 'use load() function', 'XML_CSSML_Error', true );
* Tell whether a result code from a XML_CSSML method is an error.
* @param object $in_value object in question
* @return boolean whether object is an error object
return is_a($in_value, 'xml_cssml_error');
* Return a textual error message for an XML_CSSML error code.
* @param int $in_value error code
* @return string error message, or false if not error code
// make the variable static so that it only has to do the defining on the first call
// define the varies error messages
if (!isset ($errorMessages)) {
// If this is an error object, then grab the corresponding error code
$in_value = $in_value->getCode ();
// return the textual error message corresponding to the code
return isset ($errorMessages[$in_value]) ? $errorMessages[$in_value] : $errorMessages[XML_CSSML_ERROR];
* Resets the object so it is possible to load another xml document.
* Kill the class object to free memory. Not really sure how necessary this is, but xml
* documents can be pretty big. This will kill everything, so only use it when you are done
foreach ($vars as $var => $value) {
Documentation generated on Mon, 11 Mar 2019 14:12:45 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|