php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #34281 xml_set_processing_instruction_handler PI definition is wrong
Submitted: 2005-08-27 14:06 UTC Modified: 2005-08-29 17:28 UTC
From: gk at proliberty dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gk at proliberty dot com
New email:
PHP Version: OS:

 

 [2005-08-27 14:06 UTC] 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:
--------------
[greg@p3 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:
[greg@p3 test]$ 



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-29 17:28 UTC] vrana@php.net
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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 24 07:02:12 2024 UTC