Download Domain Specific Languages for Interactive Web Services

Transcript
156
Chapter 13. Static Validation of Dynamically Generated HTML
The definition of the validity relation is straightforward. It duals the definition
of the acceptance relation in Section 13.6, except that we now have to take gaps
into account. Only the auxiliary functions, occurs and order , are non-trivial.
The function occurs(n, φ) finds the subset of N • that can occur as contents of
the current element after plugging some gaps according to the summary graph,
and order (n, φ, c1 , c2 ) checks that it is not possible to obtain an c2 before an
c1 in the contents φ. These two functions are defined as fixed points because
the summary graphs may contain loops. In the implementation we ensure
termination by applying memoization to the numerous calls to occurs and order .
Note that the validation algorithm is both sound and complete 2 with respect
to summary graphs: A graph is rejected if and only if its language contains a
template that is not in the language of the abstract DTD. Thus, in the whole
validation analysis the only source of imprecision is the data-flow analysis that
constructs the summary graph.
Also note that our notion of abstract DTDs has a useful locality property:
All requirements defined by an abstract DTD specify properties of single XML
document nodes and their attributes and immidiate contents, so if some requirement is not fulfilled by a given summary graph, it is possible to give a
precise error message.
13.8
Experiments
The validation analysis has been fully implemented as part of the <bigwig>
system using a monovariant data-flow analysis framework. It has then been
applied to all available benchmarks, some of which are shown in the following
table:
Name
chat
guess
calendar
xbiff
webboard
cdshop
jaoo
bachelor
courses
eatcs
Lines
Templates
Size
Shows
Time
65
75
77
561
1,132
1,709
1,941
2,535
4,465
5,345
3
6
5
18
37
36
73
137
57
133
(0,5)
(0,3)
(8,6)
(4,12)
(34,18)
(6,23)
(49,14)
(146,64)
(50,45)
(35,18)
2
6
2
15
25
25
17
15
17
114
0.1
0.1
0.1
0.1
0.6
0.5
2.4
8.2
1.3
6.7
The entries for each benchmark are its name, the lines of code derived from a
pretty print of the source with all macros expanded, the number of templates,
the size (|E|, |α|) of the largest summary graph, the number of show statements,
and the analysis time in seconds (on an 800 MHz Pentium III with Linux).
2
Errata: Due to the issues mentioned in the previous footnote, the validation is sound but
not complete. However, we have not encountered any spurious errors in practise, using the
abstract DTD for XHTML.