metanorma / metanorma-ogc

Metanorma processor for OGC documents
https://www.metanorma.com
BSD 2-Clause "Simplified" License
2 stars 3 forks source link

Formalize YAML ModSpec approach #493

Open ronaldtse opened 1 year ago

ronaldtse commented 1 year ago

In OGC GeoPose, ISO 19115-3 and ISO 19135, we have implemented a Liquid template to convert ModSpect instances from YAML to presentation.

This involves 2 Liquid templates:

We wish to formalize this approach for users (ModSpec users including OGC and ISO/TC 211) to use.

The implementation of this can be found here:

We will also need to update documentation on metanorma.org.

This would greatly assist our current work with the MUDDI SWG.

opoudjis commented 9 months ago

Remains desirable, some editors really like this; but because it hasn't been documented or advertised, not clear if it has had adequate testing or usage to solidify it.

opoudjis commented 6 months ago

This is an interim YAML solution, which we can document, pending the machine readable modspec of #242

"Could write a blog post, and reference that"

ghobona commented 6 months ago

Discussed 2024-02-15

opoudjis commented 5 months ago

@manuelfuenmayor Could you possibly write a blog post documenting the usage of YAML in modspec? If not, I'll do so, but you are more familiar with it than I am, I like to think :)

opoudjis commented 5 months ago

I will investigate whether there are YAML schemas that we can exploit in this formalisation.

opoudjis commented 5 months ago

(Old) solutions are shown on https://json-schema-everywhere.github.io/yaml

https://www.npmjs.com/package/pajv

It's in Node, and it's an extension of the horrific JSON Schema validator ajv.

If this yields unacceptable obscure validation responses, or if we we can always convert the YAML to ruby hashes, and validate them programmatically.

There are Ruby implementations of other validators listed, not based on JSON-Schema: https://rx.codesimply.com/ and https://github.com/kvs/kwalify, but they are unmaintained. (Kwalify last updated in 2009, Rx in 2008!) In fact, even pajv was last updated in 2017: https://github.com/json-schema-everywhere/pajv/ . YAML validation is simply not a current concern to people.

There are more recent Node-based validators, of which some use JSON Schema and some do not:

There are also several Ruby validators more recent than Kwalify: https://rubygems.org/search?query=yaml+validator . OTOH, Kwalify has 28M downloads, and the next generic validator gem is 50K. Kwalify clearly remains popular.

And there are JSON-Schema validators natively in Ruby; they don't consume YAML natively, but a YAML to JSON transformation is trivial.

So we have several options for validation, and the choice depends on

It looks like the most popular Ruby-native JSON Schema validator, https://github.com/voxpupuli/json-schema/ , would work.

ghobona commented 5 months ago

So it's a choice between https://github.com/voxpupuli/json-schema/ and https://github.com/kvs/kwalify

The fact that kwalify is unmaintained rules it out, in my opinion.

ronaldtse commented 5 months ago

@opoudjis we use JSON/YAML schemas for Glossarist already so we should continue the practice.

opoudjis commented 5 months ago

Right, useful to know. OK, then it will be voxpupuli, when whoever it is defines the JSON Schema for Modspec.

ronaldtse commented 5 months ago

FYI I've made a first cut here, serializable to YAML/JSON/XML schema:

manuelfuenmayor commented 5 months ago

FYI I've made a first cut here, serializable to YAML/JSON/XML schema:

Hm, perhaps this affects the validity of the blog post I've written?

ronaldtse commented 5 months ago

Hm, perhaps this affects the validity of the blog post I've written?

The post has been merged. Thanks!

ronaldtse commented 5 months ago

The next to do is to create a Metanorma/LutaML plugin that uses the modspec gem. It already provides the JSON/YAML/XML Schemas.

ghobona commented 4 months ago

Adding the Blog posts's link for future reference.

https://www.metanorma.org/blog/2024-04-04-ogc-modspec-in-yaml/

ronaldtse commented 2 months ago

The integration ticket is: