#34281 [Opn->Csd]: xml_set_processing_instruction_handler PI definition is wrong

From: Date: Mon, 29 Aug 2005 15:28:38 +0000
Subject: #34281 [Opn->Csd]: xml_set_processing_instruction_handler PI definition is wrong
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969369748@lists.php.net to get a copy of this message
ID: 34281 Updated by: vrana@php.net 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: -------------- [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]$ ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=34281&edit=1

« previous php.doc (#969369748) next »