1 / 30

xsugar: Dual Syntax for XML Languages

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

Kelvin_Ajay
Download Presentation

xsugar: Dual Syntax for XML Languages

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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

  2. 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

  3. 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

  4. // 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 ?

  5. // 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 ?

  6. // 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 !

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

  8. // …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

  9. // 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

  10. // 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 }

  11. // “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

  12. 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

  13. 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

  14. // 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>

  15. // 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>}

  16. // 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>

  17. // 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 !

  18. // Approximating CFG Ambiguity . • Undecidable?: • However…!: • : • Safe (over-)approximation: . ASTL / ~L L ? ambiguous unambiguous ambiguous . . unambiguous . Black-box (over-)approximation No? Yes!

  19. // 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

  20. . // 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

  21. // 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

  22. // 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

  23. 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

  24. 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

  25. // 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

  26. // 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]*]

  27. // 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/]

  28. // Assessment For “Relax NG”: lines Static guarantees: • correspondence ? vs ! • maintenance ? vs ! • reversibility ? vs ! • validity (XML) ? vs ! • termination ? vs ! Conciseness: [1/12+]

  29. // 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 !

  30. < presentation > / Questions please…

More Related