XML_CSSML
[ class tree: XML_CSSML ] [ index: XML_CSSML ] [ all elements ]

Source for file xslt.php

Documentation is available at xslt.php

  1. <?php
  2. // {{{ license
  3.  
  4. // +----------------------------------------------------------------------+
  5. // | PHP version 4.0                                                      |
  6. // +----------------------------------------------------------------------+
  7. // | Copyright (c) 1997-2003 The PHP Group                                |
  8. // +----------------------------------------------------------------------+
  9. // | This source file is subject to version 2.0 of the PHP license,       |
  10. // | that is bundled with this package in the file LICENSE, and is        |
  11. // | available at through the world-wide-web at                           |
  12. // | http://www.php.net/license/2_02.txt.                                 |
  13. // | If you did not receive a copy of the PHP license and are unable to   |
  14. // | obtain it through the world-wide-web, please send a note to          |
  15. // | license@php.net so we can mail you a copy immediately.               |
  16. // +----------------------------------------------------------------------+
  17. // | Authors: Dan Allen <dan@mojavelinux.com>                             |
  18. // +----------------------------------------------------------------------+
  19.  
  20. // $Id: xslt.php,v 1.4 2005/10/12 12:38:13 toggg Exp $
  21.  
  22. // }}}
  23. // {{{ description
  24.  
  25. // XML_CSSML is a CSSML to CSS xslt parser
  26.  
  27. // }}}
  28.  
  29. // {{{ class XML_CSSML_xslt
  30.  
  31. /**
  32.  * The XML_CSSML_xslt is a container class which
  33.  * provides the sablotron xsl functions to parse a CSSML
  34.  * document into a stylesheet with the ability to output
  35.  * to a file or return
  36.  *
  37.  * @author   Dan Allen <dan@mojavelinux.com>
  38.  * @version  Revision: 0.1
  39.  * @access   public
  40.  * @package  XML_CSSML
  41.  */
  42.  
  43. // }}}
  44. class XML_CSSML_xslt extends XML_CSSML
  45. {
  46.     // {{{ properties
  47.  
  48.     /**
  49.      * The sabltron extension can use xml strings as arguments for the
  50.      * processor, but must do so when calling xslt_process.  This variable
  51.      * holds those parameters.
  52.      * @var array $arguments 
  53.      */
  54.     var $arguments = array();
  55.  
  56.     // }}}
  57.     // {{{ constructor
  58.  
  59.     function XML_CSSML_xslt($in_CSSML = null$in_type 'string'$in_params = null)
  60.     {
  61.         if (!function_exists('xslt_create')) {
  62.             $this = PEAR::raiseError(nullXML_CSSML_ERRORnullE_USER_ERROR,
  63.              'This driver needs the xslt extension to run''XML_CSSML_Error'true);
  64.             return;
  65.         }
  66.         $this->loaded = false;
  67.         if (!is_null($in_CSSML)) {
  68.             $this->load($in_CSSML$in_type);
  69.         }
  70.  
  71.         if (!is_null($in_params)) {
  72.             $this->setParams($in_params);
  73.         }
  74.  
  75.         $this->stylesheetDoc = dirname(__FILE__'/xslt.xsl';
  76.     }
  77.  
  78.     // }}}
  79.     // {{{ process()
  80.  
  81.     // I need some error checking in here
  82.     function process()
  83.     {
  84.         if (parent::isError($process = parent::process())) {
  85.             return $process;
  86.         }
  87.  
  88.         // Prepare the params for passing to the stylesheet
  89.         $params = array(
  90.             'filter'        => $this->filter,
  91.             'browser'       => $this->browser,
  92.             'comment'       => $this->comment,
  93.         );
  94.  
  95.         $xh = xslt_create();
  96.  
  97.         $result = xslt_process($xh$this->CSSMLDoc$this->stylesheetDocnull$this->arguments$params);
  98.  
  99.         if ($this->output != 'STDOUT'{
  100.             $fp fopen($this->output'w');
  101.             fwrite($fp$result);
  102.             fclose($fp);
  103.             $result = true;
  104.         }
  105.  
  106.         return $result;
  107.     }
  108.  
  109.     // }}}
  110.     // {{{ load()
  111.  
  112.     // I need some more error checking in here
  113.     function load($in_CSSML$in_type 'string')
  114.     {
  115.         if (parent::isError($load = parent::load())) {
  116.             return $load;
  117.         }
  118.  
  119.         if ($in_type == 'file' && @file_exists($in_CSSML)) {
  120.             $this->CSSMLDoc = $in_CSSML;
  121.         elseif ($in_type == 'string' && is_string($in_CSSML)) {
  122.             $this->CSSMLDoc = 'arg:/_xml';
  123.             $this->arguments = array('/_xml' => $in_CSSML);
  124.         else {
  125.             return PEAR::raiseError(nullXML_CSSML_INVALID_DATAnullE_USER_WARNING"Request data: $in_CSSML"'XML_CSSML_Error'true);
  126.         }
  127.  
  128.         $this->loaded = true;
  129.     }
  130.  
  131.     // }}}
  132. }
  133. ?>

Documentation generated on Mon, 11 Mar 2019 14:12:45 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.