Managing XML documents with Epsilon

1,580 views

Published on

Demonstrates how to use XML documents as models with languages of the Epsilon platform.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Managing XML documents with Epsilon

  1. 1. IntroductionMotivationBackgroundSolutionConclusions... ....A Lightweight Approach for Managing XMLDocuments with MDE LanguagesDimitris Kolovos, Louis Rose, James Williams,Nicholas Matragkas, and Richard PaigeDepartment of Computer Science, University of York{dkolovos,louis,jw,nikos,paige}@cs.york.ac.ukD. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 1/32
  2. 2. IntroductionMotivationBackgroundSolutionConclusions.. IntroductionMDE is about automated processing of modelsModel (in MDE) = any machine processable document thatcontains (meta-)information of interestContemporary model management languages (M2M, M2Tetc.) mainly consider models captured atop 3-levelmetamodelling architecturesMOF, EMF etc.In this work we investigate the role of XML in MDED. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 2/32
  3. 3. IntroductionMotivationBackgroundSolutionConclusions.. XML.Pros.... ....Simple syntaxPlenty of tutorials, examplesNo need for metamodelling (more agile)No need for specialised tools: any text editor will doMost developers already familiar with it.Cons.... ....Verbose syntaxOnly good for tree-based metadata, no support for types (bydefault)References/types are possible with XML SchemaD. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 3/32
  4. 4. IntroductionMotivationBackgroundSolutionConclusions.. EMF vs. XMLXML is technically inferior to EMFPlain XML is more agile than EMFXML is immensely more popularThere is much potentially useful (meta-)information alreadystored in XMLD. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 4/32
  5. 5. IntroductionMotivationBackgroundSolutionConclusions.. MotivationEnable agile MDEBring MDE to XML-literate developers without forcing themto engage with metamodelling architecturesLower the entry barrier by introducing one thing at a timeIf MDE pays off, transition to a proper metamodellingarchitecture should be less of an issueD. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 5/32
  6. 6. IntroductionMotivationBackgroundSolutionConclusions.. How?Enable model management languages to manage schema-lessXML documents (playing the role of models)To automate tasks such as model transformation, codegeneration, model validation etc.D. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 6/32
  7. 7. IntroductionMotivationBackgroundSolutionConclusions.. Epsilon - www.eclipse.org/epsilonA family of modelling technology-agnostic model managementlanguages forCode generation (EGL)Model transformation (ETL)Model validation (EVL)Model comparison (ECL)...All Epsilon languages reuse a common expression language(Epsilon Object Language) and as such, they are consistentand interoperable with each otherD. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 7/32
  8. 8. IntroductionMotivationBackgroundSolutionConclusions.. Epsilon Model ConnectivityEpsilon Languages are decoupled from underlying modellingtechnologies through the Epsilon Model Connectivity layerSupport for concrete modelling technologies can beimplemented in the form of EMC driversIn this work we have implemented a new EMC driver for XMLdocumentsEpsilon Object Language (EOL)Epsilon Model Connectivity (EMC)EMF(XMI 2.x)MDR(XMI 1.x)Z (CZT) XMLTransformationLanguage (ETL)ValidationLanguage (EVL)Migration Language (Flock)Model-to-TextLanguage (EGL)RefactoringLanguage (EWL)ComparisonLanguage (ECL)MergingLanguage (EML)Unit Testing Framework (EUnit)D. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 8/32
  9. 9. IntroductionMotivationBackgroundSolutionConclusions.. Attack Plan...1 Introduce a small XML document...2 Demonstrate how EOL can query/modify it through the newXML driver...3 Demonstrate how the XML driver is leveraged by task specificlanguagesEpsilon Transformation Language (ETL)Epsilon Validation Language (EVL)Epsilon Generation Language (EGL)D. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 9/32
  10. 10. IntroductionMotivationBackgroundSolutionConclusions.. Example<library><book title="Eclipse Modeling Project: A Domain-SpecificLanguage (DSL) Toolkit" pages="736"><author>Richard Gronback</author><published>2009</published></book><book title="Official Eclipse 3.0 FAQs"pages="432"><author>John Arthorne</author><author>Chris Laffra</author><published>2004</published></book></library>D. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 10/32
  11. 11. IntroductionMotivationBackgroundSolutionConclusions.. Example (in Ecore)D. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 11/32
  12. 12. IntroductionMotivationBackgroundSolutionConclusions.. Working with Types in EMF// Get all Book elementsvar books = Book.all;// Get a random bookvar b = books.random();// Check if b is a book// Prints trueb.isTypeOf(Book).println();// Check if b is a library// Prints falseb.isTypeOf(Library).println();D. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 12/32
  13. 13. IntroductionMotivationBackgroundSolutionConclusions.. Emulating Types in XML... ....The t_ prefix before the name of a tag is used to emulate atype, instances of which are all the elements with that tag.// Get all <book> elementsvar books = t_book.all;// Get a random bookvar b = books.random();// Check if b is a book// Prints trueb.isTypeOf(t_book).println();// Check if b is a library// Prints falseb.isTypeOf(t_library).println();D. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 13/32
  14. 14. IntroductionMotivationBackgroundSolutionConclusions.. Getting and Setting Attribute Values in EMF// Print all the titles of the books in the libraryfor (b in Book.all) {b.title.println();}// Print the total number of pages of all booksvar total = 0;for (b in Book.all) {total = total + b.pages;}total.print();D. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 14/32
  15. 15. IntroductionMotivationBackgroundSolutionConclusions.. Getting and Setting Attribute Values in XML... ....An attribute name, prefixed by a_, can be used as a propertyof the element object.The driver also supports the following prefixes: b_ for boolean,s_ for string (alias of a_) and r_ for real values.// Print all the titles of the books in the libraryfor (b in t_book.all) {b.a_title.println();}// Print the total number of pages of all booksvar total = 0;for (b in t_book.all) {total = total + b.i_pages;}total.print();D. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 15/32
  16. 16. IntroductionMotivationBackgroundSolutionConclusions.. Navigating References in EMF// Get a random bookvar b = Book.all.random();// Get its authorvar authors = b.authors;// Get its published element and print its textb.published.year.println();D. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 16/32
  17. 17. IntroductionMotivationBackgroundSolutionConclusions.. Getting Child Elements by Tag Name in XML... ....The driver supports e_ and c_-prefixed shorthand propertiesfor accessing one or a collection of elements with the specifiedname respectively.e_ and c_ properties are read-only.// Get a random bookvar b = t_book.all.random();// Get its <author> childrenvar authors = b.c_author;// Get its <published> child and print its textb.e_published.text.println();D. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 17/32
  18. 18. IntroductionMotivationBackgroundSolutionConclusions.. Creating new Elements in EMF// Check how many books are in the library// Prints 2Book.all.size().println();// Creates a new book elementvar b = new Book;// Check again// Prints 3Book.all.size().println();D. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 18/32
  19. 19. IntroductionMotivationBackgroundSolutionConclusions.. Creating new Elements in XML... ....The standard new operator can be used to create newelements in the XML document.// Check how many <books> are in the library// Prints 2t_book.all.size().println();// Creates a new book elementvar b = new t_book;// Check again// Prints 3t_book.all.size().println();D. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 19/32
  20. 20. IntroductionMotivationBackgroundSolutionConclusions.. Another example<model><class name="Customer"><property name="name" type="String"/><property name="address" type="Address"/></class><class name="Invoice"><property name="serialNumber" type="String"/><property name="customer" type="Customer"/><property name="items" type="InvoiceItem"many="true"/></class>...</model>D. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 20/32
  21. 21. IntroductionMotivationBackgroundSolutionConclusions.. Validation Constraints with EVL... ....Constraint that checks that the type of each property in theXML model corresponds to a defined type (class or datatype).import "util.eol";context t_property {constraint TypeMustBeDefined {check : typeForName(self.a_type).isDefined()message : "Property " + self.a_name + " of class "+ self.parentNode.a_name+ " is of unknown type: " + self.a_type}}D. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 21/32
  22. 22. IntroductionMotivationBackgroundSolutionConclusions.. typeForName()operation typeForName(type : String) {return allTypes().selectOne(t|t.a_name = type);}operation allTypes() : List {return XML!t_class.all.includingAll(XML!t_datatype.all);}D. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 22/32
  23. 23. IntroductionMotivationBackgroundSolutionConclusions.. Model Transformation with ETL... ....Transformation that produces an EMF-based UML modelfrom the XML document.import "util.eol";rule t_model2Modeltransform s : XML!t_modelto t : UML!Model {t.packagedElement.addAll(s.children.equivalent());}(continued...)D. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 23/32
  24. 24. IntroductionMotivationBackgroundSolutionConclusions.. Model Transformation with ETLrule t_class2Classtransform s : XML!t_classto t : UML!Class {t.name = s.a_name;t.ownedAttribute.addAll(s.children.equivalent().select(e|e.isTypeOf(UML!Property)));}...D. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 24/32
  25. 25. IntroductionMotivationBackgroundSolutionConclusions.. Case Study: MDE for EU Grant Proposals.Problem.... ....Grant proposals contain significant duplicatione.g. tables of effort per work package, per partner, per activitytypeFigures can quickly become inconsistent across the proposal.Solution.... ....Used XML to capture core information about the proposalWork packages, partners, tasks, deliverables etc.Developed a model-to-text transformation to generate allrequired tables in the form of LATEX code from the XMLdocumentD. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 25/32
  26. 26. IntroductionMotivationBackgroundSolutionConclusions.. Project data in XML<wp title="Requirements and Use Cases" leader="TOG" type="RTD"><effort partner="TOG" months="6"/><effort partner="YORK" months="6"/><effort partner="UDA" months="2"/><effort partner="CWI" months="5"/>...<effort partner="UI" months="3"/><task title="Use Case Analysis" start="1" end="6"partners="*"/><task title="Technology Analysis" start="3" end="6"partners="*"/><task title="Evaluation Planning" start="4" end="6"partners="*"/><deliverable title="Project Requirements" due="6"nature="R" dissemination="CO" partner="TOG"/><deliverable title="Evaluation Plan" due="6"nature="R" dissemination="CO" partner="TOG"/></wp>D. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 26/32
  27. 27. IntroductionMotivationBackgroundSolutionConclusions.. EGL M2T TransformationD. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 27/32
  28. 28. IntroductionMotivationBackgroundSolutionConclusions.. Generated LaTeXnewcommand{workPackageOneEffortTable} {begin{longtable} {|p{4.4cm}|p{2.8cm}|p{2.8cm}|p{2.8cm}|p{2.8cm}|}caption{Effort table for WP1}label{tab:workPackageOneEffortTable}hlinetextbf{Work package} & 1 & multicolumn{2}{l|}{textbf{Start date}} & 1 hlinetextbf{Work package title} & multicolumn{4}{p{11.2cm}|}{Requirements and Use Cases}hlinetextbf{Activity type} & multicolumn{4}{l|}{RTD}hlinetextbf{Participant name} & textbf{TOG} & YORK & CWI & UDA hlinetextbf{Person-months} & textbf{6} & 6 & 5 & 2 hlinetextbf{Participant name} & UNIMAN & TEC & ST & UNINOVA hlinetextbf{Person-months} & 2 & 4 & 6 & 4.5 hlinetextbf{Participant name} & UI & & & hlinetextbf{Person-months} & 3 & & & hlineend{longtable}D. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 28/32
  29. 29. IntroductionMotivationBackgroundSolutionConclusions.. Rendered Table318736 OSSMETERA6. Work Package DescriptionsA6.1. WP1: Requirements and Use CasesTable 4: E↵ort table for WP1Work package 1 Start date 1Work package title Requirements and Use CasesActivity type RTDParticipant name TOG YORK CWI UDAPerson-months 6 6 5 2Participant name UNIMAN TEC ST UNINOVAPerson-months 2 4 6 4.5Participant name UIPerson-months 3Objectives:Within this workpackage the requirements will be defined for the new open source analysis tools,technologies and processes to assist European software developers and decision makers, which aredriven from both an industry and technology perspective.The use cases provided by the industrial user partners in the project will be analysed and industrydriven requirements for the project will be defined and prioritised. The technology partners willfurther detail technical requirements that address the industrial user needs within the use cases andfulfill the technological breakthroughs targeted by the project. Requirements will be established forD. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 29/32
  30. 30. IntroductionMotivationBackgroundSolutionConclusions.. ObservationsXML’s agility makes it ideal for quick prototypingNo need to design a metamodel firstModel evolution is easyModel management code is more verbose with plain XMLmodelse_, c_, a_, t_ prefixesProgrammatic not-containment reference resolutionReferential integrity must be validated programmaticallyIncreasing motivation to move to a proper modellingframework as the metamodel stabilises and complexityincreasesMigration to EMF is manual (so far) but straightforwardD. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 30/32
  31. 31. IntroductionMotivationBackgroundSolutionConclusions.. SummaryPresented a new driver for Epsilon that enables plain XMLdocuments to be managed as modelsThe proposed approach aims at lowering the MDE entrancebarrier for XML-literate developers, and at enabling agile MDESub-optimal MDE is better than no MDED. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 31/32
  32. 32. IntroductionMotivationBackgroundSolutionConclusions.. DownloadAvailable at http://www.eclipse.org/epsilon/downloadD. Kolovos et. al. | University of York | ECMFA 2012 MDE with plain XML documents - Slide 32/32

×