Doc #71595 [Ana]: NS end handler is never called
| From: | anrdaemon at freemail dot ru | Date: | Tue, 16 Feb 2016 22:16:06 +0000 |
| Subject: | Doc #71595 [Ana]: NS end handler is never called | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-13192@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71595&edit=1
ID: 71595
User updated by: anrdaemon at freemail dot ru
Reported by: anrdaemon at freemail dot ru
Summary: NS end handler is never called
Status: Analyzed
Type: Documentation Problem
Package: XML related
Operating System: Windows
PHP Version: 5.6.18
Block user comment: N
Private report: N
New Comment:
Thanks, I've apparently missed that one note.
Should probably be a warning, and way up on the page, as it would be an impediment on most
platforms.
Previous Comments:
------------------------------------------------------------------------
[2016-02-16 20:53:33] ab@php.net
Yeah, clear the documentation could and should be improved. However, with this particular ticket,
it's documented http://php.net/xml_set_end_namespace_decl_handler
, please consider the note on the page:
This event is not supported under LibXML.
Maybe it's not synced with all the available languages, but actually i see that many contain
it. What is not documented and I think it's hard to document, is what library is actually used
with any particular build in a particular binary distribution. Right now, besides Windows builds at
least Debian and Fedora use libxml instead of libxpat, for what i've checked. The main reason I
think is that libxml is being supported and updated much more frequently. This info can be however
gathered on the corresponding package pages of the respective distributions.
The other three tickets reported by you (just decrementing this ticked number :) need to be checked
thoroughly as well, but how it reads from the code snippets and from the code base - the cause seems
to be the same. So for now I'm turning this ticket into the documentation issue, lets see with
the others.
Thanks.
------------------------------------------------------------------------
[2016-02-16 17:59:22] anrdaemon at freemail dot ru
Do you think it deserves at least a note in documentation?
You know, it is rather frustrating to write a parser and find out that it just not supposed to work
as documented.
------------------------------------------------------------------------
[2016-02-16 16:08:02] ab@php.net
Thanks for the reports. How it looks like, the things you've realized do happen most likely not
due to a PHP bug, but depend on the libxml2 usage. libxml doesn't support all the available
callbacks, and it's documented. From a quick look, have to check deeper, the other tickets
you've reported have the same cause. Many Linux distros link with libxml, as well it's
used on Windows.
Thanks.
------------------------------------------------------------------------
[2016-02-15 02:38:31] anrdaemon at freemail dot ru
Description:
------------
When NS-aware parser is created, the handler set by xml_set_end_namespace_decl_handler() is never
called.
Test script:
---------------
<?php
$indent = '';
$parser = xml_parser_create_ns('UTF-8');
xml_set_end_namespace_decl_handler($parser, function($self, $name)
{
global $indent;
$ns = $name ?: '(default)';
print $indent . "/NS:{$ns}\n";
});
// Expecting at least one mention of /NS: ...
xml_parse($parser, '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE shape PUBLIC "-//Dia//DTD Dia shape 1.0//EN" "http://www.daa.com.au/~james/dia-shape-ns">
<shape>
<svg xmlns:svg="http://www.w3.org/2000/svg"
svg:width="300px" svg:height="300px" svg:viewBox="0 0 3 3">
<svg:circle svg:style="fill: yellow;" cx="1.5" cy="1.5"
r="0.5"/>
</svg>
</shape>', true);
print xml_error_string(xml_get_error_code($parser)) . "\n";
?>
Expected result:
----------------
Expecting at least one mention of "/NS:...".
Especially one, where parser leaving the enclosed SVG structure.
Actual result:
--------------
No error
(No really, there's no error. But... Where's my handlers?)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71595&edit=1