ModelicaXML A Modelica XML representation with Applications

advertisement
ModelicaXML
A Modelica XML representation
with
Applications
Adrian Pop, Peter Fritzson
Programming Environments Laboratory
Linköping University
Outline
ƒ Introduction
ƒ Why XML?
ƒ XML, DTD
ƒ ModelicaXML
ƒ ModelicaXML 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 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
ƒ 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 (W3C) 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>
</person>
</persons>
November 04, 2003
5
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
ModelicaXML
Modelica
code
read
class Test "comment"
modelicaxml
Real x;
Real xdot;
definition
equation
xdot = der(x);
component
end Test;
Modelica Parser
output
Modelica
XML
equation
component
<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
ModelicaXML Applications
Interoperability and Transformation
Modelica
code
read
XML Tools
validate,
read
output
Modelica Parser
output
output
output
validate,
read
HTML
Documentation
Parsers
read
output
Modelica
XML
Other modeling
languages
November 04, 2003
Other XML
formats
8
ModelicaXML + 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
Other modeling
languages
Modelica
XML
XSLT
Modelica
code
November 04, 2003
Other XML
formats
HTML
Documentation
9
ModelicaXML + 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
ModelicaXML + 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
9 Semantic Analysis
9 Unparsing
9 Code transformation
9 Model instantiation
9 Optimization
9 others
November 04, 2003
11
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 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
ƒ ModelicaXML
ƒ 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
ModelicaXML and ModelicaOWL
ƒ ModelicaXML
ƒ http://www.ida.liu.se/~adrpo/modelica/xml
ƒ ModelicaOWL
ƒ http://www.ida.liu.se/~adrpo/modelica/owl
November 04, 2003
16
Download