Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
|
Class implementing one SAX progressive push parser. More...
Public Member Functions | |
__construct ($case_folding=false) | |
process () | |
set_contents ($contents) | |
set_file ($file) | |
set_processor ($processor) | |
set_progress (\core\progress\base $progress) | |
Sets the progress tracker for the parser. | |
Static Public Member Functions | |
static | dirname ($path) |
Provides one cross-platform dirname function for handling parser paths, see MDL-24381 | |
Protected Attributes | |
$accum | |
$attrs | |
$contents | |
$currtag | |
$file | |
$level | |
$path | |
$prevlevel | |
progressive_parser_processor | $processor |
to be used to publish processed information | |
core progress base | $progress |
Progress tracker called for each action. | |
$topush | |
$xml_parser | |
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
progressive_parser::set_progress | ( | \core\progress\base | $progress | ) |
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.
core\progress\base | $progress | Progress tracker |