[ Index ]
 

Code source de Symfony 1.0.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/vendor/phing/parser/ -> AbstractSAXParser.php (source)

   1  <?php
   2  /*
   3   *  $Id: AbstractSAXParser.php 3076 2006-12-18 08:52:12Z fabien $
   4   *
   5   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   6   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   7   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   8   * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   9   * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  10   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  11   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  12   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  15   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16   *
  17   * This software consists of voluntary contributions made by many individuals
  18   * and is licensed under the LGPL. For more information please see
  19   * <http://phing.info>.
  20   */
  21  
  22  /**
  23   * The abstract SAX parser class.
  24   *
  25   * This class represents a SAX parser. It is a abstract calss that must be
  26   * implemented by the real parser that must extend this class
  27   *
  28   * @author    Andreas Aderhold <andi@binarycloud.com>
  29   * @author    Hans Lellelid <hans@xmpl.org>
  30   * @copyright © 2001,2002 THYRELL. All rights reserved
  31   * @version   $Revision: 1.13 $
  32   * @package   phing.parser
  33   */
  34  abstract class AbstractSAXParser {
  35      
  36      /** The AbstractHandler object. */
  37      protected $handler;
  38  
  39      /**
  40       * Constructs a SAX parser
  41       */
  42      function __construct() {}
  43  
  44      /**
  45       * Sets options for PHP interal parser. Must be implemented by the parser
  46       * class if it should be used.
  47       */
  48      abstract function parserSetOption($opt, $val);
  49  
  50      /**
  51       * Sets the current element handler object for this parser. Usually this
  52       * is an object using extending "AbstractHandler".
  53       *
  54       * @param AbstractHandler $obj The handler object.
  55       */
  56      function setHandler( $obj) {
  57          $this->handler = $obj;
  58      }
  59  
  60      /**
  61       * Method that gets invoked when the parser runs over a XML start element.
  62       *
  63       * This method is called by PHP's internal parser funcitons and registered
  64       * in the actual parser implementation.
  65       * It gives control to the current active handler object by calling the
  66       * <code>startElement()</code> method.
  67       * 
  68       * BECAUSE OF PROBLEMS WITH EXCEPTIONS BUBBLING UP THROUGH xml_parse() THIS
  69       * METHOD WILL CALL Phing::halt(-1) ON EXCEPTION.
  70       *
  71       * @param  object  the php's internal parser handle
  72       * @param  string  the open tag name
  73       * @param  array   the tag's attributes if any
  74       */
  75      function startElement($parser, $name, $attribs) {
  76          try {
  77              $this->handler->startElement($name, $attribs);        
  78          } catch (Exception $e) {
  79              print "[Exception in XML parsing]\n";
  80              print $e;
  81              Phing::halt(-1);
  82          }
  83      }
  84  
  85      /**
  86       * Method that gets invoked when the parser runs over a XML close element.
  87       *
  88       * This method is called by PHP's internal parser funcitons and registered
  89       * in the actual parser implementation.
  90       *
  91       * It gives control to the current active handler object by calling the
  92       * <code>endElement()</code> method.
  93       *
  94       * BECAUSE OF PROBLEMS WITH EXCEPTIONS BUBBLING UP THROUGH xml_parse() THIS
  95       * METHOD WILL CALL Phing::halt(-1) ON EXCEPTION.
  96       * 
  97       * @param   object  the php's internal parser handle
  98       * @param   string  the closing tag name
  99       */
 100      function endElement($parser, $name) {
 101          try {
 102              $this->handler->endElement($name);
 103          } catch (Exception $e) {
 104              print "[Exception in XML parsing]\n";
 105              print $e;
 106              Phing::halt(-1);
 107          }
 108      }
 109  
 110      /**
 111       * Method that gets invoked when the parser runs over CDATA.
 112       *
 113       * This method is called by PHP's internal parser functions and registered
 114       * in the actual parser implementation.
 115       *
 116       * It gives control to the current active handler object by calling the
 117       * <code>characters()</code> method. That processes the given CDATA.
 118       *
 119       * BECAUSE OF PROBLEMS WITH EXCEPTIONS BUBBLING UP THROUGH xml_parse() THIS
 120       * METHOD WILL CALL Phing::halt(-1) ON EXCEPTION.
 121       * 
 122       * @param resource $parser php's internal parser handle.
 123       * @param string $data the CDATA
 124       */
 125      function characters($parser, $data) {
 126          try {     
 127              $this->handler->characters($data);        
 128          } catch (Exception $e) {
 129              print "[Exception in XML parsing]\n";
 130              print $e;
 131              Phing::halt(-1);
 132          }
 133      }
 134  
 135      /**
 136       * Entrypoint for parser. This method needs to be implemented by the
 137       * child classt that utilizes the concrete parser
 138       */
 139      abstract function parse();
 140  }


Généré le : Fri Mar 16 22:42:14 2007 par Balluche grâce à PHPXref 0.7