Static Validation of Dynamically Generated XML Documents - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

Static Validation of Dynamically Generated XML Documents

Description:

Static Validation of Dynamically Generated XML Documents ... Typical solutions: embedded server-side scripting languages (PHP,ASP,JSP,etc) ... – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 10
Provided by: Vess2
Category:

less

Transcript and Presenter's Notes

Title: Static Validation of Dynamically Generated XML Documents


1
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. BRICS Basic Research in Computer
Science www.brics.dk
2
Dynamic Construction of Web Pages
  • Interactive Web Services

request
response
Client with a browser
Web server
  • Application-to-application Web Services

Clients are not humans but general programs
XML widely used as data interchange format for
Web Services
Typical solutions embedded server-side scripting
languages (PHP,ASP,JSP,etc)
Problems 1.Linear document construction
(printing string fragments to output stream)
2.No compile-time validation of the
generated XML (according to a schema)
3
Approaches to Statically Validate Dynamic XML
  • Main ideas 1.Construction based on XML templates
    (sequences of XML trees
  • containing named gaps)
  • 2.Provide compile-time validation of
    transformed XML documents
  • An XML schema S describes a set L(S) of XML
    documents
  • An XML document X is valid with respect to an XML
    schema S iff X is in the set L(S)
  • For a program, verify at compile-time that
    given that
  • for each i.
  • Evolution
  • bigwig - high-level C-based domain-specific
    programming language for developing
  • interactive Web services HTML templates are
    first-class values that may be computed
  • and stored in variables
  • JWIG - Java-based framework for Web service
    development a flexible mechanism for
  • dynamic construction and validation of XML
    documents, in particular XHTML
  • Xact an extension of JWIG applied on general
    XML, supports also deconstruction of
  • XML documents XML templates are first-class JAVA
    values

4
XML templates
An XML template is a well-formed XML fragment
with named gaps
ltrecipe numbernumbergt lttitlegtlttitlegtlt/tit
legt ltingredientsgtltlistgtlt/ingredientsgt
ltpreparationgt ltstepsgtlt/preparationgt
ltnutritiongt lt/recipegt
  • There are template gaps and attribute gaps.
  • Both templates and strings (or arrays of these)
    can be plugged into template gaps.
  • Only strings can be plugged into attribute gaps.

5
Construction
Deconstructionof XML Templates
The plug operation
The select and gapify operations
6
Compile-time Output Validation
Given an XML transformation T and an XML schema
S, is it the case that whenever T outputs an XML
document X, then X is valid with respect to S?
  • This is a hard problem
  • Practical solution give approximate but safe
    (conservative) answers
  • Perform dataflow analysis using Summary Graphs
    (a set of XML template values
  • as nodes, and edges corresponding to possible
    plugging of gaps)

The Program Analyzer
  • Construct summary graphs for each XML variable
    at each program point. The
  • set of summary graphs constitutes a finite
    lattice (suitable for dataflow analysis).
  • 2. Construct summary graphs from DTD schemas.
  • 3. Validate summary graphs (of output XML
    docs) against DTD schemas.

?
1.
2.
Set of possible XML docs
Set of valid XML docs
3.Validation!
7
Example no errors
import dk.brics.xact. public class Hello
XML person ltpersongtltnamegtJohn
Doelt/namegtlt/persongt XML html
lthtmlgt
ltheadgtlttitlegtHellolt/titlegtlt/headgt
ltbody bgcolor"red"gt
lth1gtHello ltnamegtlt/h1gt
lt/bodygt lt/htmlgt
public XML sayHello()
XML name person.select("/person/name/text()")0
return html.plug("name", name)
public static void main(String
args) Hello hello new Hello()
XML greeting hello.sayHello()
greeting.analyze("xhtml1-transitional.dtd")
System.out.println(greeting)
Output Code
lthtmlgt ltheadgt lttitlegtHellolt/titlegt
lt/headgt ltbody bgcolor"red"gt lth1gtHello
John Doelt/h1gt lt/bodygt lt/htmlgt
Browser Output
Hello John Doe 
8
Example invalid output
import dk.brics.xact. public class Hello
XML person ltpersongtltnamegtJohn
Doelt/namegtlt/persongt XML html
lthtmlgt
ltheadgtlttitlegtHellolt/titlegtlt/headgt
ltbody gbcolor"red"gt
lth1gtHello ltnamegtlt/h1gt
lt/bodygt lt/htmlgt
public XML sayHello()
XML name person.select("/person/name/text()")0
return html.plug("name", name)
public static void main(String
args) Hello hello new Hello()
XML greeting hello.sayHello()
greeting.analyze("xhtml1-transitional.dtd")
System.out.println(greeting)
Output Code
lthtmlgt ltheadgt lttitlegtHellolt/titlegt
lt/headgt ltbody gbcolor"red"gt lth1gtHello
John Doelt/h1gt lt/bodygt lt/htmlgt
Browser Output
Hello John Doe 
The XACT analyzer reports the error! Invalid
XML at line 26 XML template at line 8 attribute
gap 'gbcolor' in element 'body' not declared
9
Example plug error
import dk.brics.xact. public class Hello
XML person ltpersongtltnamegtJohn
Doelt/namegtlt/persongt XML html
lthtmlgt
ltheadgtlttitlegtHellolt/titlegtlt/headgt
ltbody bgcolor"red"gt
lth1gtHello ltnamegtlt/h1gt
lt/bodygt lt/htmlgt
public XML sayHello()
XML name person.select("/person/name/text()")0
return html.plug(nema", name)
public static void main(String
args) Hello hello new Hello()
XML greeting hello.sayHello()
greeting.analyze("xhtml1-transitional.dtd")
System.out.println(greeting)
Output Code
lthtmlgt ltheadgt lttitlegtHellolt/titlegt
lt/headgt ltbody bgcolor"red"gt lth1gtHello
lt/h1gt lt/bodygt lt/htmlgt
Browser Output
Hello
The XACT analyzer reports the error!
Inconsistent plug operation at line 20 Template
gap 'nema' does not exist
Write a Comment
User Comments (0)
About PowerShow.com