GNOME Bugzilla – Bug 614988
XML_PARSE_NSCLEAN breaks namespaces on entities
Last modified: 2021-07-05 13:24:02 UTC
((Bug found in version 2.7.7, but Bugzilla wouldn't let me enter this version.)) This is an avatar of bug #119638 back with a vengeance: vega david ~ $ cat /tmp/example.xml <?xml version="1.0"?> <!DOCTYPE root [ <!ENTITY elt "<x:foo xmlns:x='file:///x' />"> ]> <root xmlns="file:///default" xmlns:x="file:///x"> &elt; </root> vega david ~ $ xmllint --noout --nsclean /tmp/example.xml namespace warning : Namespace prefix x was not found <x:foo xmlns:x='file:///x' /> ^ vega david ~ $ cat /tmp/example2.xml <?xml version="1.0"?> <!DOCTYPE root [ <!ENTITY elt "<foo xmlns='file:///default' xmlns:x='file:///x' />"> ]> <root xmlns="file:///default" xmlns:x="file:///x"> &elt; </root> vega david ~ $ xmllint --noout --nsclean /tmp/example2.xml namespace warning : Namespace default prefix was not found <foo xmlns='file:///default' xmlns:x='file:///x' /> ^ I am forced to declare namespaces on entities to work around bug #119638 (this seems to be officially recommended, and anyway it makes sense), but then I need XML_PARSE_NSCLEAN to remove the spurious namespace declarations in questions, and apparently it won't work either! Is there a way out of this conundrum? I need to substitute some namespaced entities in a document, I can guarantee that the namespace prefixes will always be exactly identical throughout the document and will be declared at the root, but it is absolutely essential for me that there be no namespace declaration anywhere in the final tree except at the document root. How can I achieve this? I shall be eternally grateful if someone can suggest a workaround for this series of bugs!
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.