a programmable editor for developing structured documents based on bidirectional transformations...

30
A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University of Tokyo

Upload: chester-lionel-merritt

Post on 02-Jan-2016

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

A Programmable Editor forDeveloping Structured Documents based on

Bidirectional Transformations

Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi

University of Tokyo

Page 2: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

Structured Documents

IPL Address Book

Zhenjiang Hu: Assoc. Prof. Shin-Cheng Mu: Post Doc Masato Takeichi: Prof.

Names

Zhenjiang Hu: hu@mist … Shin-Cheng Mu: scm@ipl … Masato Takeichi: takeichi@ …

Addresses

XML<addressBook> <person> <name> Zhenjiang Hu </name> …. </person> <person> … </person></addressBook>

DTD XSLT

Page 3: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

Document Engineering

XML<addressBook> <person> <name> Zhenjiang Hu </name> …. </person> <person> … </person></addressBook>

DTD XSLT

Redesign &Refinement

Like software development …

Page 4: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

Editors Supporting Development of Structured Documents

http://www.xmlsoftware.com/editors.html

• XML Spy (Altova)

• Xdoc (Microsoft)

• IBM Visual XML Creator (IBM)

• Ark II (JustSYSTEM)

• Proxima (Utrecht)and many …

Page 5: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

Can we develop structured documents in a WYSIWYG

manner? IPL Address Book

Zhenjiang Hu: Assoc. Prof. Shin-Cheng Mu: Post Doc Masato Takeichi: Prof.

Names

Zhenjiang Hu: hu@mist … Shin-Cheng Mu: scm@ipl … Masato Takeichi: takeichi@ …

Addresses

Redesign &Refinement

XML, DTD, XSLT

Derive

Page 6: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

Transformation

Internal Representation IPL Address Book

Zhenjiang Hu: Assoc. Prof. Shin-Cheng Mu: Post Doc Masato Takeichi: Prof.

Names

Zhenjiang Hu: hu@mist Shin-Cheng Mu: scm@ipl Masato Takeichi: takeichi@

Addresses

Zhenjiang Hu:Position: Asso. Prof.Email: [email protected]:03-5841-7411Address: 7-3-1 Hongo, Bunkyo Tokyo 113, JapanWWW: www.ipl.t.u-tokyo.ac.jp

Masato TakeichiPosition: Prof.Email: [email protected]: 03-5841-7430…

Display

Page 7: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

Transformation

IPL Address Book

ZHENJIANG HU: Assoc. Prof. Shin-Cheng Mu: Post Doc Masato Takeichi: Prof.

Names

Zhenjiang Hu: hu@mist Shin-Cheng Mu: scm@ipl Masato Takeichi: takeichi@

Addresses

Zhenjiang Hu:Position: Asso. Prof.Email: [email protected]:03-5841-7411Address: 7-3-1 Hongo, Bunkyo Tokyo 113, JapanWWW: www.ipl.t.u-tokyo.ac.jp

Masato TakeichiPosition: Prof.Email: [email protected]: 03-5841-7430…

DisplayInternal Representation

Page 8: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

Transformation

IPL Address Book

ZHENJIANG HU: Assoc. Prof. Shin-Cheng Mu: Post Doc Masato Takeichi: Prof.

Names

ZHENJIANG HU: hu@mist Shin-Cheng Mu: scm@ipl Masato Takeichi: takeichi@

Addresses

ZHENJIANG HU:Position: Asso. Prof.Email: [email protected]:03-5841-7411Address: 7-3-1 Hongo, Bunkyo Tokyo 113, JapanWWW: www.ipl.t.u-tokyo.ac.jp

Masato TakeichiPosition: Prof.Email: [email protected]: 03-5841-7430…

DisplayInternal Representation

Page 9: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

Transformation

IPL Address Book

ZHENJIANG HU: Assoc. Prof. Shin-Cheng Mu: Post Doc Masato Takeichi: Prof.

Names

ZHENJIANG HU: hu@mist Shin-Cheng Mu: scm@ipl Masato Takeichi: takeichi@

Addresses

ZHENJIANG HU:Position: Asso. Prof.Email: [email protected]:03-5841-7411Address: 7-3-1 Hongo, Bunkyo Tokyo 113, JapanWWW: www.ipl.t.u-tokyo.ac.jp…Masato TakeichiPosition: Prof.Email: [email protected]: 03-5841-7430…

DisplayInternal Representation

3

3

Page 10: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

Source View

editingX

Two issues of concern:-- How to update the source when the view is changed?-- A formal model of the editor?

The Rest of the Talk

Page 11: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

The Rest of the Talk

• Introducing X, the language we use to code XML transformation– allowing duplication– supporting recursive tree traversals

• Overview of the editor– editing data as well as transformation– allowing data dependency and derived

values

Page 12: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

The Bidirectional Transformation Language

X

An extension of the lens language by Greenwald et al With dup, if and fold. [Ref: PLANX2004]

CView AView

View ::= N String [View]

Page 13: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

Semantics

satisfying 2 laws:

GET:PUT:

With each construct x come 2 functions:

Page 14: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

Basic Transformations

CView AView

f

g

CView AViewf

Page 15: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

Sequential Combinator

CView AView Aview’

x1 x2

Page 16: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

Product

Page 17: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

Duplication

Page 18: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

Map and Fold

Page 19: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

Derived Transformation idX and constX

constX f = NFun f

Page 20: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

Derived Transformation exchangeX

a

b

b

a

exX

Page 21: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

Derived Transformation: hoistX

m

hoistX m

Page 22: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

Hole Manipulation

Page 23: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

Bidirectionality

There are two ways to insert a new subtree:

Page 24: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

Coding Editing Operators in X

Page 25: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

Source View

editingX

Page 26: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

The Editor State

The state of the editor is a triple:

satisfying the following SNYC property:

Page 27: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

Actions the User Can Do

remembersdependency

introducetransformation

Page 28: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

General Editing Operators

InsertE p v (c,x,a) = Aa(c,x,insert p v a)

DeleteE p v (c,x,a) = Aa(c,x,delete p v a)

MoveE p1 p2 (c,x,a) = Aa(c,x,move p1 p2 a)

FieldEdit p v (c,x,a) = Aa(c,x,fieldEdit p v a)

Page 29: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

Special Editing Operators

DuplicateE p (c,x,a) = A

cx (c, (x ; applyX p Dup), a)

TransformE p x’ (c,x,a) = A

cx (c, (x ; apply p x’), a)

Page 30: A Programmable Editor for Developing Structured Documents based on Bidirectional Transformations Zhenjiang Hu, Shin-Cheng Mu, Masato Takeichi University

Conclusion

• We proposed a new transformation language with the following features.– It is bidirectional.– It supports duplication and recursive

transformation.

• We applied the language to the design of a new editor for developing structured documents:– Data dependency and local synchronization– Derived values– Efficient implementation of infinite undos