Hey everyone!


I recently discovered that nxml-mode in Emacs supports validating XML content against XML schemas, which I had never noticed before. It turns out that none of the files I've edited using nxml-mode had a supported schema.


Looking into this I learned a few things about nxml-mode:



The last point is the most impactful in terms of usability, but it might require more effort to fix than we can currently manage.


As an end-user, effectively only the RNC schemas provided with Emacs are available. To make matters worse, seemingly these list of supported schemas have not changed since 2007. Someone correct me if I'm wrong.


I would like Emacs to support XSD and automatically fetch schemas at runtime, but I also want a better nxml-mode experience for the file formats I use daily, today.


To address this, I have created RNC schemas for the formats I depend on. I have attached an abbreviated diff of the changes. The main changes are:



I tried to find tooling to convert XSD schemas to RNC, but I couldn't find anything which actually worked. After a few days of getting nowhere, I instead decided to use a tool called "jing-trang”[2] to infer the XML schema based on existing documents in my possession (200+ software projects, 50+ GBs).


While this method doesn't guarantee the accuracy of the schemas, they are based on a large number of files, ensuring that most common elements and attributes are present and specified. It may not be scientifically accurate (like an actual XSD to RNC translation), but it works for my purposes.


Accurate schema support is a small yet significant feature that can make a noticeable difference when working with XML. Ideally, Emacs should have schemas for all XML-based file-types commonly used.


As such, I would like to contribute these patches to core Emacs to help improve the current situation, but I want to make sure I'm doing it correctly.



I would appreciate any comments or feedback on this matter.


Thanks!


[1] https://relaxng.org/
[2] https://github.com/relaxng/jing-trang



Kind Regards
Jostein Kjønigsen