Kurt Nørmark ©
Department of Computer Science
Aalborg University
Denmark
Abstract Index References Contents | In this talk I present a programmatic approach to authoring of WWW material. The approach is based on my work on LAML in Scheme. With LAML it is possible to generate HTML pages from a Scheme document source. The basic idea is to mirror HTML to a number of Scheme functions. Based on this mirror, a number of document styles, tools, and additional libraries have been built. The creation of abstractions in terms of functions is a key to mastering complexity - in program development as well as WEB development. But also the possibility to perform immediate automation of routine tasks at the most natural places in the document is an important characteristics of programmatic authoring. In the talk we will discuss discuss programmatic authoring as a contrast to other WWW authoring possibilities, and we will illustrate the practical potential of the approach by a variety of different examples. We will also briefly touch of server side CGI programming using LAML. |
Programmatic Authoring |
Classes of WWW documents Slide Note Contents Index References |
|
|
|
Authoring of WWW materials Slide Note Contents Index References |
|
Programmatic authoring Slide Note Contents Index References |
The concept Programmatic authoring: Using programmatic authoring the document source is a program written in a programming language. The document is classified as a generated document. Executing the program causes a transformation of the document source program to another format, typically HTML. |
|
|
Disadvantages of programmatic authoring Slide Note Contents Index References |
|
|
Which programming paradigm and language? Slide Note Contents Index References |
|
|
|
Scheme Slide Note Contents Index References |
|
|
|
|
An Introductory Example |
Overall document abstractions Slide Note Contents Index References |
|
Program: A very simple HTML document that illustrates the overall HTML document structure. It may, however, be tedious to write these tags for each and every small HTML page you have to produce. | <html> <head> <title>This is the document title</title> </head> <body> <h1>Document title</h1> <p>Here is the first paragraph of the document</p> <p>The second paragraph has an <em>emphasized item</em> and a <b>bold face item</b>. </p> </body> </html> |
Program: The same document as an LAML expression. We see that the the shift from HTML to LAML is a matter of a few syntactical changes. Notice the use of the underscore character, which suppresses the insertion of white space. This document cannot be processed immediately. However, the next version that we show can. | (html (head (title "This is the document title") ) (body (h1 "Document title") (p "Here is the first paragraph of the document") (p "The second paragraph has an" (em "emphasized item") "and a" (b "bold face item")_".") ) ) |
Program: The document from above embedded in the LAML framework. Besides initial loading, we see the imperative writing of the functionally generated document to a specific target file. The if the source file is doc1.laml, the target file will be doc1.html. | (load (string-append laml-dir "laml.scm")) (style "simple-html4.0-loose") (write-text-file (html (head (title "This is the document title") ) (body (h1 "Document title") (p "Here is the first paragraph of the document") (p "The second paragraph has an" (em "emphasized item") "and a" (b "bold face item")_".") ) ) (full-source-path-with-extension "html")) |
Program: The document from above abstracted with the procedure www-document. We also show the definition of www-document, which typically will be moved to some LAML library for general use. By the way, the LAML libraries already has similar procedures, such as generic-page in the style simple-html4.0-loose. | (load (string-append laml-dir "laml.scm")) (style "simple-html4.0-loose") (lib-load "color.scm") (define (www-document ttl bd background-color) (write-text-file (html (head (title ttl) ) (body 'bgcolor (rgb-color-list background-color) bd)) (full-source-path-with-extension "html"))) (www-document "This is the document title" (con (h1 "Document title") (p "Here is the first paragraph of the document") (p "The second paragraph has an" (em "emphasized item") "and a" (em "bold face item")_".")) red) |
Program: The document from above with pretty printing of the generated HTML document. We only on very rare occasions pretty print the resulting HTML document. The reason is that the HTML document is a derived, low level representation of the document which is only rarely consulted by humans. The parsing and pretty printing functions are part of a LAML tool for HTML parsing and pretty printing. | (load (string-append laml-dir "laml.scm")) (style "simple-html4.0-loose") (lib-load "color.scm") (load (string-append laml-dir "tools/xml-html-support/html-support.scm")) (define (www-document ttl bd background-color) (write-text-file (pretty-print-html-parse-tree (parse-html-string (html (head (title ttl) ) (body 'bgcolor (rgb-color-list background-color) bd)))) (full-source-path-with-extension "html"))) (www-document "This is the document title" (con (h1 "Document title") (p "Here is the first paragraph of the document") (p "The second paragraph has an" (em "emphasized item") "and a" (em "bold face item")_".")) red) |
|
Quiz example Slide Note Contents Index References |
|
Program: The LAML source of a multiple choice quiz. | (load (string-append laml-dir "laml.scm")) (style "demo-quiz") (quiz (list (quiz-entry (question-formulation "What is programmatic WWW authoring?") (answers (list (answer (answer-formulation "Authoring for programmers")) (answer (answer-formulation "Authoring by means of program development"))))) (quiz-entry (question-formulation "What is LAML?") (answers (list (answer (answer-formulation "A markup language in the SGML family")) (answer (answer-formulation "A set of Scheme libraries for textual markup purposes")) (answer (answer-formulation "A Lisp abstracted markup language"))))) ) ) |
Program: An equivalent HTML document for the presentation of the quiz. Notice that this document only contains a subset of the information in the quiz. Notice the difference in abstration level of the two documents. | <html> <head> <title> Quiz Example </title> </head> <body> <font color="#ff0000"> <b> What is programmatic WWW authoring? </b> </font> <br> <input type="CHECKBOX" value="true" name="a-1-1"> Authoring for programmers <br> <input type="CHECKBOX" value="true" name="a-1-2"> Authoring by means of program development <p> <font color="#ff0000"> <b> What is LAML? </b> </font> <br> <input type="CHECKBOX" value="true" name="a-2-1"> A markup language in the SGML family <br> <input type="CHECKBOX" value="true" name="a-2-2"> A set of Scheme libraries for textual markup purposes <br> <input type="CHECKBOX" value="true" name="a-2-3"> A Lisp abstracted markup language </body> </html> |
Program: A more comprehensive variant of the LAML quiz. The document contains information about correctness and clarification of the individual answers. | (load (string-append laml-dir "laml.scm")) (style "demo-quiz") (quiz (list (quiz-entry (question-formulation "What is programmatic WWW authoring?") (answers (list (answer (answer-formulation "Authoring for programmers") (answer-correctness 0) (answer-clarification "Using programmatic authoring the document source is a program")) (answer (answer-formulation "Authoring by means of program development") (answer-correctness 100) (answer-clarification "The source of each WWW document is program"))))) (quiz-entry (question-formulation "What is LAML?") (answers (list (answer (answer-formulation "A markup language in the SGML family") (answer-correctness 0) (answer-clarification "LAML is a markup language using Lisp syntax")) (answer (answer-formulation "A set of Scheme libraries for textual markup purposes") (answer-correctness 90) (answer-clarification "In addition there are various tools in the LAML package")) (answer (answer-formulation "A Lisp abstracted markup language") (answer-correctness 100) (answer-clarification "The name covers document styles, libraries and tools"))))) ) ) |
|
The LAML System |
LAML: Lisp Abstracted Markup Language Slide Note Contents Index References | We now introduce LAML, which basically is Scheme with access to libraries which mirror HTML. In addition, we support a number of functions which in our experience are very helpful during a typical WWW authoring process. Some of these functions are organized in document styles. |
|
|
HTML mirroring Slide Note Contents Index References |
|
|
|
The HTML4.0 Mirror in LAML Slide Note Contents Index References | We will here describe the HTML4.0 loose mirror in LAML |
|
Syntax: We show the syntax of a tag application f on some text. The tag application passes the attributes a1 and a2 with given values |
|
Syntax: We show a contrast between HTML syntax and LAML syntax. The tag application passes the attributes a1 and a2 with given values |
|
|
HTML4.0 Mirror Characteristics Slide Note Contents Index References |
|
Attribute Examples Slide Note Contents Index References |
|
Program: A LAML document with css attributes - doc1 | (load (string-append laml-dir "laml.scm")) (style "simple-html4.0-loose") (define (generic-page-2 tl bd c1 c2 c3 c4) (generic-page-1 tl (b (font-size 4 bd)) c1 c2 c3 c4)) (generic-page-2 "Attribute example" (con (ol 'css:list-style-type "lower-roman" (li "First line") (li "Second line") (li 'css:text-decoration "underline" 'value "10" 'css:background-color "yellow" "Third line") (li "Final line") ) ) white black blue blue ) |
Program: A LAML document without css attributes - doc2. In this document we use the native style attribute and inlined CSS attributes. | (load (string-append laml-dir "laml.scm")) (style "simple-html4.0-loose") (define (generic-page-2 tl bd c1 c2 c3 c4) (generic-page-1 tl (b (font-size 4 bd)) c1 c2 c3 c4)) (generic-page-2 "Attribute example" (con (ol 'style "list-style-type: lower-roman;" (li "First line") (li "Second line") (li 'value "10" 'style "background-color: yellow; text-decoration: underline;" "Third line") (li "Final line") ) ) white black blue blue ) |
|
|
Problems with nested markup Slide Note Contents Index References | When we compare an SGML family language with a Lisp family programming language we find some major syntactical differences. The observation about semi-constant strings is one of the most important |
|
Program: This is a typical HTML/XML fragment | <p> A text with a <a href="subsection/sec1.html">link</a> to a <b>subsection</b> </p> |
Program: Here we attempt to use a semi-constant string in Scheme. This does actually not make sense. | (p "A text with a (a "link" 'href "subsection/sec.html") to a (b "subsection") ") |
Program: Here we see the solution we use in all our examples. This uses a plain Scheme programming approach. | (p (string-append "A text with a " (a "link" 'href "subsection/sec.html") " to a " (b "subsection"))) |
|
LAML processing Slide Note Contents Index References |
|
|
|
A practical LAML exercise |
A practical LAML programming exercise Slide Note Contents Index References |
|
|
|
|
Other examples |
Ad hoc abstraction Slide Note Contents Index References |
|
|
Program: An example with URL abstractions | (load (string-append laml-dir "laml.scm")) (style "simple-html4.0-loose") (define laml-absolute-prefix "http://www.cs.auc.dk/~normark/scheme/") (define laml-relative-prefix "../../../../") ; relative ; (define (laml-url suffix) (string-append laml-relative-prefix suffix)) ; absolute (define (laml-url suffix) (string-append laml-absolute-prefix suffix)) (generic-page-1 "URL Abstractions" (concatenate "The" (a-tag (laml-url "index.html") "LAML software home page") "contains lots of information, such as" (a-tag (laml-url "info/laml-easy-installation.html") "installation guide") "and" (a-tag (laml-url "info/laml-motivation.html") "my own motivation") "for using LAML") white black blue blue) |
Program: The example without URL abstractions | (load (string-append laml-dir "laml.scm")) (laml-style "simple-html4.0-loose") (write-text-file (html (head (title "URL Abstractions")) (body (h1 "URL Abstractions") "The " (a 'href "http://www.cs.auc.dk/~normark/scheme/index.html" "LAML software home page") "contains lots of information, such as " (a 'href "http://www.cs.auc.dk/~normark/scheme/info/laml-easy-installation.html" "installation guide") "and " (a 'href "http://www.cs.auc.dk/~normark/scheme/info/laml-motivation.html" "my own motivation") "for using LAML" (p) (p))) (string-append (startup-directory) laml-source-file-name-without-extension ".html")) |
|
Program: An example with a table abstraction | (load (string-append laml-dir "laml.scm")) (style "simple-html4.0-loose") (define row list) (generic-page-1 "Table Abstractions" (table-1 3 (list 50 100 150) (list white green blue) (list (row "Her" "er" "første") (row "Her" "er" "anden") (row "Her" "er" "tredie") (row "Her" "er" "fjerde") ) ) white black blue blue) |
Program: The example without table abstractions | (load (string-append laml-dir "laml.scm")) (laml-style "simple-html4.0-loose") (write-text-file (html (head (title "Table Abstractions")) (body (h1 "Table Abstractions") (table 'border "3" (tr (td 'width "50" 'valign "top" 'bgcolor "#ffffff" "Her") (td 'width "100" 'valign "top" 'bgcolor "#00ff00" "er") (td 'width "150" 'valign "top" 'bgcolor "#0000ff" "første")) (tr (td 'width "50" 'valign "top" 'bgcolor "#ffffff" "Her") (td 'width "100" 'valign "top" 'bgcolor "#00ff00" "er") (td 'width "150" 'valign "top" 'bgcolor "#0000ff" "anden")) (tr (td 'width "50" 'valign "top" 'bgcolor "#ffffff" "Her") (td 'width "100" 'valign "top" 'bgcolor "#00ff00" "er") (td 'width "150" 'valign "top" 'bgcolor "#0000ff" "tredie")) (tr (td 'width "50" 'valign "top" 'bgcolor "#ffffff" "Her") (td 'width "100" 'valign "top" 'bgcolor "#00ff00" "er") (td 'width "150" 'valign "top" 'bgcolor "#0000ff" "fjerde"))) ) ) (string-append (startup-directory) laml-source-file-name-without-extension ".html")) |
|
Program: An example with signature abstraction | (load (string-append laml-dir "laml.scm")) (style "simple-html4.0-loose") (define row list) (generic-page-1 "Signature Abstractions" (con "Her er mit dokument" (kn) ) white black blue blue) |
Program: The example without signature abstractions | (load (string-append laml-dir "laml.scm")) (laml-style "simple-html4.0-loose") (write-text-file (html (head (title "Signature Abstractions")) (body (h1 "Signature Abstractions") "Her er mit dokument" (p) "Kurt Nørmark" (br) (a 'href "mailto:normark@cs.auc.dk" "normark@cs.auc.dk") (br) (a 'href "http://www.cs.auc.dk/~normark/" "http://www.cs.auc.dk/~normark/"))) (string-append (startup-directory) laml-source-file-name-without-extension ".html")) |
|
LAML languages Slide Note Contents Index References |
|
|
The Questionnaire Document Style Slide Note Contents Index References |
|
Program: A sample questionnaire - please answer when you come home. This document is a good example of programmatic WWW source program. The document is formulated in a little language, which is very easy to use for the end user. | (load (string-append laml-dir "laml.scm")) (laml-style "questionnaire/questionnaire") (lib-load "time.scm") (define language-preference 'english) (questionnaire "The LAML Questionnaire" "http://www.cs.auc.dk/~normark/cgi-bin/questionnaires/generic-form-registrator.cgi" 'laml-questionnaire (identification-question 'name "What is your name?") (identification-question 'email "What is your email address?") (free-style-question 'www-approach "Describe briefly your approach and tools for WWW authoring (if any)") (rating-question 'laml-rating "How do you rate LAML as a 'tool' for WWW authoring and Internet programming?" (list "Poor" "Not good" "OK" "Good" "Very good") ) (free-style-question 'functional-opinion "What is your opions on functional programming in the Internet programming domain?" ) (multi-choice-question 'laml-use "Would you be able to use LAML for" (list "business purposes" "private purposes" "major WEB tasks" "minor WEB tasks") ) (rating-question 'laml-seminar-rating "How do you rate the seminar about LAML?" (list "Poor" "Not good" "OK" "Good" "Very good") ) (rating-question 'laml-material-rating "How do you rate the paper and the CD received on the seminar?" (list "Poor" "Not good" "OK" "Good" "Very good") ) (single-choice-question 'future-info "Would you like to receive email about future LAML distributions?" (list "yes" "no") ) (free-style-question 'laml-others "Other comments can be stated here") (kn) (font-1 1 red (when-generated)) ) |
Program: The implementation of the questionnaire document style. |
Program: The similar HTML document. |
|
|
Automation of routine tasks Slide Note Contents Index References |
|
|
Program: An example of programmed HTML escaping - external HTML | (load (string-append laml-dir "laml.scm")) (style "simple-html4.0-loose") (generic-page-1 "HTML Protection" (font-size 4 (pre (html-protect (read-text-file (string-append (startup-directory) "../" "simple-page-1.html")) ) ) ) white black blue blue ) |
Program: The example html document with manual escaping - inlined HTML |
Program: The html-protect function from the HTML4.0 convenience library. | (define (html-protect str) (transliterate (transliterate (transliterate str #\& (character-entity "amp")) #\> (character-entity "gt")) #\< (character-entity "lt"))) |
|
|
Program: An example with automated URL checking | (load (string-append laml-dir "laml.scm")) (style "simple-html4.0-loose") (lib-load "url-read.scm") (define (newline-string) cr) ; due to conflic between general and url-read. (define (a-tag-check url anchor-text) (if (page-ok? url) (a-tag url anchor-text) (con (u anchor-text) (b (font-color red " (broken)"))))) (generic-page-1 "URL Checking" (font-size 4 (con "The " (a-tag-check "http://www.cs.auc.dk" "first") " link is fine. The " (a-tag-check "http://www.cs.auc.dk/~kurt.normark" "second") " is bad (~normark, not ~kurt.normark). And the " (a-tag-check "http://abc.efg.hij" "last") " is also bad ")) white black blue blue) |
|
LENO - A large example of a LAML Document Style |
What is LENO? Slide Note Contents Index References |
|
|
|
LENO - strengths Slide Note Contents Index References |
|
LENO har en række egenskaber, som omtales nærmere her. I nogle sammenhænge taler vi om slide syn, annoteret slide syn og et aggregeret syn. |
|
|
LENO - weaknesses Slide Note Contents Index References |
|
LENO har en række svagheder, som omtales nærmere her. |
Example of the lecture note document style Slide Note Contents Index References | On this page we show an example of the most substantial LAML document style developed to date. It is called LENO: A lecture note style. The slides you are looking at right now are written in LENO. Therefore we show the underlying LENO source of this page to illustrate our approach. |
|
Program: This is the LAML expression which generates the current slide. You can easily recognize the point clauses above and below. The source-program clause inserts the large middle LAML document excerpt. | (note-page 'leno-ex (title "Example of the lecture note document style" "On this page we show an example of the most substantial LAML document style developed to date. It is called LENO: A lecture note style. The slides you are looking at right now are written in LENO. Therefore we show the underlying LENO source of this page to illustrate our approach." ) (point "These slides are written in LAML by means of the lecture note style" "" ) (source-program "livslang-01.laml" (list "(note-page 'leno-ex" demo-end-mark) (list (list "note-page" "" level-1-color 'bold) (list "title" "" level-2-color 'bold) (list point-form "" level-2-color 'bold 2) (list "source-program" "" level-2-color 'bold) (list index-word-form "" level-2-color 'bold) ) (list 'slide-inline 'book-inline) "This is the LAML expression which generates the current slide. You can easily recognize the point clauses above and below. The source-program clause inserts the large middle LAML document excerpt." ) (point "The program excerpt above is taken directly from the LAML source of these slides" "" ) (index-words "LENO" "Lecture note style (example of)") ) ; end leno-ex |
|
WWW tools around LENO Slide Note Contents Index References |
|
Figure. |
LAML and Server Side Programming |
CGI Programming Slide Note Contents Index References | In order to explore the nature of CGI programming we here take a closer look at the overall CGI scheme |
Figure. The interaction between a browser and a CGI program |
|
CGI Programming with Program State Slide Note Contents Index References | In many CGI programs we need to store a 'program state'. Often, data is transferred to and from a database. We modify the previous picture in include this observation. |
Figure. The interaction between a browser and a CGI program, which uses a database for storing the program state |
|
CGI Programming in Scheme Slide Note Contents Index References | We now return to CGI programming in Scheme. |
|
|
This conclusion is drawn from a variety of different examples, which we have implemented. Most of the examples have been used to support various aspects of 'Open University' students located off campus. |
|
CGI Examples Slide Note Contents Index References |
|
Program: An excerpt of a LAML CGI program with an interface to the LAML calendar tool. We have omitted a fair number of functions that are applied in the procedure calendar-entry-page. We are only interested to give the reader and viewer a feel for LAML CGI program. Notice that the program is represented entirely in the programming language - Scheme and LAML functions/procedures. | (calendar-entry-page (string-append "Calendar entry page" ": " (as-string calendar-name)) (form "http://www.cs.auc.dk/~normark/cgi-bin/calendar/calendar-registrate-entries.cgi" (con (h 1 (font-color red (con "Calendar entry definition" (br) calendar-entry-title))) (news-flash) (if (not (equal? "" calendar-id-word)) (con (a-tag (string-append data-url-prefix calendar-id-word ".html") "Your current calendar") (p)) "") (table-cal-entries 0 entry-width-list (make-list 11 calendar-entry-background-color) calendar-entry-headers (append (map (lambda (entry) (entry-row (row-id-gen "r") entry)) (append current-entries (empty-calendar-entries number-of-empty-entries))))) (p) (hr) (p) (reset-row-id-generation!) (i (b "Calendar color key:")) (horizontal-space 2) (font-size 2 "Here you can describe the meaning of the colors in the calendar") (p) (table-2 0 (list 350 100) (make-list 2 calendar-entry-background-color) (list "Text" "Color") (map (lambda (entry) (calendar-color-key-entry (row-id-gen "c") entry)) (append current-color-keys (empty-color-key-entries number-of-empty-color-keys)))) (reset-row-id-generation!) (p) (hr) (p) (i (b "Calendar span:")) (p) (indent-pixels 10 (con (b "Month: ") (horizontal-space 1) (text-line "start-month" 2 calendar-start-month) (horizontal-space 12) (b "Year: ") (horizontal-space 1) (text-line "start-year" 4 calendar-start-year) (horizontal-space 2) (font-size 2 "Not earlier than 1970") (horizontal-space 12) (b "Number of months: ") (horizontal-space 1) (text-line "number-of-months" 2 calendar-number-of-months) (horizontal-space 2) (font-size 2 (con-space "Minimum 1, maximum" (as-string max-calendar-length) "months.")) (horizontal-space 12))) (p) (hr) (p) (i (b "Calendar owner:")) (p) (indent-pixels 10 (con (b "Owner or purpose id: ") (horizontal-space 1) (text-line "owner" 15 calendar-id-word) (horizontal-space 2) (font-size 2 "One word, no spaces") (horizontal-space 12) (b "Password: ") (horizontal-space 1) (password-line "password" 10 "") (horizontal-space 1) (font-size 2 "Never use your system password"))) (p) (hr) (p) (i (b "Other calendar properties:")) (p) (indent-pixels 10 (con (b "Calendar title: ") (horizontal-space 1) (text-line "description" 55 calendar-entry-title) (p) (b "Calendar column width: ") (horizontal-space 1) (text-line "column-width" 4 (as-string calendar-actual-column-width)) (horizontal-space 1) (font-size 2 (con "in pixels, minimum " (as-string min-month-width) ", maximum " (as-string max-month-width))) (horizontal-space 12) (b "Font size: ") (horizontal-space 1) (text-line "font-size" 2 calendar-font-size) (horizontal-space 2) (font-size 2 "A number between 1 and 6, 1 is smallest, 6 is largest") (p) (b "Language: ") (horizontal-space 1) (select "language" (list "danish" "english") (list "danish" "english") calendar-language) (horizontal-space 12) (b "Week separator: ") (horizontal-space 1) (select "week-separator" (list "thin" "thick") (list "thin" "thick") calendar-week-separator) (horizontal-space 12))) (p) (hr) (p) (i (b "Calendar merging:")) (horizontal-space 2) (font-size 2 (con-space "Merge with another calendar (or with entries exported from the " (a-tag "http://www.cs.auc.dk/~normark/scheme/styles/course-plan/man/course-plan.html" "course plan tool") ")")) (br) (font-size 2 "Type 'owner or purpose id' of other calendars") (p) (indent-pixels 10 (con (b "Merge with calendar: ") (horizontal-space 1) (text-line "merge-1" 25 merge-1-start) (horizontal-space 2) (font-size 2 "Another calendar which you want to include in this calendar") (br) (b "Merge with calendar: ") (horizontal-space 1) (text-line "merge-2" 25 merge-2-start) (horizontal-space 2) (font-size 2 "Another calendar which you want to include in this calendar") (br) (b "Merge with calendar: ") (horizontal-space 1) (text-line "merge-3" 25 merge-3-start) (horizontal-space 2) (font-size 2 "Another calendar which you want to include in this calendar") (br) (b "Merge with calendar: ") (horizontal-space 1) (text-line "merge-4" 25 merge-4-start) (horizontal-space 2) (font-size 2 "Another calendar which you want to include in this calendar") (br) (b "Merge with calendar: ") (horizontal-space 1) (text-line "merge-5" 25 merge-5-start) (horizontal-space 2) (font-size 2 "Another calendar which you want to include in this calendar") (br) (b "Merge with calendar: ") (horizontal-space 1) (text-line "merge-6" 25 merge-6-start) (horizontal-space 2) (font-size 2 "Another calendar which you want to include in this calendar") (br) (b "Merge with calendar: ") (horizontal-space 1) (text-line "merge-7" 25 merge-7-start) (horizontal-space 2) (font-size 2 "Another calendar which you want to include in this calendar") (p) (font-size 2 (con "Danish holidays for 2001 and 2002 are available as " (kbd "helligdage-01") " and " (kbd "helligdage-02"))) (br))) (p) (hr) (p) (i (b "Auto deletion:")) (p) (indent-pixels 10 (con (b "Auto delete old entries: ") (horizontal-space 1) (checkbox "auto-delete") (p))) (p) (hr) (p) (submit "Remake Calendar") (vertical-space 2) (font-size 2 calendar-credit)))) |
Program: An excerpt of a PHP server program. Notice the mix of HTML and PHP expressions - the latter is a C-like programming language. | function display_form() { global $PHP_SELF; $dotw = array('Sunday','Monday','Tuesday','Wednesday','Thursday', 'Friday','Saturday'); $months = array( 1 => 'January','February','March','April','May','June', 'July','August','September','October','November','December'); ?> <FORM TARGET="<?php echo $PHP_SELF; ?>" METHOD=GET> Find the first <SELECT NAME="dotw"> <?php for ($i = 0; $i < 7; $i++) { echo "<OPTION> $dotw[$i]"; } echo '</SELECT> after <SELECT NAME="month">'; for ($i = 1; $i <= 12; $i++) { echo "<OPTION VALUE=\"$i\"> $months[$i]"; } echo '</SELECT> <SELECT NAME="day">'; for ($i = 1; $i <= 31; $i++) { echo "<OPTION> $i"; } echo '</SELECT>, <SELECT NAME="year">'; $start_year = date('Y') - 10; $end_year = $start_year + 20; for ($i = $start_year; $i <= $end_year; $i++) { echo "<OPTION> $i"; } echo '<INPUT TYPE="HIDDEN" NAME="stage" VALUE="process">'; echo '</SELECT> <INPUT TYPE="SUBMIT" VALUE="Do it!"7></FORM>'; } ?> |
Program: An excerpt of a JSP server program - using Java as the programming language. | <%-- Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. This software is the proprietary information of Sun Microsystems, Inc. Use is subject to license terms. --%> <%@ include file="initdestroy.jsp" %> <%@ page import="java.util.*, cart.*" %> <jsp:useBean id="bookDB" class="database.BookDB" scope="page" > <jsp:setProperty name="bookDB" property="database" value="<%=bookDBEJB%>" /> </jsp:useBean> <jsp:useBean id="cart" scope="session" class="cart.ShoppingCart"/> <jsp:useBean id="currency" class="util.Currency" scope="session"> <jsp:setProperty name="currency" property="locale" value="<%=request.getLocale()%>"/> </jsp:useBean> <html> <head><title>Shopping Cart</title></head> <%@ include file="banner.jsp" %> <% String bookId = request.getParameter("Remove"); if (bookId != null) { cart.remove(bookId); bookDB.setBookId(bookId); BookDetails book = bookDB.getBookDetails(); %> <font color="red" size="+2">You just removed: <strong><%=book.getTitle()%> </strong> <br> <br> </font> <% } if (request.getParameter("Clear") != null) { cart.clear(); %> <font color="red" size="+2"><strong> You just cleared your shopping cart! </strong><br> <br></font> <% } // Print a summary of the shopping cart int num = cart.getNumberOfItems(); if (num > 0) { %> <font size="+2">You have <%=num%> <%=(num==1 ? " item" : " items")%> in your shopping cart. </font><br> <table> <tr> <th align=left>Quantity</TH> <th align=left>Title</TH> <th align=left>Price</TH> </tr> <% Iterator i = cart.getItems().iterator(); while (i.hasNext()) { ShoppingCartItem item = (ShoppingCartItem)i.next(); BookDetails book = (BookDetails)item.getItem(); %> <tr> <td align="right" bgcolor="#ffffff"> <%=item.getQuantity()%> </td> <td bgcolor="#ffffaa"> <strong><a href="<%=request.getContextPath()%>/bookdetails?bookId=<%=book.getBookId()%>"> <%=book.getTitle()%></a></strong> </td> <td bgcolor="#ffffaa" align="right"> <jsp:setProperty name="currency" property="amount" value="<%=book.getPrice()%>"/> <jsp:getProperty name="currency" property="format"/> </td> <td bgcolor="#ffffaa"> <strong> <a href="<%=request.getContextPath()%>/showcart?Remove=<%=book.getBookId()%>">Remove Item</a></strong> </td></tr> <% // End of while } %> <tr><td colspan="5" bgcolor="#ffffff"> <br></td></tr> <tr> <td colspan="2" align="right" "bgcolor="#ffffff"> Subtotal:</td> <td bgcolor="#ffffaa" align="right"> <jsp:setProperty name="currency" property="amount" value="<%=cart.getTotal()%>"/> <jsp:getProperty name="currency" property="format"/> </td> </td><td><br></td></tr></table> <p> <p> <strong><a href="<%=request.getContextPath()%>/catalog">Continue Shopping</a> <a href="<%=request.getContextPath()%>/cashier">Check Out</a> <a href="<%=request.getContextPath()%>/showcart?Clear=clear">Clear Cart</a></strong> <% } else { %> <font size="+2">There is nothing in your shopping cart.</font> <br> <br> <center><a href="<%=request.getContextPath()%>/catalog">Back to the Catalog</a> </center> <% // End of if } %> </body> </html> |
Program: An excerpt of an ASP server program - using Visual Basic as the programming language | <% @Language=VBScript %> <html dir=ltr> <head> <title>View Guest Book</title> </head> <body bgcolor="#FFFFFF" text="#000000"> <% 'This section makes it possible for visitors to sort the data in the columns in ascending order. if request.form("sort")<> "" THEN StrSort=request.form("sort") ELSE StrSort="TB1 ASC" END IF strQuery="SELECT * FROM Guestbook ORDER BY " &StrSort 'Database path statement describing the driver to use and the path to the desired database. strProvider = "Driver=Microsoft Access Driver (*.mdb); DBQ=C:\Inetpub\Wwwroot\Tutorial\guestbook.mdb;" IF Request("ID") <> "" THEN strIDNum=Request("ID") 'Creates an instance of an Active server component set objConn = server.createobject("ADODB.Connection") 'Opens the connection to the data store objConn.Open strProvider 'Instantiate Command object and use ActiveConnection property to 'attach connection to Command object set cm = Server.CreateObject("ADODB.Command") cm.ActiveConnection = objConn 'Define SQL query cm.CommandText = "DELETE FROM Guestbook WHERE ID = " &strIDNum cm.Execute END IF 'Instantiate a Recordset object and open a recordset using 'the Open method Set rst = Server.CreateObject("ADODB.recordset") rst.Open strQuery, strProvider %> <h1>Guest Book</h1> <form name=viewdb.asp action=viewdb.asp method=post> <table border=1 cellspacing=3 cellpadding=3 rules=box> <% ON ERROR RESUME NEXT IF rst.EOF THEN Response.Write "There are no entries in the database." ELSE%> <tr> <% 'Deletes rows from the database, this cannot be undone Response.Write "<td width=200><center>Delete Record</center></td>" FOR i = 1 to rst.Fields.Count -1 Response.Write "<td width=200><input name=sort value=" & rst(i).Name & " type=submit></td>" NEXT WHILE NOT rst.EOF %> <tr> <% Response.Write "<td align=left valign=top bgcolor='#ffffff'> <a href=viewdb.asp?id=" & rst(0) & ">Delete</a></td>" FOR i = 1 to rst.fields.count - 1 Response.Write "<td align=left valign=top bgcolor='#ffffff'>" & rst(i) &"</td>" NEXT rst.MoveNext WEND END IF %> </table> </form> </body> </html> |
|
|
LAML in relation to XML |
Overall comparison between XML and LAML Slide Note Contents Index References |
|
Less anarchistic use of LAML Slide Note Contents Index References |
|
|
How to integrate programming power Slide Note Contents Index References |
|
|
|
|
Conclusions |
Conclusions Slide Note Contents Index References |
|
|
|
Source files in this lecture Contents Index References | includes/document-abstractions/initial-document.html includes/document-abstractions/doc0.laml includes/document-abstractions/doc1.laml includes/document-abstractions/doc2.laml includes/document-abstractions/doc3.laml includes/demo-quiz/quiz-example-slim.laml includes/demo-quiz/quiz-example-pp.html includes/demo-quiz/quiz-example.laml ../../styles/demo-quiz.scm includes/attributes/doc1.laml includes/attributes/doc2.laml includes/adhoc-abstractions/d1-with.laml includes/adhoc-abstractions/d1-without.laml includes/adhoc-abstractions/d2-with.laml includes/adhoc-abstractions/d2-without.laml includes/adhoc-abstractions/d3-with.laml includes/adhoc-abstractions/d3-without.laml includes/laml-opinions.laml ../../styles/questionnaire/questionnaire.scm includes/laml-opinions-pp.html includes/automations/d1-with.laml includes/automations/d1-without.html ../../lib4/html4.0-loose/convenience.scm includes/automations/d3-with.laml livslang-01.laml includes/laml-cgi-example-pp.scm includes/php-example includes/jsp-example includes/asp-example |
A Programmatic Approach to WWW Authoring
Course home Author home About producing this web Previous lecture (top) Next lecture (top) Previous lecture (bund) Next lecture (bund)
Generated: August 21, 2001, 10:57:53