helly           Sun Jul 17 13:38:18 2005 EDT

  Added files:                 
    /php-src/ext/xml/tests      bug26614_libxml.phpt 

  Modified files:              
    /php-src/ext/xml/tests      bug26614.phpt 
  Log:
  - 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.
  
  
http://cvs.php.net/diff.php/php-src/ext/xml/tests/bug26614.phpt?r1=1.4&r2=1.5&ty=u
Index: php-src/ext/xml/tests/bug26614.phpt
diff -u php-src/ext/xml/tests/bug26614.phpt:1.4 
php-src/ext/xml/tests/bug26614.phpt:1.5
--- php-src/ext/xml/tests/bug26614.phpt:1.4     Mon Mar 29 00:56:18 2004
+++ php-src/ext/xml/tests/bug26614.phpt Sun Jul 17 13:38:16 2005
@@ -1,5 +1,7 @@
 --TEST--
 Bug #26614 (CDATA sections skipped on line count)
+--SKIPIF--
+<?php if (defined("LIBXML_VERSION")) die('skip expat test'); ?>
 --FILE--
 <?php
 /*

http://cvs.php.net/co.php/php-src/ext/xml/tests/bug26614_libxml.phpt?r=1.1&p=1
Index: php-src/ext/xml/tests/bug26614_libxml.phpt
+++ php-src/ext/xml/tests/bug26614_libxml.phpt
--TEST--
Bug #26614 (CDATA sections skipped on line count)
--SKIPIF--
<?php if (!defined("LIBXML_VERSION")) die('skip libxml2 test'); ?>
--FILE--
<?php
/*
this test works fine with Expat but fails with libxml
which we now use as default

further investigation has shown that not only line count
is skippet on CDATA sections but that libxml does also
show different column numbers and byte positions depending
on context and in opposition to what one would expect to
see and what good old Expat reported just fine ...
*/

$xmls = array();

// Case 1: CDATA Sections
$xmls["CDATA"] ='<?xml version="1.0" encoding="iso-8859-1" ?>
<data>
<![CDATA[
multi
line 
CDATA
block
]]>
</data>';

// Case 2: replace some characters so that we get comments instead
$xmls["Comment"] ='<?xml version="1.0" encoding="iso-8859-1" ?>
<data>
<!-- ATA[
multi
line 
CDATA
block
-->
</data>';

// Case 3: replace even more characters so that only textual data is left 
$xmls["Text"] ='<?xml version="1.0" encoding="iso-8859-1" ?>
<data>
-!-- ATA[
multi
line 
CDATA
block
---
</data>';

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("</$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 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
<DATA> at line 2, col 6 (byte 9)
</DATA> at line 9, col 8 (byte 56)
Comment
<DATA> at line 2, col 6 (byte 9)
</DATA> at line 9, col 8 (byte 56)
Text
<DATA> at line 2, col 6 (byte 9)
</DATA> at line 9, col 8 (byte 56)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to