GNOME Bugzilla – Bug 142880
Would like to remove redundant NS declarations from a DOM tree
Last modified: 2021-07-05 13:23:11 UTC
I previously requested an API to remove redundant NS declarations in bug 120981 (http://bugzilla.gnome.org/show_bug.cgi?id=120981). In response, a new parser option (nsclean) was added in 2.6.0. That's fantastic, but what I now find myself wanting is the ability to apply such NS cleanups to a DOM tree itself at a later stage, after parsing. The problem is that after building a DOM tree (with NS's cleaned up), some of the manipulations that I make later (inserting new nodes etc) can introduce redundant declarations again. I would like to be able to clean up such declarations before I write the tree back to a file. At the moment the only way that I can write out a "clean" XML file is to write the DOM tree once (just to a string suffices), then reparse it using the nsclean parser option, then write it out to the file for real. It would be great to have something like a xmlNsClean() function that can be called on the DOM document before writing the file. Alternatively, perhaps new xmlSave*() functions (or new options for existing functions) could be introduced to do the clean-up as the file is being written. - Steve
Okay that's a request for improvement, namespace "cleanup" could be done both ways, the first one could lead to an easy but inefficient implementation of the second method. Might be easiest. Lack of time means it will be done faster if you help building such a patch (then post on the list). Daniel
Still no progress, nobody worked on this yet, Daniel
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.