From dfeddbe539bd26c28cc6d2c652cddc53012e3856 Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Sun, 17 Jul 2005 17:38:16 +0000 Subject: - If you ask me both (expat and libxml) are not really accurate about byte positions and columns...however the line number information is now correct for both so for the moment we live with the situation that they return different byte and column information. --- ext/xml/tests/bug26614.phpt | 2 + ext/xml/tests/bug26614_libxml.phpt | 90 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100755 ext/xml/tests/bug26614_libxml.phpt diff --git a/ext/xml/tests/bug26614.phpt b/ext/xml/tests/bug26614.phpt index 14a4ea8a9f..a8a91ae876 100644 --- a/ext/xml/tests/bug26614.phpt +++ b/ext/xml/tests/bug26614.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #26614 (CDATA sections skipped on line count) +--SKIPIF-- + --FILE-- +--FILE-- + + + +'; + +// Case 2: replace some characters so that we get comments instead +$xmls["Comment"] =' + + +'; + +// Case 3: replace even more characters so that only textual data is left +$xmls["Text"] =' + +-!-- ATA[ +multi +line +CDATA +block +--- +'; + +function startElement($parser, $name, $attrs) { + printf("<$name> at line %d, col %d (byte %d)\n", + xml_get_current_line_number($parser), + xml_get_current_column_number($parser), + xml_get_current_byte_index($parser)); +} + +function endElement($parser, $name) { + printf(" at line %d, col %d (byte %d)\n", + xml_get_current_line_number($parser), + xml_get_current_column_number($parser), + xml_get_current_byte_index($parser)); +} + +function characterData($parser, $data) { + // dummy +} + +foreach ($xmls as $desc => $xml) { + echo "$desc\n"; + $xml_parser = xml_parser_create(); + xml_set_element_handler($xml_parser, "startElement", "endElement"); + xml_set_character_data_handler($xml_parser, "characterData"); + if (!xml_parse($xml_parser, $xml, true)) + echo "Error: ".xml_error_string(xml_get_error_code($xml_parser))."\n"; + xml_parser_free($xml_parser); +} +?> +--EXPECT-- +CDATA + at line 2, col 6 (byte 9) + at line 9, col 8 (byte 56) +Comment + at line 2, col 6 (byte 9) + at line 9, col 8 (byte 56) +Text + at line 2, col 6 (byte 9) + at line 9, col 8 (byte 56) -- cgit v1.2.1