Making Flexmi YAML flavour more natural
I tried writing some Flexmi files in YAML format today, using this custom metamodel:
I tried writing this bit:
?nsuri: https://eclipse.org/hawk/sqlite/queries
queryset:
name: NonTimeawareQueries
queries:
- name: "nodeIDsByLabel"
sql: "SELECT rowid FROM nodes WHERE label = ?;"
parameters:
- name: label
type: String
- name: "nodeCountByLabelStatement"
sql: "SELECT COUNT(1) FROM nodes WHERE label = ?;"
parameters:
- name: label
type: String
I expected to see one QuerySet with its proper name and two queries, each with their own name and parameters. This is in line with typical use of YAML, which supports three types of nodes: maps (essentially, objects), sequences (lists), and scalar values. I had expected to see maps turned into objects, sequences turned into ELists, and scalar values to be used to set attributes / references.
Unfortunately, I got something rather odd instead:

I had one Query with two parameters, for some reason.
I had to change the YAML file to this, which is cumbersome to type with all the -s, and it's also not natural YAML:
?nsuri: https://eclipse.org/hawk/sqlite/queries
queryset:
- name: NonTimeawareQueries
- query:
- name: "nodeIDsByLabel"
- sql: "SELECT rowid FROM nodes WHERE label = ?;"
- parameters:
- name: label
- type: String
- query:
- name: "nodeCountByLabelStatement"
- sql: "SELECT COUNT(1) FROM nodes WHERE label = ?;"
- parameters:
- name: label
- type: String
That produced the expected outline:

From a semantic point of view, it doesn't make sense to have queryset need to contain a list with its first element being a map whose key is name just to set the name of that queryset. Same goes for specifying its child objects.
To clarify, what I mean is that it's much more natural YAML to do:
queryset:
name: foo
Than to do this:
queryset:
- name: foo
The first option says "name is a property of the queryset, which is equal to 'foo'".
The second option says "queryset contains an element whose name is 'foo'".
For comparison, I changed this to Flexmi XML just now:
<?nsuri https://eclipse.org/hawk/sqlite/queries?>
<queryset name="NonTimeawareQueries">
<query name="nodeIDsByLabel" sql="SELECT rowid FROM nodes WHERE label = ?;">
<param name="label" type="String"/>
</query>
<query name="nodeCountByLabelStatement" sql="SELECT COUNT(1) FROM nodes WHERE label = ?;">
<param name="label" type="String"/>
</query>
</queryset>
From a semantic point of view, this matches my first attempt with YAML more closely than the second version I had to write to get it to work.
That produces the expected result:
