xsugar Dual Syntax for XML Languages - PowerPoint PPT Presentation

1 / 30
About This Presentation
Title:

xsugar Dual Syntax for XML Languages

Description:

Dual Syntax for XML Languages. Claus Brabrand Anders M ller ... Grammar Ambiguity ? Transformation (i.e. ): Information Preservation ? // 'The Big Picture' ... – PowerPoint PPT presentation

Number of Views:55
Avg rating:3.0/5.0
Slides: 31
Provided by: bri60
Category:

less

Transcript and Presenter's Notes

Title: xsugar Dual Syntax for XML Languages


1
xsugarDual Syntax for XML Languages
  • Claus Brabrand Anders Møller
    Michael Schwartzbach
  • brabrand,amoeller,mis_at_brics.dk
  • BRICS, Department of Computer Science
  • University of Aarhus, Denmark

2
// Abstract
xsugar Dual Syntax for XML Languages
XML is successful as a machine processable data
interchange format, but it is often too verbose
for human use. For this reason, many XML
languages permit an alternative more legible
non-XML syntax. XSLT stylesheets are often used
to convert from the XML syntax to the alternative
syntax however, such transformations are not
reversible since no general tool exists to
automatically parse the alternative syntax back
into XML. We present xsugar, which makes it
possible to manage dual syntax for XML languages.
An xsugar specification is built around a
context-free grammar that unifies the two
syntaxes of a language. Given such a
specification, the xsugar tool can translate from
alternative syntax to XML and vice versa.
Moreover, the tool statically checks that the
transformations are reversible and that all XML
documents generated from the alternative syntax
are valid according to a given XML schema.
3
// Outline (3 parts)
  • Validation Analysis
  • DTDs Summary Graphs
  • Schema Languages

Introduction (xsugar)
1
  • Introduction
  • xsugar
  • Syntax and Semantics
  • Unifying Syntax Tree

Assessment
3
  • Teleportation
  • More Examples
  • Related Future Work
  • Assessment
  • Conclusion

Static Analyses
2
  • Reversibility Analysis
  • Info Preservation
  • Unambiguity

4
// Part 1 Introduction
  • Validation Analysis
  • DTDs Summary Graphs
  • Schema Languages

Introduction (xsugar)
1
  • Introduction
  • xsugar
  • Syntax and Semantics
  • Unifying Syntax Tree

Assessment
3
  • Teleportation
  • More Examples
  • Related Future Work
  • Assessment
  • Conclusion

Static Analyses
2
  • Reversibility Analysis
  • Info Preservation
  • Unambiguity

5
// Motivation
  • Relax NG

Relax RNG
Relax RNC
  • RNC-to-RNG
  • Python script (1,478 lines)
  • RNG-to-RNC
  • XSLT stylesheet (894 lines)

Dynamic issues
  • correspondence ?
  • maintenance ?
  • reversibility ?
  • validity (XML) ?
  • termination ?

6
// Motivation (contd)
  • XQuery

XQueryX
XQuery
Dynamic issues
  • XQuery-to-XQueryX
  • Non-existent...!
  • XQueryX-to-XQuery
  • XSLT stylesheet (845 lines)
  • correspondence ?
  • maintenance ?
  • reversibility ?
  • validity (XML) ?
  • termination ?

7
// xsugar
  • One stylesheet produces

s L ? X
X
L
xsugar
Static guarantees
  • L2X
  • Transformation L ? X
  • X2L
  • Reverse transformation X ? L
  • correspondence !
  • maintenance !
  • reversibility !
  • validity (XML) !
  • termination !

8
// Example Transformation
ltstudent id19920539gt ltnamegtClaus
Brabrandlt/namegt ltemailgtbrabrand_at_brics.dklt/emai
lgt lt/studentgt
unparsing
x
transformation
l
parsing
Claus Brabrand (brabrand_at_brics.dk) 19920539
Name n
Email e
Id id
Name ... Email ... Id
0-9 student Name n ( Email e
) Id id \n ltstudent idId idgt
ltnamegtltName ngtlt/namegt
ltemailgtltEmail egtlt/emailgt lt/studentgt
s L ? X
parsing
unparsing
9
// and Reverse Transformation
Id id
Name n
Email e
ltstudent id19920539gt ltnamegtClaus
Brabrandlt/namegt ltemailgtbrabrand_at_brics.dklt/emai
lgt lt/studentgt
parsing
x
reverse transformation
l
unparsing
Claus Brabrand (brabrand_at_brics.dk) 19920539
Name ... Email ... Id
0-9 student Name n ( Email e
) Id id \n ltstudent idId idgt
ltnamegtltName ngtlt/namegt
ltemailgtltEmail egtlt/emailgt lt/studentgt
s L ? X
unparsing
parsing
10
// Unifying Grammar
student Name n ( Email e ) Id id \n
ltstudent idId idgt
ltnamegtltName ngtlt/namegt ltemailgtltEmail
egtlt/emailgt lt/studentgt
G ? N, ?, s, U, ? ?
  • N finite set of unifying nonterminals
  • ? finite alphabet of terminals
  • s ? N start unifying nonterminal
  • U finite set of unification names
  • ? N ? P(E ? E), unifying production
    function, E (N ? U)?? ?

unification 2 right-hand sides
11
// Regular Nonterminal Shorthand
Name ... Email ... Id
0-9 student Name n ( Email e
) Id id \n ...
  • Regular expressions (convenient short-hand) for
    regular nonterminals (w/ identity unification)

Id 0-9
desugaring
id num n id i ltnum ngt ltid
igt num n ltnum ngt
num 0 0
9 9
12
// The Big Picture
  • Reversible ? (i.e. ? )
  • Parsing / Unparsing (i.e. ? )
  • Grammar Ambiguity ?
  • Transformation (i.e. ? )
  • Information Preservation ?

UST
.
.
.
transformation
transformation
1-1?
1-1?
un-/parsing
un-/parsing
1-1/L?
1-1/XML?
L ? X
ASTL / L
ASTX / XML
L
X
1-1
.
Legend
.
1-1
Canonical l ? L
.
.
Ordered tree
.
.
Unordered tree
1-1
Partially Ordered
Canonical x ? X
13
// Part 1 Introduction
  • Validation Analysis
  • DTDs Summary Graphs
  • Schema Languages

Introduction (xsugar)
1
  • Introduction
  • xsugar
  • Syntax and Semantics
  • Unifying Syntax Tree

Assessment
3
  • Teleportation
  • More Examples
  • Related Future Work
  • Assessment
  • Conclusion

Static Analyses
2
  • Reversibility Analysis
  • Info Preservation
  • Unambiguity

14
// Part 2 Static Analyses
  • Validation Analysis
  • DTDs Summary Graphs
  • Schema Languages

Introduction (xsugar)
1
  • Introduction
  • xsugar
  • Syntax and Semantics
  • Unifying Syntax Tree

Assessment
3
  • Teleportation
  • More Examples
  • Related Future Work
  • Assessment
  • Conclusion

Static Analyses
2
  • Reversibility Analysis
  • Grammar Unambiguity
  • Information Preservation

15
// Motivating Example (Ex. contd)
Name (\n Email ,)
Id 0-9 student Name n
( emails es ) Id id \n ltstudent
ididgt ltnamegtltngtlt/namegt ltemailsgtltesgtlt/emails
gt lt/studentgt emails Email e
ltemailgtltegtlt/emailgt Email e ,
emails es ltemailgtltegtlt/emailgt ltesgt
Anders Moeller (amoeller_at_brics.dk,mrmoeller_at_gmail.
com) 19940392
?
ltstudent id19940392gt ltnamegtAnders
Moellerlt/namegt ltemailsgt
ltemailgtamoeller_at_brics.dklt/emailgt
ltemailgtmrmoeller_at_gmail.comlt/emailgt
lt/emailsgt lt/studentgt
16
// Motivating Example (contd2)
Name (\n Email ,)
Id 0-9 student Name n
opt_emails e Id id \n ltstudent
ididgt ltnamegtltngtlt/namegt ltegt lt/studentgt
opt_emails ( email e )
ltegt ( email e , emails es
) ltemailsgtltegtltesgtlt/emailsgt emails
email e ltegt email e ,
emails es ltegtltesgt email
Email e ltemailgtltegtlt/emailgt
17
// Example (contd)
Claus Brabrand (brabrand_at_brics.dk)
19920539 Anders Moeller (amoeller_at_brics.dk,
mrmoeller_at_gmail.com) 19940392 Michael
Schwartzbach 18791398
ltstudent id19920539gt ltnamegtClaus
Brabrandlt/namegt ltemailgtbrabrand_at_brics.dklt/
emailgt lt/studentgt ltstudent
id19940392gt ltnamegtAnders
Moellerlt/namegt ltemailsgt
ltemailgtamoeller_at_brics.dklt/emailgt
ltemailgtmrmoeller_at_gmail.comlt/emailgt
lt/emailsgt lt/studentgt ltstudent id8gt
ltnamegtMichael Schwartzbach 1879139lt/namegt
lt/studentgt
18
// Example (contd)
Claus Brabrand (brabrand_at_brics.dk)
19920539 Anders Moeller (amoeller_at_brics.dk,
mrmoeller_at_gmail.com) 19940392 Michael
Schwartzbach 18791398
ltstudent id19920539gt ltnamegtClaus
Brabrandlt/namegt ltemailgtbrabrand_at_brics.dklt/
emailgt lt/studentgt ltstudent
id19940392gt ltnamegtAnders
Moellerlt/namegt ltemailsgt
ltemailgtamoeller_at_brics.dklt/emailgt
ltemailgtmrmoeller_at_gmail.comlt/emailgt
lt/emailsgt lt/studentgt ltstudent id8gt
ltnamegtMichael Schwartzbach 1879139lt/namegt
lt/studentgt
Ambiguous grammar !
19
// Approximating CFG Ambiguity
.
  • Undecidable ?
  • However!
  • Safe (over-)approximation

.
ASTL / L
L
?
ambiguous
unambiguous
ambiguous
.
.
unambiguous
.
Black-box
(over-)approximation
No?
Yes!
20
// Information Preservation
  • Never throw away or duplicate information
  • i.e. all named arguments must be used exactly
    once!

UST
UST
.
.
.
.
L ? X
L ? X
ASTL / L
ASTL / L
21
// Reversible Stylesheets!
Reversibility (proof)
.
.
1-1 !
1-1 !
1-1 !
1-1 !
un-/parsing
transformation
transformation
un-/parsing
?
xsugar 1-1 !
.
.
.
xsugar 1-1 !
L ? X
ASTL / L
ASTX / XML
L
X
22
// Validation Analysis
  • GivenDTD, D

? l ? L x(l) ? L(D)
?
L(X) ? L(D)
?
SG(X) ? L(D)
Black-box
Static Validation of Dynamically Generated
HTML Claus Brabrand Anders Møller Michael
Schwartzbach PASTE, 2001
23
// Summary Graphs
Id 0-9 Name (\n
Email ,) student Name n
( emails es ) Id id \n ltstudent
ididgt ltnamegtltngtlt/namegt ltemailsgtltesgtlt/emails
gt lt/studentgt emails Email e
ltemailgtltegtlt/emailgt Email e ,
emails es ltemailgtltegtlt/emailgt ltesgt
0-9
(\n
,)
ltstudent id gt ltnamegtlt gtlt/namegt ltemailsgtlt
gtlt/emailsgt lt/studentgt
ltemailgtlt gtlt/emailgt
ltemailgtlt gtlt/emailgt lt gt
SG(X) ? L(D)
Black-box
Static Validation of Dynamically Generated
HTML Claus Brabrand Anders Møller Michael
Schwartzbach PASTE, 2001
24
// Part 2 Static Analyses
  • Validation Analysis
  • DTDs Summary Graphs
  • Schema Languages

Introduction (xsugar)
1
  • Introduction
  • xsugar
  • Syntax and Semantics
  • Unifying Syntax Tree

Assessment
3
  • Teleportation
  • More Examples
  • Related Future Work
  • Assessment
  • Conclusion

Static Analyses
2
  • Reversibility Analysis
  • Grammar Unambiguity
  • Information Preservation

25
// Part 3 Assessment
  • Validation Analysis
  • DTDs Summary Graphs
  • Schema Languages

Introduction (xsugar)
1
  • Introduction
  • xsugar
  • Syntax and Semantics
  • Unifying Syntax Tree

Assessment
3
  • Teleportation
  • More Examples
  • Related Future Work
  • Assessment
  • Conclusion

Static Analyses
2
  • Reversibility Analysis
  • Info Preservation
  • Unambiguity

26
// Related Work
  • XSLT (aka. XSL Stylesheets)
  • However, only one direction
  • Presenting XML

Java web application framework for presenting
HTML, PDF, WML etc., in a device independent
manner.
It aims to achieve a complete separation of
content and presentation.
Relax RNG
Relax RNC
P1
P2
27
// Related Work (contd)
  • Bi-directional Transformation Language for XML
  • Kawanaka Hosoya
  • XML ltgt XML transformations

ltpersongt ltnamegtJohn Doelt/namegt
ltmailgtjohn_at_doe.comlt/mailgt ltphonegt01-2345-6789lt/p
honegt ltphonegt090-2345-6781lt/phonegt lt/persongt
ltcardgt ltnamegtJohn Doelt/namegt
ltemailgtjohn_at_doe.comlt/emailgt lttelgt01-2345-6789lt/t
elgt lttelgt090-2345-6781lt/telgt lt/cardgt
relation personcard
personnamevar x as String,
mailvar y as String, phonevar z
as String
cardnamevar x as String, emailvar y
as String, telvar z as String
28
// Full On-line Implementation
  • Impementation (in Java) 82 K src
  • http//www.brics.dk/xsugar/
  • Google xsugar )
  • On-line demo(!)
  • http//www.brics.dk/xsugar/

29
// Assessment
  • For Relax NG

lines
Static guarantees
  • correspondence ? vs !
  • maintenance ? vs !
  • reversibility ? vs !
  • validity (XML) ? vs !
  • termination ? vs !

Conciseness 1 / 12
30
// Conclusion
  • xsugar Reversible Stylesheets

s L ? X
X
L
xsugar
Static guarantees
  • L2X
  • Stylesheet L ? X
  • X2L
  • Reverse stylesheet X ? L
  • correspondence !
  • maintenance !
  • reversibility !
  • validity (XML) !
  • termination !

31
lt presentation gt
/
  • Questions please
Write a Comment
User Comments (0)
About PowerShow.com