Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 401 and 402] [Versions 401 and 403]

(no description)

Copyright: 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 308 lines (11 kb)
Included or required:0 times
Referenced: 1 time
Includes or requires: 0 files

Defines 2 classes

progressive_parser:: (15 methods):
  __construct()
  set_file()
  set_contents()
  set_processor()
  set_progress()
  process()
  dirname()
  parse()
  publish()
  inform_start()
  inform_end()
  postprocess_cdata()
  start_tag()
  end_tag()
  char_data()

progressive_parser_exception:: (1 method):
  __construct()


Class: progressive_parser  - X-Ref

Class implementing one SAX progressive push parser.

SAX parser able to process XML content from files/variables. It supports
attributes and case folding and works only with UTF-8 content. It's one
progressive push parser because, intead of loading big crunchs of information
in memory, it "publishes" (pushes) small information in a "propietary array format" througt
the corresponding @progressive_parser_processor, that will be the responsibe for
returning information into handy formats to higher levels.

Note that, while this progressive parser is able to process any XML file, it is
100% progressive so it publishes the information in the original order it's parsed (that's
the expected behaviour) so information belonging to the same path can be returned in
different chunks if there are inner levels/paths in the middle. Be warned!

The "propietary array format" that the parser publishes to the @progressive_parser_processor
is this:
array (
'path' => path where the tags belong to,
'level'=> level (1-based) of the tags
'tags  => array (
'name' => name of the tag,
'attrs'=> array( name of the attr => value of the attr),
'cdata => cdata of the tag
)
)

TODO: Finish phpdocs
__construct($case_folding = false)   X-Ref


set_file($file)   X-Ref
No description

set_contents($contents)   X-Ref
No description

set_processor($processor)   X-Ref
No description

set_progress(\core\progress\base $progress)   X-Ref
Sets the progress tracker for the parser. If set, the tracker will be
called to report indeterminate progress for each chunk of XML.

The caller should have already called start_progress on the progress tracker.

param: \core\progress\base $progress Progress tracker

process()   X-Ref
No description

dirname($path)   X-Ref
Provides one cross-platform dirname function for
handling parser paths, see MDL-24381


parse($data, $eof)   X-Ref
No description

publish($data)   X-Ref
No description

inform_start($path)   X-Ref
Inform to the processor that we have started parsing one path


inform_end($path)   X-Ref
Inform to the processor that we have finished parsing one path


postprocess_cdata($data)   X-Ref
No description

start_tag($parser, $tag, $attributes)   X-Ref
No description

end_tag($parser, $tag)   X-Ref
No description

char_data($parser, $data)   X-Ref
No description

Class: progressive_parser_exception  - X-Ref

__construct($errorcode, $a=NULL, $debuginfo=null)   X-Ref
No description