Iver Band
EA Principals Senior Instructor and ArchiMate Expert
December 20, 2020
Are you an ArchiMate modeler who also creates entity-relationship diagram (ERDs), UML class diagrams or other styles of data models?  Have you ever wished that you could use one standard language and free tool for both enterprise architecture modeling and data modeling?  If so, here is some good news:  data modeling with ArchiMate is an emerging capability due to recent enhancements in the Archi free and open-source tool for ArchiMate modeling [1], the introduction of the jArchi plugin for Archi scripting [2], and the longstanding support of custom profiles by both the ArchiMate language [3] and Archi.     


This is the second article in a series.  In the first article [4], I introduced a one-view Cruise Ship model, and showed how to use jArchi scripting and Archi label expressions, which are not yet scriptable, to express cardinality relationships (one-to-one, one-to-many, etc.). This article builds on its predecessor with a script that adds entity attributes specified in a JSON Schema [5] file.  It was inspired in part by a comment made on LinkedIn by Open Group ArchiMate Forum Chair and Archi contributor J-B Sarrodie [6], who noted that it was now possible to use a label expression to show a list of attributes for an object.  
J-B’s comment got me thinking about a commonly-used and standards-based source for those attributes, and the JavaScript-based jArchi scripting capability led me to JSON Schema, which JavaScript can easily parse into objects and generate from objects. Furthermore, there are various open-source packages, including at least one in JavaScript [7], that convert SQL DDL (Data Definition Language) to JSON Schema 
If you have not read the first article, now is the time to take a break and read it here.

Selecting the JavaScript Version

Before working on my script, I clicked on Edit > Preferences > Scripting as shown below to set the JavaScript Engine to Nashorn ES6 (ECMAScript 6 [8]), which provides a richer version of the language than the default of Nashorn ES5.  Nashorn is a JavaScript engine than runs in a 

Java Virtual Machine [9]. 


The Schema

The example here uses on the National Registration entity in the single-view Cruise Ship model below

The National Registration entity schema, which I developed with one of several free schema validation tools available online [10], consists of three text fields, host Nation Name, ship Name, and owner Name, which are constrained only by a regular expression pattern that requires them to be at least four characters long and begin with a capital letter.  There is also a registration Number which must be exactly ten numeric digits, as well as the registration Date and the Expiration Date, which must both be in YYYY-MM-DD format.  All fields are required.  The schema is shown below with some portions collapsed for brevity.

The Script

The first part of the script, shown below, ensures that the console is visible, prompts the user for the name of the schema file and reads it in.  The technique I use here is patterned after a jArchi script by Steven Mileham [11].
The script next parses the JSON schema and adds information from it to the Archi model. It begins by capturing the schema attributes that occur only once, i.e., the title and description, and then initializing a counter:
The script then cycles through all the ArchiMate elements (as opposed to relationships) that are selected.  It first sets the name, the documentation, and stereotype of each element that is selected, and then cycles through the properties in the schema object. For each property object, it creates a working copy called “props”, and fashions a string consisting of the description followed by a dictionary of all the remaining attributes (except $id which I omit).  The script then sets the corresponding model element property to that descriptive string.  It also accumulates a list of attribute names separated by newline characters, which it ultimately assigns to the element property “attributes”. After it has set all properties for all selected elements as shown in the excerpt below, it reports on the number of elements it has updated and terminates.

The Label Expression

The label consists of simple formatting and successive references to the stereotype property, the element name and documentation, and the attributes property.

The Result

The selected element, a data object in this case, is identified as an ERD component, and is labeled with the title and description from the schema object, as well as a list of the schema object properties. 


In addition, the element has a set of properties that correspond to the properties in the JSON schema, each consisting of a description followed by a dictionary:



Opportunities for Future Work

This script could be further developed to reverse-engineer SQL DDL by leveraging an open-source package that converts JSON schema to DDL.  It could be applied to situations where many objects require the same metadata, such as in the creation of business capability models. The script could be enhanced to work on a larger scale through simple performance optimization; right now, the schema object parsing is repeated for each selected object.  Finally, along with the script described in the previous article, it could become part of a suite for modeling large schemas by creating and linking model concepts from an imported file instead of just manipulating their properties.  


The generation of model element attributes from JSON Schema files provides additional evidence that Archi and its jArchi plugin can support data modeling through the implementation and management of data modeling profiles for the ArchiMate language. There are many opportunities for ArchiMate modelers and tool builders to contribute to this work. 


  1. Archi – Open Source ArchiMate Modeling. https://www.archimatetool.com/
  2. jArchi – Scripting for Archi. https://www.archimatetool.com/plugins/#jArchi
  3. ArchiMate Standard – Adding Attributes to ArchiMate Elements and Relationships. https://pubs.opengroup.org/architecture/archimate3-doc/chap15.html#_Toc10045465
  4. Data Modeling with Archi. https://www.eaprincipals.com/content/data-modeling-archi
  5. JSON Schema. https://json-schema.org/
  6. LinkedIn Comment by J-B Sarrodie https://www.linkedin.com/feed/update/urn:li:activity:6738567508346974208?commentUrn=urn%3Ali%3Acomment%3A%28activity%3A6738567508346974208%2C6738772420854853632%29
  7. SQL DDL to JSON Schema NPM Package. 
  8. ECMAScript 6 – New Features: Overview & Comparison. http://es6-features.org/
  9. Nashorn Engine. https://docs.oracle.com/javase/10/nashorn/introduction.htm
  10. JSON Schema Validator. https://www.jsonschemavalidator.net/
  11. jArchi Script: Import from CSV.ajs. https://gist.github.com/smileham/1e57a5946235e780dee5a824f664aa3d


Can't find what you are looking for? Call (703) 333-6098 or Contact Us.
If you are having issues with our website, Contact our Webmaster.