ID:               34281
 Updated by:       [EMAIL PROTECTED]
 Reported By:      gk at proliberty dot com
-Status:           Open
+Status:           Closed
 Bug Type:         Documentation problem
 Operating System: Linux
 PHP Version:      Irrelevant
 New Comment:

This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation
better.




Previous Comments:
------------------------------------------------------------------------

[2005-08-27 14:06:40] gk at proliberty dot com

Description:
------------
xml_set_processing_instruction_handler manual page says:

--- BEGIN QUOTE
A processing instruction has the following format: 


<?
       target 
       data?>

--- END QUOTE

The truth is:
<?target 
       data?>

There cannot be any space between '<?' and target.

This can be verified:
1. According to the XML 1.0 Specification, and
2. According to how xml_set_processing_instruction_handler() behaves
     
--- BEGIN QUOTED MATERIAL
2.6 Processing Instructions

[Definition: Processing instructions (PIs) allow documents to contain
instructions for applications.]
Processing Instructions
[16]    PI         ::=          '<?' PITarget (S (Char* - (Char* '?>' Char*)))?
'?>'    
[17]    PITarget           ::=          Name - (('X' | 'x') ('M' | 'm') ('L' |
'l'))   

REFERENCE:
XML 1.0 (Third Edition): http://www.w3.org/TR/REC-xml/#sec-pi


Reproduce code:
---------------
--- test.php
<?php

$q = '?';
$validPI = <<< EOD
<{$q}xml version="1.0"{$q}>
<test> PHP 5.0.2
<{$q}pi 
    DATA 
{$q}>
</test>
EOD;

$invalidPI = <<< EOD
<{$q}xml version="1.0"{$q}>
<test> PHP 5.0.2
<{$q} pi 
    DATA 
{$q}>
</test>
EOD;

$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); 
// this doesn't do anything:
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0); 
xml_set_element_handler($parser, "start_element", "stop_element"); 
xml_set_character_data_handler($parser, "char_data"); 
xml_set_processing_instruction_handler( $parser, "_handlePI");

echo "--- VALID PI in document:\n$validPI\n";
echo "--- Result of parsing:\n";
xml_parse( $parser, $validPI );
echo "\n";
echo "--- INVALID PI in document:\n$invalidPI\n";
echo "--- Result of parsing:\n";
xml_parse( $parser, $invalidPI );

function _handlePI($parser, $target, $data) {
    echo(">>>".$data."<<<");
}

function start_element($parser, $data, $attribs) {
echo $data;
}
function stop_element($parser, $data ) {
echo $data;

}
function char_data($parser, $data ) {
echo $data;
}
?>


Actual result:
--------------
[EMAIL PROTECTED] test]$ php test.php
--- VALID PI in document:
<?xml version="1.0"?>
<test> PHP 5.0.2
<?pi 
    DATA 
?>
</test>
--- Result of parsing:
test PHP 5.0.2
>>>DATA 
<<<
test
--- INVALID PI in document:
<?xml version="1.0"?>
<test> PHP 5.0.2
<? pi 
    DATA 
?>
</test>
--- Result of parsing:
[EMAIL PROTECTED] test]$ 




------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=34281&edit=1

Reply via email to