68 function __construct($a_xml_file =
'', $throwException =
false)
74 $this->xml_file = $a_xml_file;
75 $this->input_type =
'file';
85 $this->xml_content = $a_xml_content;
86 $this->input_type =
'string';
115 $this->
parse($xml_parser,$fp);
119 $this->
parse($xml_parser);
123 $this->
handleError(
"No input type given. Set filename in constructor or choose setXMLContent()",
124 $this->
ilias->error_obj->FATAL);
137 $xml_parser = xml_parser_create(
"UTF-8");
139 if($xml_parser ==
false)
141 $this->
handleError(
"Cannot create an XML parser handle",$this->
ilias->error_obj->FATAL);
152 xml_parser_set_option($a_xml_parser,XML_OPTION_CASE_FOLDING,
false);
161 echo 'ilSaxParser::setHandlers() must be overwritten';
171 if(!($fp = fopen($this->xml_file,
'r')))
173 $this->
handleError(
"Cannot open xml file \"".$this->xml_file.
"\"",$this->ilias->error_obj->FATAL);
183 function parse($a_xml_parser,$a_fp = null)
189 while(
$data = fread($a_fp,4096))
191 $parseOk = xml_parse($a_xml_parser,
$data,feof($a_fp));
200 && (xml_get_error_code($a_xml_parser) != XML_ERROR_NONE))
202 $errorCode = xml_get_error_code($a_xml_parser);
203 $line = xml_get_current_line_number($a_xml_parser);
204 $col = xml_get_current_column_number($a_xml_parser);
205 $this->
handleError(
"XML Parse Error: ".xml_error_string($errorCode).
" at line ".$line.
", col ". $col .
" (Code: ".$errorCode.
")" ,$this->ilias->error_obj->FATAL);
219 if ($this->throwException) {
220 require_once (
'./Services/Xml/exceptions/class.ilSaxParserException.php');
223 if (is_object($this->
ilias))
241 if(!xml_parser_free($a_xml_parser))
243 $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 ...
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