emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Adding new schemas to nxml-mode. Am I doing it right?


From: Jostein Kjønigsen
Subject: Adding new schemas to nxml-mode. Am I doing it right?
Date: Sun, 18 Feb 2024 21:12:51 +0100

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:


  • XML is not validated against XSD schemas, which are the most common schema format today.
  • Emacs relies on RNC schemas[1], which are less common and have fewer tools, but are simpler.
  • Emacs cannot automatically obtain the schemas which are declared in XML documents.


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:


  • Updating schemas.xml with typeIDs and conditions for applying them in the correct order.
  • Generating new RNC schemas based on those typeIDs.


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.


  • How can I create accurate, quality schemas in RNC with the current tooling?
  • What are the criteria for accepting new schemas in Emacs core? Are there any?


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

Attachment: schemas.patch
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]