X sugar dual syntax for xml languages
Download
1 / 30

xsugar: Dual Syntax for XML Languages - PowerPoint PPT Presentation


  • 294 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 l.jpg

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 l.jpg

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 l.jpg

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 l.jpg
// 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 l.jpg
    // 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 l.jpg
    // 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 l.jpg
    // Example: Transformation…

    <student id=“19920539”>

    <name>Claus Brabrand</name>

    <email>brabrand@brics.dk</email>

    </student>

    unparsing

    x:

    transformation

    l :

    parsing

    Claus Brabrand (brabrand@brics.dk) 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 l.jpg
    // …and Reverse Transformation

    [Id id]

    [Name n]

    [Email e]

    <student id=“19920539”>

    <name>Claus Brabrand</name>

    <email>brabrand@brics.dk</email>

    </student>

    parsing

    x:

    reverse transformation

    l :

    unparsing

    Claus Brabrand (brabrand@brics.dk) 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 l.jpg
    // 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 l.jpg
    // 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 l.jpg
    // “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 l.jpg

    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 l.jpg

    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 l.jpg
    // 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 (amoeller@brics.dk,mrmoeller@gmail.com) 19940392

    <student id=“19940392”>

    <name>Anders Moeller</name>

    <emails>

    <email>amoeller@brics.dk</email>

    <email>mrmoeller@gmail.com</email>

    </emails>

    </student>


    Motivating example cont d 2 l.jpg
    // 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 l.jpg
    // Example (cont’d)

    Claus Brabrand (brabrand@brics.dk) 19920539

    Anders Moeller (amoeller@brics.dk, mrmoeller@gmail.com) 19940392

    Michael Schwartzbach 18791398

    <student id=“19920539”>

    <name>Claus Brabrand</name>

    <email>brabrand@brics.dk</email>

    </student>

    <student id=“19940392”>

    <name>Anders Moeller</name>

    <emails>

    <email>amoeller@brics.dk</email>

    <email>mrmoeller@gmail.com</email>

    </emails>

    </student>

    <student id=“8”>

    <name>Michael Schwartzbach 1879139</name>

    </student>


    Example cont d17 l.jpg
    // Example (cont’d)

    Claus Brabrand (brabrand@brics.dk) 19920539

    Anders Moeller (amoeller@brics.dk, mrmoeller@gmail.com) 19940392

    Michael Schwartzbach 18791398

    <student id=“19920539”>

    <name>Claus Brabrand</name>

    <email>brabrand@brics.dk</email>

    </student>

    <student id=“19940392”>

    <name>Anders Moeller</name>

    <emails>

    <email>amoeller@brics.dk</email>

    <email>mrmoeller@gmail.com</email>

    </emails>

    </student>

    <student id=“8”>

    <name>Michael Schwartzbach 1879139</name>

    </student>

    Ambiguous grammar !


    Approximating cfg ambiguity l.jpg
    // Approximating CFG Ambiguity

    .

    • Undecidable?:

    • However…!:

      • :

        • Safe (over-)approximation:

    .

    ASTL / ~L

    L

    ?

    ambiguous

    unambiguous

    ambiguous

    .

    .

    unambiguous

    .

    Black-box

    (over-)approximation

    No?

    Yes!


    Information preservation l.jpg
    // 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 l.jpg

    .

    // 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 l.jpg
    // 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 l.jpg
    // 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 l.jpg

    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 l.jpg

    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 l.jpg
    // 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 l.jpg
    // Related Work (cont’d)

    • “Bi-directional Transformation Language for XML”

      • [Kawanaka & Hosoya]

        • XML <=> XML transformations:

    <person>

    <name>John Doe</name>

    <mail>john@doe.com</mail>

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

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

    </person>

    <card>

    <name>John Doe</name>

    <email>john@doe.com</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 l.jpg
    // 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 l.jpg
    // Assessment

    For “Relax NG”:

    lines

    Static guarantees:

    • correspondence ? vs !

    • maintenance ? vs !

    • reversibility ? vs !

    • validity (XML) ? vs !

    • termination ? vs !

    Conciseness: [1/12+]


    Conclusion l.jpg
    // 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 l.jpg

    < presentation >

    /

    Questions please…