![Page 1: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/1.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Flexible, Safe, and Efficient Dynamic Generation of HTML
Claus Brabrand*Anders Møller, Anders Sandholm, and Michael Schwartzbach
BRICS, University of Aarhus, Denmark*Visiting IBM Research, Hawthorne, NY, USA
![Page 2: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/2.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Outline
• Introduction
• Dynamic Documents
• Type Safety
• HTML Validation
• Caching
• Form-Field Validation
• Conclusion
![Page 3: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/3.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Outline
• Introduction
• Dynamic Documents
• Type Safety
• HTML Validation
• Caching
• Form-Field Validation
• Conclusion
![Page 4: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/4.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Interactive (Form-Based) Web Services
• Approaches:• Script-Centered• Page-Centered• Session-Centered
”Web servers on which clients can initiate sessions that involve several exchanges of information mediated by HTML forms”.
”Web servers on which clients can initiate sessions that involve several exchanges of information mediated by HTML forms”.
serverclient Internet
![Page 5: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/5.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Script-Centered:Perl/CGI
e
CLIENT INTERNET SERVER
e
eWebService
save
restoresubmit
![Page 6: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/6.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
e
e
eWebService
save
restore
Page-Centered:PHP, ASP, JSP, ...
CLIENT INTERNET SERVER
submit
![Page 7: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/7.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Page-Centered
• Increased level of abstraction:• CGI protocol details abstracted away
• Easy to add dynamics to static pages:•
• Scalability:• Specialized Web server
“Service code embedded in tags and interpreted by specialized Web server”“Service code embedded in tags and interpreted by specialized Web server”
<html><body>Time: <%= Now() %></body></html><html><body>Time: <%= Now() %></body></html><%= Now() %>
![Page 8: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/8.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Script- 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 (<%...
%>)
![Page 9: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/9.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Both:Fundamental Drawbacks!
<input name=”x”>
a_script another_script
<%= $y %>submit
WebService
• Interpretation-based:• Errors at runtime• (Efficiency)
• A service = A collection of scripts/pages!– Implicit control-flow:
• No input / output correspondence:
![Page 10: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/10.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Language Requirements!
• Compilation-based:• Errors at compile-time• (Efficiency)
• A complete service specification– Explicit control-flow:
• Statically check input / output correspondence
![Page 11: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/11.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Session-Centered:Mawl and <bigwig>!e
CLIENT INTERNET SERVER
e
e
Web Service
save
restore
one process
show x;
show y;
suspend
resume
x
y
submit
![Page 12: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/12.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
What is <bigwig>?
• A high-level domain-specific programming language for developing interactive Web services.
<bigwig><bigwig>
HTMLHTML
CGI ScriptsCGI Scripts
JavaScriptJavaScript
HTTP Auth.HTTP Auth.
Java AppletsJava Applets
CompleteService
Specification
CompleteService
Specification
![Page 13: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/13.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
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
![Page 14: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/14.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
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
![Page 15: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/15.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Outline
• Introduction
• Dynamic Documents
• Type Safety
• HTML Validation
• Caching
• Form-Field Validation
• Conclusion
![Page 16: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/16.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Outline
• Introduction
• Dynamic Documents
• Type Safety
• HTML Validation
• Caching
• Form-Field Validation
• Conclusion
![Page 17: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/17.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Dynamically Generated HTML:Current Problems
• Traditionally:• print(...) in Perl/CGI• <% print(...) %> in PHP, ASP, JSP, ...
• Problems:• Forces linear document construction• Intermixes programmer / designer aspects• No input / output correspondence• No static HTML validation• No common fragments caching
![Page 18: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/18.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Our Solution: HTML documents in <bigwig>
• Templates (1st class, higher-order values):• XML fragments with named gaps:
• Operations:• plug: for document construction• show: for client interaction
<html> Hello <[what]>!</html>
<html> Hello <[what]>!</html>
![Page 19: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/19.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Plug
• Plug: exp <[ id = exp ]
![Page 20: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/20.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Plug
• Plug: exp <[ id = exp ]
• Example:
html hello = <html>Hello <[what]>!</html>;html world = <html><b>World</b></html>;
html h = hello <[what = world];...;
html hello = <html>Hello <[what]>!</html>;html world = <html><b>World</b></html>;
html h = hello <[what = world];...;
![Page 21: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/21.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Show
• Show: show exp ;
x
CLIENT INTERNET SERVER
eshow x;
submitsuspendresume
![Page 22: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/22.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Show
• Show: show exp ;
• Example:
x
CLIENT INTERNET SERVER
eshow x;
submitsuspendresume
html hello = <html>Hello <[what]>!</html>;html world = <html><b>World</b></html>;
html h = hello <[what = world];show h;
html hello = <html>Hello <[what]>!</html>;html world = <html><b>World</b></html>;
html h = hello <[what = world];show h;
![Page 23: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/23.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Show-Receive
• Show: show exp receive[v =f, ...];
x
CLIENT INTERNET SERVER
eshow x;
f, ...
suspendreceive & resumesubmit
![Page 24: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/24.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Show-Receive
• Show: show exp receive[v =f, ...];
• Example:string s;html input = <html> Enter email: <input type=”text” name=”email”></html>;
show input receive[s = email];
string s;html input = <html> Enter email: <input type=”text” name=”email”></html>;
show input receive[s = email];
x
CLIENT INTERNET SERVER
eshow x;
f, ...
suspendreceive & resumesubmit
![Page 25: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/25.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Example: ”Welcome”
html greeting = <html> Hello <[who]>, welcome to <[what]>.</html>;
html cover = <html> <head><title>Welcome</title></head> <body><[contents]></body></html>;
html h;h = greeting <[who = ”Stranger”];h = h <[what = <html><b>BRICS</b></html>];show cover <[contents = h];
html greeting = <html> Hello <[who]>, welcome to <[what]>.</html>;
html cover = <html> <head><title>Welcome</title></head> <body><[contents]></body></html>;
html h;h = greeting <[who = ”Stranger”];h = h <[what = <html><b>BRICS</b></html>];show cover <[contents = h];
![Page 26: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/26.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
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
<% ..1.. %>
...or...
<% ..2.. %>
<% ..20.. %> :
<% for i=1 to N do { ..i.. } %>
![Page 27: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/27.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Flexibility: <bigwig>
• List of results (e.g. “search engine”):
<ul> <li>1 <li>2 : <li>N</ul>
<ul> <li>1 <li>2 : <li>N</ul>
![Page 28: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/28.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Flexibility: <bigwig>
• List of results (e.g. “search engine”):• Two templates: “layout” and “entry”...
html layout = <html><ul><[items]></ul><html>;html entry = <html><li><[num]><[items]></html>;
html layout = <html><ul><[items]></ul><html>;html entry = <html><li><[num]><[items]></html>;
<ul> <li>1 <li>2 : <li>N</ul>
<ul> <li>1 <li>2 : <li>N</ul>
![Page 29: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/29.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Flexibility: <bigwig>
• List of results (e.g. “search engine”):• Two templates: “layout” and “entry”...
• ...and one recursive function: “f”
html f(int n) { if (n == 0) return layout; return f(n-1) <[items = entry <[num = n]];}
html f(int n) { if (n == 0) return layout; return f(n-1) <[items = entry <[num = n]];}
html layout = <html><ul><[items]></ul><html>;html entry = <html><li><[num]><[items]></html>;
html layout = <html><ul><[items]></ul><html>;html entry = <html><li><[num]><[items]></html>;
<ul> <li>1 <li>2 : <li>N</ul>
<ul> <li>1 <li>2 : <li>N</ul>
![Page 30: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/30.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Flexibility: <bigwig>
• List of results (e.g. “search engine”):• Two templates: “layout” and “entry”...
• ...and one recursive function: “f”
• Example usage:
html f(int n) { if (n == 0) return layout; return f(n-1) <[items = entry <[num = n]];}
html f(int n) { if (n == 0) return layout; return f(n-1) <[items = entry <[num = n]];}
<ul> <li>1 <li>2 : <li>27</ul>
<ul> <li>1 <li>2 : <li>27</ul>
html layout = <html><ul><[items]></ul><html>;html entry = <html><li><[num]><[items]></html>;
html layout = <html><ul><[items]></ul><html>;html entry = <html><li><[num]><[items]></html>;
show f(27);show f(27);
![Page 31: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/31.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Problems?
• “DynDoc”:• Templates with named gaps• Plug and show
• Problems:• Forces linear document construction• Intermixes programmer / designer aspects• No input / output correspondence• No static HTML validation• No common fragments caching
![Page 32: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/32.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Problems?
• “DynDoc”:• Templates with named gaps• Plug and show
• Problems:• Forces linear document construction• Intermixes programmer / designer aspects• No input / output correspondence• No static HTML validation• No common fragments caching
![Page 33: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/33.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Problems?
• “DynDoc”:• Templates with named gaps• Plug and show
• Problems:• Forces linear document construction• Intermixes programmer / designer aspects• No input / output correspondence• No static HTML validation• No common fragments caching
![Page 34: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/34.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Problems?
• “DynDoc”:• Templates with named gaps• Plug and show
• Problems:• Forces linear document construction• Intermixes programmer / designer aspects• No input / output correspondence• No static HTML validation• No common fragments caching
![Page 35: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/35.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Problems?
• Problems:• Forces linear document construction• Intermixes programmer / designer aspects• No input / output correspondence• No static HTML validation• No common fragments caching
<input name=”x”>
a_script another_script
<%= $y %>submit
![Page 36: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/36.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Outline
• Introduction
• Dynamic Documents
• Type Safety
• HTML Validation
• Caching
• Form-Field Validation
• Conclusion
![Page 37: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/37.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Outline
• Introduction
• Dynamic Documents
• Type Safety
• HTML Validation
• Caching
• Form-Field Validation
• Conclusion
![Page 38: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/38.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Type Safety(in terms of <bigwig>)
• Show/Receive correspondence:
• Gap presence:
html d = <html> Enter email: <input type=“text” name=“email”><html>;
show d receive[s = age];
html d = <html> Enter email: <input type=“text” name=“email”><html>;
show d receive[s = age];
html hello = <html>Hello <[what]>!<html>;html world = <html><b>World</b></html>;html h;
h = hello <[contents = world];
html hello = <html>Hello <[what]>!<html>;html world = <html><b>World</b></html>;html h;
h = hello <[contents = world];
![Page 39: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/39.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Static Analysis!
Apply standard, data-flow analysis techniques,but with highly domain-specific lattices
Apply standard, data-flow analysis techniques,but with highly domain-specific lattices
![Page 40: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/40.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
A (5 mins) Crash Course on Data-Flow Analysis
Claus Brabrand*
BRICS, University of Aarhus, Denmark*Visiting IBM Research, Hawthorne, NY, USA
![Page 41: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/41.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Data-Flow Analysis
• We need 3 things:• A control-flow graph• A lattice• Transfer functions
“Simulate runtime execution at compile-time
using abstract values”
“Simulate runtime execution at compile-time
using abstract values”
![Page 42: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/42.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Data-Flow Analysis
• We need 3 things:• A control-flow graph• A lattice• Transfer functions
• Example: “integer constant propagation”
“Simulate runtime execution at compile-time
using abstract values”
“Simulate runtime execution at compile-time
using abstract values”
![Page 43: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/43.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
A Control Flow Graph
int x = 1;int y = 3;
if (..) { x = x+2;} else { x <-> y;}...; // x? y?
int x = 1;int y = 3;
if (..) { x = x+2;} else { x <-> y;}...; // x? y?
int x = 1;int x = 1;
int y = 3;int y = 3;
if-else
x = x+2;x = x+2; x <-> y;x <-> y;
...; // x? y?...; // x? y?
true false
![Page 44: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/44.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
A Lattice
• Lattice L of abstract values of interestand their relationships (i.e. ordering “”):
• Induces least-upper-bound operator:(a.k.a. “join”) for joining information
~ “value unknown at C-T!”
~ “we haven’t analyzed yet”
·· -3 -2 -1 0 1 2 3 ··
“top”
“bottom”
![Page 45: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/45.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Transfer Functions
• For simulating statement computation(on abstract envs, ENVL = VAR L L|VAR|):
• Transfer Function: ENVL ENVL
• Examples:– E . E[y 3]
– E . E[x E(x) L 2]
...where
int y = 3;int y = 3;
x = x + 2;x = x + 2;
, if n = m = n L m = , if n = m =
r , o.w. (where r = n + m)
, if n = m = n L m = , if n = m =
r , o.w. (where r = n + m)
![Page 46: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/46.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Data-Flow Analysis!
int x = 1;int x = 1;
int y = 3;int y = 3;
if-else
x = x+2;x = x+2; x <-> y;x <-> y;
...; // x? y?...; // x? y?
![Page 47: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/47.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Data-Flow Analysis!
int x = 1;int x = 1;
int y = 3;int y = 3;
if-else
x = x+2;x = x+2; x <-> y;x <-> y;
...; // x? y?...; // x? y?
E . E[x 1]
E . E[y 3]
E . E[x E(x) 2]
E . E[x E(y), y E(x)]
![Page 48: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/48.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Data-Flow Analysis!
int x = 1;int x = 1;
int y = 3;int y = 3;
if-else
x = x+2;x = x+2; x <-> y;x <-> y;
...; // x? y?...; // x? y?
E . E[x 1]
E . E[y 3]
E . E[x E(x) 2]
E . E[x E(y), y E(x)]
![Page 49: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/49.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Data-Flow Analysis!
int x = 1;int x = 1;
int y = 3;int y = 3;
if-else
x = x+2;x = x+2; x <-> y;x <-> y;
...; // x? y?...; // x? y?
E . E[x 1]
E . E[y 3]
E . E[x E(x) 2]
E . E[x E(y), y E(x)]
[ , ] ENVL
[ , ]
[ , ]
[ , ]
[ , ]
[ , ] [ , ][ , ]
[ , ] [ , ][ , ]
x y
![Page 50: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/50.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Data-Flow Analysis!
int x = 1;int x = 1;
int y = 3;int y = 3;
if-else
x = x+2;x = x+2; x <-> y;x <-> y;
...; // x? y?...; // x? y?
E . E[x 1]
E . E[y 3]
E . E[x E(x) 2]
E . E[x E(y), y E(x)]
[ , ]
[ 1 , ]
[ , ]
[ , ]
[ , ]
[ , ] [ , ][ , ]
[ , ] [ , ][ , ]
![Page 51: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/51.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Data-Flow Analysis!
int x = 1;int x = 1;
int y = 3;int y = 3;
if-else
x = x+2;x = x+2; x <-> y;x <-> y;
...; // x? y?...; // x? y?
E . E[x 1]
E . E[y 3]
E . E[x E(x) 2]
E . E[x E(y), y E(x)]
[ , ]
[ 1 , ]
[ 1 , ]
[ , ]
[ , ]
[ , ] [ , ][ , ]
[ , ] [ , ][ , ]
![Page 52: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/52.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Data-Flow Analysis!
int x = 1;int x = 1;
int y = 3;int y = 3;
if-else
x = x+2;x = x+2; x <-> y;x <-> y;
...; // x? y?...; // x? y?
E . E[x 1]
E . E[y 3]
E . E[x E(x) 2]
E . E[x E(y), y E(x)]
[ , ]
[ 1 , ]
[ 1 , ]
[ , ]
[ , ] [ , ][ , ]
[ , ] [ , ][ , ]
[ 1 , 3 ]
![Page 53: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/53.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Data-Flow Analysis!
int x = 1;int x = 1;
int y = 3;int y = 3;
if-else
x = x+2;x = x+2; x <-> y;x <-> y;
...; // x? y?...; // x? y?
E . E[x 1]
E . E[y 3]
E . E[x E(x) 2]
E . E[x E(y), y E(x)]
[ , ]
[ 1 , ]
[ 1 , ]
[ , ] [ , ][ , ]
[ , ] [ , ][ , ]
[ 1 , 3 ]
[ 1 , 3 ]
![Page 54: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/54.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Data-Flow Analysis!
int x = 1;int x = 1;
int y = 3;int y = 3;
if-else
x = x+2;x = x+2; x <-> y;x <-> y;
...; // x? y?...; // x? y?
E . E[x 1]
E . E[y 3]
E . E[x E(x) 2]
E . E[x E(y), y E(x)]
[ , ]
[ 1 , ]
[ 1 , ]
[ , ][ , ]
[ , ] [ , ][ , ]
[ 1 , 3 ]
[ 1 , 3 ]
[ 1 , 3 ]
![Page 55: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/55.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Data-Flow Analysis!
int x = 1;int x = 1;
int y = 3;int y = 3;
if-else
x = x+2;x = x+2; x <-> y;x <-> y;
...; // x? y?...; // x? y?
E . E[x 1]
E . E[y 3]
E . E[x E(x) 2]
E . E[x E(y), y E(x)]
[ , ]
[ 1 , ]
[ 1 , ]
[ , ]
[ , ] [ , ][ , ]
[ 1 , 3 ]
[ 1 , 3 ]
[ 1 , 3 ][ 1 , 3 ]
![Page 56: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/56.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Data-Flow Analysis!
int x = 1;int x = 1;
int y = 3;int y = 3;
if-else
x = x+2;x = x+2; x <-> y;x <-> y;
...; // x? y?...; // x? y?
E . E[x 1]
E . E[y 3]
E . E[x E(y), y E(x)]
[ , ]
[ 1 , ]
[ 1 , ]
[ , ]
[ , ] [ , ]
[ 1 , 3 ]
[ 1 , 3 ]
[ 1 , 3 ][ 1 , 3 ]E . E[x E(x) 2]
[ 3 , 3 ]
![Page 57: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/57.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Data-Flow Analysis!
int x = 1;int x = 1;
int y = 3;int y = 3;
if-else
x = x+2;x = x+2; x <-> y;x <-> y;
...; // x? y?...; // x? y?
E . E[x 1]
E . E[y 3]
E . E[x E(y), y E(x)]
[ , ]
[ 1 , ]
[ 1 , ]
[ , ]
[ , ]
[ 1 , 3 ]
[ 1 , 3 ]
[ 1 , 3 ][ 1 , 3 ]E . E[x E(x) 2]
[ 3 , 3 ] [ 3 , 3 ]
![Page 58: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/58.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Data-Flow Analysis!
int x = 1;int x = 1;
int y = 3;int y = 3;
if-else
x = x+2;x = x+2; x <-> y;x <-> y;
...; // x? y?...; // x? y?
E . E[x 1]
E . E[y 3]
E . E[x E(y), y E(x)]
[ , ]
[ 1 , ]
[ 1 , ]
[ , ]
[ 1 , 3 ]
[ 1 , 3 ]
[ 1 , 3 ][ 1 , 3 ]E . E[x E(x) 2]
[ 3 , 3 ] [ 3 , 3 ]
[ 1 , 3 ]
![Page 59: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/59.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Data-Flow Analysis!
int x = 1;int x = 1;
int y = 3;int y = 3;
if-else
x = x+2;x = x+2; x <-> y;x <-> y;
...; // x? y?...; // x? y?
E . E[x 1]
E . E[y 3]
E . E[x E(y), y E(x)]
[ , ]
[ 1 , ]
[ 1 , ]
[ 1 , 3 ]
[ 1 , 3 ]
[ 1 , 3 ][ 1 , 3 ]E . E[x E(x) 2]
[ 3 , 3 ] [ 3 , 3 ]
[ 1 , 3 ]
[ 3 , 1 ]
![Page 60: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/60.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Data-Flow Analysis!
int x = 1;int x = 1;
int y = 3;int y = 3;
if-else
x = x+2;x = x+2; x <-> y;x <-> y;
...; // x? y?...; // x? y?
E . E[x 1]
E . E[y 3]
E . E[x E(y), y E(x)]
[ , ]
[ 1 , ]
[ 1 , ]
[ 1 , 3 ]
[ 1 , 3 ]
[ 1 , 3 ][ 1 , 3 ]E . E[x E(x) 2]
[ 3 , 3 ] [ 3 , ]
[ 1 , 3 ]
[ 3 , 1 ]
![Page 61: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/61.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Fixed-Point!
int x = 1;int x = 1;
int y = 3;int y = 3;
if-else
x = x+2;x = x+2; x <-> y;x <-> y;
...; // x? y?...; // x? y?
E . E[x 1]
E . E[y 3]
E . E[x E(y), y E(x)]
[ , ]
[ 1 , ]
[ 1 , ]
[ 1 , 3 ]
[ 1 , 3 ]
[ 1 , 3 ][ 1 , 3 ]E . E[x E(x) 2]
[ 3 , 3 ] [ 3 , ]
[ 1 , 3 ]
[ 3 , 1 ]
![Page 62: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/62.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Fixed-Point Theorem
• One big abstract value vector• [ , , ... , ] (L|VAR|)|PP|
• One big transfer function• F : (L|VAR|)|PP| (L|VAR|)|PP|
• “Fixed-Point Theorem” :• Lattice finite height• Transfer functions monotone
lfp(F) that is computable as: n F n
( PROG ) n F n
( PROG )
[ , ] [ , ] [ , ]
![Page 63: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/63.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Approximation Only!
• In general: runtime value of an expression, E, is statically undecidable
• Conservatively “err on the safe side”• Sound, but not complete
if ( E ) { ...something good...;} else { ...something bad!...;}/* Here we must assume the worst! */
if ( E ) { ...something good...;} else { ...something bad!...;}/* Here we must assume the worst! */
![Page 64: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/64.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Type Safety(in terms of <bigwig>)
• Show/Receive correspondence:
• Gap presence:
html d = <html> Enter email: <input type=“text” name=“email”><html>;
show d receive[s = age];
html d = <html> Enter email: <input type=“text” name=“email”><html>;
show d receive[s = age];
html hello = <html>Hello <[what]>!<html>;html world = <html><b>World</b></html>;html h;
h = hello <[contents = world];
html hello = <html>Hello <[what]>!<html>;html world = <html><b>World</b></html>;html h;
h = hello <[contents = world];
![Page 65: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/65.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Static Analysis!
• Conservatively approximatefor all HTML variables & program points:
• Their gaps and fields (and their kinds) all possible runtime values
• Forward data-flow analysis:1. Control-flow graph (trivial for <bigwig>)
2. Finite lattice: Gap-and-Field
3. Monotone transfer functions: plug, assign, ...
![Page 66: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/66.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Gap-and-Field LatticeGKind
nogap
string
html
error
FKind
error
text
nofield
checkboxradio
tup(F1)
rel(F1) rel(Fn)
tup(Fn)
..
..
• 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
![Page 67: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/67.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Monotone Transfer Functions
• Plug: x1 <[g = x2] x1 <[g = x2]
![Page 68: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/68.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Monotone Transfer Functions
• Plug: x1 <[g = x2] x1 <[g = 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
![Page 69: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/69.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Monotone Transfer Functions
• Plug: x1 <[g = x2] x1 <[g = x2]
<[g = ]
FName FKind
a html
g html
n nogap
GName GKind
a html
g html
n nogap
FName FKind
a html
g html
n nogap
GName GKind
a nogap
g nogap
n html
FName FKind
a html
g html
n nogap
GName GKind
a
g
n
G : GKind x GKind GKind
![Page 70: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/70.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Monotone Transfer Functions
• Plug: x1 <[g = x2] x1 <[g = x2]
<[g = ]
FName FKind
a html
g html
n nogap
GName GKind
a html
g html
n nogap
FName FKind
a html
g html
n nogap
GName GKind
a nogap
g nogap
n html
FName FKind
a html
g html
n nogap
GName GKind
a html
g
n
G : GKind x GKind GKind
![Page 71: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/71.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Monotone Transfer Functions
• Plug: x1 <[g = x2] x1 <[g = x2]
<[g = ]
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
G : GKind x GKind GKind
![Page 72: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/72.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Monotone Transfer Functions
• Plug: x1 <[g = x2] x1 <[g = x2]
<[g = ]
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
G : GKind x GKind GKind
![Page 73: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/73.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Monotone Transfer Functions
• Plug: x1 <[g = x2] x1 <[g = x2]
<[g = ]
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
![Page 74: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/74.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Then: Check Solution
• Traverse solution: intercept errors
![Page 75: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/75.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Then: Check Solution
• Traverse solution: intercept errors
gap present
E1 <[g = E2]E1 <[g = E2]FName FKind
a html
g html
n nogap
GName GKind
a html
g html
n nogap
![Page 76: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/76.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Then: Check Solution
• Traverse solution: intercept errors
gap present
field present
type check: v ~ text
E1 <[g = E2]E1 <[g = E2]
show E receive[v=f, ...];show E receive[v=f, ...];
FName FKind
a html
g html
n nogap
GName GKind
a html
g html
n nogap
GName GKind
a html
g html
n nogap
FName FKind
e radio
f text
t text
![Page 77: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/77.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Type Safety?
• Show/Receive correspondence:
• Gap presence:
html d = <html> Enter email: <input type=“text” name=“email”><html>;
show d receive[s = age];
html d = <html> Enter email: <input type=“text” name=“email”><html>;
show d receive[s = age];
html hello = <html>Hello <[what]>!<html>;html world = <html><b>World</b></html>;html h;
h = hello <[contents = world];
html hello = <html>Hello <[what]>!<html>;html world = <html><b>World</b></html>;html h;
h = hello <[contents = world];
![Page 78: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/78.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Type Safety!
• Show/Receive correspondence:
• Gap presence:
html d = <html> Enter email: <input type=“text” name=“email”><html>;
show d receive[s = age];
html d = <html> Enter email: <input type=“text” name=“email”><html>;
show d receive[s = age];
html hello = <html>Hello <[what]>!<html>;html world = <html><b>World</b></html>;html h;
h = hello <[contents = world];
html hello = <html>Hello <[what]>!<html>;html world = <html><b>World</b></html>;html h;
h = hello <[contents = world];
*** receive.wig:5: input field ‘email’ not received no such input field ‘age’
*** receive.wig:5: input field ‘email’ not received no such input field ‘age’
*** plug.wig:5: no such gap ‘contents’*** plug.wig:5: no such gap ‘contents’
![Page 79: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/79.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Problems?
• “DynDoc”:• Templates with named gaps• Plug and show
• Problems:• Forces linear document construction• Intermixes programmer / designer aspects• No input / output correspondence• No static HTML validation• No common fragments caching
![Page 80: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/80.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Problems?
• “DynDoc”:• Templates with named gaps• Plug and show
• Problems:• Forces linear document construction• Intermixes programmer / designer aspects• No input / output correspondence• No static HTML validation• No common fragments caching
![Page 81: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/81.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Problems?
• “DynDoc”:• Templates with named gaps• Plug and show
• Problems:• Forces linear document construction• Intermixes programmer / designer aspects• No input / output correspondence• No static HTML validation• No common fragments caching
![Page 82: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/82.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Outline
• Introduction
• Dynamic Documents
• Type Safety
• HTML Validation
• Caching
• Form-Field Validation
• Conclusion
![Page 83: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/83.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Outline
• Introduction
• Dynamic Documents
• Type Safety
• HTML Validation
• Caching
• Form-Field Validation
• Conclusion
![Page 84: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/84.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Example: ”Welcome”
html greeting = <html> Hello <[who]>, welcome to <[what]>.</html>;
html cover = <html> <head><title>Welcome</title></head> <body><[contents]></body></html>;
html h;h = greeting <[who = ”Stranger”];h = h <[what = <html><b>BRICS</b></html>];show cover <[contents = h];
html greeting = <html> Hello <[who]>, welcome to <[what]>.</html>;
html cover = <html> <head><title>Welcome</title></head> <body><[contents]></body></html>;
html h;h = greeting <[who = ”Stranger”];h = h <[what = <html><b>BRICS</b></html>];show cover <[contents = h];
![Page 85: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/85.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Example: ”Welcome”
html greeting = <html> Hello <[who]>, welcome to <[what]>.</html>;
html cover = <html> <head><title>Welcome</title></head> <body><[contents]></body></html>;
html h;h = greeting <[who = ”Stranger”];h = h <[what = <html><b>BRICS</b></html>];show cover <[contents = h];
html greeting = <html> Hello <[who]>, welcome to <[what]>.</html>;
html cover = <html> <head><title>Welcome</title></head> <body><[contents]></body></html>;
html h;h = greeting <[who = ”Stranger”];h = h <[what = <html><b>BRICS</b></html>];show cover <[contents = h];
Valid HTML !?Valid HTML !?
![Page 86: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/86.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Static Analysis (again)!
• Conservatively approximatefor all HTML variables & program points:
• A summary graph all possible runtime values
• Forward data-flow analysis:1. Control-flow graph: (trivial for <bigwig>)
2. Finite lattice: summary graphs
3. Monotone transfer functions: plug, assign, ...
![Page 87: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/87.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Summary Graph
html greeting = ...;
html cover = ...;
html h;h = greeting <[who = ”Stranger”];h = h <[what = <html><b>BRICS</b></html>];show cover <[contents = h];
html greeting = ...;
html cover = ...;
html h;h = greeting <[who = ”Stranger”];h = h <[what = <html><b>BRICS</b></html>];show cover <[contents = h];
![Page 88: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/88.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Summary Graph
”Stranger”greetingwho
html greeting = ...;
html cover = ...;
html h;h = greeting <[who = ”Stranger”];h = h <[what = <html><b>BRICS</b></html>];show cover <[contents = h];
html greeting = ...;
html cover = ...;
html h;h = greeting <[who = ”Stranger”];h = h <[what = <html><b>BRICS</b></html>];show cover <[contents = h];
![Page 89: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/89.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Summary Graph
”Stranger”greeting
brics
who
what
html greeting = ...;
html cover = ...;
html h;h = greeting <[who = ”Stranger”];h = h <[what = <html><b>BRICS</b></html>];show cover <[contents = h];
html greeting = ...;
html cover = ...;
html h;h = greeting <[who = ”Stranger”];h = h <[what = <html><b>BRICS</b></html>];show cover <[contents = h];
![Page 90: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/90.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Summary Graph
”Stranger”
cover
greeting
brics
contents who
what
html greeting = ...;
html cover = ...;
html h;h = greeting <[who = ”Stranger”];h = h <[what = <html><b>BRICS</b></html>];show cover <[contents = h];
html greeting = ...;
html cover = ...;
html h;h = greeting <[who = ”Stranger”];h = h <[what = <html><b>BRICS</b></html>];show cover <[contents = h];
![Page 91: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/91.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Monotone Transfer Function
• Plug: x1 <[g = x2] x1 <[g = x2]
![Page 92: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/92.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Monotone Transfer Function
• Plug:
g
g
gg
x1 <[g = x2] x1 <[g = x2]
![Page 93: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/93.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Monotone Transfer Function
• Plug:
g
g
gg
g
g
gg
x1 <[g = x2] x1 <[g = x2]
<[g = ]
![Page 94: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/94.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Monotone Transfer Function
• Plug:
g
g
gg
g
g
gg
x1 <[g = x2] x1 <[g = x2]
<[g = ]
![Page 95: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/95.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Monotone Transfer Function
• Plug:
g
g
gg
g
g
gg
x1 <[g = x2] x1 <[g = x2]
<[g = ]
However, too imprecise!However, too imprecise!
![Page 96: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/96.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Monotone Transfer Function
g
g
gg
g
g
gg<[g = ]
x1 <[g = x2] x1 <[g = x2]• Plug:
open gaps
![Page 97: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/97.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Monotone Transfer Function
g
g
gg
g
g
gg<[g = ]
x1 <[g = x2] x1 <[g = x2]• Plug:
open gaps
![Page 98: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/98.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
GapTrack Analysis
• GapTrack data-flow analysis: program points compute:
• “Tracks the origins (templates) of open gaps”
g
g
gg
g
g
gg<[g = ]
(g ) (g ) ’
: GName 2TEMPLATES : GName 2TEMPLATES
![Page 99: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/99.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
...;h = greeting <[who = ”Stranger”];h = h <[what = <html><b>BRICS</b></html>];show cover <[contents = h];
...;h = greeting <[who = ”Stranger”];h = h <[what = <html><b>BRICS</b></html>];show cover <[contents = h];
• Now: summary graph show statements• Then what...?
Validation?
”Stranger”
cover
greeting
brics
contents who
what
![Page 100: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/100.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Validation?
a set of hopeful
XML docs
a set of hopeful
XML docs
A summary graphdescribes:
![Page 101: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/101.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Validation?
a set of hopeful
XML docs
a set of hopeful
XML docs
a set of valid
XML docs
a set of valid
XML docs
A summary graphdescribes:
A DTD describes(e.g. XHTML 1.0):
![Page 102: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/102.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Validation!
a set of hopeful
XML docs
a set of hopeful
XML docs
a set of valid
XML docs
a set of valid
XML docs
validation!
A summary graphdescribes:
A DTD describes(e.g. XHTML 1.0):
![Page 103: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/103.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Validation!
a set of hopeful
XML docs
a set of hopeful
XML docs
a set of valid
XML docs
a set of valid
XML docs
validation!
• Decidable!:• Summary graph traversal (parsing vs. DTD)• Memoization termination• Sound and complete!
• Decidable!:• Summary graph traversal (parsing vs. DTD)• Memoization termination• Sound and complete!
![Page 104: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/104.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
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
![Page 105: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/105.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
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
![Page 106: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/106.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Example Revisited
html greeting = <html> Hello <[who]>, welcome to <[what]>.</html>;
html cover = <html> <head><title>Welcome</title></head> <body><[contents]></body></html>;
html h;h = greeting <[who = ”Stranger”];h = h <[what = <html><b>BRICS</b></html>];show cover <[contents = h];
html greeting = <html> Hello <[who]>, welcome to <[what]>.</html>;
html cover = <html> <head><title>Welcome</title></head> <body><[contents]></body></html>;
html h;h = greeting <[who = ”Stranger”];h = h <[what = <html><b>BRICS</b></html>];show cover <[contents = h];
![Page 107: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/107.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Planting an Error
html greeting = <html> <td>Hello <[who]>, welcome to <[what]>.</td></html>;
html cover = <html> <head><title>Welcome</title></head> <body><table><[contents]></table></body></html>;
html h;h = greeting <[who = ”Stranger”];h = h <[what = <html><b>BRICS</b></html>];show cover <[contents = h];
html greeting = <html> <td>Hello <[who]>, welcome to <[what]>.</td></html>;
html cover = <html> <head><title>Welcome</title></head> <body><table><[contents]></table></body></html>;
html h;h = greeting <[who = ”Stranger”];h = h <[what = <html><b>BRICS</b></html>];show cover <[contents = h];
![Page 108: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/108.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Example Revisited--- welcome.wig:13 HTML Validation:welcome.wig:7 warning: possible illegal subelement ‘td’ of ‘table’ template: <table><[contents]></table> contents: td plugs: contents:{welcome.wig:13}
--- welcome.wig:13 HTML Validation:welcome.wig:7 warning: possible illegal subelement ‘td’ of ‘table’ template: <table><[contents]></table> contents: td plugs: contents:{welcome.wig:13}
123456789
10111213
html greeting = <html> <td>Hello <[who]>, welcome to <[what]>.</td></html>;
html cover = <html> <head><title>Welcome</title></head> <body><table><[contents]></table></body></html>;
html h;h = greeting <[who = ”Stranger”];h = h <[what = <html><b>BRICS</b></html>];show cover <[contents = h];
html greeting = <html> <td>Hello <[who]>, welcome to <[what]>.</td></html>;
html cover = <html> <head><title>Welcome</title></head> <body><table><[contents]></table></body></html>;
html h;h = greeting <[who = ”Stranger”];h = h <[what = <html><b>BRICS</b></html>];show cover <[contents = h];
![Page 109: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/109.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Problems?
• “DynDoc”:• Templates with named gaps• Plug and show
• Problems:• Forces linear document construction• Intermixes programmer / designer aspects• No input / output correspondence• No static HTML validation• No common fragments caching
![Page 110: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/110.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Problems?
• “DynDoc”:• Templates with named gaps• Plug and show
• Problems:• Forces linear document construction• Intermixes programmer / designer aspects• No input / output correspondence• No static HTML validation• No common fragments caching
![Page 111: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/111.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Problems?
• “DynDoc”:• Templates with named gaps• Plug and show
• Problems:• Forces linear document construction• Intermixes programmer / designer aspects• No input / output correspondence• No static HTML validation• No common fragments caching
![Page 112: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/112.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Outline
• Introduction
• Dynamic Documents
• Type Safety
• HTML Validation
• Caching
• Form-Field Validation
• Conclusion
![Page 113: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/113.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Outline
• Introduction
• Dynamic Documents
• Type Safety
• HTML Validation
• Caching
• Form-Field Validation
• Conclusion
![Page 114: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/114.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Document Representation
![Page 115: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/115.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Document Representation
document structure
![Page 116: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/116.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Document Representation
document structure
string
![Page 117: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/117.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Document Representation
document structure
string templates
![Page 118: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/118.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Document Representation
dynamic
![Page 119: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/119.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Document Representation
static
dynamic
![Page 120: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/120.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Document Representation
static
dynamic“Transmit JavaScript recipe for client-side doc. reconstruction”
“Transmit JavaScript recipe for client-side doc. reconstruction”
![Page 121: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/121.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Document Representation
static
dynamic“Transmit JavaScript recipe for client-side doc. reconstruction”
“Transmit JavaScript recipe for client-side doc. reconstruction”
“Write each template to a separate file so that it can be cached”
“Write each template to a separate file so that it can be cached”
![Page 122: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/122.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Experiments
• Size of HTML: original HTML
JavaScript reconstruction
...all templates cached
Cut to 2.6% – 25% size
![Page 123: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/123.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Experiments
• Time (download + render) on 700MHz PC, 28.8 Modem:
original HTML
...all templates cached
2.2x – 10x faster
![Page 124: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/124.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Problems?
• “DynDoc”:• Templates with named gaps• Plug and show
• Problems:• Forces linear document construction• Intermixes programmer / designer aspects• No input / output correspondence• No static HTML validation• No common fragments caching
![Page 125: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/125.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Problems?
• “DynDoc”:• Templates with named gaps• Plug and show
• Problems:• Forces linear document construction• Intermixes programmer / designer aspects• No input / output correspondence• No static HTML validation• No common fragments caching
![Page 126: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/126.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Outline
• Introduction
• Dynamic Documents
• Type Safety
• HTML Validation
• Caching
• Form-Field Validation
• Conclusion
![Page 127: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/127.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Outline
• Introduction
• Dynamic Documents
• Type Safety
• HTML Validation
• Caching
• Form-Field Validation
• Conclusion
![Page 128: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/128.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Example: ”EnterEmail”
html input = <html> Please enter your email:<br> <input type=”text” name=”email”></html>;
html output = <html>Your email is: <[email]></html>;
string s;show input receive[s = email];show output <[email = s];
html input = <html> Please enter your email:<br> <input type=”text” name=”email”></html>;
html output = <html>Your email is: <[email]></html>;
string s;show input receive[s = email];show output <[email = s];
![Page 129: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/129.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Example: ”EnterEmail”format Email = regexp(”\w@\w(\.\w)+”);
html input = <html> Please enter your email:<br> <input type=”text” name=”email”></html>;
html output = <html>Your email is: <[email]></html>;
string s;show input receive[s = email];show output <[email = s];
format Email = regexp(”\w@\w(\.\w)+”);
html input = <html> Please enter your email:<br> <input type=”text” name=”email”></html>;
html output = <html>Your email is: <[email]></html>;
string s;show input receive[s = email];show output <[email = s];
![Page 130: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/130.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Example: ”EnterEmail”format Email = regexp(”\w@\w(\.\w)+”);
html input = <html> Please enter your email:<br> <input type=”text” name=”email” format=”Email”></html>;
html output = <html>Your email is: <[email]></html>;
string s;show input receive[s = email];show output <[email = s];
format Email = regexp(”\w@\w(\.\w)+”);
html input = <html> Please enter your email:<br> <input type=”text” name=”email” format=”Email”></html>;
html output = <html>Your email is: <[email]></html>;
string s;show input receive[s = email];show output <[email = s];
![Page 131: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/131.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Example: ”EnterEmail”format Email = regexp(”\w@\w(\.\w)+”);
html input = <html> Please enter your email:<br> <input type=”text” name=”email” format=”Email”></html>;
html output = <html>Your email is: <[email]></html>;
string s;show input receive[s = email];show output <[email = s];
format Email = regexp(”\w@\w(\.\w)+”);
html input = <html> Please enter your email:<br> <input type=”text” name=”email” format=”Email”></html>;
html output = <html>Your email is: <[email]></html>;
string s;show input receive[s = email];show output <[email = s];
![Page 132: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/132.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
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
PowerFormsPowerFormsHTMLHTML
JavaScript
(subset)
JavaScript
(subset)
HTMLHTML
RegexpsRegexps
![Page 133: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/133.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Form-Field Interdependency
• “Favorite Letter”• Select filtering
• “NYC Office”• Complex interdependency
![Page 134: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/134.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Outline
• Introduction
• Dynamic Documents
• Type Safety
• HTML Validation
• Caching
• Form-Field Validation
• Conclusion
![Page 135: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/135.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
Outline
• Introduction
• Dynamic Documents
• Type Safety
• HTML Validation
• Caching
• Form-Field Validation
• Conclusion
![Page 136: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/136.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
<bigwig> Dynamic Documents+ Static Analyses:
• Yield: Flexible, Safe, and EfficientDynamic Generation of HTMLFlexible, Safe, and Efficient
Dynamic Generation of HTML
![Page 137: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/137.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
<bigwig> Dynamic Documents+ Static Analyses:
• Yield:
• AND:• Non-linear document construction• Separates programmer / designer aspects• Guaranteed input / output correspondence• Static HTML validation• Common fragments caching
Flexible, Safe, and EfficientDynamic Generation of HTMLFlexible, Safe, and Efficient
Dynamic Generation of HTML
![Page 138: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/138.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
The <bigwig> Compiler
• Version 2.0:• Implemented in C (for UNIX / Linux)• Complete source code available
– Approximately 2.5 MB source
• License: GPL (Gnu Public License)
<bigwig><bigwig>
HTMLHTML
CGI ScriptsCGI Scripts
JavaScriptJavaScript
HTTP Auth.HTTP Auth.
Java AppletsJava Applets
CompleteService
Specification
CompleteService
Specification
![Page 139: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/139.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
<bigwig> Publications
• Concurrency Control ETAPS/FASE, 1998• Runtime System WWW 8, 1999• Dynamic Documents POPL, 2000• Form-Field Validation WWW Journal, 2000• HTML Validation PASTE, 2001• The <bigwig> Project ...submitted, 2001• Syntax Macros ...submitted, 2001• Document Caching ...submitted, 2001• ...
![Page 140: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/140.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
http://www.brics.dk/bigwig/http://www.brics.dk/bigwig/
• Homepage:– Introduction– Examples– Ref. manual– Tutorials– Papers– Presentations– Downloads:
• src / bin
– 72 mins Audio/Video Presentation
![Page 141: Flexible, Safe, and Efficient Dynamic Generation of HTML](https://reader036.vdocuments.mx/reader036/viewer/2022081516/56813f98550346895daa891a/html5/thumbnails/141.jpg)
IBM Research, NY, USA Dynamic Generation of HTML July 13, 2001
The End