ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilSaxParser Class Reference

Base class for sax-based expat parsing extended classes need to overwrite the method setHandlers and implement their own handler methods. More...

+ Inheritance diagram for ilSaxParser:
+ Collaboration diagram for ilSaxParser:

Public Member Functions

 ilSaxParser ($a_xml_file= '', $throwException=false)
 Constructor setup ILIAS global object public.
 setXMLContent ($a_xml_content)
 getXMLContent ()
 getInputType ()
 startParsing ()
 stores xml data in array
 createParser ()
 create parser
 setOptions ($a_xml_parser)
 set parser options
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class private
 openXMLFile ()
 open xml file
 parse ($a_xml_parser, $a_fp=null)
 parse xml file
 freeParser ($a_xml_parser)
 free xml parser handle
 setThrowException ($throwException)
 set error handling
- Public Member Functions inherited from PEAR
 PEAR ($error_class=null)
 Constructor.
 _PEAR ()
 Destructor (the emulated type of...).
getStaticProperty ($class, $var)
 If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them.
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes.
 isError ($data, $code=null)
 Tell whether a value is a PEAR error.
 setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled.
 expectError ($code= '*')
 This method is used to tell which errors you expect to get.
 popExpect ()
 This method pops one element off the expected error codes stack.
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available.
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack.
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied.
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options.
 staticPushErrorHandling ($mode, $options=null)
 staticPopErrorHandling ()
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack.
 popErrorHandling ()
 Pop the last error handler used.
 loadExtension ($ext)
 OS independant PHP extension load.

Data Fields

 $input_type = null
 $xml_content = ''
 $ilias
 $lng
 $xml_file
 $throwException = false
- Data Fields inherited from PEAR
 $_debug = false
 $_default_error_mode = null
 $_default_error_options = null
 $_default_error_handler = ''
 $_error_class = 'PEAR_Error'
 $_expected_errors = array()

Protected Member Functions

 handleError ($message, $code)
 use given error handler to handle error message or internal ilias error message handle

Detailed Description

Base class for sax-based expat parsing extended classes need to overwrite the method setHandlers and implement their own handler methods.

Author
Stefan Meyer <smeyer>
Version
Id:
class.ilSaxParser.php 28147 2011-03-20 15:45:21Z hschottm

Definition at line 17 of file class.ilSaxParser.php.

Member Function Documentation

ilSaxParser::createParser ( )

create parser

private

Exceptions
ilSaxParserExceptionor ILIAS Error

Definition at line 134 of file class.ilSaxParser.php.

References handleError().

Referenced by startParsing(), and ilnetucateResponse\startParsing().

{
$xml_parser = xml_parser_create("UTF-8");
if($xml_parser == false)
{
$this->handleError("Cannot create an XML parser handle",$this->ilias->error_obj->FATAL);
}
return $xml_parser;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilSaxParser::freeParser (   $a_xml_parser)

free xml parser handle

private

Definition at line 238 of file class.ilSaxParser.php.

Referenced by startParsing(), and ilnetucateResponse\startParsing().

{
if(!xml_parser_free($a_xml_parser))
{
$this->ilias->raiseError("Error freeing xml parser handle ",$this->ilias->error_obj->FATAL);
}
}

+ Here is the caller graph for this function:

ilSaxParser::getInputType ( )

Definition at line 93 of file class.ilSaxParser.php.

References $input_type.

Referenced by ilXMLChecker\parse(), SurveyImportParser\parse(), SurveyImportParserPre38\parse(), parse(), and startParsing().

{
}

+ Here is the caller graph for this function:

ilSaxParser::getXMLContent ( )

Definition at line 88 of file class.ilSaxParser.php.

References $xml_content.

Referenced by ilXMLChecker\parse(), SurveyImportParser\parse(), SurveyImportParserPre38\parse(), and parse().

{
}

+ Here is the caller graph for this function:

ilSaxParser::handleError (   $message,
  $code 
)
protected

use given error handler to handle error message or internal ilias error message handle

Parameters
string$message
string$code
Exceptions
ilSaxParserExceptionor ILIAS Error

Definition at line 217 of file class.ilSaxParser.php.

Referenced by createParser(), openXMLFile(), parse(), and startParsing().

{
if ($this->throwException) {
require_once ('./classes/class.ilSaxParserException.php');
throw new ilSaxParserException ($message, $code);
} else {
if (is_object($this->ilias))
{
$this->ilias->raiseError($message, $code);
}
else
{
die($message);
}
}
return false;
}

+ Here is the caller graph for this function:

ilSaxParser::openXMLFile ( )

open xml file

private

Exceptions
ilSaxParserExceptionor ILIAS Error

Definition at line 168 of file class.ilSaxParser.php.

References handleError().

Referenced by startParsing().

{
if(!($fp = fopen($this->xml_file,'r')))
{
$this->handleError("Cannot open xml file \"".$this->xml_file."\"",$this->ilias->error_obj->FATAL);
}
return $fp;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilSaxParser::parse (   $a_xml_parser,
  $a_fp = null 
)

parse xml file

private

Exceptions
ilSaxParserExceptionor ILIAS Error

Reimplemented in SurveyImportParserPre38, SurveyImportParser, ilnetucateResponse, ilXMLChecker, and ilObjectXMLParser.

Definition at line 182 of file class.ilSaxParser.php.

References $data, getInputType(), getXMLContent(), and handleError().

Referenced by startParsing().

{
switch($this->getInputType())
{
case 'file':
while($data = fread($a_fp,4096))
{
$parseOk = xml_parse($a_xml_parser,$data,feof($a_fp));
}
break;
case 'string':
$parseOk = xml_parse($a_xml_parser,$this->getXMLContent());
break;
}
if(!$parseOk
&& (xml_get_error_code($a_xml_parser) != XML_ERROR_NONE))
{
$errorCode = xml_get_error_code($a_xml_parser);
$line = xml_get_current_line_number($a_xml_parser);
$col = xml_get_current_column_number($a_xml_parser);
$this->handleError("XML Parse Error: ".xml_error_string($errorCode)." at line ".$line.", col ". $col . " (Code: ".$errorCode.")" ,$this->ilias->error_obj->FATAL);
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilSaxParser::setOptions (   $a_xml_parser)

set parser options

private

Definition at line 149 of file class.ilSaxParser.php.

Referenced by startParsing(), and ilnetucateResponse\startParsing().

{
xml_parser_set_option($a_xml_parser,XML_OPTION_CASE_FOLDING,false);
}

+ Here is the caller graph for this function:

ilSaxParser::setThrowException (   $throwException)

set error handling

Parameters
$error_handler

Definition at line 251 of file class.ilSaxParser.php.

References $throwException.

Referenced by ilFolderXmlParser\__construct(), and ilWebLinkXmlParser\__construct().

{
$this->throwException = $throwException;
}

+ Here is the caller graph for this function:

ilSaxParser::startParsing ( )

stores xml data in array

private

Exceptions
ilSaxParserExceptionor ILIAS Error

Reimplemented in ilUserImportParser, ilQTIParser, ilManifestParser, SurveyImportParserPre38, SurveyImportParser, ilContObjParser, ilnetucateResponse, ilGroupXMLParser, ilMailImportParser, ilSCORMPackageParser, ilXMLChecker, ilCategoryImportParser, ilStyleImportParser, ilDataSetImportParser, ilExportFileParser, ilPluginReader, and ilSimpleXMLTableDataParser.

Definition at line 104 of file class.ilSaxParser.php.

References createParser(), freeParser(), getInputType(), handleError(), openXMLFile(), parse(), setHandlers(), and setOptions().

Referenced by ilMD\cloneMD(), ilSCORM13Package\dbImportLM(), ilSCORM13Package\dbImportSco(), ilModuleReader\getModules(), ilServiceReader\getServices(), ilFolderXmlParser\start(), ilWebLinkXmlParser\start(), ilExerciseXMLParser\start(), and ilFileXMLParser\start().

{
$xml_parser = $this->createParser();
$this->setOptions($xml_parser);
$this->setHandlers($xml_parser);
switch($this->getInputType())
{
case 'file':
$fp = $this->openXMLFile();
$this->parse($xml_parser,$fp);
break;
case 'string':
$this->parse($xml_parser);
break;
default:
$this->handleError("No input type given. Set filename in constructor or choose setXMLContent()",
$this->ilias->error_obj->FATAL);
break;
}
$this->freeParser($xml_parser);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilSaxParser::$input_type = null

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

Referenced by getInputType().

ilSaxParser::$throwException = false
ilSaxParser::$xml_content = ''

Definition at line 34 of file class.ilSaxParser.php.

Referenced by getXMLContent().

ilSaxParser::$xml_file

Definition at line 55 of file class.ilSaxParser.php.


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