x sugar dual syntax for xml languages
Download
Skip this Video
Download Presentation
xsugar: Dual Syntax for XML Languages

Loading in 2 Seconds...

play fullscreen
1 / 30

xsugar: Dual Syntax for XML Languages - PowerPoint PPT Presentation


  • 293 Views
  • Uploaded on

BRICS, Department of Computer Science. University of Aarhus, Denmark. 2 ... XML is successful as a machine processable data interchange format, but it is ...

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'xsugar: Dual Syntax for XML Languages' - Kelvin_Ajay


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
x sugar dual syntax for xml languages

xsugarDual Syntax for XML Languages

Claus Brabrand Anders Møller Michael Schwartzbach

{brabrand,amoeller,mis}@brics.dk

BRICS, Department of Computer Science

University of Aarhus, Denmark

outline 3 parts
Introduction

xsugar

Syntax and Semantics

Unifying Syntax Tree

Validation Analysis

DTDs & Summary Graphs

Schema Languages

// Outline (3 parts)

Introduction (xsugar)

1

Assessment

3

Teleportation

More Examples

Related & Future Work

Assessment

Conclusion

Static Analyses

2

  • Reversibility Analysis
    • Info Preservation
    • Unambiguity
part 1 introduction
Validation Analysis

DTDs & Summary Graphs

Schema Languages

Introduction

xsugar

Syntax and Semantics

Unifying Syntax Tree

// Part 1: Introduction

Introduction (xsugar)

1

Assessment

3

Teleportation

More Examples

Related & Future Work

Assessment

Conclusion

Static Analyses

2

  • Reversibility Analysis
    • Info Preservation
    • Unambiguity
motivation
// Motivation
  • Relax NG:

Relax RNC

Relax RNG

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

Dynamic issues:

  • correspondence ?
  • maintenance ?
  • reversibility ?
  • validity (XML) ?
  • termination ?
motivation cont d
// Motivation (cont’d)
  • XQuery:

XQuery

XQueryX

Dynamic issues:

  • XQuery-to-XQueryX:
      • Non-existent...!
  • XQueryX-to-XQuery:
      • XSLT stylesheet (845 lines)
  • correspondence ?
  • maintenance ?
  • reversibility ?
  • validity (XML) ?
  • termination ?
x sugar
// xsugar
  • One stylesheet produces:

s : L X

L

X

xsugar

Static guarantees:

  • L2X:
      • Transformation: LX
  • X2L:
      • Reverse transformation: XL
  • correspondence !
  • maintenance !
  • reversibility !
  • validity (XML) !
  • termination !
example transformation
// Example: Transformation…

<student id=“19920539”>

<name>Claus Brabrand</name>

<email>[email protected]</email>

</student>

unparsing

x:

transformation

l :

parsing

Claus Brabrand ([email protected]) 19920539

[Name n]

[Email e]

[Id id]

Name= { ... }

Email= { ... }

Id= { [0-9]+ }

student: [Name n] ( [Emaile] ) [Id id] \n = {

<student id=[Id id]>

<name><[Namen]></name>

<email><[Email e]></email>

</student>

}

s: L X

parsing

unparsing

and reverse transformation
// …and Reverse Transformation

[Id id]

[Name n]

[Email e]

<student id=“19920539”>

<name>Claus Brabrand</name>

<email>brabra[email protected]</email>

</student>

parsing

x:

reverse transformation

l :

unparsing

Claus Brabrand ([email protected]) 19920539

Name= { ... }

Email= { ... }

Id= { [0-9]+ }

student: [Name n] ( [Emaile] ) [Id id] \n = {

<student id=[Id id]>

<name><[Namen]></name>

<email><[Email e]></email>

</student>

}

s: L X

unparsing

parsing

unifying grammar
// Unifying Grammar

student: [Name n] ( [Emaile] ) [Id id] \n = {

<student id=[Idid]>

<name><[Name n]></name>

<email><[Emaile]></email>

</student>

}

  • 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) 

G =  N, , s, U,  

unification:

2 right-hand sides

regular nonterminal shorthand
// Regular Nonterminal Shorthand

Name= { ... }

Email= { ... }

Id= { [0-9]+ }

student: [Name n] ( [Emaile] ) [Id id] \n = {

...

}

  • Regular expressions (convenient short-hand) for regular nonterminals (w/ identity unification):

Id={ [0-9]+ }

desugaring

id: [numn] [idi] = { <[num n]><[idi]> }

: [numn] = { <[num n]> }

num : 0 = { 0 }

: 9 = { 9 }

the big picture
// “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

part 1 introduction12
Validation Analysis

DTDs & Summary Graphs

Schema Languages

Introduction

xsugar

Syntax and Semantics

Unifying Syntax Tree

// Part 1: Introduction

Introduction (xsugar)

1

Assessment

3

Teleportation

More Examples

Related & Future Work

Assessment

Conclusion

Static Analyses

2

  • Reversibility Analysis
    • Info Preservation
    • Unambiguity
part 2 static analyses
Introduction

xsugar

Syntax and Semantics

Unifying Syntax Tree

Validation Analysis

DTDs & Summary Graphs

Schema Languages

// Part 2: Static Analyses

Introduction (xsugar)

1

Assessment

3

Teleportation

More Examples

Related & Future Work

Assessment

Conclusion

Static Analyses

2

  • Reversibility Analysis
    • Grammar Unambiguity
    • Information Preservation
motivating example ex cont d
// Motivating Example (Ex. cont’d)

Name= { [^(\n]+ }

Email= { [^,) ]+ }

Id={ [0-9]+ }

student: [Name n] ( [emailses] ) [Id id] \n = {

<student id=[id]> <name><[n]></name> <emails><[es]></emails> </student>

}

emails:[Emaile]= {<email><[e]></email>}

:[Emaile] , [emailses]= { <email><[e]></email> <[es]>}

Anders Moeller ([email protected],[email protected]) 19940392

<student id=“19940392”>

<name>Anders Moeller</name>

<emails>

<email>[email protected]</email>

<email>[email protected]</email>

</emails>

</student>

motivating example cont d 2
// Motivating Example (cont’d2)

Name= { [^(\n]+ }

Email= { [^,) ]+ }

Id={ [0-9]+ }

student: [Name n][opt_emailse][Id id] \n = {

<student id=[id]> <name><[n]></name> <[e]> </student>

}

opt_emails: = {}

: ( [email e] ) = {<[e]>}

: ( [email e] , [emails es] ) = {<emails><[e]><[es]></emails>}

emails:[emaile]= {<[e]>}

:[emaile] , [emails es]= { <[e]><[es]>}

email:[Emaile]= {<email><[e]></email>}

example cont d
// Example (cont’d)

Claus Brabrand ([email protected]) 19920539

Anders Moeller ([email protected], [email protected]) 19940392

Michael Schwartzbach 18791398

<student id=“19920539”>

<name>Claus Brabrand</name>

<email>[email protected]</email>

</student>

<student id=“19940392”>

<name>Anders Moeller</name>

<emails>

<email>[email protected]</email>

<email>[email protected]</email>

</emails>

</student>

<student id=“8”>

<name>Michael Schwartzbach 1879139</name>

</student>

example cont d17
// Example (cont’d)

Claus Brabrand ([email protected]) 19920539

Anders Moeller ([email protected], [email protected]) 19940392

Michael Schwartzbach 18791398

<student id=“19920539”>

<name>Claus Brabrand</name>

<email>[email protected]</email>

</student>

<student id=“19940392”>

<name>Anders Moeller</name>

<emails>

<email>[email protected]</email>

<email>[email protected]</email>

</emails>

</student>

<student id=“8”>

<name>Michael Schwartzbach 1879139</name>

</student>

Ambiguous grammar !

approximating cfg ambiguity
// Approximating CFG Ambiguity

.

  • Undecidable?:
  • However…!:
    • :
      • Safe (over-)approximation:

.

ASTL / ~L

L

?

ambiguous

unambiguous

ambiguous

.

.

unambiguous

.

Black-box

(over-)approximation

No?

Yes!

information preservation
// 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

reversible stylesheets

.

// Reversible Stylesheets!

Reversibility (proof):

.

.

1-1 !

1-1 !

1-1 !

1-1 !

un-/parsing

un-/parsing

transformation

transformation

xsugar1-1 !

.

xsugar: 1-1 !

.

.

L  X

ASTL / ~L

ASTX / ~XML

L

X

validation analysis
// 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

summary graphs
// Summary Graphs

Id={ [0-9]+ }

Name= { [^(\n]+ }

Email= { [^,) ]+ }

student: [Name n] ( [emailses] ) [Id id] \n = {

<student id=[id]> <name><[n]></name> <emails><[es]></emails> </student>

}

emails:[Emaile]= {<email><[e]></email>}

:[Emaile] , [emails es]= { <email><[e]></email> <[es]>}

[0-9]+

[^(\n]+

[^,) ]+

<student id=[]> <name><[]></name> <emails><[]></emails> </student>

<email><[]></email>

<email><[]></email> <[ ]>

SG(X)  L(D)

Black-box

“Static Validation of Dynamically Generated HTML”

[ Claus Brabrand | Anders Møller | Michael Schwartzbach ]

PASTE, 2001

part 2 static analyses23
Introduction

xsugar

Syntax and Semantics

Unifying Syntax Tree

Validation Analysis

DTDs & Summary Graphs

Schema Languages

// Part 2: Static Analyses

Introduction (xsugar)

1

Assessment

3

Teleportation

More Examples

Related & Future Work

Assessment

Conclusion

Static Analyses

2

  • Reversibility Analysis
    • Grammar Unambiguity
    • Information Preservation
part 3 assessment
Validation Analysis

DTDs & Summary Graphs

Schema Languages

Introduction

xsugar

Syntax and Semantics

Unifying Syntax Tree

// Part 3: Assessment

Introduction (xsugar)

1

Assessment

3

Teleportation

More Examples

Related & Future Work

Assessment

Conclusion

Static Analyses

2

  • Reversibility Analysis
    • Info Preservation
    • Unambiguity
related work
// 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 RNC

Relax RNG

P1

P2

related work cont d
// Related Work (cont’d)
  • “Bi-directional Transformation Language for XML”
    • [Kawanaka & Hosoya]
      • XML <=> XML transformations:

<person>

<name>John Doe</name>

<mail>[email protected]</mail>

<phone>01-2345-6789</phone>

<phone>090-2345-6781</phone>

</person>

<card>

<name>John Doe</name>

<email>[email protected]</email>

<tel>01-2345-6789</tel>

<tel>090-2345-6781</tel>

</card>

relation personcard =

person[name[var x as String],

mail[var y as String]*,

phone[var z as String]*]

card[name[var x as String],

email[var y as String]*,

tel[var z as String]*]

full on line implementation
// 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/]
assessment
// Assessment

For “Relax NG”:

lines

Static guarantees:

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

Conciseness: [1/12+]

conclusion
// Conclusion
  • xsugar: Reversible Stylesheets

s : L X

L

X

xsugar

Static guarantees:

  • L2X:
      • Stylesheet: LX
  • X2L:
      • Reverse stylesheet: XL
  • correspondence !
  • maintenance !
  • reversibility !
  • validity (XML) !
  • termination !
presentation

< presentation >

/

Questions please…

ad