ILIAS  release_8 Revision v8.24
ilSaxController Class Reference

Controller class for sax element handlers. More...

+ Collaboration diagram for ilSaxController:

Public Member Functions

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

Protected Attributes

ilSaxSubsetParser $default_handler = null
 
array $element_handlers = []
 
array $handlers_in_use = []
 
 $handler_in_use = null
 
ilSaxSubsetParser $current_handler
 

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

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

Member Function Documentation

◆ handlerBeginTag()

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

default handlerBeginTag

@access public

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

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

72 : void
73 {
74 if (isset($this->element_handlers[$a_name]) or $this->handler_in_use) {
75 if (!$this->handler_in_use) {
76 $this->handler_in_use = $this->element_handlers[$a_name];
77 }
78 // Forward to handler
79 $this->current_handler = $this->handler_in_use;
80 $this->current_handler->handlerBeginTag($a_xml_parser, $a_name, $a_attribs);
81 return;
82 }
83 // Call default handler
84 $this->handler_in_use = false;
85 $this->current_handler = $this->default_handler;
86 $this->default_handler->handlerBeginTag($a_xml_parser, $a_name, $a_attribs);
87 }
ilSaxSubsetParser $default_handler
handlerBeginTag($a_xml_parser, string $a_name, array $a_attribs)
Start element handler.

References $default_handler, $handler_in_use, and ilSaxSubsetParser\handlerBeginTag().

+ Here is the call graph for this function:

◆ handlerCharacterData()

ilSaxController::handlerCharacterData (   $a_xml_parser,
string  $a_data 
)

handler for character data

Parameters
resource$a_xml_parserxml parser
string$a_datacharacter data

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

121 : void {
122 $this->current_handler->handlerCharacterData(
123 $a_xml_parser,
124 $a_data
125 );
126 }

◆ handlerEndTag()

ilSaxController::handlerEndTag (   $a_xml_parser,
string  $a_name 
)

handler for end of element

Parameters
resource$a_xml_parserxml parser
string$a_nameelement name

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

95 : void
96 {
97 if (isset($this->element_handlers[$a_name])) {
98 $this->handler_in_use = false;
99 $this->current_handler = $this->element_handlers[$a_name];
100 $this->element_handlers[$a_name]->handlerEndTag($a_xml_parser, $a_name);
101 return;
102 } elseif ($this->handler_in_use) {
103 $this->current_handler = $this->handler_in_use;
104 $this->current_handler->handlerEndTag($a_xml_parser, $a_name);
105 return;
106 }
107 $this->handler_in_use = false;
108 $this->current_handler = $this->default_handler;
109 $this->default_handler->handlerEndTag($a_xml_parser, $a_name);
110 }
handlerEndTag($a_xml_parser, string $a_name)
End element handler.

References $default_handler, $handler_in_use, and ilSaxSubsetParser\handlerEndTag().

+ Here is the call graph for this function:

◆ setDefaultElementHandler()

ilSaxController::setDefaultElementHandler ( ilSaxSubsetParser  $a_default_parser)

Set default element handler.

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

49 : void
50 {
51 $this->default_handler = $a_default_parser;
52 }

◆ setElementHandler()

ilSaxController::setElementHandler ( ilSaxSubsetParser  $a_parser,
string  $a_element 
)
Parameters
ilSaxSubsetParser$a_parserobject that parses the xmlsubset must implement interface ilSaxSubsetParser
string$a_elementelement name that triggers the handler

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

58 : void
59 {
60 $this->element_handlers[$a_element] = $a_parser;
61 $this->handlers_in_use[$a_element] = false;
62 }

◆ setHandlers()

ilSaxController::setHandlers (   $a_xml_parser)

Set handlers.

Parameters
resourcexml_parser instance

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

39 : void
40 {
41 xml_set_object($a_xml_parser, $this);
42 xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
43 xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
44 }

Field Documentation

◆ $current_handler

ilSaxSubsetParser ilSaxController::$current_handler
protected

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

◆ $default_handler

ilSaxSubsetParser ilSaxController::$default_handler = null
protected

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

Referenced by handlerBeginTag(), and handlerEndTag().

◆ $element_handlers

array ilSaxController::$element_handlers = []
protected

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

◆ $handler_in_use

ilSaxController::$handler_in_use = null
protected

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

Referenced by handlerBeginTag(), and handlerEndTag().

◆ $handlers_in_use

array ilSaxController::$handlers_in_use = []
protected

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


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