After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 119638 - xmllint: namespace evaluated in entity definition
xmllint: namespace evaluated in entity definition
Status: VERIFIED WONTFIX
Product: libxml2
Classification: Platform
Component: general
2.5.8
Other Solaris
: Normal normal
: ---
Assigned To: Daniel Veillard
Daniel Veillard
Depends on:
Blocks:
 
 
Reported: 2003-08-11 14:52 UTC by Jens Emmerich
Modified: 2010-03-25 17:27 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Jens Emmerich 2003-08-11 14:52:01 UTC
In a complex DocBook customization, the problem demonstrated by the
following valid test document showed up:

<?xml version="1.0" ?>
<!DOCTYPE a [
<!ELEMENT a (n:b)>
<!ATTLIST a xmlns:n CDATA #FIXED "http://some.test.namespace">
<!ELEMENT n:b EMPTY>
<!ENTITY nb "<n:b/>">
]>

<a>&nb;</a>

Running
  xmllint --version --debug --debugent --noout --valid aaaa.xml
results in:
****************
xmllint: using libxml version 20509
   compiled with: FTP HTTP HTML C14N Catalog DocBook XPath XPointer
XInclude Iconv Unicode Regexps Automata Schemas 
new input from file: aaaa.xml
Entity: line 1: warning: Namespace prefix n is not defined
<n:b/>
    ^
aaaa.xml:1: validity error: No declaration for element b
<a>&nb;</a>
       ^
aaaa.xml:9: validity error: Element a content does not follow the DTD
Expecting (n:b), got (CDATA)
<a>&nb;</a>
           ^
DOCUMENT
Entities in internal subset
nb : INTERNAL GENERAL, 
 orig "<n:b/>"
 content "<n:b/>"
No entities in external subset
************
Providing an explicit xmlns:n attribute at "a" doesn't help either.
Some more experiments showed that xmllint obviously tries to interprete a
namespace declaration when reading the ENTITY definition for nb, which
can't be present when parsing the internal/external subset, i.e. before the
root element. The same happens in an external subset and in parameter entities.
Comment 1 Daniel Veillard 2003-08-11 15:12:52 UTC
Put the namespace declaration in the entity it does work.
There is no way around the current behaviour, libxml2 was designed
as an *editing* toolkit, i.e. multiple entities references share
the same underlying tree.
Contrary to what you state adding the namespace declaration in the
entity either manually or through a defaulted attribute on n:b does
work.


paphio:~/XML -> cat tst.xml
<?xml version="1.0" ?>
<!DOCTYPE a [
<!ELEMENT a (n:b)>
<!ATTLIST a xmlns:n CDATA #FIXED "http://some.test.namespace">
<!ELEMENT n:b EMPTY>
<!ATTLIST n:b xmlns:n CDATA #FIXED "http://some.test.namespace">
<!ENTITY nb "<n:b/>">
]>
 
<a>&nb;</a>
paphio:~/XML -> xmllint --noout --valid tst.xml
paphio:~/XML ->

Daniel
Comment 2 David Madore 2010-03-25 17:27:48 UTC
I was bitten by this bug also.

I understand it may be too difficult to fix, but would it be possible to add a warning instead?  E.g., instead of simply emitting the "Namespace prefix (whatever) is not defined" warning, would it be possible, when this happens in an entity definition, to clarify that "this is a libxml2 limitation, see <https://bugzilla.gnome.org/show_bug.cgi?id=119638>" or some such explanation?

This would make it clear that the document may be conforming, and would be useful since a workaround is indicated here.