Multifocal: A Strategic Bidirectional Transformation Language for - - PowerPoint PPT Presentation

multifocal a strategic bidirectional transformation
SMART_READER_LITE
LIVE PREVIEW

Multifocal: A Strategic Bidirectional Transformation Language for - - PowerPoint PPT Presentation

Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas Hugo Pacheco Alcino Cunha HASLab / INESC TEC & Universidade do Minho, Braga, Portugal ICMT 2012 Prague - May 28th 2012 Two-level Transformations model


slide-1
SLIDE 1

Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas

Hugo Pacheco

Alcino Cunha

HASLab / INESC TEC & Universidade do Minho, Braga, Portugal

ICMT 2012 Prague - May 28th 2012

slide-2
SLIDE 2

Two-level Transformations

model transformations are frequent in software engineering coupled transformations

?

two-level transformations

S S T T Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 2 / 1

Hugo Pacheco, Alcino Cunha

slide-3
SLIDE 3

XML Transformation Languages

XML transformation languages (XSLT, XQuery, XPath) generic, structure-shy programs

XML File //b XML File

<a> <b/> <b/> </a>

/a/b

<b/> <b/> <b> <a/> </b> <b/>

/b

<b/> <b/>

easier to write, multiple inputs not two-level

XML File XML Schema XML Schema XML File

XSLT Transformation XSLT Transformation

Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 3 / 1

Hugo Pacheco, Alcino Cunha

slide-4
SLIDE 4

Bidirectional Transformations

bidirectional transformations

S T

Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 4 / 1

Hugo Pacheco, Alcino Cunha

slide-5
SLIDE 5

Bidirectional XML Transformation Languages

many bidirectional languages tree-structured data (XML) lenses (view-update)

S S V V

not two-level, not generic

S V S V

Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 5 / 1

Hugo Pacheco, Alcino Cunha

slide-6
SLIDE 6

Motivation: Multifocal Language

two-level bidirectional transformations

S S T T

Multifocal XML transformation language

XML Schema XML Schema Multifocal Transformation S1 V1 S2 V2

schema-level transformations as views between XML Schemas model-level transformations as lenses between XML documents multiple focus points

Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 6 / 1

Hugo Pacheco, Alcino Cunha

slide-7
SLIDE 7

Application Example: XML Views

source XML Schema modeling a movie database

* * + * actor imdb series movie year title review boxoffice year title review season name user comment country value user comment name result played year title role award * * * * year episode * *

?

director * * Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 7 / 1

Hugo Pacheco, Alcino Cunha

slide-8
SLIDE 8

Application Example: XML Views

informal XML Schema transformation

1

delete series

2

for each movie:

count its popularity (total number of review comments) estimate its profit (sum of the boxoffice values)

3

for each actor, select its name and a list of award names

view XML Schema

awname imdb * * * title year profit movie actor popularity director name

Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 8 / 1

Hugo Pacheco, Alcino Cunha

slide-9
SLIDE 9

Application Example: XML Views

<imdb> <movie> <year>2003</year> <title>Kill Bill: Vol. 1</title> <review user="emma"> <comment>Gorgeous!</comment></review> <director>Quentin Tarantino</director> <boxoffice country="USA" value="22089322"/> <boxoffice country="Japan" value="3521628"/> </movie> <series><year>2011</year> <title>Game of Thrones</title> <season><year>2011</year> <episode>Winter is Coming</episode> </season></series> <actor name="Umma Thurman"> <played><year>2003</year> <title>Kill Bill: Vol. 1</title> <role>The Bride</role> <award name="Saturn" result="Won"/> </played></actor> </imdb>

Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 9 / 1

Hugo Pacheco, Alcino Cunha

slide-10
SLIDE 10

Application Example: XML Views

<imdb> <movie popularity="1" profit="25610950"> <year>2003</year> <title>Kill Bill: Vol. 1</title> <director>Quentin Tarantino</director> </movie> <actor name="Umma Thurman"> <awname>Saturn</awname> </actor> </imdb>

Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 10 / 1

Hugo Pacheco, Alcino Cunha

slide-11
SLIDE 11

Application Example: XML Views

<imdb> <movie> ... </movie> <movie popularity=”2” profit=”15”> <year>2012</year> <title>Sherlock Holmes: Game of Shadows</title> <director>Guy Ritchie</director> </movie> <actor name=”Uma Thurman”> <awname>Saturn Best Actress</awname> </actor> </imdb>

Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 11 / 1

Hugo Pacheco, Alcino Cunha

slide-12
SLIDE 12

Application Example: XML Views

<imdb> <movie> ... </movie> <series> ... </series> <movie><year>2012</year> <title>Sherlock Holmes: Game of Shadows</title> <review user=”” comment=””/> <review user=”” comment=””/> <director>Guy Ritchie</director> <boxoffice country=”” value=”15”/> </movie> <actor name=”Uma Thurman”> <played><year>2003</year> <title>Kill Bill: Vol. 1</title> <role>The Bride</role> <award name=”Saturn Best Actress” result="Won"/> </played></actor> </imdb>

Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 12 / 1

Hugo Pacheco, Alcino Cunha

slide-13
SLIDE 13

Multifocal Language: Basic Combinators

generic style = concise specification strategic rewrite system Rule = Schema → Maybe (Schema, Lens) construct flexible strategies in a compositional way basic combinators (in what order? how often?)

identity nop : Rule → Rule sequentially (>>) : Rule → Rule → Rule alternatively (||) : Rule → Rule → Rule repetitively many : Rule → Rule → Rule

  • ptionally

try : Rule → Rule

Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 13 / 1

Hugo Pacheco, Alcino Cunha

slide-14
SLIDE 14

Multifocal Language: Traversal Combinators

traversal combinators (at what depth?)

apply a rule to all children

+ * all r + * r r r

apply a rule to all descendants everywhere : Rule → Rule apply a rule once at an arbitrary depth

r n

+ n m

  • *

n

  • nce r

+ m * r

  • n

apply a rule many times at an arbitrary depth

  • utermost : Rule → Rule

Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 14 / 1

Hugo Pacheco, Alcino Cunha

slide-15
SLIDE 15

Multifocal Language: Local Combinators

control the application of certain rules local combinators (under which conditions?)

at a particular element

n at "n" n

at a particular location

n when "ns" n * * ns

XML name-based combinators

n

hoist plunge "n"

n n

rename "m"

m Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 15 / 1

Hugo Pacheco, Alcino Cunha

slide-16
SLIDE 16

Multifocal Language: Abstraction Combinators

language for defining XML views abstraction combinators

erase the current tree (explicit)

erase

empty tree apply an XPath query (implicit)

+ n m

  • *

p select "//p" * p 1

specialize the XPath expression (/m / p) for the source schema

2

convert it to a lens into the query’s result type

Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 16 / 1

Hugo Pacheco, Alcino Cunha

slide-17
SLIDE 17

Application Example: Multifocal XML Views

1

everywhere (try (at "series" erase))

2

>> everywhere (try (at "movie" (

  • utermost (when "reviews" (

select "count(//comment)" >> plunge "@popularity")) >> outermost (when "boxoffices" ( select "sum(//@value)" >> plunge "@profit")))))

3

>> everywhere (try (at "actor" (

  • utermost (at "played" (

select "award/@name" >> all (rename "awname"))))))

Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 17 / 1

Hugo Pacheco, Alcino Cunha

slide-18
SLIDE 18

Multifocal Framework

XML File (.xml) XML Schema (.xsd) XML File (.xml) Multifocal File (.2lt) XML Schema (.xsd) Evaluate XML File (.xml) Bidirectional Lens Executable Forward Backward XML File (.xml) Compile

two stages:

1

evaluate: XML Schema ⇒ XML Schema + lens

2

compile: lens ⇒ executable

Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 18 / 1

Hugo Pacheco, Alcino Cunha

slide-19
SLIDE 19

Implementation

Bidirectional Lens Executable Haskell value Haskell type Haskell value Haskell Strategic Program Haskell type Evaluate Haskell value Forward Backward Haskell value Haskell Lens Expression Compile Multifocal File (.2lt) XML Schema (.xsd) parse XML Schema (.xsd) pprint parse XML File (.xml) XML File (.xml) XML File (.xml) XML File (.xml) parse pprint pprint parse

XML-Haskell front-ends (type-safe) strategic two-level library (Haskell) bidirectional lens library (Haskell)

Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 19 / 1

Hugo Pacheco, Alcino Cunha

slide-20
SLIDE 20

Optimization

resulting lenses could be more efficient support for automatic optimization

  • ptimize lenses ⇒ generate efficient

executables

  • nce-a-time penalty

propagate multiple updates

XML File XML Schema XML Schema XML File XML Files XML Files

Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 20 / 1

Hugo Pacheco, Alcino Cunha

slide-21
SLIDE 21

Conclusions

+ Multifocal language for XML Schema evolution + strategic: concise and generic + two-level: multiple views, free document migrations + bidirectional: lenses, nice update semantics + staged optimization + framework (type-safe) – expressiveness of the bidirectional language (views) – alignment (parameterization) – integration with XML technologies Demo: Tool / Library more (recursive) XML Schema evolution examples http://hackage.haskell.org/package/multifocal

Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 21 / 1

Hugo Pacheco, Alcino Cunha