home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / XML / Indexing / Builder / Attribute.php next >
Encoding:
PHP Script  |  2008-07-02  |  2.4 KB  |  80 lines

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  3. /**
  4.  * XML_Indexing's attribute-based indexes builder
  5.  *
  6.  * PHP versions 4 and 5
  7.  *
  8.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  9.  * that is available through the world-wide-web at the following URI:
  10.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  11.  * the PHP License and are unable to obtain it through the web, please
  12.  * send a note to license@php.net so we can mail you a copy immediately.
  13.  *
  14.  * @category   XML
  15.  * @package    XML_Indexing
  16.  * @copyright  2004 Samalyse SARL corporation
  17.  * @author     Olivier Guilyardi <olivier@samalyse.com>
  18.  * @license    http://www.php.net/license/3_0.txt  PHP License
  19.  * @version    CVS: $Id: Attribute.php,v 1.1 2005/02/17 16:37:29 olivierg Exp $
  20.  * @link       http://pear.php.net
  21.  * @link       http://www.samalyse.com/code/xml_indexing
  22.  * @since      File available since Release 0.1
  23.  */
  24.     
  25.  
  26. require_once 'XML/Indexing/Builder.php';
  27.     
  28. /**
  29.  * Attribute-based indexes builder
  30.  *
  31.  * @copyright  2004 Samalyse SARL corporation
  32.  * @author  Olivier Guilyardi <olivier@samalyse.com>
  33.  * @license    http://www.php.net/license/3_0.txt  PHP License
  34.  * @version    Release: @package_version@
  35.  * @link       http://pear.php.net
  36.  * @since      Class available since Release 0.1
  37.  */
  38. class XML_Indexing_Builder_Attribute extends XML_Indexing_Builder
  39. {
  40.     /**
  41.      * Attribute being analysed
  42.      * @var string 
  43.      * @access private
  44.      */
  45.     var $_attributeName;
  46.  
  47.     /**
  48.      * Constructor
  49.      * 
  50.      * @param string $filename The filename to build an index against
  51.      * @param string $xroot XPath root 
  52.      * @param string $attr Name of the attribute to analyse
  53.      * @access public
  54.      */
  55.     function XML_Indexing_Builder_Attribute ($filename, $xroot, $attr)
  56.     {
  57.         $this->_attributeName = $attr;
  58.         $this->XML_Indexing_Builder ($filename, $xroot);
  59.     }
  60.  
  61.     /**
  62.      * Handle a matched region
  63.      *
  64.      * @param int $offset Byte offset of the matched region
  65.      * @param int $length Length in bytes of the matched region
  66.      * @param array $attribs Attributes of the tag enclosing the region
  67.      * @access protected
  68.      * @return void
  69.      */
  70.     function _handleRegion($offset, $length, $attribs)
  71.     {
  72.         if (isset ($attribs[$this->_attributeName])) {
  73.             $this->_regions[$attribs[$this->_attributeName]][] 
  74.                 = array ($offset, $length);
  75.         }
  76.     }
  77. }
  78.     
  79. ?>
  80.