Index: simplified_parser_processor.class.php =================================================================== RCS file: /cvsroot/moodle/moodle/backup/util/xml/parser/processors/simplified_parser_processor.class.php,v retrieving revision 1.3 diff -u -r1.3 simplified_parser_processor.class.php --- simplified_parser_processor.class.php 5 Jul 2010 22:10:52 -0000 1.3 +++ simplified_parser_processor.class.php 23 Aug 2010 17:04:09 -0000 @@ -92,11 +92,16 @@ unset($this->parentsinfo[$parentpath][$tag]['attrs']); } // Now, let's simplify the tags array, ignoring tag attributtes and - // reconverting to simpler name => value array + // reconverting to simpler name => value array. At the same time, + // check for all the tag values being whitespace-string values, if all them + // are whitespace strings, we aren't going to postprocess/dispatch the chunk + $alltagswhitespace = true; foreach ($data['tags'] as $key => $value) { // If the value is already a single value, do nothing - // surely was added above from parentsinfo + // surely was added above from parentsinfo attributes, + // so we'll process the chunk always if (!is_array($value)) { + $alltagswhitespace = false; continue; } // If the path including the tag name matches another selected path @@ -108,14 +113,20 @@ } // Convert to simple name => value array $data['tags'][$key] = isset($value['cdata']) ? $value['cdata'] : null; + + // Check $alltagswhitespace continues being true + if ($alltagswhitespace && strlen($data['tags'][$key]) !== 0 && trim($data['tags'][$key]) !== '') { + $alltagswhitespace = false; // Found non-whitespace value + } } - // Arrived here, if the chunk has tags, send it to postprocess filter that - // will decide about dispatching - if (!empty($data['tags'])) { + // Arrived here, if the chunk has tags and not all tags are whitespace, + // send it to postprocess filter that will decide about dispatching. Else + // skip the chunk completely + if (!empty($data['tags']) && !$alltagswhitespace) { return $this->postprocess_chunk($data); } else { - $this->chunks--; // Chunk skipped + $this->chunks--; // Chunk skipped } } else { $this->chunks--; // Chunk skipped