Location: PHPKode > projects > Entier Studio > entierstudio/framework/xml.explorer.php
<?php
/**
 * Entier Studio
 *
 * LICENSE
 *
 *	Copyright 2006 Entier Studio team.
 *
 *	Licensed under the Apache License, Version 2.0 (the "License");
 *	you may not use this file except in compliance with the License.
 *	You may obtain a copy of the License at
 *
 *		http://www.apache.org/licenses/LICENSE-2.0
 *
 *	Unless required by applicable law or agreed to in writing, software
 *	distributed under the License is distributed on an "AS IS" BASIS,
 *	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *	See the License for the specific language governing permissions and
 *	limitations under the License.
 *
 * @package    entier.framework
 * @copyright  Copyright (c) 2006 Entier Studio team. All rights reserved.
 * @version	   $Id: xml.explorer.php 81 2008-01-17 23:08:21Z yannromefort $
 */
//-----------------------------------------------------------------------------
//	namespace
if (!defined("DefXMLExplorer")) {
    //-------------------------------------------------------------------------
    //	Define
    define("DefXMLExplorer", "1");
    //-------------------------------------------------------------------------
    //	Include
    @require_once (FRAMEWORK_DIR . "datasource.explorer.php");
    @require_once (FRAMEWORK_DIR . "text.datasource.php");
    //-------------------------------------------------------------------------
    //	Class
    class XMLExplorer extends DataSourceExplorer {
        //---------------------------------------------------------------------
        //	Attributes
        
        /**
         * Lookup Element name
         * @var	boolean
         */
        var $m_nodeName = false;
        /**
         * Lookup Element type
         * @var	string
         */
        var $m_typeName = "";
        /**
         * Parse Element name
         * @var	string
         */
        var $m_TempName = "";
        /**
         * Parse Element type
         * @var	string
         */
        var $m_TempType = "";
        /**
         * Parse Element name node
         * @var	boolean
         */
        var $m_NameNode = false;
        /**
         * Parser error code
         * @var	integer
         */
        var $m_errorCode = 0;
        /**
         * Parser error line
         * @var	integer
         */
        var $m_errorLine = 0;
        //---------------------------------------------------------------------
        //	Constructor
        
        /**
         *
         * @param	string	host
         * @param	string	port
         * @param	string	user
         * @param	string	pass
         * @param	string	base
         */
        function XMLExplorer($hostName = "", $hostPort = 0, $userName = "", $passWord = "", $dataBase = "") {
            //
            $this->m_Source = new TEXTDataSource($hostName, $hostPort, $userName, $passWord, $dataBase);
        }
        //---------------------------------------------------------------------
        //	Methods
        //	DataSourceExplorer interface
        
        /**
         *
         * Select a data source element
         * -> retrieve informations
         *
         * @param	string	Target element name
         * @param	string	Target element type
         * @return	boolean	Return flag
         */
        /**
         * Parse a file source model
         *
         * @param	string	Target element name ( format parent/chield )
         * @param	string	Target element type
         * @return	integer parsed set size
         */
        function parseObject($name = "", $type = "") {
            //
            if (($this->m_Source->isConnectionOpen() == false) && ($this->m_Source->openConnection() == false)) return (false);
            //
            $this->resetObject();
            //
            $this->m_nodeName = $name;
            $this->m_typeName = $type;
            //
            $xml_parser = @xml_parser_create();
            @xml_set_object($xml_parser, $this);
            @xml_set_element_handler($xml_parser, "startElement", "endElement");
            @xml_set_character_data_handler($xml_parser, "characterData");
            @xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false); // use case-folding so we are sure to find the tag in $map_array
            //
            while ($data = $this->m_Source->ReadText(4096)) {
                if (!@xml_parse($xml_parser, $data, $this->m_Source->EndOfText())) {
                    //
                    $this->m_errorCode = @xml_get_error_code($xml_parser);
                    $this->m_errorLine = @xml_get_current_line_number($xml_parser);
                    //
                    @xml_parser_free($xml_parser);
                    //
                    return ($this->m_Source->closeConnection());
                }
            }
            //
            @xml_parser_free($xml_parser);
            //
            return ($this->m_Source->closeConnection());
        }
    };
    //	Class
    //-------------------------------------------------------------------------
    
}
//	namespace
//-----------------------------------------------------------------------------
?>
Return current item: Entier Studio