<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Using Model-to-Text Transformation for Dynamic Web-based Model Navigation</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Dimitrios S. Kolovos</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Louis M. Rose</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>James R. Williams</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Department of Computer Science, University of York</institution>
          ,
          <addr-line>Deramore Lane, York, YO10 5GH</addr-line>
          ,
          <country country="UK">UK</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>One of the main objectives of modelling is to enable collaborative decision making and communication among the stakeholders of the system. It is essential that both technical and non-technical stakeholders can access and comment on the models of the system at any time. In this paper we propose a model-to-text transformation approach for producing dynamic, web-based views of models { captured atop di erent modelling technologies and conforming to arbitrary metamodels { so that stakeholders can be provided with web-based, on-demand and upto-date access to the models of the system using only their web browser. We demonstrate the practicality of this approach through case studies and identify a number of open challenges in the eld of web-based model management.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>
        One of the main objectives of modelling is to enable collaborative decision
making and communication among the stakeholders of the system { particularly so
in the early stages of the software development lifecycle. To this end,
stakeholders must be able to access { possibly di erent parts of { the models constructed
by the designers of the system. In principle, the simplest way to achieve this is
to establish a centralised repository where designers share the models that they
construct with other stakeholders, so that the latter can navigate the models
using the same modelling tools that the designers used to create them.
However, experience obtained from interacting with our industrial partners { some
of which was summarised in an earlier paper [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] { suggests that this is not always
feasible or desirable, for a number of reasons:
{ Cost: Purchasing licenses of expensive modelling tools only to view and
provide feedback on the models of the system may be impractical or too
expensive.
{ Time: In some industrial environments, installing new software requires a
formal approval process which can take signi cant time to complete.
{ Complexity/Training: Modelling tools are typically complex because they
accommodate the needs of software designers. As such, training is typically
required for non-expert users, even to support them in relatively
straightforward tasks.
{ Access control: It may be desirable that some stakeholders are only granted
access to some parts of the models.
      </p>
      <p>We have encountered the above issues in the context of ongoing work with
one of our major industrial collaborators. To address such issues in practice,
modellers typically construct word processor design documents which are then
disseminated to the stakeholders, who therefore are not required to purchase,
install and learn to use any new software. However, this approach has known
shortcomings. Assembling and synchronising such documents can be
labourintensive and error-prone, particularly if they are not supported natively by the
modelling tool. Moreover, for large models, designers need to create
correspondingly large documents, which ultimately become di cult to navigate and read.
Finally, and as a consequence of the other shortcomings, such design documents
quickly become out-of-date and do not re ect the current version of the models.</p>
      <p>To eliminate the overhead of creating and distributing snapshots of the
current versions of models in the form of design documents, we propose a
model-totext transformation approach for producing dynamic web-based views of models
{ captured atop a range of di erent modelling technologies { so that
stakeholders can be provided with web-based, on-demand and up-to-date access to the
models of the system from their web browser and without needing to purchase
or install any additional tooling.</p>
      <p>The remainder of the paper is organised as follows. Section 2 introduces the
proposed transformation-based approach and discusses the details of the
technical solution we have developed to realise it. Section 3 provides two case studies
that demonstrate using the proposed approach to implement web application for
navigating and animating state machine models, and for browsing Ecore
metamodels in a Javadoc-like fashion. Section 4 discusses related work and Section 5
concludes the paper and provides interesting directions for further work on the
subject.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Dynamic Web-Based Model Navigation</title>
      <p>To overcome the shortcomings identi ed above, we propose an approach that
allows stakeholders to have direct, on-demand and up-to-date access to the (parts
of the) models in which they are interested. Additionally, the approach
proposed in this section { like the design document approach { does not require
stakeholders to purchase, install, or use any additional software other than their
web browser.</p>
      <p>
        To enable web-based access to models that have been de ned atop a range of
modelling technologies, in this work we have integrated the Epsilon Generation
Language [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ], which is a template-based model-to-text transformation language,
with a Java-based servlet container and web-server (Tomcat). Like most
modelto-text transformation languages, EGL was originally designed to support batch
code generation; in this work, by integrating EGL with Tomcat, we can use
EGL templates as server-side scripts to generate HTML content from models on
demand, as displayed in Figure 1.
      </p>
      <p>Web Browser</p>
      <p>Tomcat
requests
returns
HTML
returns
HTML
forwards
request
EGL Controller</p>
      <p>Servlet
produces</p>
      <p>HTML</p>
      <p>Web Application</p>
      <p>
        Model Repository
locates/
executes
loads/
reads
EGL Template
In the following sections we provide a brief overview of EGL and its
underlying infrastructure and discuss the process and challenges involved in using it
as a server-side scripting language. Before detailing the technical aspects of our
work, we stress that, although in this work we use EGL and Tomcat as
supporting technologies for our implementation, the proposed approach is not bound
to a speci c model-to-text transformation language or web-server. In principle,
it can be implemented using any other model-to-text transformation language,
such as Xpand[
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], MOFScript[
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] and Acceleo1. We selected EGL and Tomcat
due to our technical expertise with them.
2.1
      </p>
      <sec id="sec-2-1">
        <title>The Epsilon Generation Language</title>
        <p>
          EGL is a template-based model-to-text transformation language implemented
atop the Epsilon model management platform [
          <xref ref-type="bibr" rid="ref5">5</xref>
          ]. Epsilon provides a layered
architecture that enables the construction of interoperable task-speci c model
management languages for tasks such as model transformation, validation,
comparison, merging and refactoring. To enable model management languages built
atop it to manage models captured using di erent modelling technologies,
Epsilon provides an abstraction layer called EMC (Epsilon Model Connectivity)
which speci es an API against which drivers for di erent modelling technologies
are implemented. To date, EMC drivers for technologies such as EMF, MDR,
Z (through CZT [
          <xref ref-type="bibr" rid="ref6">6</xref>
          ]), and plain XML have been implemented { and as such, all
        </p>
        <sec id="sec-2-1-1">
          <title>1 www.eclipse.org/acceleo</title>
          <p>
            model management languages in Epsilon can manage models captured with all
of these technologies. A more detailed discussion on EMC is available in [
            <xref ref-type="bibr" rid="ref7">7</xref>
            ].
          </p>
          <p>As EGL is implemented atop Epsilon, it is interoperable with all of the
modelling technologies listed above. Therefore, although in this work we demonstrate
using EGL to build web applications around EMF-based models, any of the
supported modelling technologies can also be used.
2.2</p>
        </sec>
      </sec>
      <sec id="sec-2-2">
        <title>Integration with Apache Tomcat</title>
        <p>Apache Tomcat is a widely used web server and Java servlet container. Tomcat
comes with built-in support for the Java Server Pages (JSP) server-side scripting
language for producing dynamic web pages, but also provides a exible
architecture which allows developers to extend it with support for additional server-side
languages. To integrate EGL with Tomcat, we added a new servlet mapping
that instructs Tomcat to redirect all requests for URLs that end with .egl to a
dedicated controller servlet that is responsible for processing these requests.</p>
        <p>
          As illustrated in Figure 1, when Tomcat receives a request for a URL that
ends with .egl, it forwards the request to the EGL controller servlet which in turn
locates and parses the respective EGL template, and if no errors occur during
parsing, it executes the template and returns the produced text to Tomcat {
which nally returns it to the browser. Similarly to the majority of server-side
programming languages, EGL templates have access to a number of prede ned
variables for accessing request parameters and setting/getting session and
application properties. Moreover, since the expression language on which EGL builds
can re ectively access Java objects, EGL templates can interoperate seamlessly
with existing Java libraries, and can be used in the context of frameworks such
as Apache Struts2, which facilitates the creation of J2EE applications.
Accessing Models To minimise the overhead of loading and storing models
in individual EGL templates, each web application is provided with a dedicated
model repository which EGL templates can access { to load and store models {
via the built-in modelManager variable. The application model repository caches
models so that they can be readily accessed by all of the EGL templates in an
application. Templates have read/write access to the models in the repository;
however, the ability for multiple users to modify models in the repository
concurrently depends on whether the underlying modelling technology is thread-safe
or not. In the current EGL{Tomcat integration, only support for EMF models
has been implemented, and as EMF is not thread-safe, all of the applications
that we have constructed so far have read-only access to the underlying models.
Template Factories EGL provides several types of built-in template [
          <xref ref-type="bibr" rid="ref2">2</xref>
          ]. For
example, EglTemplate is used for generating plaintext and
EglFileGeneratingTemplate for generating les on disk. Templates are accessed via the built-in
TemplateFactory variable. Extenders of EGL can also specify their own template
        </p>
        <sec id="sec-2-2-1">
          <title>2 http://struts.apache.org/</title>
          <p>types and their own template factories for capturing and re-using other code
generation logic. For instance, the example described in Section 3.1 uses a
custom template type and factory to produce an image le from the text generated
by a template.</p>
          <p>The dedicated EGL servlet queries the metadata of each web application
to determine which type of template factory will be used to execute the
templates of that application. Users can specify the fully-quali ed Java class name
of the template factory for their application as a parameter to the EGL servlet
de nition.</p>
          <p>Caching To facilitate scalability of the applications developed atop the
approach described in this section, the EGL servlet provides two types of caching,
which can be used in web-based EGL applications. Caching is achieved from
EGL templates via a built-in cache object.</p>
          <p>Page Caching allows repeated requests for the same URL to be served without
invoking any EGL templates. The EGL controller servlet maintains a cache that
maps requests (URLs) to responses (the HTML generated by invoking an EGL
template). A response is cached the rst time that it is requested, and subsequent
requests for to same URL are served from the cache. Applications can control
which requests should be cached via the built-in cache object. Similarly, a URL
can be marked as expired using the built-in cache object, and the next request
for that URL will be served by invoking an EGL template rather than from the
cache.</p>
          <p>Fragment Caching allows unchanging page elements { such as headers and
footers { to be shared between requests for di erent URLs, and requires that the
EGL application be decomposed into separate subtemplates. The EGL controller
servlet maintains a cache that maps subtemplates to partial responses (part of
the HTML generated for a request to a particular URL). As with page caching,
applications can control the fragment caching strategy via the built-in cache
object, which provides methods for caching and expiring fragments. The case study
in Section 3 uses fragment caching to cache headers, footers and sidebars.
Page caching results in less server-side processing than fragment caching, but
is more brittle. For example, consider the e ects of changes to a model on page
and fragment caches. Pages and fragments that have been a ected by changes to
a model must be expired (removed from the cache). In the worst case then, the
page and fragment caches must be completely emptied to ensure that
stakeholders can view and navigate the updated model. The page cache will become fully
populated only when every page of the web application is visited. By contrast,
fragments for say, shared headers and footers, are cached by a request to any
page, and future requests to any other page bene t from the cached fragment.</p>
        </sec>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Case Studies</title>
      <p>In this section, we present two case studies that demonstrate using the proposed
approach for browsing behavioural and structural models. The rst case study
employs the proposed approach to visualise state machines and concentrates on
automated diagram generation. The second case study illustrates a web
application for navigating Ecore metamodels in a Javadoc-like style, through which we
demonstrate the caching mechanisms discussed in Section 2.2 and evaluate the
scalability of our implementation.
3.1</p>
      <sec id="sec-3-1">
        <title>Visualisation and Animation of State Machine Models</title>
        <p>In order to facilitate animation of the Mealy machine, asynchronous calls to
two di erent server-side EGL scripts are required { one to generate an image of
the model's current state, and another to request the output of the machine upon
ring the selected transition. The user initially requests a standard HTML page,
which, upon loading, makes a request to MealyHandler.egl to generate an
image of the machine in its initial state. Clicking on a successor state will cause
another request to MealyHandler.egl to return the image representing the
machine in the new state, and will also make a request to MealyOutput.egl
to display the results of executing that transition.</p>
        <p>Before discussing the two templates used to animate the Mealy machine, we
rst brie y summarise the structure of a typical EGL template. EGL templates
comprises dynamic sections, which contain executable code, and static sections,
which contain text to be emitted. Consider Listing 1.2. Dynamic sections, such
if (request.getParameter(’st’).isDefined()) {</p>
        <p>currentState = request.getParameter(’st’);
} else {
currentState = State.all.select(s|s.initialState==true).first().name;
Listing 1.1: Generating an SVG image of the Mealy machine
1 digraph G{
2 center=true;
3 nodesep=1.5;
4
5
6
7
as the one on line 9, are enclosed in [% %] tags; static sections, such as the
one on lines 1-5, are not enclosed in [% %] tags. Dynamic sections can take
an alternate form, using a [%= %] tag (such as the one on line 7) to emit a
dynamically computed value (the currentState variable in this case).</p>
        <p>MealyHandler.egl (listing 1.1) generates the image of the machine
using Mealy2dot.egl. The call to generate (line 15) delegates to an
image generating template factory, which invokes DOT to convert the output of
Mealy2dot.egl to an SVG (Scalable Vector Graphics) image.</p>
        <p>Mealy2dot.egl (listing 1.2) outputs a Graphviz3 DOT language
description of the machine and the template factory executes the DOT description,
creating an SVG le. Animation is achieved by passing the current state name
as a parameter in the URL query string to MealyHandler.egl (e.g.
MealyHandler.egl?st=s0) which populates the currentState variable in the</p>
        <sec id="sec-3-1-1">
          <title>3 www.graphviz.org</title>
          <p>Mealy2dot.egl template (listing 1.1, line 14). Mealy2dot.egl highlights the
current state by changing its background colour, and assigns URLs to any nodes
reachable by outgoing transitions from the current state, making them clickable
in the generated image. The URLs execute a JavaScript function,
doTransition(src,tgt), which handles the asynchronous request to generate the new
image and replace the existing image with the newly generated one.</p>
          <p>After the asynchronous request to generate the image has been made,
doTransition() also makes an asynchronous request to MealyOutput.egl which
returns a string containing the input and output strings from the transition.
These are then printed underneath the image, showing the input and output
history of the animation. Figure 3 shows the output of animating a Mealy
machine over four transitions.
3.2</p>
        </sec>
      </sec>
      <sec id="sec-3-2">
        <title>Navigation of Ecore metamodels</title>
        <p>This section presents a web-application for on-demand navigation of Ecore
metamodels in a Javadoc-like style and explores the way in which the scalability of
the proposed approach is a ected by the server-side processing load and the
type of caching employed. The results presented in this section suggest that the
approach proposed in Section 2 is well-suited to viewing and navigating models
via the web for a signi cant number of concurrent users.</p>
        <p>
          EglDoc: Metamodel Documentation This section demonstrates the
approach proposed in Section 2 by describing the way in which an existing EGL
application, EglDoc [8, Ch.5], has been ported to provide web-based model
navigation and view extraction. EglDoc generates HTML documentation for Ecore
metamodels (and is similar to Javadoc for Java in this respect). Figure 4 shows
the output produced by EglDoc for the NamedElement class of the UML 2.2
[
          <xref ref-type="bibr" rid="ref9">9</xref>
          ] metamodel. EglDoc can be applied to produce documentation for any Ecore
metamodel.
        </p>
        <p>EglDoc comprises several templates, which are used to generate the header,
footer, navigation bar and content of each page. An extract of the EGL template
that generates documentation for attributes is shown in Listing 1.3. EGL is a
template-based model-to-text language. Listing 1.3 generates an HTML table of
attributes, listing the name and type of each attribute. Lines 10-12 generate a
link to other pages, using the toUrl() operation on lines 19-21.</p>
        <p>The existing version of EglDoc generates one HTML le for each element of
the Ecore metamodel. Porting EglDoc to interoperate with the web-based model
navigation and view extraction approach proposed in Section 2 involved
parameterising the existing EGL templates to facilitate the identi cation of metamodel
elements via the URL of a request to the web server. For example, a request for
(lines 2-3) and the p parameter of the request is interpreted (lines 6-8). Note
the use of the modelManager built-in variable for loading a model, which was
discussed in 2.2. In Listing 1.4, the model to be loaded (’UML.ecore’) is
hardcoded for clarity. In practice, the location of the model is speci ed as a URI,
which can be con gured by the user.
4</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Related Work</title>
      <p>Several mature Java-based template languages such as JSP, Velocity4 and
FreeMarker5 are available as server-side scripting languages for Java-based web
servers such as Tomcat. In principle we could have used any of these languages
4 http://velocity.apache.org
5 http://freemarker.sourceforge.net
in combination with the re ective API of EMF { or using code generated from
the respective Ecore metamodels in order to achieve a more concise syntax. For
dynamic languages such as Velocity and FreeMarker, developers could even
implement EMF-speci c extensions to enable a concise navigation style without
needing to generate code from the Ecore metamodels. However, compared to
these languages, we strongly believe that EGL is more suitable for the task as
it provides rst-order logic OCL-based collection navigation operations, built-in
support for accessing mutliple models concurrently, and a number of existing
drivers for interacting with a number of modelling technologies. Even more
importantly, since the model connectivity framework discussed in Section 2.1
provides a uniform interface for di erent modelling technologies, the
underlying modelling technology can be substituted later on if necessary (e.g. switch to
a database-backed model serialisation format for performance reasons) without
requiring changes to the EGL templates.</p>
      <p>The Web 2.0 MetaModelbrowser6 is a web application that can visualise
Ecore metamodels and their instances using a xed tree-based interface that
closely mimics the Eclipse-based EMF re ective tree editor. In contrast to
MetaModelbrowser, the approach proposed in this paper allows developers to
implement custom interfaces for displaying models to end users. Also, using the
Graphviz extension our approach enables developers to also embed
automaticallygenerated diagrams to their model browsing web applications.
5</p>
    </sec>
    <sec id="sec-5">
      <title>Conclusions and Further Work</title>
      <p>In this paper we have presented an approach for re-using a model-to-text
transformation language in order to provide support for web-based model navigation
and view extraction. Using this approach, non-technical stakeholders can have
access to the latest versions of the models of the system from their browser,
without needing to purchase and install additional software. Moreover, using
such an approach, access control can be enforced if necessary.</p>
      <p>With the advent of cloud computing, we believe that web-based model
management is a promising eld of study with signi cant potential for practical
real-world impact. A few of the open issues that we have identi ed through this
work include management of very large models, concurrent modi cation of
models, caching, and access control. In the future, we will investigate related work in
areas such as the management of very large databases and web-based
technologies, and adapt best-of-breed approaches to solve the respective problems in the
eld of web-based model management.</p>
      <p>Acknowledgements. The work in this paper was supported by the
European Commission via the MADES and INESS projects, co-funded under the
7th Framework programme (grants #218575 (INESS), #248864 (MADES)). We
would also like to thank Darren Clowes, Chris Holmes, Julian Johnson, Ray</p>
      <sec id="sec-5-1">
        <title>6 http://www.metamodelbrowser.org/</title>
        <p>Dawson, and Steve Probets from BAE Systems and Loughborough University
for their contributions to earlier work that led to the approach presented in this
paper.</p>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>Darren</given-names>
            <surname>Clowes</surname>
          </string-name>
          , Dimitrios S. Kolovos, Chris Holmes, Louis Rose, Richard Paige, Julian Johnson, Ray Dawson, and
          <string-name>
            <given-names>Steve</given-names>
            <surname>Probets</surname>
          </string-name>
          .
          <article-title>A Re ective Approach to Model Driven Web Engineering</article-title>
          .
          <source>In Proc. 6th European Conference on Modelling Foundations and Applications (ECMFA)</source>
          , Paris, France,
          <year>2010</year>
          2010.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Louis</surname>
            <given-names>M.</given-names>
          </string-name>
          <string-name>
            <surname>Rose</surname>
          </string-name>
          , Richard F. Paige, Dimitrios S. Kolovos, Fiona A.
          <string-name>
            <surname>C.</surname>
          </string-name>
          <article-title>Polack. The Epsilon Generation Language (EGL)</article-title>
          .
          <source>In Proc. European Conference in Model Driven Architecture (ECMDA)</source>
          ,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Sven</surname>
            <given-names>E</given-names>
          </string-name>
          tinge.
          <article-title>XPand Language Reference</article-title>
          . http://www.eclipse.org/gmt/oaw/doc/4.1/r20 xPandReference.pdf.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>Jon</given-names>
            <surname>Oldevik</surname>
          </string-name>
          .
          <article-title>MOFScript User Guide</article-title>
          . http://www.eclipse.org/gmt/mofscript/doc/ MOFScript-User-Guide.pdf.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <given-names>Eclipse</given-names>
            <surname>Foundation</surname>
          </string-name>
          .
          <article-title>Epsilon Modeling GMT component</article-title>
          . http://www.eclipse.org/gmt/epsilon.
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>6. Community Z Tools. http://czt.sourceforge.net.</mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Dimitrios</surname>
            <given-names>S.</given-names>
          </string-name>
          <string-name>
            <surname>Kolovos</surname>
          </string-name>
          , Louis M. Rose, Richard F. Paige.
          <source>The Epsilon Book</source>
          .
          <year>2008</year>
          . http://www.eclipse.org/gmt/epsilon/doc/book/.
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Louis</surname>
            <given-names>M.</given-names>
          </string-name>
          <string-name>
            <surname>Rose</surname>
          </string-name>
          .
          <article-title>A text-generation language for Epsilon</article-title>
          .
          <source>Master's thesis</source>
          , University of York,
          <year>2007</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9. OMG.
          <source>Uni ed Modelling Language 2</source>
          .2 Speci cation [online].
          <source>[Accessed 10 February</source>
          <year>2011</year>
          ] Available at: http://www.omg.org/spec/UML/2.2/,
          <year>2007</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>