Presentation is loading. Please wait.

Presentation is loading. Please wait.

GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific Languages for Interactive Web Services Claus Brabrand [ Joint work with.

Similar presentations


Presentation on theme: "GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific Languages for Interactive Web Services Claus Brabrand [ Joint work with."— Presentation transcript:

1 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific Languages for 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 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 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 Project: http://www.brics.dk/bigwig/

3 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion

4 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion

5 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Program Family ”Web servers on which clients can initiate sessions that involve several exchanges of information that involve several exchanges of information mediated by HTML forms”. mediated by HTML forms”. server client Internet Interactive (Form-Based) Web Services:

6 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 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(" Servlet Demo "); if (session.isNew()) { out.println(" " + "Enter your name: " + " "); session.putValue("state", "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("name"); out.println("Goodbye " + name); session.invalidate(); } } out.println(" "); } } A Program from the Program Family Java Servlet

7 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 A Program from the Program Family WebService CLIENT INTERNET SERVER

8 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 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(" Servlet Demo "); if (session.isNew()) { out.println(" " + "Enter your name: " + " "); session.putValue("state", "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("name"); out.println("Goodbye " + name); session.invalidate(); } } out.println(" "); } } A Program from the Program Family session management Java Servlet

9 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 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(" Servlet Demo "); if (session.isNew()) { out.println(" " + "Enter your name: " + " "); session.putValue("state", "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("name"); out.println("Goodbye " + name); session.invalidate(); } } out.println(" "); } } A Program from the Program Family state management Java Servlet

10 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 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(" Servlet Demo "); if (session.isNew()) { out.println(" " + "Enter your name: " + " "); session.putValue("state", "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("name"); out.println("Goodbye " + name); session.invalidate(); } } out.println(" "); } } A Program from the Program Family document construction Java Servlet

11 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 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(" Servlet Demo "); if (session.isNew()) { out.println(" " + "Enter your name: " + " "); session.putValue("state", "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("name"); out.println("Goodbye " + name); session.invalidate(); } } out.println(" "); } } A Program from the Program Family Java Servlet session management state management document construction

12 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 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(" Servlet Demo "); if (session.isNew()) { out.println(" " + "Enter your name: " + " "); session.putValue("state", "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("name"); out.println("Goodbye " + name); session.invalidate(); } } out.println(" "); } } A Program from the Program Family session management state management document construction Java Servlet

13 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 The Language/System A high-level domain-specific programming language for developing interactive Web services. A high-level domain-specific programming language for developing interactive Web services. HTML CGI Scripts JavaScript HTTP Auth. Java Applets Complete Service Specification Complete Service Specification

14 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 = a Collection of Domain Specific Languages = a Collection of Domain Specific Languages C-like core language with C-like core language with Session-based runtime system Session-based runtime system Dynamic documents Dynamic documents Form-field validation Form-field validation Relational database Relational database Concurrency control Concurrency control Semantic security Semantic security Cryptographic security Cryptographic security Syntactic-level macros Syntactic-level macros

15 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 = a Collection of Domain Specific Languages = a Collection of Domain Specific Languages C-like core language with C-like core language with Session-based runtime system Session-based runtime system Dynamic documents Dynamic documents Form-field validation Form-field validation Relational database Relational database Concurrency control Concurrency control Semantic security Semantic security Cryptographic security Cryptographic security Syntactic-level macros Syntactic-level macros

16 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion

17 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion

18 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Implementation Approaches Traditionally 2 approaches: Traditionally 2 approaches: –Script-centered: Perl/CGI, Java Servlets, … Perl/CGI, Java Servlets, … –Page-centered: ASP, PHP, JSP,... ASP, PHP, JSP,...

19 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Script-Centered: Perl/CGI, Servlets,... e CLIENT INTERNET SERVER WebService

20 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Script-Centered: Perl/CGI, Servlets,... e CLIENT INTERNET SERVER WebService request

21 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Script-Centered: Perl/CGI, Servlets,... e CLIENT INTERNET SERVER WebService computereply

22 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Script-Centered: Perl/CGI, Servlets,... e CLIENT INTERNET SERVER e WebService HTML

23 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Script-Centered: Perl/CGI, Servlets,... e CLIENT INTERNET SERVER e WebService submit

24 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Script-Centered: Perl/CGI, Servlets,... e CLIENT INTERNET SERVER e WebService computereply

25 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Script-Centered: Perl/CGI, Servlets,... e CLIENT INTERNET SERVER e e WebService HTML

26 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 e e e Page-Centered: PHP, ASP, JSP,... CLIENT INTERNET SERVER WebService

27 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Page-Centered Increased level of abstraction: Increased level of abstraction: CGI protocol details abstracted away CGI protocol details abstracted away Easy to add dynamics to static pages: Easy to add dynamics to static pages: Scalability: Scalability: Specialized Web server Specialized Web server “Service code embedded in tags and interpreted by specialized Web server” interpreted by specialized Web server” Time:

28 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Script-Centered vs. Page-Centered As the service complexity increases: As the service complexity increases: –Page-Centered  Script-Centered A lot of HTML is generated by script elements A lot of HTML is generated by script elements Interesting duality: Interesting duality: Script-centered: Script-centered: –Default: programming, Escape: printing ( print ) Page-centered: Page-centered: –Default: printing, Escape: programming ( )

29 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Fundamental Drawbacks a_scriptanother_script submit WebService A service = a collection of scripts/pages! A service = a collection of scripts/pages! Implicit control-flow: Implicit control-flow: No interaction correspondence: No interaction correspondence:

30 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Session-Centered: Mawl and ! e CLIENT INTERNET SERVER e e Web Service show x; show y; x y submit

31 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Session-Centered: Mawl and ! e e Web Service show x; show y; x submit Domain specific abstration: show Domain specific abstration: show Explicit control-flow Explicit control-flow Check interaction correspondence Check interaction correspondence

32 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion

33 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion

34 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 e e e General Purpose  Manually CLIENT INTERNET SERVER WebService

35 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 e e e save General Purpose  Manually CLIENT INTERNET SERVER WebService

36 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 e e e save restore General Purpose  Manually CLIENT INTERNET SERVER WebService

37 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 General Purpose  Manually Private (to each session thread): Private (to each session thread): ServletContext context = getServletContext(); int p ((Integer) context.getAttribute("p")).intValue(); p++; context.setAttribute("p", new Integer(var));

38 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 General Purpose  Manually Private (to each session thread): Private (to each session thread): Shared (among all session threads): Shared (among all session threads): HttpSession session = request.getSession(true); int s ((Integer) session.getValue("s")).intValue(); s++; session.setValue("s", new Integer(var)); ServletContext context = getServletContext(); int p ((Integer) context.getAttribute("p")).intValue(); p++; context.setAttribute("p", new Integer(var));

39 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific: shared modifier Private (to each session thread): Private (to each session thread): int p;... p++;...

40 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific: shared modifier Private (to each session thread): Private (to each session thread): Shared (among all session threads): Shared (among all session threads): shared int s;... s++;... int p;... p++;...

41 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific  Automatically e CLIENT INTERNET SERVER e e Web Service [ save ] [ restore ] show x; show y; x y submit

42 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion

43 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion

44 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Dynamically Generated XML: Current Problems Traditionally: Traditionally: print(...) in Perl/CGI,... print(...) in Perl/CGI,... in PHP, ASP, JSP,... in PHP, ASP, JSP,... Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching

45 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Our Solution: HTML documents in Our Solution: HTML documents in Templates (1 st class, higher-order values): Templates (1 st class, higher-order values): XML fragments with named gaps: XML fragments with named gaps: Operations: Operations: plug:for document construction plug:for document construction show:for client interaction show:for client interaction [[ Hello ! Hello !]]

46 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Plug Plug: exp <[ id = exp ] Plug: exp <[ id = exp ]

47 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Plug Plug: exp <[ id = exp ] Plug: exp <[ id = exp ] Example: Example: html hello = [[ Hello ! ]]; html world = [[ World ]]; html h = hello <[what = world];...;

48 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Show Show: show exp ; Show: show exp ; x CLIENT INTERNET SERVER e show x; submit suspend resume

49 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Show Show: show exp ; Show: show exp ; Example: Example: x CLIENT INTERNET SERVER e show x; submit suspend resume html hello = [[ Hello ! ]]; html world = [[ World ]]; html h = hello <[what = world]; show h;

50 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Show-Receive Show: show exp receive[v =f,... ]; Show: show exp receive[v =f,... ]; x CLIENT INTERNET SERVER e f,... submit show x receive[v=f,..];

51 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Show-Receive Show: show exp receive[v =f,... ]; Show: show exp receive[v =f,... ]; Example: Example: string s; html input = [[ Enter email: Enter email: ]]; show input receive[s = email]; x CLIENT INTERNET SERVER e show x receive[v=f,..]; f,... submit

52 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Example: ”Welcome” html greeting = [[ Hello, welcome to. Hello, welcome to. ]]; html cover = [[ Welcome Welcome ]]; html h; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h];

53 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Flexibility: PHP/ASP/JSP List of results (e.g. “search engine”): List of results (e.g. “search engine”): One template with 10,20,30, or 40 hardwired server-side script elements: One template with 10,20,30, or 40 hardwired server-side script elements: One template with one big ”generate-all” server-side script element:  script-centered One template with one big ”generate-all” server-side script element:  script-centered...or... : <% for i=1 to N do {..i.. } %> {..i.. } %>

54 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Flexibility: Flexibility: List of results (e.g. “search engine”): List of results (e.g. “search engine”): 1 2 : N 1 2 : N

55 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Flexibility: Flexibility: List of results (e.g. “search engine”): List of results (e.g. “search engine”): Two templates: “ layout ” and “ entry ”... Two templates: “ layout ” and “ entry ”... 1 2 : N 1 2 : N html layout = [[ ]]; html entry = [[ ]];

56 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Flexibility: Flexibility: List of results (e.g. “search engine”): List of results (e.g. “search engine”): Two templates: “ layout ” and “ entry ”... Two templates: “ layout ” and “ entry ”......and one recursive function: “ f ”...and one recursive function: “ f ” html f(int n) { if (n == 0) return layout; if (n == 0) return layout; return f(n-1) <[items = entry <[num = n]]; return f(n-1) <[items = entry <[num = n]];} html layout = [[ ]]; html entry = [[ ]]; 1 2 : N 1 2 : N

57 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Flexibility: Flexibility: List of results (e.g. “search engine”): List of results (e.g. “search engine”): Two templates: “ layout ” and “ entry ”... Two templates: “ layout ” and “ entry ”......and one recursive function: “ f ”...and one recursive function: “ f ” Example usage: Example usage: html f(int n) { if (n == 0) return layout; if (n == 0) return layout; return f(n-1) <[items = entry <[num = n]]; return f(n-1) <[items = entry <[num = n]];} 1 2 : 27 1 2 : 27 html layout = [[ ]]; html entry = [[ ]]; show f(27);

58 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 html f(int n) { if (n == 0) return layout; if (n == 0) return layout; return f(n-1) <[items = entry <[num = n]]; return f(n-1) <[items = entry <[num = n]];} html layout = [[ ]]; html entry = [[ ]]; Flexibility: Separates Designer / Programmer Aspects

59 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 html f(int n) { if (n == 0) return layout; if (n == 0) return layout; return f(n-1) <[items = entry <[num = n]]; return f(n-1) <[items = entry <[num = n]];} html layout = [[ ]]; html entry = [[ ]]; html layout = [[ ]]; html entry = [[ ]]; Flexibility: Separates Designer / Programmer Aspects

60 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Problems? “DynDoc”: “DynDoc”: Templates with named gaps Templates with named gaps Plug and show Plug and show Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching

61 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Problems? “DynDoc”: “DynDoc”: Templates with named gaps Templates with named gaps Plug and show Plug and show Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching

62 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Problems? “DynDoc”: “DynDoc”: Templates with named gaps Templates with named gaps Plug and show Plug and show Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching

63 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Problems? “DynDoc”: “DynDoc”: Templates with named gaps Templates with named gaps Plug and show Plug and show Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching

64 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Problems? Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching a_scriptanother_script submit

65 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion

66 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion

67 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Type Safety (in terms of ) Show/Receive correspondence: Show/Receive correspondence: Gap presence: Gap presence: html d = [[ Enter email: Enter email: ]]; show d receive[s = age]; html hello = [[ Hello ! ]]; html world = [[ World ]]; html h; h = hello <[contents = world];  

68 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Static Analysis! Apply standard, data-flow analysis techniques, but with highly domain-specific lattices

69 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Static Analysis! Conservatively approximate for all HTML variables & program points: Conservatively approximate for all HTML variables & program points: Their gaps and fields (and their kinds)  all possible runtime values Their gaps and fields (and their kinds)  all possible runtime values Forward data-flow analysis: Forward data-flow analysis: 1. Control-flow graph (trivial for ) 2. Finite lattice: Gap-and-Field 3. Monotone transfer functions: plug, assign,...

70 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Gap-and-Field Lattice GKind nogap string html error FKind text nofield checkboxradio tup(F 1 ) rel(F 1 )rel(F n ) tup(F n ).. An abstract document is: (GName  GKind) x (FName  FKind) An abstract document is: (GName  GKind) x (FName  FKind) FNameFKind ahtml ghtml nnogap GNameGKindahtml ghtml nnogap

71 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Functions Plug: Plug: x 1 <[g = x 2 ] x 1 <[g = x 2 ]

72 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Functions Plug: Plug: x 1 <[g = x 2 ] x 1 <[g = x 2 ]FNameFKindahtml ghtml nnogapFNameFKindahtml ghtml nnogap GNameGKindanogap gnogap nhtmlGNameGKindahtml ghtml nnogap

73 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Functions Plug: Plug: x 1 <[g = x 2 ] x 1 <[g = x 2 ] <[g = ]  FNameFKind ahtml ghtml nnogap GNameGKindahtml ghtml nnogap FNameFKindahtml ghtml nnogap GNameGKindanogap gnogap nhtml FNameFKindahtml ghtml nnogap GNameGKinda g n  G : GKind x GKind  GKind

74 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Functions Plug: Plug: x 1 <[g = x 2 ] x 1 <[g = x 2 ] <[g = ]  FNameFKind ahtml ghtml nnogap GNameGKindahtml ghtml nnogap FNameFKindahtml ghtml nnogap GNameGKindanogap gnogap nhtml FNameFKindahtml ghtml nnogap GNameGKindahtml g n  G : GKind x GKind  GKind

75 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Functions Plug: Plug: x 1 <[g = x 2 ] x 1 <[g = x 2 ] <[g = ]  FNameFKind ahtml ghtml nnogapFNameFKindahtml ghtml nnogapFNameFKindahtml ghtml nnogap GNameGKindahtml ghtml nnogapGNameGKindanogap gnogap nhtmlGNameGKindahtml gnogap n  G : GKind x GKind  GKind

76 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Functions Plug: Plug: x 1 <[g = x 2 ] x 1 <[g = x 2 ] <[g = ]  FNameFKind ahtml ghtml nnogapFNameFKindahtml ghtml nnogapFNameFKindahtml ghtml nnogap GNameGKindahtml ghtml nnogapGNameGKindanogap gnogap nhtmlGNameGKindahtml gnogap nhtml  G : GKind x GKind  GKind

77 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Functions Plug: Plug: x 1 <[g = x 2 ] x 1 <[g = x 2 ] <[g = ] FNameFKindahtml ghtml nnogapFNameFKindahtml ghtml nnogapFNameFKindahtml ghtml nnogap GNameGKindahtml ghtml nnogapGNameGKindanogap gnogap nhtmlGNameGKindahtml gnogap nhtml

78 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Then: Check Solution Traverse solution: intercept errors Traverse solution: intercept errors

79 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Then: Check Solution Traverse solution: intercept errors Traverse solution: intercept errors  gap present E 1 <[g = E 2 ] FNameFKindahtml ghtml nnogap GNameGKindahtml ghtml nnogap

80 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Then: Check Solution Traverse solution: intercept errors Traverse solution: intercept errors  gap present  field present type check: v ~ text E 1 <[g = E 2 ] show E receive[v=f,... ]; FNameFKindahtml ghtml nnogap GNameGKindahtml ghtml nnogap GNameGKindahtml ghtml nnogap FNameFKinderadio ftext ttext

81 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Type Safety? Show/Receive interaction correspondence: Show/Receive interaction correspondence: Gap presence: Gap presence: html d = [[ Enter email: Enter email: ]]; show d receive[s = age]; html hello = [[ Hello ! ]]; html world = [[ World ]]; html h; h = hello <[contents = world];  

82 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Type Safety! Show/Receive interaction correspondence: Show/Receive interaction correspondence: Gap presence: Gap presence: html d = [[ Enter email: Enter email: ]]; show d receive[s = age]; html hello = [[ Hello ! ]]; html world = [[ World ]]; 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’

83 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Problems? “DynDoc”: “DynDoc”: Templates with named gaps Templates with named gaps Plug and show Plug and show Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching

84 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Problems? “DynDoc”: “DynDoc”: Templates with named gaps Templates with named gaps Plug and show Plug and show Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching

85 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Problems? “DynDoc”: “DynDoc”: Templates with named gaps Templates with named gaps Plug and show Plug and show Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching

86 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Example: ”Welcome” html greeting = [[ Hello, welcome to. Hello, welcome to. ]]; html cover = [[ Welcome Welcome ]]; html h; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h];

87 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Example: ”Welcome” html greeting = [[ Hello, welcome to. Hello, welcome to. ]]; html cover = [[ Welcome Welcome ]]; html h; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h]; Valid HTML !?

88 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Static Analysis (again)! Conservatively approximate for all HTML variables & program points: Conservatively approximate for all HTML variables & program points: A summary graph  all possible runtime values A summary graph  all possible runtime values Forward data-flow analysis: Forward data-flow analysis: 1. Control-flow graph: (trivial for ) 2. Finite lattice: summary graphs 3. Monotone transfer functions: plug, assign,...

89 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Summary Graph html greeting =...; html cover =...; html h; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h];

90 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Summary Graph ”Stranger” greeting who html greeting =...; html cover =...; html h; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h];

91 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Summary Graph ”Stranger” greeting gpce who what html greeting =...; html cover =...; html h; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h];

92 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Summary Graph ”Stranger” cover greeting gpce contentswho what html greeting =...; html cover =...; html h; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h];

93 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Function Plug: Plug: x 1 <[g = x 2 ] x 1 <[g = x 2 ]

94 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Function Plug: Plug: g g gg x 1 <[g = x 2 ] x 1 <[g = x 2 ]

95 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Function Plug: Plug: <[g = ] x 1 <[g = x 2 ] x 1 <[g = x 2 ] g g gg

96 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Function Plug: Plug: <[g = ]  x 1 <[g = x 2 ] x 1 <[g = x 2 ] g g gg g g gg

97 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Function Plug: Plug: <[g = ]  x 1 <[g = x 2 ] x 1 <[g = x 2 ] g g gg g g gg

98 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Function Plug: Plug: <[g = ]  x 1 <[g = x 2 ] x 1 <[g = x 2 ] g g gg g g gg However, too imprecise...!

99 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Function <[g = ]  Plug: Plug: open gaps x 1 <[g = x 2 ] x 1 <[g = x 2 ] g g gg g g gg

100 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Function Plug: Plug: x 1 <[g = x 2 ] x 1 <[g = x 2 ] <[g = ]  open gaps g g gg g g gg

101 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 GapTrack Analysis GapTrack data-flow analysis: GapTrack data-flow analysis: –  program points compute: “Tracks the origins (templates) of open gaps” “Tracks the origins (templates) of open gaps”  (g ) (g ) (g ) (g )   ’ ’ ’ ’  : GName  2 TEMPLATES <[g = ]  g g gg g g gg

102 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003...; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h]; Now: summary graph  show statements Now: summary graph  show statements Then what...? Then what...? Validation? ”Stranger” cover greeting brics contentswho what

103 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Validation? a set of a set ofhopeful XML docs a set of a set ofhopeful XML docs A summary graph describes:

104 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Validation? a set of a set ofhopeful XML docs a set of a set ofhopeful XML docs a set of a set ofvalid XML docs a set of a set ofvalid XML docs A summary graph describes: A DTD describes (e.g. XHTML 1.0):

105 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Validation! a set of a set ofhopeful XML docs a set of a set ofhopeful XML docs a set of a set ofvalid XML docs a set of a set ofvalid XML docs  validation! A summary graph describes: A DTD describes (e.g. XHTML 1.0):

106 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Validation! a set of a set ofhopeful XML docs a set of a set ofhopeful XML docs a set of a set ofvalid XML docs a set of a set ofvalid XML docs  validation 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!

107 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Compiler Validation Recipe Step-by-Step: 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 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Experiments 800MHz Pentium III / Linux Program# Lines# TemplatesTime (sec.) chat 65 30.1 guess 75 60.1 calendar 77 50.1 xbiff 561 180.1 webboard 1132 370.6 cdshop 1709 360.5 jaoo 1941 732.4 bachelor 25351378.2 courses 4465 571.3 eatcs 53451336.7 Many validation errors found, no spurious errors

109 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Example Revisited html greeting = [[ Hello, welcome to. ]]; html cover = [[ Welcome ]]; html h; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h]; html greeting = [[ Hello, welcome to. ]]; html cover = [[ Welcome ]]; html h; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h];

110 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Planting an Error html greeting = [[ Hello, welcome to. ]]; html cover = [[ Welcome ]]; html h; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h]; html greeting = [[ Hello, welcome to. ]]; html cover = [[ Welcome ]]; html h; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h];

111 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Example Revisited --- welcome.wig:13 HTML Validation: welcome.wig:7 warning: possible illegal subelement ‘td’ of ‘table’ template: contents: td plugs: contents:{welcome.wig:13} --- welcome.wig:13 HTML Validation: welcome.wig:7 warning: possible illegal subelement ‘td’ of ‘table’ template: contents: td plugs: contents:{welcome.wig:13} 12345678910111213 html greeting = [[ Hello, welcome to. ]]; html cover = [[ Welcome ]]; html h; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h]; html greeting = [[ Hello, welcome to. ]]; html cover = [[ Welcome ]]; html h; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h];

112 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Problems? “DynDoc”: “DynDoc”: Templates with named gaps Templates with named gaps Plug and show Plug and show Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching

113 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Problems? “DynDoc”: “DynDoc”: Templates with named gaps Templates with named gaps Plug and show Plug and show Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching

114 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Problems? “DynDoc”: “DynDoc”: Templates with named gaps Templates with named gaps Plug and show Plug and show Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching

115 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion

116 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion

117 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific Representation

118 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific Representation Constant: Constant: O (1) O (1) Plug: Plug: O (1) O (1) Show: Show: O (|d|) O (|d|) [[ hello ! ]] x <[g = y] show d;

119 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific Representation document structure

120 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific Representation document structure string

121 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific Representation document structure stringtemplates

122 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific Representation dynamic

123 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific Representation static dynamic

124 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific Representation static dynamic “Transmit JavaScript recipe for client-side doc. reconstruction” “Transmit JavaScript recipe for client-side doc. reconstruction”

125 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific 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”

126 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Experiments Size of HTML: Size of HTML: original HTML JavaScript reconstruction...all templates cached Cut to 2.6% – 25% size

127 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Experiments (700MHz, 28.8 Modem) Time (download+render): Time (download+render): original HTML...all templates cached 2.2x – 10x faster

128 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Problems? “DynDoc”: “DynDoc”: Templates with named gaps Templates with named gaps Plug and show Plug and show Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching

129 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Problems? “DynDoc”: “DynDoc”: Templates with named gaps Templates with named gaps Plug and show Plug and show Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching

130 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion

131 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion

132 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Example: ”EnterEmail” html input = [[ Please enter your email: Please enter your email: ]]; html output = [[ Your email is: ]]; string s; show input receive[s = email]; show output <[email = s];

133 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Example: ”EnterEmail” format Email = regexp(” @ (\. )+”); html input = [[ Please enter your email: Please enter your email: ]]; html output = [[ Your email is: ]]; string s; show input receive[s = email]; show output <[email = s];

134 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Example: ”EnterEmail” format Email = regexp(” @ (\. )+”); html input = [[ Please enter your email: Please enter your email: ]]; html output = [[ Your email is: ]]; string s; show input receive[s = email]; show output <[email = s];

135 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Example: ”EnterEmail” format Email = regexp(” @ (\. )+”); html input = [[ Please enter your email: Please enter your email: ]]; html output = [[ Your email is: ]]; string s; showshow input receive[s = email]; show show output <[email = s];

136 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Form Field Validation: “PowerForms” Domain specific language: Domain specific language: uniquely for form-field validation uniquely for form-field validation Declarative specification (regexps): Declarative specification (regexps): Abstracts away operational details Abstracts away operational details PowerForms also available as stand-alone tool PowerForms also available as stand-alone tool PowerFormsPowerForms HTML JavaScript (subset) JavaScript (subset) HTML Regexps

137 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Form-Field Interdependency “Favorite Letter” “Favorite Letter”Favorite LetterFavorite Letter Select filtering Select filtering “NYC Office” “NYC Office”NYC OfficeNYC Office Complex interdependency Complex interdependency

138 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion

139 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion

140 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific Language Design and Analyses: Yield: Yield: Flexible, Safe, and Efficient Dynamic Generation of XML

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

142 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Objective Assessments Robustness: Robustness: Session integrity Session integrity State integrity State integrity Interaction correspondence Interaction correspondence XML validity XML validity Performance Performance Well... Well... Conciseness Conciseness 1/5 code (compared to Java Servlets) 1/5 code (compared to Java Servlets)

143 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 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(" Servlet Demo "); if (session.isNew()) { out.println(" " + "Enter your name: " + " "); session.putValue("state", "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("name"); out.println("Goodbye " + name); session.invalidate(); } } out.println(" "); } } session management state management document construction Conciseness (Servlets)

144 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Conciseness ( ) service { shared int users = 0; session Hello() { string name; show [[Enter your name: ]] receive[name=handle]; users++; show [[Hello, you are user number ]] ]] <[who=name]; } }

145 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Conciseness ( ) service { shared int users = 0; session Hello() { string name; show [[Enter your name: ]] receive[name=handle]; users++; show [[Hello, you are user number ]] ]] <[who=name]; } } session management state management document construction misc. Overall: 1/5 code

146 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 The Compiler Version 2.0: Version 2.0: Implemented in C (for UNIX / Linux) Implemented in C (for UNIX / Linux) Complete source code available Complete source code available –Approximately 2.5 MB source License: GPL (Gnu Public License) License: GPL (Gnu Public License) HTML CGI Scripts JavaScript HTTP Auth. Java Applets Complete Service Specification Complete Service Specification

147 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Homepage: Homepage: –Introduction –Examples –Ref. manual –Tutorials –Papers –Presentations –Downloads: src / bin src / bin –2 Recorded Presentations (MS & IBM Research) http://www.brics.dk/bigwig/

148 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Publications Publications Concurrency ControlETAPS/FASE,1998 Concurrency ControlETAPS/FASE,1998 Runtime SystemComputer Networks J., 1999 Runtime SystemComputer Networks J., 1999 Dynamic DocumentsPOPL, 2000 Dynamic DocumentsPOPL, 2000 Form-Field ValidationWWW Journal, 2000 Form-Field ValidationWWW Journal, 2000 HTML ValidationPASTE, 2001 HTML ValidationPASTE, 2001 The ProjectTOIT Journal,2002 The ProjectTOIT Journal,2002 Syntax MacrosPEPM, 2002 Syntax MacrosPEPM, 2002 Document CachingWWW Journal, 2002 Document CachingWWW Journal, 2002

149 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 JWIG (Java) JWIG (Java) http://www.brics.dk/JWIG/

150 GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Thank you!


Download ppt "GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific Languages for Interactive Web Services Claus Brabrand [ Joint work with."

Similar presentations


Ads by Google