ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilSaxController Class Reference

Controller class for sax element handlers. More...

+ Collaboration diagram for ilSaxController:

Public Member Functions

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

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 smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilSaxController::__construct ( )

Constructor.

@access public

Parameters

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

49 {
50 }

Member Function Documentation

◆ handlerBeginTag()

ilSaxController::handlerBeginTag (   $a_xml_parser,
  $a_name,
  $a_attribs 
)

Set default element handler.

@access public

Parameters
stringxml element that triggers the handler call
objectobject that parses the xmlsubset
stringmethod name default handlerBeginTag

@access public

Parameters
resource$a_xml_parserxml parser
string$a_nameelement name
array$a_attribselement attributes array

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

112 {
113 if(isset($this->element_handlers[$a_name]) or $this->handler_in_use)
114 {
115 if(!$this->handler_in_use)
116 {
117 $this->handler_in_use = $this->element_handlers[$a_name];
118 }
119 // Forward to handler
120 $this->current_handler = $this->handler_in_use;
121 return $this->current_handler->handlerBeginTag($a_xml_parser,$a_name,$a_attribs);
122 }
123 // Call default handler
124 $this->handler_in_use = false;
125 $this->current_handler = $this->default_handler;
126 return $this->default_handler->handlerBeginTag($a_xml_parser,$a_name,$a_attribs);
127 }

References $default_handler.

◆ handlerCharacterData()

ilSaxController::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

Parameters
resource$a_xml_parserxml parser
string$a_datacharacter data

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

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

◆ handlerEndTag()

ilSaxController::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

Parameters
resource$a_xml_parserxml parser
string$a_nameelement name

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

136 {
137 if(isset($this->element_handlers[$a_name]))
138 {
139 $this->handler_in_use = false;
140 $this->current_handler = $this->element_handlers[$a_name];
141 return $this->element_handlers[$a_name]->handlerEndTag($a_xml_parser,$a_name);
142 }
143 elseif($this->handler_in_use)
144 {
145 $this->current_handler = $this->handler_in_use;
146 return $this->current_handler->handlerEndTag($a_xml_parser,$a_name);
147 }
148 $this->handler_in_use = false;
149 $this->current_handler = $this->default_handler;
150 return $this->default_handler->handlerEndTag($a_xml_parser,$a_name);
151 }

References $default_handler.

◆ setDefaultElementHandler()

ilSaxController::setDefaultElementHandler ( ilSaxSubsetParser  $a_default_parser)

Set default element handler.

@access public

Parameters
objectobject that parses the xmlsubset must implement interface ilSaxSubsetParser

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

75 {
76 $this->default_handler = $a_default_parser;
77 }

◆ setElementHandler()

ilSaxController::setElementHandler ( ilSaxSubsetParser  $a_parser,
  $a_element 
)

Set element handler by element name.

Parameters
stringelement name that triggers the handler
objectobject that parses the xmlsubset must implement interface ilSaxSubsetParser @access public

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

88 {
89 $this->element_handlers[$a_element] = $a_parser;
90 $this->handlers_in_use[$a_element] = false;
91 }

◆ setHandlers()

ilSaxController::setHandlers (   $a_xml_parser)

Set handlers.

@access public

Parameters
resourcexml_parser instance

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

60 {
61 xml_set_object($a_xml_parser,$this);
62 xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
63 xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
64 return;
65 }

Field Documentation

◆ $default_handler

ilSaxController::$default_handler = null
protected

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

Referenced by handlerBeginTag(), and handlerEndTag().

◆ $element_handlers

ilSaxController::$element_handlers = array()
protected

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

◆ $handlers_in_use

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: