Domain Specific Languages for Interactive Web Services - PowerPoint PPT Presentation

1 / 149
About This Presentation
Title:

Domain Specific Languages for Interactive Web Services

Description:

Increasingly, HTML/XML documents on the Web are dynamically generated by ... We also show how to augment XHTML documents with form-field validation through ... – PowerPoint PPT presentation

Number of Views:175
Avg rating:3.0/5.0
Slides: 150
Provided by: claus151
Category:

less

Transcript and Presenter's Notes

Title: Domain Specific Languages for Interactive Web Services


1
Domain Specific Languagesfor Interactive Web
Services
  • Claus Brabrand
  • Joint work with Anders Møller, Michael
    Schwartzbach, BRICS, Denmark
  • Compose Research Group
  • INRIA/LaBRI, University of Bordeaux I

2
Abstract
Increasingly, HTML/XML documents on the Web are
dynamically generated by embedded server-side
scripting languages, such as PHP, ASP, and JSP.
However, this has five serious limitations it
forces linear document construction, intermixes
designer/programmer aspects, yields implicit
control-flow, prevents static XML validation, and
precludes caching. This talk presents a
flexible, safe, and efficient language for
dynamically generating XML documents that solves
the above problems. We also show how to augment
XHTML documents with form-field validation
through declarative specifications. More
information The ltbigwiggt Project http//www.bric
s.dk/bigwig/
3
Outline
  • Introduction (Program Family)
  • Session Management
  • State Management
  • Document Construction
  • Domain Specific Verifications
  • Domain Specific Optimization
  • Form-Field Validation
  • Conclusion

4
Outline
  • Introduction (Program Family)
  • Session Management
  • State Management
  • Document Construction
  • Domain Specific Verifications
  • Domain Specific Optimization
  • Form-Field Validation
  • Conclusion

5
Program Family
Interactive (Form-Based) Web Services
Web servers on which clients can initiate
sessions that involve several exchanges of
information mediated by HTML forms.
client
server
Internet
6
A Program from the Program Family
Java Servlet
public class SessionServlet extends HttpServlet
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws
ServletException, IOException
ServletContext context getServletContext()
HttpSession session request.getSession(true)
response.setContentType("text/html")
PrintWriter out response.getWriter()
out.println("ltHTMLgtltHEADgtltTITLEgtServlet
Demolt/TITLEgtlt/HEADgtltBODYgt") if
(session.isNew()) out.println("ltFORM
ACTIONSessionServletgt" "Enter your name
ltINPUT NAMEhandlegt" "ltINPUT
TYPESUBMITgtlt/FORMgt") session.putValue("sta
te", "1") else String state
(String) session.getValue("state") if
(state.equals("1")) String name
(String) request.getParameter("handle")
int users ((Integer) context.getAttribute("users
")).intValue() 1 context.setAttribute("
users", new Integer(users))
session.putValue("name", name)
out.println("Hello " name ", you are user
number " users) session.putValue("state
", "2") else / state.equals("2") /
String name (String) session.getValue("nam
e") out.println("Goodbye " name)
session.invalidate()
out.println("lt/BODYgtlt/HTMLgt")
7
A Program from the Program Family
Web Service
CLIENT INTERNET
SERVER
8
A Program from the Program Family
Java Servlet
public class SessionServlet extends HttpServlet
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws
ServletException, IOException
ServletContext context getServletContext()
HttpSession session request.getSession(true)
response.setContentType("text/html")
PrintWriter out response.getWriter()
out.println("ltHTMLgtltHEADgtltTITLEgtServlet
Demolt/TITLEgtlt/HEADgtltBODYgt") if
(session.isNew()) out.println("ltFORM
ACTIONSessionServletgt" "Enter your name
ltINPUT NAMEhandlegt" "ltINPUT
TYPESUBMITgtlt/FORMgt") session.putValue("sta
te", "1") else String state
(String) session.getValue("state") if
(state.equals("1")) String name
(String) request.getParameter("handle")
int users ((Integer) context.getAttribute("users
")).intValue() 1 context.setAttribute("
users", new Integer(users))
session.putValue("name", name)
out.println("Hello " name ", you are user
number " users) session.putValue("state
", "2") else / state.equals("2") /
String name (String) session.getValue("nam
e") out.println("Goodbye " name)
session.invalidate()
out.println("lt/BODYgtlt/HTMLgt")
session management
9
A Program from the Program Family
Java Servlet
public class SessionServlet extends HttpServlet
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws
ServletException, IOException
ServletContext context getServletContext()
HttpSession session request.getSession(true)
response.setContentType("text/html")
PrintWriter out response.getWriter()
out.println("ltHTMLgtltHEADgtltTITLEgtServlet
Demolt/TITLEgtlt/HEADgtltBODYgt") if
(session.isNew()) out.println("ltFORM
ACTIONSessionServletgt" "Enter your name
ltINPUT NAMEhandlegt" "ltINPUT
TYPESUBMITgtlt/FORMgt") session.putValue("sta
te", "1") else String state
(String) session.getValue("state") if
(state.equals("1")) String name
(String) request.getParameter("handle")
int users ((Integer) context.getAttribute("users
")).intValue() 1 context.setAttribute("
users", new Integer(users))
session.putValue("name", name)
out.println("Hello " name ", you are user
number " users) session.putValue("state
", "2") else / state.equals("2") /
String name (String) session.getValue("nam
e") out.println("Goodbye " name)
session.invalidate()
out.println("lt/BODYgtlt/HTMLgt")
state management
10
A Program from the Program Family
Java Servlet
public class SessionServlet extends HttpServlet
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws
ServletException, IOException
ServletContext context getServletContext()
HttpSession session request.getSession(true)
response.setContentType("text/html")
PrintWriter out response.getWriter()
out.println("ltHTMLgtltHEADgtltTITLEgtServlet
Demolt/TITLEgtlt/HEADgtltBODYgt") if
(session.isNew()) out.println("ltFORM
ACTIONSessionServletgt" "Enter your name
ltINPUT NAMEhandlegt" "ltINPUT
TYPESUBMITgtlt/FORMgt") session.putValue("sta
te", "1") else String state
(String) session.getValue("state") if
(state.equals("1")) String name
(String) request.getParameter("handle")
int users ((Integer) context.getAttribute("users
")).intValue() 1 context.setAttribute("
users", new Integer(users))
session.putValue("name", name)
out.println("Hello " name ", you are user
number " users) session.putValue("state
", "2") else / state.equals("2") /
String name (String) session.getValue("nam
e") out.println("Goodbye " name)
session.invalidate()
out.println("lt/BODYgtlt/HTMLgt")
document construction
11
A Program from the Program Family
Java Servlet
public class SessionServlet extends HttpServlet
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws
ServletException, IOException
ServletContext context getServletContext()
HttpSession session request.getSession(true)
response.setContentType("text/html")
PrintWriter out response.getWriter()
out.println("ltHTMLgtltHEADgtltTITLEgtServlet
Demolt/TITLEgtlt/HEADgtltBODYgt") if
(session.isNew()) out.println("ltFORM
ACTIONSessionServletgt" "Enter your name
ltINPUT NAMEhandlegt" "ltINPUT
TYPESUBMITgtlt/FORMgt") session.putValue("sta
te", "1") else String state
(String) session.getValue("state") if
(state.equals("1")) String name
(String) request.getParameter("handle")
int users ((Integer) context.getAttribute("users
")).intValue() 1 context.setAttribute("
users", new Integer(users))
session.putValue("name", name)
out.println("Hello " name ", you are user
number " users) session.putValue("state
", "2") else / state.equals("2") /
String name (String) session.getValue("nam
e") out.println("Goodbye " name)
session.invalidate()
out.println("lt/BODYgtlt/HTMLgt")
12
A Program from the Program Family
Java Servlet
public class SessionServlet extends HttpServlet
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws
ServletException, IOException
ServletContext context getServletContext()
HttpSession session request.getSession(true)
response.setContentType("text/html")
PrintWriter out response.getWriter()
out.println("ltHTMLgtltHEADgtltTITLEgtServlet
Demolt/TITLEgtlt/HEADgtltBODYgt") if
(session.isNew()) out.println("ltFORM
ACTIONSessionServletgt" "Enter your name
ltINPUT NAMEhandlegt" "ltINPUT
TYPESUBMITgtlt/FORMgt") session.putValue("sta
te", "1") else String state
(String) session.getValue("state") if
(state.equals("1")) String name
(String) request.getParameter("handle")
int users ((Integer) context.getAttribute("users
")).intValue() 1 context.setAttribute("
users", new Integer(users))
session.putValue("name", name)
out.println("Hello " name ", you are user
number " users) session.putValue("state
", "2") else / state.equals("2") /
String name (String) session.getValue("nam
e") out.println("Goodbye " name)
session.invalidate()
out.println("lt/BODYgtlt/HTMLgt")
13
The ltbigwiggt Language/System
  • A high-level domain-specific programming language
    for developing interactive Web services.

HTML
JavaScript
Complete Service Specification
ltbigwiggt
CGI Scripts
HTTP Auth.
Java Applets
14
ltbigwiggt a Collection ofDomain Specific
Languages
  • C-like core language with
  • Session-based runtime system
  • Dynamic documents
  • Form-field validation
  • Relational database
  • Concurrency control
  • Semantic security
  • Cryptographic security
  • Syntactic-level macros

15
ltbigwiggt a Collection ofDomain Specific
Languages
  • C-like core language with
  • Session-based runtime system
  • Dynamic documents
  • Form-field validation
  • Relational database
  • Concurrency control
  • Semantic security
  • Cryptographic security
  • Syntactic-level macros

16
Outline
  • Introduction (Program Family)
  • Session Management
  • State Management
  • Document Construction
  • Domain Specific Verifications
  • Domain Specific Optimization
  • Form-Field Validation
  • Conclusion

17
Outline
  • Introduction (Program Family)
  • Session Management
  • State Management
  • Document Construction
  • Domain Specific Verifications
  • Domain Specific Optimization
  • Form-Field Validation
  • Conclusion

18
Implementation Approaches
  • Traditionally 2 approaches
  • Script-centered
  • Perl/CGI, Java Servlets,
  • Page-centered
  • ASP, PHP, JSP, ...

19
Script-CenteredPerl/CGI, Servlets, ...
e
Web Service
CLIENT INTERNET
SERVER
20
Script-CenteredPerl/CGI, Servlets, ...
e
request
Web Service
CLIENT INTERNET
SERVER
21
Script-CenteredPerl/CGI, Servlets, ...
e
compute reply
Web Service
CLIENT INTERNET
SERVER
22
Script-CenteredPerl/CGI, Servlets, ...
e
HTML
e
Web Service
CLIENT INTERNET
SERVER
23
Script-CenteredPerl/CGI, Servlets, ...
e
e
submit
Web Service
CLIENT INTERNET
SERVER
24
Script-CenteredPerl/CGI, Servlets, ...
e
e
Web Service
compute reply
CLIENT INTERNET
SERVER
25
Script-CenteredPerl/CGI, Servlets, ...
e
e
Web Service
HTML
e
CLIENT INTERNET
SERVER
26
Page-CenteredPHP, ASP, JSP, ...
e
e
Web Service
e
CLIENT INTERNET
SERVER
27
Page-Centered
Service code embedded in tags and interpreted
by specialized Web server
  • Increased level of abstraction
  • CGI protocol details abstracted away
  • Easy to add dynamics to static pages
  • Scalability
  • Specialized Web server

lthtmlgtltbodygtTime lt Now() gtlt/bodygtlt/htmlgt
lt Now() gt
28
Script-Centered vs. Page-Centered
  • As the service complexity increases
  • Page-Centered ? Script-Centered
  • A lot of HTML is generated by script elements
  • Interesting duality
  • Script-centered
  • Default programming, Escape printing (print)
  • Page-centered
  • Default printing, Escape programming
    (lt...gt)

29
Fundamental Drawbacks
  • A service a collection of scripts/pages!
  • Implicit control-flow
  • No interaction correspondence

ltinput namexgt
lt y gt
submit
a_script
another_script
30
Session-CenteredMawl and ltbigwiggt!
e
Web Service
x
e
show x
submit
y
e
show y
CLIENT INTERNET
SERVER
31
Session-CenteredMawl and ltbigwiggt!
e
Web Service
x
e
show x
submit
  • Domain specific abstration show
  • Explicit control-flow
  • Check interaction correspondence

show y
32
Outline
  • Introduction (Program Family)
  • Session Management
  • State Management
  • Document Construction
  • Domain Specific Verifications
  • Domain Specific Optimization
  • Form-Field Validation
  • Conclusion

33
Outline
  • Introduction (Program Family)
  • Session Management
  • State Management
  • Document Construction
  • Domain Specific Verifications
  • Domain Specific Optimization
  • Form-Field Validation
  • Conclusion

34
General Purpose ? Manually
e
e
Web Service
e
CLIENT INTERNET
SERVER
35
General Purpose ? Manually
e
save
e
Web Service
e
CLIENT INTERNET
SERVER
36
General Purpose ? Manually
e
save
e
restore
Web Service
e
CLIENT INTERNET
SERVER
37
General Purpose ? Manually
  • Private (to each session thread)

ServletContext context getServletContext()int
p ((Integer) context.getAttribute("p")
).intValue() p context.setAttribute("p", new
Integer(var))
38
General Purpose ? Manually
  • Private (to each session thread)
  • Shared (among all session threads)

ServletContext context getServletContext()int
p ((Integer) context.getAttribute("p")
).intValue() p context.setAttribute("p", new
Integer(var))
HttpSession session request.getSession(true) in
t s ((Integer) session.getValue("s")).
intValue() ssession.setValue("s", new
Integer(var))
39
Domain Specific shared modifier
  • Private (to each session thread)

int p ... p ...
40
Domain Specific shared modifier
  • Private (to each session thread)
  • Shared (among all session threads)

int p ... p ...
shared int s ... s ...
41
Domain Specific ? Automatically
e
Web Service
save restore
x
e
show x
submit
y
e
show y
CLIENT INTERNET
SERVER
42
Outline
  • Introduction (Program Family)
  • Session Management
  • State Management
  • Document Construction
  • Domain Specific Verifications
  • Domain Specific Optimization
  • Form-Field Validation
  • Conclusion

43
Outline
  • Introduction (Program Family)
  • Session Management
  • State Management
  • Document Construction
  • Domain Specific Verifications
  • Domain Specific Optimization
  • Form-Field Validation
  • Conclusion

44
Dynamically Generated XMLCurrent Problems
  • Traditionally
  • print(...) in Perl/CGI, ...
  • lt print(...) gt in PHP, ASP, JSP, ...
  • Problems
  • Forces linear document construction
  • Intermixes programmer / designer aspects
  • No interaction correspondence
  • No static XML validation
  • No common fragments caching

45
Our SolutionHTML documents in ltbigwiggt
  • Templates (1st class, higher-order values)
  • XML fragments with named gaps
  • Operations
  • plug for document construction
  • show for client interaction

Hello ltwhatgt!
46
Plug
  • Plug exp lt id exp

47
Plug
  • Plug exp lt id exp
  • Example

html hello Hello ltwhatgt! html world
ltbgtWorldlt/bgt html h hello ltwhat
world ...
48
Show
  • Show show exp

x
e
suspend
show x
resume
submit
CLIENT INTERNET SERVER
49
Show
  • Show show exp
  • Example

x
e
suspend
show x
resume
submit
CLIENT INTERNET SERVER
html hello Hello ltwhatgt! html world
ltbgtWorldlt/bgt html h hello ltwhat
world show h
50
Show-Receive
  • Show show exp receivev f, ...

x
e
show x receivevf,..
submit
f, ...
CLIENT INTERNET SERVER
51
Show-Receive
  • Show show exp receivev f, ...
  • Example

x
e
show x receivevf,..
submit
f, ...
CLIENT INTERNET SERVER
string s html input Enter email ltinput
typetext nameemailgt show input
receives email
52
Example Welcome
html greeting Hello ltwhogt, welcome to
ltwhatgt. html cover
ltheadgtlttitlegtWelcomelt/titlegtlt/headgt
ltbodygtltcontentsgtlt/bodygt html h h
greeting ltwho Stranger h h ltwhat
ltbgtGPCElt/bgt show cover ltcontents h
53
Flexibility PHP/ASP/JSP
  • List of results (e.g. search engine)
  • One template with 10,20,30, or 40 hardwired
    server-sidescript elements
  • One template with one big generate-all
    server-side script element ? script-centered

lt ..1.. gt
lt ..2.. gt

...or...
lt ..20.. gt
lt for i1 to N do ..i.. gt
54
Flexibility ltbigwiggt
ltulgt ltligt1 ltligt2 ltligtN lt/ulgt
  • List of results (e.g. search engine)

55
Flexibility ltbigwiggt
ltulgt ltligt1 ltligt2 ltligtN lt/ulgt
  • List of results (e.g. search engine)
  • Two templates layout and entry...

html layout ltulgtltitemsgtlt/ulgt html
entry ltligtltnumgtltitemsgt
56
Flexibility ltbigwiggt
ltulgt ltligt1 ltligt2 ltligtN lt/ulgt
  • List of results (e.g. search engine)
  • Two templates layout and entry...
  • ...and one recursive function f

html layout ltulgtltitemsgtlt/ulgt html
entry ltligtltnumgtltitemsgt
html f(int n) if (n 0) return layout
return f(n-1) ltitems entry ltnum n
57
Flexibility ltbigwiggt
ltulgt ltligt1 ltligt2 ltligt27 lt/ulgt
  • List of results (e.g. search engine)
  • Two templates layout and entry...
  • ...and one recursive function f
  • Example usage

html layout ltulgtltitemsgtlt/ulgt html
entry ltligtltnumgtltitemsgt
html f(int n) if (n 0) return layout
return f(n-1) ltitems entry ltnum n
show f(27)
58
Flexibility Separates Designer / Programmer
Aspects
html layout ltulgtltitemsgtlt/ulgt html
entry ltligtltnumgtltitemsgt
html f(int n) if (n 0) return layout
return f(n-1) ltitems entry ltnum n
59
Flexibility Separates Designer / Programmer
Aspects
html layout ltulgtltitemsgtlt/ulgt html
entry ltligtltnumgtltitemsgt
html layout lttablegtltitemsgtlt/tablegt
html entry lttrgtlttdgtltnumgtlt/tdgtlt/trgt
ltitemsgt
html f(int n) if (n 0) return layout
return f(n-1) ltitems entry ltnum n
60
Problems?
  • DynDoc
  • Templates with named gaps
  • Plug and show
  • Problems
  • Forces linear document construction
  • Intermixes programmer / designer aspects
  • No interaction correspondence
  • No static XML validation
  • No common fragments caching

61
Problems?
  • DynDoc
  • Templates with named gaps
  • Plug and show
  • Problems
  • Forces linear document construction
  • Intermixes programmer / designer aspects
  • No interaction correspondence
  • No static XML validation
  • No common fragments caching

62
Problems?
  • DynDoc
  • Templates with named gaps
  • Plug and show
  • Problems
  • Forces linear document construction
  • Intermixes programmer / designer aspects
  • No interaction correspondence
  • No static XML validation
  • No common fragments caching

63
Problems?
  • DynDoc
  • Templates with named gaps
  • Plug and show
  • Problems
  • Forces linear document construction
  • Intermixes programmer / designer aspects
  • No interaction correspondence
  • No static XML validation
  • No common fragments caching

64
Problems?
  • Problems
  • Forces linear document construction
  • Intermixes programmer / designer aspects
  • No interaction correspondence
  • No static XML validation
  • No common fragments caching

ltinput namexgt
lt y gt
submit
a_script
another_script
65
Outline
  • Introduction (Program Family)
  • Session Management
  • State Management
  • Document Construction
  • Domain Specific Verifications
  • Domain Specific Optimization
  • Form-Field Validation
  • Conclusion

66
Outline
  • Introduction (Program Family)
  • Session Management
  • State Management
  • Document Construction
  • Domain Specific Verifications
  • Domain Specific Optimization
  • Form-Field Validation
  • Conclusion

67
Type Safety(in terms of ltbigwiggt)
  • Show/Receive correspondence
  • Gap presence

html d Enter email ltinput typetext
nameemailgt show d receives age
?
html hello Hello ltwhatgt! html world
ltbgtWorldlt/bgt html h h hello ltcontents
world
?
68
Static Analysis!
Apply standard, data-flow analysis
techniques, but with highly domain-specific
lattices
69
Static Analysis!
  • Conservatively approximatefor all HTML variables
    program points
  • Their gaps and fields (and their kinds) ? all
    possible runtime values
  • Forward data-flow analysis
  • Control-flow graph (trivial for ltbigwiggt)
  • Finite lattice Gap-and-Field
  • Monotone transfer functions plug, assign, ...

70
Gap-and-Field Lattice
GKind
FKind
nogap
error
string
..
text
checkbox
radio
rel(F1)
rel(Fn)
html
..
nofield
tup(F1)
tup(Fn)
error
  • An abstract document is(GName ? GKind) x
    (FName ? FKind)

FName ? FKind
a ? html
g ? html
n ? nogap
GName ? GKind
a ? html
g ? html
n ? nogap
71
Monotone Transfer Functions
  • Plug

x1 ltg x2
72
Monotone Transfer Functions
  • Plug

x1 ltg x2
FName ? FKind
a ? html
g ? html
n ? nogap
FName ? FKind
a ? html
g ? html
n ? nogap
GName ? GKind
a ? nogap
g ? nogap
n ? html
GName ? GKind
a ? html
g ? html
n ? nogap
73
Monotone Transfer Functions
  • Plug

x1 ltg x2
FName ? FKind
a ? html
g ? html
n ? nogap
FName ? FKind
a ? html
g ? html
n ? nogap
FName ? FKind
a ? html
g ? html
n ? nogap
GName ? GKind
a ? html
g ? html
n ? nogap
GName ? GKind
a ? nogap
g ? nogap
n ? html
GName ? GKind
a ?
g ?
n ?
ltg
?
?G GKind x GKind ? GKind
74
Monotone Transfer Functions
  • Plug

x1 ltg x2
FName ? FKind
a ? html
g ? html
n ? nogap
FName ? FKind
a ? html
g ? html
n ? nogap
FName ? FKind
a ? html
g ? html
n ? nogap
GName ? GKind
a ? html
g ? html
n ? nogap
GName ? GKind
a ? nogap
g ? nogap
n ? html
GName ? GKind
a ? html
g ?
n ?
ltg
?
?G GKind x GKind ? GKind
75
Monotone Transfer Functions
  • Plug

x1 ltg x2
FName ? FKind
a ? html
g ? html
n ? nogap
FName ? FKind
a ? html
g ? html
n ? nogap
FName ? FKind
a ? html
g ? html
n ? nogap
GName ? GKind
a ? html
g ? html
n ? nogap
GName ? GKind
a ? nogap
g ? nogap
n ? html
GName ? GKind
a ? html
g ? nogap
n ?
ltg
?
?G GKind x GKind ? GKind
76
Monotone Transfer Functions
  • Plug

x1 ltg x2
FName ? FKind
a ? html
g ? html
n ? nogap
FName ? FKind
a ? html
g ? html
n ? nogap
FName ? FKind
a ? html
g ? html
n ? nogap
GName ? GKind
a ? html
g ? html
n ? nogap
GName ? GKind
a ? nogap
g ? nogap
n ? html
GName ? GKind
a ? html
g ? nogap
n ? html
ltg
?
?G GKind x GKind ? GKind
77
Monotone Transfer Functions
  • Plug

x1 ltg x2
FName ? FKind
a ? html
g ? html
n ? nogap
FName ? FKind
a ? html
g ? html
n ? nogap
FName ? FKind
a ? html
g ? html
n ? nogap
GName ? GKind
a ? html
g ? html
n ? nogap
GName ? GKind
a ? nogap
g ? nogap
n ? html
GName ? GKind
a ? html
g ? nogap
n ? html
ltg
?
78
Then Check Solution
  • Traverse solution intercept errors

79
Then Check Solution
  • Traverse solution intercept errors
  • ?
  • gap present

FName ? FKind
a ? html
g ? html
n ? nogap
E1 ltg E2
GName ? GKind
a ? html
g ? html
n ? nogap
80
Then Check Solution
  • Traverse solution intercept errors
  • ?
  • gap present
  • ?
  • field present
  • type check v text

FName ? FKind
a ? html
g ? html
n ? nogap
E1 ltg E2
GName ? GKind
a ? html
g ? html
n ? nogap
GName ? GKind
a ? html
g ? html
n ? nogap
FName ? FKind
e ? radio
f ? text
t ? text
show E receivevf, ...
81
Type Safety?
  • Show/Receive interaction correspondence
  • Gap presence

html d Enter email ltinput typetext
nameemailgt show d receives age
?
html hello Hello ltwhatgt! html world
ltbgtWorldlt/bgt html h h hello ltcontents
world
?
82
Type Safety!
  • Show/Receive interaction correspondence
  • Gap presence

html d Enter email ltinput typetext
nameemailgt show d receives age
receive.wig5 input field email not
received no such input field
age
html hello Hello ltwhatgt! html world
ltbgtWorldlt/bgt html h h hello ltcontents
world
plug.wig5 no such gap contents
83
Problems?
  • DynDoc
  • Templates with named gaps
  • Plug and show
  • Problems
  • Forces linear document construction
  • Intermixes programmer / designer aspects
  • No interaction correspondence
  • No static XML validation
  • No common fragments caching

84
Problems?
  • DynDoc
  • Templates with named gaps
  • Plug and show
  • Problems
  • Forces linear document construction
  • Intermixes programmer / designer aspects
  • No interaction correspondence
  • No static XML validation
  • No common fragments caching

85
Problems?
  • DynDoc
  • Templates with named gaps
  • Plug and show
  • Problems
  • Forces linear document construction
  • Intermixes programmer / designer aspects
  • No interaction correspondence
  • No static XML validation
  • No common fragments caching

86
Example Welcome
html greeting Hello ltwhogt, welcome to
ltwhatgt. html cover
ltheadgtlttitlegtWelcomelt/titlegtlt/headgt
ltbodygtltcontentsgtlt/bodygt html h h
greeting ltwho Stranger h h ltwhat
ltbgtGPCElt/bgt show cover ltcontents h
87
Example Welcome
html greeting Hello ltwhogt, welcome to
ltwhatgt. html cover
ltheadgtlttitlegtWelcomelt/titlegtlt/headgt
ltbodygtltcontentsgtlt/bodygt html h h
greeting ltwho Stranger h h ltwhat
ltbgtGPCElt/bgt show cover ltcontents h
Valid HTML !?
88
Static Analysis (again)!
  • Conservatively approximatefor all HTML variables
    program points
  • A summary graph ? all possible runtime values
  • Forward data-flow analysis
  • Control-flow graph (trivial for ltbigwiggt)
  • Finite lattice summary graphs
  • Monotone transfer functions plug, assign, ...

89
Summary Graph
html greeting ... html cover ... html
h h greeting ltwho Stranger h h ltwhat
ltbgtGPCElt/bgt show cover ltcontents h
90
Summary Graph
html greeting ... html cover ... html
h h greeting ltwho Stranger h h ltwhat
ltbgtGPCElt/bgt show cover ltcontents h
Stranger
greeting
who
91
Summary Graph
html greeting ... html cover ... html
h h greeting ltwho Stranger h h ltwhat
ltbgtGPCElt/bgt show cover ltcontents h
Stranger
greeting
who
what
gpce
92
Summary Graph
html greeting ... html cover ... html
h h greeting ltwho Stranger h h ltwhat
ltbgtGPCElt/bgt show cover ltcontents h
Stranger
greeting
contents
who
what
cover
gpce
93
Monotone Transfer Function
  • Plug

x1 ltg x2
94
Monotone Transfer Function
  • Plug

x1 ltg x2
g
g
g
g
95
Monotone Transfer Function
  • Plug

x1 ltg x2
g
g
ltg
g
g
96
Monotone Transfer Function
  • Plug

x1 ltg x2
g
g
g
g
?
ltg
g
g
g
g
97
Monotone Transfer Function
  • Plug

x1 ltg x2
g
g
g
g
?
ltg
g
g
g
g
98
Monotone Transfer Function
  • Plug

x1 ltg x2
g
g
g
g
?
ltg
g
g
g
g
However, too imprecise...!
99
Monotone Transfer Function
  • Plug

x1 ltg x2
g
g
g
g
?
ltg
g
g
g
g
open gaps
100
Monotone Transfer Function
  • Plug

x1 ltg x2
g
g
g
g
?
ltg
g
g
g
g
open gaps
101
GapTrack Analysis
  • GapTrack data-flow analysis
  • ? program points compute
  • Tracks the origins (templates) of open gaps

? GName ? 2TEMPLATES
g
g
g
g
?
ltg
g
g
g
g
?
?
? (g )
102
Validation?
  • Now summary graph ?show statements
  • Then what...?

... h greeting ltwho Stranger h h
ltwhat ltbgtGPCElt/bgt show cover
ltcontents h
Stranger
greeting
contents
who
what
cover
brics
103
Validation?
A summary graph describes
a set of hopeful XML docs
104
Validation?
A summary graph describes
A DTD describes (e.g. XHTML 1.0)
a set of hopeful XML docs
a set of valid XML docs
105
Validation!
A summary graph describes
A DTD describes (e.g. XHTML 1.0)
a set of hopeful XML docs
a set of valid XML docs
?
validation!
106
Validation!
  • Decidable!
  • Summary graph traversal (parsing vs. DTD)
  • Memoization ?? termination
  • Sound and complete!

a set of hopeful XML docs
a set of valid XML docs
?
validation!
107
Compiler Validation Recipe
  • Step-by-Step
  • 1. Extract control-flow graph
  • 2. Gap-and-Field data-flow analysis
  • 3. GapTrack data-flow analysis
  • 4. Summary Graph data-flow analysis
  • 5. Validation (?shows) graph analysis

108
Experiments 800MHz Pentium III / Linux
Program Lines Templates Time (sec.)
chat 65 3 0.1
guess 75 6 0.1
calendar 77 5 0.1
xbiff 561 18 0.1
webboard 1132 37 0.6
cdshop 1709 36 0.5
jaoo 1941 73 2.4
bachelor 2535 137 8.2
courses 4465 57 1.3
eatcs 5345 133 6.7
Many validation errors found, no spurious errors
109
Example Revisited
html greeting Hello ltwhogt, welcome to
ltwhatgt. html cover
ltheadgtlttitlegtWelcomelt/titlegtlt/headgt
ltbodygtltcontentsgtlt/bodygt html h h
greeting ltwho Stranger h h ltwhat
ltbgtGPCElt/bgt show cover ltcontents h
110
Planting an Error
html greeting lttdgtHello ltwhogt, welcome
to ltwhatgt.lt/tdgt html cover
ltheadgtlttitlegtWelcomelt/titlegtlt/headgt
ltbodygtlttablegtltcontentsgtlt/tablegtlt/bodygt html
h h greeting ltwho Stranger h h
ltwhat ltbgtGPCElt/bgt show cover
ltcontents h
111
Example Revisited
--- welcome.wig13 HTML Validation welcome.wig7
warning possible illegal subelement td of
table template lttablegtltcontentsgtlt/tablegt
contents td plugs contentswelcome.wig13
1 2 3 4 5 6 7 8 9 10 11 12 13
html greeting lttdgtHello ltwhogt, welcome
to ltwhatgt.lt/tdgt html cover
ltheadgtlttitlegtWelcomelt/titlegtlt/headgt
ltbodygtlttablegtltcontentsgtlt/tablegtlt/bodygt html
h h greeting ltwho Stranger h h
ltwhat ltbgtGPCElt/bgt show cover
ltcontents h
112
Problems?
  • DynDoc
  • Templates with named gaps
  • Plug and show
  • Problems
  • Forces linear document construction
  • Intermixes programmer / designer aspects
  • No interaction correspondence
  • No static XML validation
  • No common fragments caching

113
Problems?
  • DynDoc
  • Templates with named gaps
  • Plug and show
  • Problems
  • Forces linear document construction
  • Intermixes programmer / designer aspects
  • No interaction correspondence
  • No static XML validation
  • No common fragments caching

114
Problems?
  • DynDoc
  • Templates with named gaps
  • Plug and show
  • Problems
  • Forces linear document construction
  • Intermixes programmer / designer aspects
  • No interaction correspondence
  • No static XML validation
  • No common fragments caching

115
Outline
  • Introduction (Program Family)
  • Session Management
  • State Management
  • Document Construction
  • Domain Specific Verifications
  • Domain Specific Optimization
  • Form-Field Validation
  • Conclusion

116
Outline
  • Introduction (Program Family)
  • Session Management
  • State Management
  • Document Construction
  • Domain Specific Verifications
  • Domain Specific Optimization
  • Form-Field Validation
  • Conclusion

117
Domain Specific Representation
118
Domain Specific Representation
  • Constant
  • O (1)
  • Plug
  • O (1)
  • Show
  • O (d)

hello ltwhatgt!
x ltg y
show d
119
Domain Specific Representation
document structure
120
Domain Specific Representation
document structure
string
121
Domain Specific Representation
document structure
string
templates
122
Domain Specific Representation
dynamic
123
Domain Specific Representation
dynamic
static
124
Domain Specific Representation
dynamic
Transmit JavaScript recipe for client-side
doc. reconstruction
static
125
Domain Specific Representation
dynamic
Transmit JavaScript recipe for client-side
doc. reconstruction
Write each template to a separate file so
that it can be cached
static
126
Experiments
  • Size of HTML

original HTML
JavaScript reconstruction
...all templates cached
Cut to 2.6 25 size
127
Experiments (700MHz, 28.8 Modem)
  • Time (downloadrender)

original HTML
...all templates cached
2.2x 10x faster
128
Problems?
  • DynDoc
  • Templates with named gaps
  • Plug and show
  • Problems
  • Forces linear document construction
  • Intermixes programmer / designer aspects
  • No interaction correspondence
  • No static XML validation
  • No common fragments caching

129
Problems?
  • DynDoc
  • Templates with named gaps
  • Plug and show
  • Problems
  • Forces linear document construction
  • Intermixes programmer / designer aspects
  • No interaction correspondence
  • No static XML validation
  • No common fragments caching

130
Outline
  • Introduction (Program Family)
  • Session Management
  • State Management
  • Document Construction
  • Domain Specific Verifications
  • Domain Specific Optimization
  • Form-Field Validation
  • Conclusion

131
Outline
  • Introduction (Program Family)
  • Session Management
  • State Management
  • Document Construction
  • Domain Specific Verifications
  • Domain Specific Optimization
  • Form-Field Validation
  • Conclusion

132
Example EnterEmail
html input Please enter your emailltbrgt
ltinput typetext nameemailgt html
output Your email is ltemailgt string
s show input receives email show output
ltemail s
133
Example EnterEmail
format Email regexp(ltwordgt_at_ltwordgt(\.ltwordgt))
html input Please enter your emailltbrgt
ltinput typetext nameemailgt html
output Your email is ltemailgt string
s show input receives email show output
ltemail s
134
Example EnterEmail
format Email regexp(ltwordgt_at_ltwordgt(\.ltwordgt))
html input Please enter your emailltbrgt
ltinput typetext nameemail
formatEmailgt html output Your email
is ltemailgt string s show input
receives email show output ltemail s
135
Example EnterEmail
format Email regexp(ltwordgt_at_ltwordgt(\.ltwordgt))
html input Please enter your emailltbrgt
ltinput typetext nameemail
formatEmailgt html output Your email
is ltemailgt string s show input receives
email show output ltemail s
136
Form Field Validation PowerForms
  • Domain specific language
  • uniquely for form-field validation
  • Declarative specification (regexps)
  • Abstracts away operational details
  • PowerForms also available as stand-alone tool

HTML
HTML
PowerForms
JavaScript (subset)
Regexps
137
Form-Field Interdependency
  • Favorite Letter
  • Select filtering
  • NYC Office
  • Complex interdependency

138
Outline
  • Introduction (Program Family)
  • Session Management
  • State Management
  • Document Construction
  • Domain Specific Verifications
  • Domain Specific Optimization
  • Form-Field Validation
  • Conclusion

139
Outline
  • Introduction (Program Family)
  • Session Management
  • State Management
  • Document Construction
  • Domain Specific Verifications
  • Domain Specific Optimization
  • Form-Field Validation
  • Conclusion

140
Domain Specific Language Design and Analyses
  • Yield

Flexible, Safe, and Efficient Dynamic Generation
of XML
141
Domain Specific Language Design and Analyses
  • Yield
  • AND
  • Non-linear document construction
  • Separates programmer / designer aspects
  • Guaranteed interaction correspondence
  • Static XML validation
  • Common fragments caching

Flexible, Safe, and Efficient Dynamic Generation
of XML
142
Objective Assessments
  • Robustness
  • Session integrity
  • State integrity
  • Interaction correspondence
  • XML validity
  • Performance
  • Well...
  • Conciseness
  • 1/5 code (compared to Java Servlets)

143
Conciseness (Servlets)
public class SessionServlet extends HttpServlet
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws
ServletException, IOException
ServletContext context getServletContext()
HttpSession session request.getSession(true)
response.setContentType("text/html")
PrintWriter out response.getWriter()
out.println("ltHTMLgtltHEADgtltTITLEgtServlet
Demolt/TITLEgtlt/HEADgtltBODYgt") if
(session.isNew()) out.println("ltFORM
ACTIONSessionServletgt" "Enter your name
ltINPUT NAMEhandlegt" "ltINPUT
TYPESUBMITgtlt/FORMgt") session.putValue("sta
te", "1") else String state
(String) session.getValue("state") if
(state.equals("1")) String name
(String) request.getParameter("handle")
int users ((Integer) context.getAttribute("users
")).intValue() 1 context.setAttribute("
users", new Integer(users))
session.putValue("name", name)
out.println("Hello " name ", you are user
number " users) session.putValue("state
", "2") else / state.equals("2") /
String name (String) session.getValue("nam
e") out.println("Goodbye " name)
session.invalidate()
out.println("lt/BODYgtlt/HTMLgt")
144
Conciseness (ltbigwiggt)
service shared int users 0 session
Hello() string name show Enter your
name ltinput namehandlegt receivenamehandle
users show Hello ltwhogt, you are
user number ltcountgt ltwhoname,countusers
show Goodbye ltwhogt ltwhoname
145
Conciseness (ltbigwiggt)
service shared int users 0 session
Hello() string name show Enter your
name ltinput namehandlegt receivenamehandle
users show Hello ltwhogt, you are
user number ltcountgt ltwhoname,countusers
show Goodbye ltwhogt ltwhoname

session management state management
document construction misc.
Overall 1/5 code
146
The ltbigwiggt Compiler
  • Version 2.0
  • Implemented in C (for UNIX / Linux)
  • Complete source code available
  • Approximately 2.5 MB source
  • License GPL (Gnu Public License)

147
http//www.brics.dk/bigwig/
  • Homepage
  • Introduction
  • Examples
  • Ref. manual
  • Tutorials
  • Papers
  • Presentations
  • Downloads
  • src / bin
  • 2 Recorded Presentations (MS IBM Research)

148
ltbigwiggt Publications
  • Concurrency Control ETAPS/FASE, 1998
  • Runtime System Computer Networks J., 1999
  • Dynamic Documents POPL, 2000
  • Form-Field Validation WWW Journal, 2000
  • HTML Validation PASTE, 2001
  • The ltbigwiggt Project TOIT Journal, 2002
  • Syntax Macros PEPM, 2002
  • Document Caching WWW Journal, 2002

149
ltbigwiggt JWIG (Java)
http//www.brics.dk/JWIG/
150
Thank you!
Write a Comment
User Comments (0)
About PowerShow.com