From: gk at proliberty dot com
Operating system: Linux
PHP version: Irrelevant
PHP Bug Type: Documentation problem
Bug description: xml_set_processing_instruction_handler PI definition is wrong
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 bug report at http://bugs.php.net/?id=34281&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34281&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=34281&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=34281&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=34281&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=34281&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=34281&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=34281&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=34281&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=34281&r=support
Expected behavior: http://bugs.php.net/fix.php?id=34281&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=34281&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=34281&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=34281&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34281&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=34281&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=34281&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=34281&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=34281&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=34281&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=34281&r=mysqlcfg