Sep 282015
 
 28th September 2015  Posted by at 9:05 am 1 Response »

In this blog post I describe how to generate a basic standalone HTML report from an XML file exported in The Open Group’s ArchiMate exchange format using an XSLT stylesheet.

In my last blog post I wrote about The Open Group’s ArchiMate exchange format and how its main purpose is to allow the exchange of ArchiMate models between conforming tools. I also mentioned that it could be possible to do more with an ArchiMate exchange file, and use XSLT (Extensible Stylesheet Language Transformations) to display the contents of the file in a human readable format. XSLT is a language for transforming XML documents into other documents or other formats such as HTML, plain text or PDF, and as an ArchiMate exchange file is in a fairly straightforward XML format this should be possible.

This idea was first brought to my attention (via Andrew Josey of The Open Group) by Thorbjørn Ellefsen, Security Architect for the Agency for Public Management and eGovernment (Difi) in Norway. Thorbjørn had suggested that this would be an avenue worth exploring and provided a simple XSLT file that demonstrated the process. This piqued my interest and so I took Thorbjørn’s XSLT file and played around with it to see if I could produce some interesting HTML that could be used as a proof-of-concept ArchiMate report. In this blog post I want to share the results of my experiments.

Generating the ArchiMate Exchange XML file

The first thing we need is an ArchiMate model saved in the correct format. In Archi I exported the “Archisurance” example model to The Open Group’s exchange format:

exchange_format

I named the output file as “Archisurance.xml”. You can download a copy of the file here.

Here are the first few lines of the file:

As you can see, it’s not exactly user-friendly, but we can use this file as the data input for something more useful. If you have exported the file yourself and viewed it, you may notice a slight difference between your copy and the one above. Note that the following line has been added near the start of the file:

This line is important. I manually inserted it in my copy of “Archisurance.xml” in order to denote that the contents of the XML file should be processed using the “elements.xsl” XSLT stylesheet. If you are using your own copy of the file, you also need to manually insert this line into the file using a text editor.

Adding the XSLT stylesheet

Next we need the XSLT stylesheet that will transform the data in the XML file into HTML. For this first example, we’ll display a table of all the elements (concepts) in the model. The file is called “elements.xsl” and you can download it here. Here’s what it looks like:

This stylesheet is basically an XML file with some HTML tags and XPath queries that will generate HTML using data from the “Archisurance.xml” file. There is a <style> section for some simple CSS, a <html> and <body> section for the HTML structure, and a <table> to display all of the ArchiMate elements. If we put the two files together we should see a result. But how do we do that?

Displaying the result

Normally, we would use a special processor or tool to combine the two files in order to generate an HTML file (the command line tool xsltproc on Linux/Mac, for example) but for this demonstration we can very easily display the result in a browser. However, be warned that this may only render correctly in Firefox or Internet Explorer. If the two files, “Archisurance.xml” and “elements.xsl” are in the same directory on your computer you can open the “Archisurance.xml” file in Firefox or Internet Explorer. It should look like this:

ex_elements

We can see the model name and description, the ArchiMate elements, their IDs, name, documentation (if any) and their type. The XSLT code generates a table of elements by looping through each <element> tag in the XML file and displaying the contents of the “identifier” attribute, the <label> tag, the <documentation> tag, and the “type” attribute. The table is sorted alphabetically on the “type” attribute because it is specified in this line:

Note that XPath is used as the query language for selecting the elements in the XML file.

It’s a good start. Perhaps we could also display the relationships in the model? Yes we can, by applying the same principles as we did with the elements. To demonstrate this I’ve created another XSL stylesheet, a file named “elements_relations.xsl” and you can download it here. This file is the same as the first XSL file, but I’ve added some code to display the ArchiMate relationships:

The code iterates through each <relationship> tag in the XML file and, using an XPath query, finds the relevant tags and attributes needed to display the data. Notice that there are two XPath queries that reference elements elsewhere in the file in order to display the Source and Target element names of each relationship. The code uses XSLT variables, “Source” and “Target”, to make things a little easier to create the XPath queries.

In order to display the results of this new XSLT stylesheet, we need to replace the line in the “Archisurance.xml” file so it references this new file:

Open up “Archisurance.xml” in Firefox or Internet Explorer again (or refresh).

Here’s a sample of some of the output that is generated:

ex_relations

As before, we can see the ArchiMate relationships, their IDs, name, source and target elements, and their type.

Displaying the structure

One of the features of The Open Group’s ArchiMate exchange format is to be able to (optionally) represent and exchange a given structure of the ArchiMate elements and relationships in the model. By this we mean an organization of elements, relationships, and views much like a table of contents in a book. Most ArchiMate tools allow you to organise ArchiMate elements and relationships in some kind of hierarchical structure. In Archi this is the tree in the “Models View”. This is something that can be usefully exported and imported into another tool.

So far we have displayed the elements and relationships as flat lists, but we can use this structural, or “organization”, information in the XML file to display a tree of links to the elements and relationships.

We need to use a new XSL file containing the new code, named “structure.xsl”, and you can download it here.

Once again, we have to replace the line in the “Archisurance.xml” file so it references the new file:

I won’t show the new code here this time, but you can take a look at it in a text editor. The XSLT code iterates recursively through each <item> tag in the XML file and then generates a hierarchical HTML list of elements, relationships and views with links to the corresponding entry in the tables of elements and relationships.

Open up “Archisurance.xml” in Firefox or Internet Explorer again (or refresh).

Here’s a sample of some of the output:

ex_structure

If you click on one of the links, it will jump to the corresponding element or relationship in the tables.

Further experiments – displaying the diagrams

Once I’d reached this point with my XSLT experiments I felt ready for a new challenge. I wanted to know if it would be possible to generate the actual ArchiMate diagrams (views) using XSLT. It turns out that it is possible, to a certain extent, by using SVG (Scalable Vector Graphics). What I achieved is only proof of concept, and I only got as far as displaying the elements as coloured boxes without connections, but it may be possible to take this further, or even come up with an alternative method perhaps by using a combination of Javascript and CSS.

To demonstrate this, we need another XSLT file, this time it’s named “views_experimental.xsl” and you can download it here.

Once again, we need to replace the line in the “Archisurance.xml” file so it references this new file:

Open up the “Archisurance.xml” file in Firefox (sadly, the SVG does not display in Internet Explorer). If you scroll to the end you should see some basic diagrams. Here’s an example:

ex_view

As I said, this is very much proof of concept, and it needs much more work. It may turn out to be too onerous to generate the full diagrams using SVG, particularly when it comes to creating connections (they need bend-points, anchor points and so on) and I’m sure there is a better way to do this. This does, at least, demonstrate the possibility of generating diagrams from the raw XML file.

Conclusion

I’ve tried to show that it’s possible to use The Open Group’s ArchiMate XML exchange file and display some of the data as HTML using XSLT stylesheets. I’ve also shown that it’s possible to generate some basic diagrams from the data. All of this needs much more work, and I’m aware that this work is at proof-of-concept level.

But for me the important thing is that this clearly demonstrates that by using existing technologies based on XML, XSLT, HTML, and CSS one doesn’t have to resort to a proprietary tool in order to display and share that data. Both the data and the representations of that data can exist in an open, standalone format.

Personally, I think this is very cool and it would be nice to see some XSLT stylesheets created to display ArchiMate models in more interesting ways. For example, one might display a summary and preview of a model. Or it may be possible to take advantage of a model’s Properties (attributes) and use them as variables that could be parsed conditionally for output formatting. I think that the potential inherent in The Open Group’s ArchiMate exchange format is very exciting and I’d love to see if anyone can take this further.

Many thanks to Thorbjørn Ellefsen for drawing my attention to the potential power of utilising XSLT with The Open Group’s ArchiMate exchange format.

(All files can be found in GitHub)

Sep 142015
 
 14th September 2015  Posted by at 12:34 pm No Responses »

Some of you might have noticed that Archi 3.3 has been released. This latest version of Archi includes a new plug-in which supports The Open Group’s ArchiMate file exchange format. This represents the fruits of some years and months’ labour! I’ve been collaborating with The Open Group, and representatives from associated parties and tool vendors, for some time now to produce a file format that can be used to exchange single ArchiMate models between conforming toolsets. Finally, version 1.0 has been released!

The file format uses XML, which is backed by a validating XSD Schema. Why is this? Wouldn’t XMI be better? Well, yes it would if we had a MOF representation of ArchiMate. Currently, one doesn’t exist. Also, it’s very hard to agree exactly what should be formally represented in a persistence format, as against what can be usefully represented and exchanged using a persistence format. For example, ArchiMate symbols use colour to denote the different layers, and custom colour schemes can be employed to convey meaning. Clearly, this is not something that can be enforced in a specification. Probably the only things that can be enforced are the ArchiMate concepts and relations themselves. Views, viewpoints, and visual arrangements of those concepts and relations are, arguably, optional. A valid ArchiMate model could simply consist of a set of concepts and relations. However, this is probably not very useful in the real world, and so the exchange format seeks to provide a file format for describing and exchanging the most used aspects of ArchiMate models, optional aspects as well as mandatory aspects.

So, simply put, the aim of The Open Group’s ArchiMate file exchange format is to provide a pragmatic and useful mechanism for exchanging ArchiMate models and visual representations between compliant toolsets. It does not seek to create a definitive representation of an ArchiMate model. For that to happen, I believe many things would have to be formally declared in the ArchiMate specification. For this reason, many of the components in the exchange format are optional. For example, the ArchiMate 2.1 specification describes the use of attributes as a means to extend the language and provide additional properties to the concepts and relations. The specification does not rigidly mandate their use. However, many toolsets do support and encourage the use of attributes to create model profiles, for example. To support this, the exchange format provides a properties mechanism, consisting of typed key/value pairs. This allows implementers to (optionally) represent additional information for all of the concepts, relations and views.

Even though I have emphasised that the main use for the exchange format is exchange (the name is a bit of a giveaway here ;-)), another advantage of using XML/XSD for the file format is that it is possible to use XSLT to transform the XML ArchiMate model instances into HTML documents, reports, as input for a database, and so on. I would say that the potential for exploiting ArchiMate data in this way is huge.

The exchange format could also help with learning the ArchiMate language and Enterprise Architecture – imagine a repository of ArchiMate models (tagged with Dublin Core metadata to facilitate search and description) that could be used as a resource pool of model patterns and examples for those new to the language. One thing that I personally would like to see is an extensive pool of example models and model snippets as examples of good modelling practice. And using the exchange format, these models and snippets can be loaded into any supporting toolset.

Here are my five “winning features” for the ArchiMate exchange format:

  • Transparent
  • Simple
  • Well understood format
  • Pragmatic
  • Open

I’m sure that The Open Group’s ArchiMate exchange format will contribute to, and encourage the use of ArchiMate, and perhaps reassure users that their valuable data is not locked into any one vendor’s proprietary tool format. I personally think that this is a great initiative and that we have achieved a great result. Of course, nothing is perfect and the exchange format is still at version 1.0, so user feedback is welcome. With greater uptake the format can be improved, and we may see it being exploited in ways that we have not yet thought of!

(For more information about the exchange format, see here)