73 $this->xml_file = $a_xml_file;
74 $this->input_type =
'file';
84 $this->xml_content = $a_xml_content;
85 $this->input_type =
'string';
113 $this->
parse($xml_parser, $fp);
117 $this->
parse($xml_parser);
122 "No input type given. Set filename in constructor or choose setXMLContent()",
123 $this->
ilias->error_obj->FATAL
137 $xml_parser = xml_parser_create(
"UTF-8");
139 if ($xml_parser ==
false) {
140 $this->
handleError(
"Cannot create an XML parser handle", $this->
ilias->error_obj->FATAL);
151 xml_parser_set_option($a_xml_parser, XML_OPTION_CASE_FOLDING,
false);
160 echo 'ilSaxParser::setHandlers() must be overwritten';
170 if (!($fp =
fopen($this->xml_file,
'r'))) {
171 $this->
handleError(
"Cannot open xml file \"" . $this->xml_file .
"\"", $this->
ilias->error_obj->FATAL);
181 public function parse($a_xml_parser, $a_fp = null)
186 while (
$data = fread($a_fp, 4096)) {
187 $parseOk = xml_parse($a_xml_parser,
$data, feof($a_fp));
196 && (xml_get_error_code($a_xml_parser) != XML_ERROR_NONE)) {
197 $errorCode = xml_get_error_code($a_xml_parser);
198 $line = xml_get_current_line_number($a_xml_parser);
199 $col = xml_get_current_column_number($a_xml_parser);
214 if ($this->throwException) {
215 require_once(
'./Services/Xml/exceptions/class.ilSaxParserException.php');
218 if (is_object($this->
ilias)) {
233 if (!xml_parser_free($a_xml_parser)) {
234 $this->
ilias->raiseError(
"Error freeing xml parser handle ", $this->
ilias->error_obj->FATAL);
setOptions($a_xml_parser)
set parser options
__construct($a_xml_file='', $throwException=false)
Constructor setup ILIAS global object public.
startParsing()
stores xml data in array
freeParser($a_xml_parser)
free xml parser handle
setThrowException($throwException)
set error handling
SaxParserException thrown by ilSaxParser if property throwException is set.
Base class for sax-based expat parsing extended classes need to overwrite the method setHandlers and ...
handleError($message, $code)
use given error handler to handle error message or internal ilias error message handle ...
catch(Exception $e) $message
redirection script todo: (a better solution should control the processing via a xml file) ...
parse($a_xml_parser, $a_fp=null)
parse xml file
openXMLFile()
open xml file
setXMLContent($a_xml_content)
setHandlers($a_xml_parser)
set event handler should be overwritten by inherited class private
createParser()
create parser