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

Source for file libxslt.php

Documentation is available at libxslt.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: libxslt.php,v 1.6 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_domxml
  30.  
  31. /**
  32.  * The XML_CSSML_domxml is a container class which
  33.  * provides the libxslt 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_libxslt extends XML_CSSML
  45. {
  46.     // {{{ constructor
  47.  
  48.     function XML_CSSML_libxslt($in_CSSML = null$in_type 'string'$in_params = null)
  49.     {
  50.         if (!function_exists('domxml_version')) {
  51.             $this = PEAR::raiseError(nullXML_CSSML_ERRORnullE_USER_ERROR,
  52.              'This driver needs the domxml extension to run''XML_CSSML_Error'true);
  53.             return;
  54.         }
  55.         $this->loaded = false;
  56.         if (!is_null($in_CSSML)) {
  57.             $this->load($in_CSSML$in_type);
  58.         }
  59.  
  60.         if (!is_null($in_params)) {
  61.             $this->setParams($in_params);
  62.         }
  63.  
  64.         $this->stylesheetDoc = domxml_xslt_stylesheet_file(dirname(__FILE__'/libxslt.xsl');
  65.     }
  66.  
  67.     // }}}
  68.     // {{{ process()
  69.  
  70.     function process()
  71.     {
  72.         if (parent::isError($process = parent::process())) {
  73.             return $process;
  74.         }
  75.  
  76.         // Prepare the params for passing to the stylesheet
  77.         $params = array(
  78.             'filter'        => $this->filter,
  79.             'browser'       => $this->browser,
  80.             'comment'       => $this->comment,
  81.             'output'        => $this->output,
  82.         );
  83.  
  84.         // Run the transformation and return the result (empty if stream is file)
  85.         $result $this->stylesheetDoc->process($this->CSSMLDoc$params);
  86.  
  87.         // If stream is STDOUT then create string and return
  88.         if ($this->output == 'STDOUT'{
  89.             $resultData $result->document_element();
  90.             $output $resultData->get_content();
  91.         }
  92.  
  93.         return isset($output$output : true;
  94.     }
  95.  
  96.     // }}}
  97.     // {{{ load()
  98.  
  99.     function load($in_CSSML$in_type 'string')
  100.     {
  101.         if (parent::isError($load = parent::load())) {
  102.             return $load;
  103.         }
  104.  
  105.         // If the CSSML data is already a DOM object (can tell by checking for root)
  106.         if ($in_type == 'object' && get_class($in_CSSML== 'DomDocument'{
  107.             $this->CSSMLDoc = $in_CSSML;
  108.         }
  109.         // If this is a data file, then make it an DOM object with the file function
  110.         elseif ($in_type == 'file' && @file_exists($in_CSSML)) {
  111.             $this->CSSMLDoc = domxml_open_file($in_CSSML);
  112.         }
  113.         // If we were given a string, then make it a DOM object with the string function
  114.         elseif ($in_type == 'string' && is_string($in_CSSML)) {
  115.             $this->CSSMLDoc = domxml_open_mem($in_CSSML);
  116.         }
  117.         // We need to die here because we have no data or it cannot be xml
  118.         else {
  119.             return PEAR::raiseError(nullXML_CSSML_INVALID_DATAnullE_USER_WARNING"Request data: $in_CSSML"'XML_CSSML_Error'true);
  120.         }
  121.  
  122.         if (!is_a($this->CSSMLDoc'DomDocument')) {
  123.             return PEAR::raiseError(nullXML_CSSML_INVALID_DOCUMENTnullE_USER_WARNING"Request data: $in_CSSML"'XML_CSSML_Error'true);
  124.         }
  125.  
  126.         $this->loaded = true;
  127.     }
  128.  
  129.     // }}}
  130. }
  131. ?>

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