Roger Costello
Roger Costello

Reputation: 3209

Use Alloy as an abstract modeling language?

I would like to create an abstract model and then auto-generate from it various data-format-specific models such as an XML model (i.e., auto-generate from the abstract model an XML schema), a JSON model (i.e., auto-generate from the abstract model a JSON schema), and so forth.

It would be great to use Alloy as the language for expressing the abstract model.

But I'm not sure that I would be able to auto-generate from an Alloy model the desired data-format-specific models. Allow me to explain, please.

Consider this simple Alloy model:

sig Test {
   A: Int,
   B: Int
} {
    A > B
}

That model contains two types of things: (1) it contains information about the structure of the data, and (2) it contains co-dependency information ("A" must be greater than "B").

From the Alloy model I can auto-generate various data-format-specific models which express structure information; here's how:

I can doExecute > Show Metamodel which generates an instance that shows the structure. In the instance I can do File > Export As XML. Then I can convert the XML into an XML schema or into a JSON schema or anything else.

Alloy appears to be suitable as an abstract language from which various data-format-specific models expressing structure information can be auto-generated.

Notice in the above model that "A" must be greater than "B". That constraint is not described in the Alloy instance. But that constraint needs to be expressed in the format-specific models (e.g., for the XML format the constraint would be expressed in a Schematron rule).

How to extract the constraints that are expressed in an Alloy model and translate them into data-format-specific rules?

I suppose that I could try to extract the constraints directly from the .als file. But that seems exceptionally challenging.

I seek your recommendations, please.

Upvotes: 1

Views: 128

Answers (1)

Peter Kriens
Peter Kriens

Reputation: 15372

Yes, I've though of the same idea. I also know how to implement it. Slight detail to find some funding :-(

I think this could be a really good use of Alloy.

UPDATE

This answer was a bit facetious. You can exactly do something in Alloy. You can export the model to XML and then the XML can be translated via XSLT or other tools. However, that is not easy and hard to automate. Ideal would be if Alloy could handle some scripting so you could transform into the format you need.

Upvotes: 2

Related Questions