Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(INT) Proposal/Development for supporting Relax-NG schema #248

Open
5 of 12 tasks
KCMertens opened this issue Aug 31, 2021 · 0 comments
Open
5 of 12 tasks

(INT) Proposal/Development for supporting Relax-NG schema #248

KCMertens opened this issue Aug 31, 2021 · 0 comments
Labels
ELEXIS-technical important for ELEXIS project time-long

Comments

@KCMertens
Copy link
Collaborator

This is a general issue for tracking progress on creating support for Relax-NG (and possibly in the future, XML Schema).
The original proposal can be found here

Progress so far

The Relax-NG parser:

I've created a rudimentary parser in a separate project:
Written in Typescript, but the build step outputs a standalone javascript file that can be included in a webpage.

  • A standalone library that simply converts a Relax-NG document as string into a Xema object for use with Lexonomy.
  • No longer use a Xema, but directly generate a DocSpec
    This is needed to support most of the features below, but Xonomy itself needs some work for this to be possible/easy
  • Supports nested choice trees (e.g. element A must contain B&C, or contain D)
    These are flattened into A must contain B&C&D for now
  • Use validation warnings from the schema in Xonomy
    Warnings are stripped at the moment, and the only warnings you will see in Xonomy are those the Xematron generates based on the Xema
  • Regex pattern validation for attribute values
    Relax-NG supports this, but the Xema does not, so it's not in yet

Lexonomy itself

Changes here are very specific to my local development setup, just some hard edits to make it run and hook in the parser code.
But I've included it here for completeness.
https://github.com/INL/lexonomy/tree/relax-ng-support

  • Made some minor fixes to make it run on Windows
  • Edits to the xematron to enable separating element name from docspec element definition

The Xonomy library:

I've worked some on getting a better editor experience when developing Xonomy. I hope to create a small NPM package that I can use as dependency in the Relax-NG parser. I noticed several Github issues also discussing changes not unlike these, so it seemed like a worthwhile approach to tackle this in the context of this project.

see here

  • A typescript version with only minimal changes, basically adding argument and return type annotations to all functions.
  • Adding support for separating the name of an element from its rules in the DocSpec
    This is a big one for supporting schemas. To preserve backward compatibility, this is an opt-in feature of the docspec
  • Some tests to validate everything still works as expected
    It would be nice to have access to some examples of customizations users have made to the editor
  • Publish to NPM (this probably needs a little involvement from you guys/Michal)
  • Add any required features in new major/minor versions, ideally with backward compat. With how pluggable Xonomy is, it doesn't seem like this will be required much.

How to integrate with the existing codebase?

Right now Lexonomy is very old-school in its way of development on the javascript side of things: No build step and no dependency manager. This makes it hard to integrate code that's written using a more modern approach, or code written in typescript, it also makes it hard to work with modern language features (browser support..), getting better autocomplete in editors, etc.

I would be in favor of at least setting up some dependency management and a small build step, so we can go on to develop with some more modern amenities.

For now I've not done any of this, and the parser integrates laterally - just run the build step in that project, and copy over the output into lexonomy.

@iztokkosem iztokkosem added the ELEXIS-technical important for ELEXIS project label Feb 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ELEXIS-technical important for ELEXIS project time-long
Projects
None yet
Development

No branches or pull requests

3 participants