multifocal a strategic bidirectional transformation
play

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


  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

  2. Two-level Transformations model transformations are frequent in software engineering coupled transformations ? two-level transformations S T S T � Hugo Pacheco � , Alcino Cunha Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 2 / 1

  3. XML Transformation Languages XML transformation languages (XSLT, XQuery, XPath) generic, structure-shy programs XML File XML File //b <a> <b> <b/> <b/> <a/> <b/> /a/b /b <b/> <b/> </b> <b/> </a> <b/> easier to write, multiple inputs not two-level XSLT Transformation XML XML Schema Schema XSLT Transformation XML File XML File � Hugo Pacheco � , Alcino Cunha Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 3 / 1

  4. Bidirectional Transformations bidirectional transformations S T � Hugo Pacheco � , Alcino Cunha Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 4 / 1

  5. Bidirectional XML Transformation Languages many bidirectional languages tree-structured data (XML) lenses (view-update) S V S V not two-level, not generic S V S V � Hugo Pacheco � , Alcino Cunha Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 5 / 1

  6. Motivation: Multifocal Language two-level bidirectional transformations S T S T Multifocal XML transformation language Multifocal Transformation XML XML Schema Schema S1 V1 S2 V2 schema-level transformations as views between XML Schemas model-level transformations as lenses between XML documents multiple focus points � Hugo Pacheco � , Alcino Cunha Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 6 / 1

  7. Application Example: XML Views source XML Schema modeling a movie database imdb * + * movie series actor * * * * * year title review director boxoffice year title review season name played * ? * * * user comment country value user comment year episode year title role award name result � Hugo Pacheco � , Alcino Cunha Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 7 / 1

  8. Application Example: XML Views informal XML Schema transformation delete series 1 for each movie: 2 count its popularity (total number of review comments) estimate its profit (sum of the boxoffice values) for each actor, select its name and a list of award names 3 view XML Schema imdb * * movie actor * year title director name awname popularity profit � Hugo Pacheco � , Alcino Cunha Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 8 / 1

  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> � Hugo Pacheco � , Alcino Cunha Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 9 / 1

  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> � Hugo Pacheco � , Alcino Cunha Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 10 / 1

  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> � Hugo Pacheco � , Alcino Cunha Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 11 / 1

  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> � Hugo Pacheco � , Alcino Cunha Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 12 / 1

  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 optionally try : Rule → Rule � Hugo Pacheco � , Alcino Cunha Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 13 / 1

  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 m m + * + * once r n n o n o n r r apply a rule many times at an arbitrary depth outermost : Rule → Rule � Hugo Pacheco � , Alcino Cunha Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 14 / 1

  15. Multifocal Language: Local Combinators control the application of certain rules local combinators (under which conditions?) at a particular element at a particular location n n ns * * at "n" n n when "ns" XML name-based combinators n n n m plunge rename hoist "n" "m" � Hugo Pacheco � , Alcino Cunha Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 15 / 1

  16. Multifocal Language: Abstraction Combinators language for defining XML views abstraction combinators erase the current tree apply an XPath query (implicit) (explicit) m select * + * "//p" erase n o p p empty tree specialize the XPath expression 1 ( / m / p ) for the source schema convert it to a lens into the 2 query’s result type � Hugo Pacheco � , Alcino Cunha Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 16 / 1

  17. Application Example: Multifocal XML Views everywhere (try (at "series" erase)) 1 >> everywhere (try (at "movie" ( 2 outermost (when "reviews" ( select "count(//comment)" >> plunge "@popularity")) >> outermost (when "boxoffices" ( select "sum(//@value)" >> plunge "@profit"))))) >> everywhere (try (at "actor" ( 3 outermost (at "played" ( select "award/@name" >> all (rename "awname")))))) � Hugo Pacheco � , Alcino Cunha Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 17 / 1

  18. Multifocal Framework Multifocal File (.2lt) XML Schema XML Schema Evaluate (.xsd) (.xsd) Compile Bidirectional Lens Executable XML File XML File Forward (.xml) (.xml) XML File XML File Backward (.xml) (.xml) two stages: evaluate: XML Schema ⇒ XML Schema + lens 1 compile: lens ⇒ executable 2 � Hugo Pacheco � , Alcino Cunha Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 18 / 1

  19. Implementation Multifocal File (.2lt) parse Haskell Strategic Program parse pprint XML Schema Haskell Haskell XML Schema Evaluate (.xsd) type type (.xsd) Haskell Lens Expression Compile Bidirectional Lens Executable parse pprint XML File Haskell Haskell XML File Forward (.xml) value value (.xml) pprint parse XML File Haskell Haskell XML File Backward (.xml) value value (.xml) XML-Haskell front-ends (type-safe) strategic two-level library (Haskell) bidirectional lens library (Haskell) � Hugo Pacheco � , Alcino Cunha Multifocal: A Strategic Bidirectional Transformation Language for XML Schemas 19 / 1

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend