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

Slides:



Advertisements
Similar presentations
Microsoft Research March 20, 2000 A Programming Language for Developing Interactive Web Services Claus Brabrand BRICS, University of Aarhus, Denmark.
Advertisements

Java Script Session1 INTRODUCTION.
JSP1 Java Server Pages (JSP) Introducing JavaServer Pages TM (JSP TM ) JSP scripting elements.
DT228/3 Web Development WWW and Client server model.
Java Servlet & JSP © copyright 2005 SNU OOPSLA Lab.
Servlets Stoney Jackson
CSE 190: Internet E-Commerce Lecture 7. HTML Templates Designed to separate server side logic from HTML presentation Key features –Escapes from HTML into.
An introduction to Java Servlet Programming
28/1/2001 Seminar in Databases in the Internet Environment Introduction to J ava S erver P ages technology by Naomi Chen.
18-Jun-15 JSP Java Server Pages Reference: Tutorial/Servlet-Tutorial-JSP.html.
JSP Java Server Pages Reference:
Datalogforeningen December 7, 1999 A Programming Language for Developing Interactive Web Services Claus Brabrand BRICS, University of Aarhus, Denmark.
Static Validation of Dynamically Generated XML Documents A survey on a series of papers by the BRICS research group at the University of Aarhus, Denmark.
Java Server Pages Russell Beale. What are Java Server Pages? Separates content from presentation Good to use when lots of HTML to be presented to user,
Introduction to Servlet & JSP
Java Server and Servlet CS616 Team 9 Kim Doyle, Susan Kroha, Arunima Palchowdhury, Wei Xu.
JSP Architecture  JSP is a simple text file consisting of HTML or XML content along with JSP elements  JSP packages define the interface for the compiled.
Servlets Compiled by Dr. Billy B. L. Lim. Servlets Servlets are Java programs which are invoked to service client requests on a Web server. Servlets extend.
Java Servlets. What Are Servlets? Basically, a java program that runs on the server Basically, a java program that runs on the server Creates dynamic.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
Server-side Technologies
Introduction Servlets and JSP Celsina Bignoli
Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 15: PHP Introduction.
INTRODUCTION TO WEB DATABASE PROGRAMMING
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 9 JavaServer Pages (JSP) (Based on Møller.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
PHP TUTORIAL. HISTORY OF PHP  PHP as it's known today is actually the successor to a product named PHP/FI.  Created in 1994 by Rasmus Lerdorf, the very.
Servlets. - Java technology for Common Gateway Interface (CGI) programming. - It is a Java class that dynamically extends the function of a web server.
WWW8 - Toronto "A Runtime System for Interactive Web Services" May 12, 1999 A Runtime System for Interactive Web Services Claus Brabrand, Anders Møller,
Java support for WWW Babak Esfandiari (sources: Qusay Mahmoud, Roger Impey, textbook)
Chapter 7 Java Server Pages. Objectives Explain how the separation of concerns principle applies to JSP Describe the operation and life-cycle of a JSP.
Web Server Programming 1. Nuts and Bolts. Premises of Course Provides general introduction, no in-depth training Assumes some HTML knowledge Assumes some.
JAVA SERVER PAGES. 2 SERVLETS The purpose of a servlet is to create a Web page in response to a client request Servlets are written in Java, with a little.
Slides © Marty Hall, book © Sun Microsystems Press 1 JSP Scripting Elements Core Servlets & JSP book:
Chapter 3 Servlet Basics. 1.Recall the Servlet Role 2.Basic Servlet Structure 3.A simple servlet that generates plain text 4.A servlet that generates.
Webcommerce Computer Networks Webcommerce by Linnea Reppa Douglas Martindale Lev Shalevich.
Mark Dixon 1 09 – Java Servlets. Mark Dixon 2 Session Aims & Objectives Aims –To cover a range of web-application design techniques Objectives, by end.
1 CS122B: Projects in Databases and Web Applications Spring 2015 Notes 03: Web-App Architectures Professor Chen Li Department of Computer Science CS122B.
CSC 2720 Building Web Applications JavaServer Pages (JSP) The Basics.
20-Nov-15introServlets.ppt Intro to servlets. 20-Nov-15introServlets.ppt typical web page – source Hello Hello.
Overview of Form and Javascript fundamentals. Brief matching exercise 1. This is the software that allows a user to access and view HTML documents 2.
Servlets Part 3. Topics Session Tracking ServletToServletCommunication-Servlet Chaining ServerSideIncludes AppletToServlet.
JavaServer Page by Antonio Ko. Overview ► Introduction ► What is a servlet? ► What can servlets do? ► Servlets Vs JSP ► Syntax ► Samples ► JavaBean ►
ASP (Active Server Pages) by Bülent & Resul. Presentation Outline Introduction What is an ASP file? How does ASP work? What can ASP do? Differences Between.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
Java Servlets and Java Server Pages Norman White Stern School of Business.
Copyright © 2002 ProsoftTraining. All rights reserved. Java Servlets.
JSP Pages. What and Why of JSP? JSP = Java code imbedded in HTML or XML –Static portion of the page is HTML –Dynamic portion is Java Easy way to develop.
Middleware 3/29/2001 Kang, Seungwoo Lee, Jinwon. Description of Topics 1. CGI, Servlets, JSPs 2. Sessions/Cookies 3. Database Connection(JDBC, Connection.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, Responds oriented other.
1 Introduction to Servlets. Topics Web Applications and the Java Server. HTTP protocol. Servlets 2.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 1COMP9321, 15s2, Week.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
©SoftMoore ConsultingSlide 1 Overview of Servlets and JavaServer Pages (JSP)
Java Servlets and Java Server Pages
How CGI and Java Servlets are Run By David Stein 14 November 2006.
 Java Server Pages (JSP) By Offir Golan. What is JSP?  A technology that allows for the creation of dynamically generated web pages based on HTML, XML,
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
Bayu Priyambadha, S.Kom. Static content  Web Server delivers contents of a file (html) 1. Browser sends request to Web Server 3. Web Server sends HTML.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
1 Web Programming with Servlets & JSPs WEB APPLICATIONS – AN OVERVIEW.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
Introduction Servlets and JSP
Servlet Fudamentals.
Servlets and Java Server Pages
Presentation transcript:

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

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:

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

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

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:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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:

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 ( )

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:

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

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

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

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

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

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

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

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));

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));

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++;...

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++;...

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

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

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

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

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 !]]

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

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];...;

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

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;

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,..];

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 Enter ]]; show input receive[s = ]; x CLIENT INTERNET SERVER e show x receive[v=f,..]; f,... submit

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];

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.. } %>

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

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 ” : N 1 2 : N html layout = [[ ]]; html entry = [[ ]];

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

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 html layout = [[ ]]; html entry = [[ ]]; show f(27);

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

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

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

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

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

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

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

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

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

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 Enter ]]; show d receive[s = age]; html hello = [[ Hello ! ]]; html world = [[ World ]]; html h; h = hello <[contents = world];  

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

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

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

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 ]

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

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

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

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

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

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

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

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

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

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 Enter ]]; show d receive[s = age]; html hello = [[ Hello ! ]]; html world = [[ World ]]; html h; h = hello <[contents = world];  

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 Enter ]]; show d receive[s = age]; html hello = [[ Hello ! ]]; html world = [[ World ]]; html h; h = hello <[contents = world]; *** receive.wig:5: input field ‘ ’ not received no such input field ‘age’ *** receive.wig:5: input field ‘ ’ not received no such input field ‘age’ *** plug.wig:5: no such gap ‘contents’

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

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

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

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];

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 !?

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

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];

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];

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];

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];

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 ]

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 ]

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

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

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

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

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

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

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

GPCE 2003, Erfurt Dynamic Generation of XML September 22, ; 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

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:

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):

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):

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!

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

GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Experiments 800MHz Pentium III / Linux Program# Lines# TemplatesTime (sec.) chat guess calendar xbiff webboard cdshop jaoo bachelor courses eatcs Many validation errors found, no spurious errors

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];

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];

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} 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];

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

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

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

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

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

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

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;

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

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

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

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

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

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”

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”

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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)

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)

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]; } }

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

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

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)

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

GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 JWIG (Java) JWIG (Java)

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