GNOME Bugzilla – Bug 445790
xmllint problem agains a given dtd (--dtdvalid) (bis)
Last modified: 2021-07-05 13:26:51 UTC
Here are a couple of 'xml' and a 'dtd' files --- begin "a.xml" --- <?xml version="1.0"?> <!DOCTYPE root SYSTEM "a.dtd"> <root ns:attr="1"/> --- end "a.xml" --- --- begin "b.xml" --- <?xml version="1.0"?> <root ns:attr="1"/> --- end "b.xml" --- --- begin "a.dtd" --- <!ELEMENT root EMPTY> <!ATTLIST root xmlns:ns CDATA #FIXED "http://foo-dtd.org" ns:attr CDATA #IMPLIED> --- end "a.dtd" --- When i use 'xmllint' to verify the validity of "a.xml" against "a.dtd" implicitly ("--valid") or explicitly ("--dtdvalid a.dtd"), all goes well: "a.xml" result valid. But when i verify the validity of "b.xml" explicitly against "a.dtd" ("--dtdvalid a.dtd"), i obtain the following error: --- begin output --- <root ns:attr="1"/> ^ b.xml:2: element root: validity error : No declaration for attribute attr of element root Document b.xml does not validate against a.dtd --- end output --- I suppose that this bug (i suppose this is a bug) is caused by the fact that the attributes default values are write down in the parser context ("xmlHashTablePtr attsDefault"); i suppose they must be write down in the internal or in the external subset. When xmlParseDTD() (xmlSAXParseDTD()) return the dtd pointer, the 'attsDefault' are missed. When 'xmllint' validate "a.xml" explicitly ("--dtdvalid") against "a.dtd", it use the dtd explicitly loaded *and* the 'attsDefault' implicitly loaded; so "a.xml" result valid. When 'xmllint' validate "b.xml" explicitly against "a.dtd", the 'attsDefault' are missed; so "b.xml" result invalid. If i'm not wrong, obvioulsy massimo morara
I suggest to close this 8 years old bug.
With 2.9.4 the document validates, but I get a namespace error: b.xml:2: namespace error : Namespace prefix ns for attr on root is not defined <root ns:attr="1"/> ^ <?xml version="1.0"?> <root ns:attr="1"/> So it seems that there's a problem with default attributes from DTDs loaded via --dtdload. But this looks more like an enhancement than a bug.
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new ticket at https://gitlab.gnome.org/GNOME/libxml2/-/issues/ Thank you for your understanding and your help.