Public Member Functions | Protected Attributes

ilSaxController Class Reference

Controller class for sax element handlers. More...

Public Member Functions

 __construct ()
 Constructor.
 setHandlers ($a_xml_parser)
 Set handlers.
 setDefaultElementHandler (ilSaxSubsetParser $a_default_parser)
 Set default element handler.
 setElementHandler (ilSaxSubsetParser $a_parser, $a_element)
 Set element handler by element name.
 handlerBeginTag ($a_xml_parser, $a_name, $a_attribs)
 Set default element handler.
 handlerEndTag ($a_xml_parser, $a_name)
 handler for end of element
 handlerCharacterData ($a_xml_parser, $a_data)
 handler for character data

Protected Attributes

 $default_handler = null
 $element_handlers = array()
 $handlers_in_use = array()

Detailed Description

Controller class for sax element handlers.

Could be used to split the xml handling in different responsible classes. Use the methods addElementHandler, addDefaultElementHandler

Author:
Stefan Meyer <smeyer@databay.de>
Version:
$Id$

Definition at line 35 of file class.ilSaxController.php.


Constructor & Destructor Documentation

ilSaxController::__construct (  ) 

Constructor.

public

Parameters:
 

Definition at line 48 of file class.ilSaxController.php.

        {
                
        }


Member Function Documentation

ilSaxController::handlerBeginTag ( a_xml_parser,
a_name,
a_attribs 
)

Set default element handler.

public

Parameters:
string xml element that triggers the handler call
object object that parses the xmlsubset
string method name default handlerBeginTag public
resource $a_xml_parser xml parser
string $a_name element name
array $a_attribs element attributes array

Definition at line 112 of file class.ilSaxController.php.

        {
                if(isset($this->element_handlers[$a_name]) or $this->handler_in_use)
                {
                        if(!$this->handler_in_use)
                        {
                                $this->handler_in_use = $this->element_handlers[$a_name];
                        }
                        // Forward to handler
                        $this->current_handler = $this->handler_in_use;
                        return $this->current_handler->handlerBeginTag($a_xml_parser,$a_name,$a_attribs);
                }
                // Call default handler
                $this->handler_in_use = false;
                $this->current_handler = $this->default_handler;
                return $this->default_handler->handlerBeginTag($a_xml_parser,$a_name,$a_attribs);
        }

ilSaxController::handlerCharacterData ( a_xml_parser,
a_data 
)

handler for character data

Parameters:
resource $a_xml_parser xml parser
string $a_data character data

Definition at line 160 of file class.ilSaxController.php.

        {
                return $this->current_handler->handlerCharacterData(a_xml_parser,$a_data);
        }

ilSaxController::handlerEndTag ( a_xml_parser,
a_name 
)

handler for end of element

Parameters:
resource $a_xml_parser xml parser
string $a_name element name

Definition at line 136 of file class.ilSaxController.php.

        {
                if(isset($this->element_handlers[$a_name]))
                {
                        $this->handler_in_use = false;
                        $this->current_handler = $this->element_handlers[$a_name];
                        return $this->element_handlers[$a_name]->handlerEndTag($a_xml_parser,$a_name);
                }
                elseif($this->handler_in_use)
                {
                        $this->current_handler = $this->handler_in_use;
                        return $this->current_handler->handlerEndTag($a_xml_parser,$a_name);
                }
                $this->handler_in_use = false;
                $this->current_handler = $this->default_handler;
                return $this->default_handler->handlerEndTag($a_xml_parser,$a_name);
        }

ilSaxController::setDefaultElementHandler ( ilSaxSubsetParser a_default_parser  ) 

Set default element handler.

public

Parameters:
object object that parses the xmlsubset must implement interface ilSaxSubsetParser

Definition at line 75 of file class.ilSaxController.php.

        {
                $this->default_handler = $a_default_parser;
        }

ilSaxController::setElementHandler ( ilSaxSubsetParser a_parser,
a_element 
)

Set element handler by element name.

Parameters:
string element name that triggers the handler
object object that parses the xmlsubset must implement interface ilSaxSubsetParser public

Definition at line 88 of file class.ilSaxController.php.

        {
                $this->element_handlers[$a_element] = $a_parser;
                $this->handlers_in_use[$a_element] = false;
        }

ilSaxController::setHandlers ( a_xml_parser  ) 

Set handlers.

public

Parameters:
resource xml_parser instance

Definition at line 60 of file class.ilSaxController.php.

        {
                xml_set_object($a_xml_parser,$this);
                xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
                xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
                return;
        }


Field Documentation

ilSaxController::$default_handler = null [protected]

Definition at line 37 of file class.ilSaxController.php.

ilSaxController::$element_handlers = array() [protected]

Definition at line 38 of file class.ilSaxController.php.

ilSaxController::$handlers_in_use = array() [protected]

Definition at line 39 of file class.ilSaxController.php.


The documentation for this class was generated from the following file: