Title: Model Driven Architecture based
1Model Driven Architecture based XML
Processing Ivan Kurtev, Klaas van den
Berg University of Twente, the Netherlands
2Outline
- Technologies for XML Processing
- Problem Statement
- Model Driven Architecture (MDA) Concepts
- MDA based XML Processing
- Example
- Transformation Language
- Conclusions
3Context
- Applications written in an OO language
- Main goal transform a document into a set of
application objects
Domain
Implements concepts
ApplicationClasses
Encodes data from
Instances
Transformation
XMLDocument
ApplicationObjects
The Transformation is a recurring task and
requires automation
4Technologies for XML Processing
- Generic interfaces to XML documents (e.g. DOM)
XMLDocument
DOM Parser
Processing Code
DOM Tree
Application Objects
Tree traversing, class instantiation, type
conversions are performed by processing code.
- Compilation and Unmarshalling are automated
- Not applicable in case of dissimilarities between
the schema and the application structure
Compilation
Schema
ApplicationClasses
Instance of
Instance of
XMLDocument
Objects
Unmarshalling
5Problem Statement
- XML Processing
- Definition and execution of transformations
between XML documents and application objects - Requirements
- Transformations should be automated
- Transformations should produce the desired
application objects - Current technologies are either low-level or do
not always produce the desired application
objects - More powerful transformation techniques are
required! - Solution
- Application of Model Driven Architecture (MDA)
model transformation techniques
6Basic MDA Concepts
- Separation of system specification from system
implementation - Models
- Model Transformations
- The MDA Pattern (from MDA Guide)
7Meta Modeling and XML (1)
- In the MDA models can be defined in the Meta
Object Facility (MOF) based on four meta layers - Similar meta layer organization is observed in
the XML technology
Example
8Meta Modeling and XML (2)
- Schemas play the role of models for XML
documents - Schemas may be considered as MOF models if a
proper Schema meta-model is defined
Example In MOF Data Binding is a model
transformation. Arbitrary transformation
policies may be specified.
9MDA based XML Processing
- Document schema is a Source Model (at level M1)
- Application Classes form a Target Model
- Transformations are specified between the source
and the target model - Transformations are executed over source XML
documents and result in a set of target objects
10XML Schema Meta-model
Fragment of the XML Schema Meta-model (based on
the W3C specification)
11Target Meta-model
Constructs Class, Attribute, Method,
Generalization
Fragment of the target meta-model (subset of UML
meta-model)
12Example Address and Person
Source Schema Simplified version of the
canonical PurchaseOrder schema from the XML
Schema Primer
Application Classes (implemented in Java)
public class Address public String
street public class USAddress extends
Address public String zip
ltcomplexType name"Address"gt ltsequencegt
ltelement name"name
type"string"/gt ltelement name"street"
type"string"/gt
lt/sequencegt lt/complexTypegt
public class Person private Address address
public String firstName public String
lastName public Person(Address address)
...
ltcomplexType name"USAddress"gt
ltcomplexContentgt ltextension baseAddressgt
ltsequencegt ltelement name"zip "
type"string"/gt
lt/sequencegt lt/extensiongt
lt/complexContentgt lt/complexTypegt
13Example Target Model
- The target model wraps the application Java
classes - Deriving the target model from Java classes
- Java class to a model class
- Extension to generalization
- Public fields to attributes
- Constructor parameters to attributes
- Information not included in the target model
- Collections that implement multivalued
attributes - Access to the attributes
14Example Transformation Specification
- Transformation Language
- Abstract Syntax MOF-based Transformation
Meta-model - Concrete Syntax specified as a grammar
- Two types of rules Class and Attribute Rules
Class Rules specify instantiations of classes
in the target model based on selection of source
components
Example
personRule ClassRule source
AddressCT/nameE target Person
constructor address
firstName
getFirstName(source),
lastName
getLastName(source)
15Example Transformation Specification
Attribute Rules specify how the attribute
values are obtained from the source.
Example
addressAttribute rule specifies how to locate the
value of the address attribute
addressAttribute AttributeRule source E
target address pathparent
And the address object is created by another
class rule
addressRule ClassRule source AddressCT
target Address street
16Adaptation to Java
- Transformation language does not specify how
objects are created and attributes are set - In Java
- Object creation constructor, factory method
- Attribute access getter and setter methods,
public fields - Multivalued attributes implemented as
collections (array, Vector, etc.) - This is provided separately as additional meta
information
17Transformation Execution
- There is no predefined execution order over the
rules - Implicit dependencies among the rules
- Constructor attributes are calculated before
class instantiation - Other attributes are set after the instantiation
- During execution the dependencies are resolved
- Dependency graph is formed
- Execution order is determined after a topological
sort over the dependency graph - Circularity prevents the execution of the
transformation
18Conclusions
- Approach for XML Processing
- Based on transformations between source schema
and target application model - Declarative language for defining
transformations - Based on the MDA/MOF technology
- Allows reuse of existing application classes
- A prototype of an interpreter that supports the
core transformation language features is
implemented
19Future Work
- Applying schema matching techniques for rule
identification - Generalizing the language to the arbitrary
model-to-model transformations in the context of
MOF - Reuse and composition of transformations
following the composition of the source XML
schemas - More efficient rule execution