Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00035 class ilSaxController
00036 {
00037 protected $default_handler = null;
00038 protected $element_handlers = array();
00039 protected $handlers_in_use = array();
00040
00048 public function __construct()
00049 {
00050
00051 }
00052
00060 public function setHandlers($a_xml_parser)
00061 {
00062 xml_set_object($a_xml_parser,$this);
00063 xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
00064 xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
00065 return;
00066 }
00067
00075 public function setDefaultElementHandler(ilSaxSubsetParser $a_default_parser)
00076 {
00077 $this->default_handler = $a_default_parser;
00078 }
00079
00088 public function setElementHandler(ilSaxSubsetParser $a_parser,$a_element)
00089 {
00090 $this->element_handlers[$a_element] = $a_parser;
00091 $this->handlers_in_use[$a_element] = false;
00092 }
00093
00112 public function handlerBeginTag($a_xml_parser,$a_name,$a_attribs)
00113 {
00114 if(isset($this->element_handlers[$a_name]) or $this->handler_in_use)
00115 {
00116 if(!$this->handler_in_use)
00117 {
00118 $this->handler_in_use = $this->element_handlers[$a_name];
00119 }
00120
00121 $this->current_handler = $this->handler_in_use;
00122 return $this->current_handler->handlerBeginTag($a_xml_parser,$a_name,$a_attribs);
00123 }
00124
00125 $this->handler_in_use = false;
00126 $this->current_handler = $this->default_handler;
00127 return $this->default_handler->handlerBeginTag($a_xml_parser,$a_name,$a_attribs);
00128 }
00129
00136 function handlerEndTag($a_xml_parser,$a_name)
00137 {
00138 if(isset($this->element_handlers[$a_name]))
00139 {
00140 $this->handler_in_use = false;
00141 $this->current_handler = $this->element_handlers[$a_name];
00142 return $this->element_handlers[$a_name]->handlerEndTag($a_xml_parser,$a_name);
00143 }
00144 elseif($this->handler_in_use)
00145 {
00146 $this->current_handler = $this->handler_in_use;
00147 return $this->current_handler->handlerEndTag($a_xml_parser,$a_name);
00148 }
00149 $this->handler_in_use = false;
00150 $this->current_handler = $this->default_handler;
00151 return $this->default_handler->handlerEndTag($a_xml_parser,$a_name);
00152 }
00153
00160 function handlerCharacterData($a_xml_parser,$a_data)
00161 {
00162 return $this->current_handler->handlerCharacterData(a_xml_parser,$a_data);
00163 }
00164
00165 }
00166 ?>