Bug #51897 [Fbk]: LIBXML_NOWARNING does not suppress warnings when passed to xinclude().
Edit report at http://bugs.php.net/bug.php?id=51897&edit=1
ID: 51897
Updated by: rquadling@php.net
Reported by: rquadling@php.net
Summary: LIBXML_NOWARNING does not suppress warnings when
passed to xinclude().
Status: Feedback
Type: Bug
Package: DOM XML related
Operating System: Windows XP SP3
PHP Version: 5.3.2
Assigned To: rrichards
New Comment:
This is about as short as I can get. I can't work out how to get the
xinclude
working in this
example, but that is not the issue. The warning that is generated is the
issue.
Only the code
below is required - no PHPDoc or DocBook, etc.
<?php
file_put_contents('my.dtd', <<< END_DTD
<!ENTITY % db.common.attributes
"xml:id ID #IMPLIED">
<!ENTITY % db.common.linking.attributes
"xmlns:xi CDATA #FIXED 'http://www.w3.org/2001/XInclude'">
<!ELEMENT people_list (person*)>
<!ATTLIST people_list
%db.common.attributes;
%db.common.linking.attributes;>
<!ELEMENT person (name, birthdate?, gender?, socialsecuritynumber?)>
<!ATTLIST person
%db.common.attributes;
%db.common.linking.attributes;>
<!ELEMENT name (#PCDATA)>
<!ELEMENT birthdate (#PCDATA)>
<!ELEMENT gender (#PCDATA)>
<!ELEMENT socialsecuritynumber (#PCDATA)>
END_DTD
);
file_put_contents('my.xml', <<< END_XML
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE people_list SYSTEM "my.dtd">
<people_list xmlns:xi="http://www.w3.org/2001/XInclude">
<person xml:id="fred">
<name>Fred Bloggs</name>
<birthdate>27/11/2008</birthdate>
<gender>Male</gender>
</person>
<person xml:id="john">
<name>John Bloggs</name>
<gender>Male</gender>
<!-- Include fred's birthdate -->
<xi:include xpointer="xmlns(db=my.dtd)
xpointer(id('fred')/db:birthdate)">
<xi:fallback />
</xi:include>
</person>
</people_list>
END_XML
);
echo
file_get_contents('my.dtd'), PHP_EOL, PHP_EOL,
file_get_contents('my.xml'), PHP_EOL, PHP_EOL;
$doc = new DOMDocument();
$doc->load('my.xml', LIBXML_NOENT);
var_dump($doc->xinclude(LIBXML_NOWARNING));
var_dump($doc->validate());
$doc->save('final.xml');
echo PHP_EOL, file_get_contents('final.xml');
unlink('final.xml');
unlink('my.dtd');
unlink('my.xml');
?>
Other than the XML and the DTD, the output is ...
Warning: DOMDocument::xinclude(): XPointer evaluation failed:
#xmlns(db=my.dtd)
xpointer(id('fred')/db:birthdate) in Z:\testinc.php on line 49
int(-1)
bool(true)
The Warning is present, even though LIBXML_NOWARNING is present. I
believe that
the issue is
that xinclude processing doesn't look at the same flags as the xml
parser. But
that's just a
half-arsed guess at trying to read the c code of something I'm clearly
not
understanding 100%
Richard.
Previous Comments:
------------------------------------------------------------------------
[2010-06-18 20:19:45] rrichards@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
please submit a test case that doesnt require phpdoc to be pulled
------------------------------------------------------------------------
[2010-05-24 12:35:56] rquadling@php.net
Description:
------------
This issue is in relation to http://news.php.net/php.doc/969381854
Trying to standardise the documentation in relation to including class
synopsis,
I'm including constructor and destructor synopsis via an xinclude with
an
pointer and a xfallback...
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook)
xpointer(id('class.datetime')/db:refentry/db:refsect1[@role='description']/desce
ndant::db:destructorsynopsis[not(@role='procedural')])">
<xi:fallback />
</xi:include>
As there is no destructor for datetime, the fallback is used (which is
empty).
All would seem to be well.
The problem is that the xinclude processing generates a warning when
using the
online documentation editor - but not when I run this locally via
phpdoc's
configure.
I've been supplied a test script (http://news.php.net/php.doc/969381870)
which
will generate the errors locally.
And so to the bug.
In the example the xinclude() call has no parameters.
Supplying LIBXML_NOWARNING does _NOT_ suppress the warnings.
To run the test script, you will need the doc-base/manual.xml file
produced by
running the doc-base/configure.php script (part of PHPDoc).
Test script:
---------------
<?php
$doc = new DOMDocument();
$doc->load('doc-base/manual.xml', LIBXML_NOENT);
var_dump($doc->xinclude(LIBXML_NOWARNING));
var_dump($doc->validate());
?>
Expected result:
----------------
int(-1)
bool(true)
Actual result:
--------------
Warning: DOMDocument::xinclude(): XPointer evaluation failed:
#xmlns(db=http://docbook.org/ns/docbook)
xpointer(id('class.datetime')/db:refentry/db:refsect1[@role='description']/desce
ndant::db:destructorsynopsis[not(@role='procedural')]) in - on line 4
Warning: DOMDocument::xinclude(): XPointer evaluation failed:
#xmlns(db=http://docbook.org/ns/docbook)
xpointer(id('class.datetimezone')/db:refentry/db:refsect1[@role='description']/d
escendant::db:destructorsynopsis[not(@role='procedural')]) in - on line
4
Warning: DOMDocument::xinclude(): XPointer evaluation failed:
#xmlns(db=http://docbook.org/ns/docbook)
xpointer(id('class.dateinterval')/db:refentry/db:refsect1[@role='description']/d
escendant::db:destructorsynopsis[not(@role='procedural')]) in - on line
4
Warning: DOMDocument::xinclude(): XPointer evaluation failed:
#xmlns(db=http://docbook.org/ns/docbook)
xpointer(id('class.dateperiod')/db:refentry/db:refsect1[@role='description']/des
cendant::db:destructorsynopsis[not(@role='procedural')]) in - on line 4
Warning: DOMDocument::xinclude(): XPointer evaluation failed:
#xmlns(db=http://docbook.org/ns/docbook)
xpointer(id('class.dateperiod')/db:refentry/db:refsect1[@role='description']/des
cendant::db:methodsynopsis[not(@role='procedural')]) in - on line 4
int(-1)
bool(true)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=51897&edit=1
Thread (6 messages)