Modelica XML A Modelica XML representation with Applications

  • Slides: 16
Download presentation
Modelica. XML A Modelica XML representation with Applications Adrian Pop, Peter Fritzson Programming Environments

Modelica. XML A Modelica XML representation with Applications Adrian Pop, Peter Fritzson Programming Environments Laboratory Linköping University

Outline § Introduction § Why XML? § XML, DTD § Modelica. XML Applications §

Outline § Introduction § Why XML? § XML, DTD § Modelica. XML Applications § Problems with XML § Semantic Web Languages § Conclusions and Future Work November 04, 2003 2

Introduction § Modelica has a fast growing code base § Modelica adopters have to

Introduction § Modelica has a fast growing code base § Modelica adopters have to develop their own tools for tasks like: § § § analysis of models (checkers and validators) pretty printing (un-parsing) interchange with other modeling languages query and transformation of models impose code style guidelines documentation § All these utilities § need easy access to the structure of the language § should interoperate. November 04, 2003 3

Why XML? § Store the structure of the Modelica code using an alternative representation

Why XML? § Store the structure of the Modelica code using an alternative representation § Perform the tasks on this alternative representation § The alternative representation should § be easy accessible from any programming language § be easy to transform, query and manipulate § support validation § XML has all these properties November 04, 2003 4

Extensible Markup Language (XML) § World Wide Web Consortium (W 3 C) standard §

Extensible Markup Language (XML) § World Wide Web Consortium (W 3 C) standard § XML represents information as trees using tags <? xml version="1. 0"? > <!DOCTYPE persons SYSTEM "persons. dtd"> <persons> <person job="programmer"> <name>John Doe</name> <email>email@none. ro</email> </person> … <person job="manager"> <comment>Classified</comment> </persons> November 04, 2003 5

Document Type Definition (DTD) § DTDs specify the allowed content of the XML elements

Document Type Definition (DTD) § DTDs specify the allowed content of the XML elements § Are used for XML document validation <!ENTITY % person-job-attribute "job (programmer|manager) #REQUIRED"> <!ELEMENT persons (person*)> <!ELEMEN person((name+, email*)|comment+)> <!ATTLIST person project CDATA #IMPLIED &person-job-attribute; > <!ELEMENT name(#PCDATA)> <!ELEMENT email(#PCDATA)> <!ELEMENT comment (#PCDATA)> November 04, 2003 6

Modelica. XML Modelica code read class Test "comment" modelicaxml Real x; Real xdot; definition

Modelica. XML Modelica code read class Test "comment" modelicaxml Real x; Real xdot; definition equation xdot = der(x); componen end Test; t componen t Modelica Parser output Modelica XML equation <modelicaxml> <definition ident= "Test" comment="comment"> <component ident="x" type="Real" visibility="public" /> <component ident="xdot" type="Real" visibility="public" /> <equation>. . . </equation> </definition> </modelicaxml> November 04, 2003 7

Modelica. XML Applications Interoperability and Transformation Modelica code read XML Tools validate, read output

Modelica. XML Applications Interoperability and Transformation Modelica code read XML Tools validate, read output Modelica Parser output HTML Documentation Parsers read output Modelica XML Other modeling languages November 04, 2003 Other XML formats 8

Modelica. XML + XSLT § The Stylesheet Language for Transformation (XSLT) § § is

Modelica. XML + XSLT § The Stylesheet Language for Transformation (XSLT) § § is a declarative language for transforming XML trees selects parts of the XML tree using the XPath language uses templates to transform the selected parts outputs desired format Modelica XML Other modeling languages XSLT Modelica code November 04, 2003 Other XML formats HTML Documentation 9

Modelica. XML + XQuery § The Query Language for XML (XQuery) § is a

Modelica. XML + XQuery § The Query Language for XML (XQuery) § is a declarative language for query of XML trees § selects parts of the XML tree using the XPath language § uses SQL-like query language to further manipulate the results Model Queries Modelica XML XQuery Style guidelines Answers November 04, 2003 10

Modelica. XML + DOM § Document Object Model (DOM) § is a platform and

Modelica. XML + DOM § Document Object Model (DOM) § is a platform and language neutral interface for § access and update the content/structure/style of XML trees in XML documents § implementation in almost all programming languages Modelica XML Programming Languages DOM November 04, 2003 ü Semantic Analysis ü Unparsing ü Code transformation ü Model instantiation ü Optimization ü others 11

Problems with the XML Representation § XML can only express syntax § No easy

Problems with the XML Representation § XML can only express syntax § No easy way to automatically handle semantics § Possible solutions § use more expressive markup languages to express Modelica semantics § use available tools for these languages November 04, 2003 12

Semantic Web Languages § Resource Description Framework (RDF) § § represents graphs describes classes

Semantic Web Languages § Resource Description Framework (RDF) § § represents graphs describes classes and relations out of the box tools for graph query some type checking is available § Web Ontology Language (OWL) § adds a Description Logics layer on top of RDF § out of the box tools for: § type checking § model consistency § making the implicit sub-typing and equivalence relations explicit (inference) November 04, 2003 13

Conclusions and Future Work § Modelica. XML § offers easy access to Modelica language

Conclusions and Future Work § Modelica. XML § offers easy access to Modelica language structure § helps in providing more non-simulation applications for Modelica § is not enough for handling Modelica semantics § Future Work § formal definition of all the intermediate steps from Modelica to flat Modelica (static semantics, interoperability) § tools will act on these level independent of each other § further investigation of the use of the Semantic Web Languages to express Modelica semantics is needed November 04, 2003 14

End Thank you! Questions? November 04, 2003 15

End Thank you! Questions? November 04, 2003 15

Modelica. XML and Modelica. OWL § Modelica. XML § http: //www. ida. liu. se/~adrpo/modelica/xml

Modelica. XML and Modelica. OWL § Modelica. XML § http: //www. ida. liu. se/~adrpo/modelica/xml § Modelica. OWL § http: //www. ida. liu. se/~adrpo/modelica/owl November 04, 2003 16