Presentation is loading. Please wait.

Presentation is loading. Please wait.

Technical University of Valencia Computer Science Department SOFSEM’07 (22/01/2007) A Program Slicing Based Method to Filter XML/DTD documents.

Similar presentations


Presentation on theme: "Technical University of Valencia Computer Science Department SOFSEM’07 (22/01/2007) A Program Slicing Based Method to Filter XML/DTD documents."— Presentation transcript:

1 Technical University of Valencia Computer Science Department SOFSEM’07 (22/01/2007) A Program Slicing Based Method to Filter XML/DTD documents

2 2 Motivation Program Slicing XML DTD XSLT Slicing XML Documents Example Implementation Conclusions & Future Work Contents Program Slicing

3 3 Definition: Definition: Program transformation to extract the program statements that (potentially) affect the values computed at some point of interest. Origin: Origin: Originally introduced by Weiser. Example: (1) read(n); (2) i:=1; (3) sum:=0; (4) product:=1; (5) while (i<=n) do begin (6) sum:=sum+i; (7) product:=product*i; (8) i:=i+1; end; (9) write(sum); (10) write(product); Slicing Criterion = (10, product)

4 4 Program Slicing Definition: Definition: Program transformation to extract the program statements that (potentially) affect the values computed at some point of interest. Origin: Origin: Originally introduced by Weiser. Example: (1) read(n); (2) i:=1; (3) sum:=0; (4) product:=1; (5) while (i<=n) do begin (6) sum:=sum+i; (7) product:=product*i; (8) i:=i+1; end; (9) write(sum); (10) write(product); Slicing Criterion = (10, product)

5 5 Program Slicing Applications: Debugging Code understanding Specialization etc. All the applications are based on the Program Dependence Graphs (PDGs) (structure and behaviour of programs) What would happen if Program Slicing was applied to a data structure? Would it be interesting?

6 6 Motivation Program Slicing XML DTD XSLT Slicing XML Documents Example Implementation Conclusions & Future Work Contents XML

7 7 Origin: Origin: XML was developed by an XML Working Group formed under the auspices of the World Wide Web Consortium (W3C) in 1996. Structure: Structure: Documents are trees composed by ‘ELEMENTS’ which contain attributes. Example of XML document XML (eXtensible Markup Language)

8 8 XML Objective: Objective: The purpose of a DTD is to define the legal building blocks of an XML document. It defines the document structure with a list of legal elements. Structure: Structure: Documents are graphs composed by ‘ELEMENTS’. Example of DTD document DTD (Document Type Definition)

9 9 Professor Ryan Gibson Logic Mon/Wed 16-18 4-Mathematics Algebra Mon/Tur 11-13 3-Mathematics … <Project name = “SysLog’’ year = “2003-2004’’ budget = “16000€’’ />... <!ELEMENT PersonalInfo (Contact, Teaching, Research)> <!ELEMENT Contact (Status, Name, Surname)> <!ELEMENT Subject (Name, Sched, Course)> <!ATTLIST Project name CDATA #REQUIRED year CDATA #REQUIRED budget CDATA #IMPLIED > DTD (Document Type Definition) XML (eXtensible Markup Language)

10 10 XML Objective: Objective: XSLT is a language for transforming XML. Structure: Structure: An XSLT stylesheet specifies the presentation of a class of XML documents by describing how an instance of the class is transformed into an XML document that uses a formatting vocabulary, such as (X)HTML or XSL-FO XSLT is a programming language Example of XSLT document (Source Code) XSLT (eXtensible Stylesheet Language Transformations) Example of XSLT document (Result)

11 11 Motivation Program Slicing XML DTD XSLT Slicing XML Documents Example Implementation Conclusions & Future Work Contents Slicing XML Documents

12 12 Slicing XML Documents We see XML documents and DTDs as trees. Professor Ryan Gibson Logic Mon/Wed 16-18 4-Mathematics Algebra Mon/Tur 11-13 3-Mathematics … <Project name = “SysLog’’ year = “2003-2004’’ budget = “16000€’’ />... Logic Mon/Wed 16-184-Mathematics Subject Algebra Mon/Tur 11-133-Mathematics Professor Ryan Gibson Subject Syslog2003-200416000 € Project … PersonalInfo ContactTeachingResearch …

13 13 Slicing XML Documents The Slicing Criterion is composed by a set of nodes in the tree. For each node in the slicing criterion, we extract from the tree all those nodes that are in the path from the root to the node. Web Page (Original) Web Page (Slice) XML / DTD Forward / Backward

14 14 NameSchedCourse Subject Status Name Surname NameYearBudget Project PersonalInfo ContactTeachingResearch Slicing XML Documents DTD backward slicing criterion. <!ELEMENT PersonalInfo (Contact, Teaching, Research)> <!ELEMENT Contact (Status, Name, Surname)> <!ELEMENT Subject (Name, Sched, Course)> <!ATTLIST Project name CDATA #REQUIRED year CDATA #REQUIRED budget CDATA #IMPLIED > NameSched Course Subject Status Name Surname NameYearBudget Project PersonalInfo Contact Teaching Research <!ELEMENT PersonalInfo (Contact, Teaching, Research)> <!ELEMENT Contact (Status, Name, Surname)> <!ELEMENT Subject (Name, Sched, Course)> <!ATTLIST Project name CDATA #REQUIRED year CDATA #REQUIRED budget CDATA #IMPLIED > Web Page (Original) Web Page (Slice)

15 15 Slicing XML Documents XML backward slicing criterion. Professor Ryan Gibson Logic Mon/Wed 16-18 4-Mathematics Algebra Mon/Tur 11-13 3-Mathematics … <Project name = “SysLog’’ year = “2003-2004’’ budget = “16000€’’ />... Logic Mon/Wed 16-184-Mathematics Subject Algebra Mon/Tur 11-133-Mathematics Professor Ryan Gibson Subject Syslog2003-200416000 € Project … PersonalInfo ContactTeachingResearch … Professor Ryan Gibson Logic Mon/Wed 16-18 4-Mathematics Algebra Mon/Tur 11-13 3-Mathematics … <Project name = “SysLog’’ year = “2003-2004’’ budget = “16000€’’ />... Logic Mon/Wed 16-184-Mathematics Subject Algebra Mon/Tur 11-133-Mathematics Professor Ryan Gibson Subject Syslog2003-200416000 € Project … PersonalInfo Contact Teaching Research … Web Page (Original) Web Page (Slice)

16 16 Slicing XML Documents XML backward slicing criterion. Logic Mon/Wed 16-184-Mathematics Subject Algebra Mon/Tur 11-133-Mathematics Professor Ryan Gibson Subject Syslog2003-200416000 € Project … PersonalInfo Contact Teaching Research … Professor Ryan Gibson Logic Mon/Wed 16-18 4-Mathematics Algebra Mon/Tur 11-13 3-Mathematics … <Project name = “SysLog’’ year = “2003-2004’’ budget = “16000€’’ />... Web Page (Original) Web Page (Slice)

17 17 Slicing XML Documents We distinguish between DTD and XML slicing criterions. XML slicing criterions are more fine-grained than DTD slicing criterions We distinguish between forward and backward slices (or a combination). Web Page (Original) Web Page (Slice) XML / DTD Forward / Backward

18 18 NameSchedCourse Subject Status Name Surname NameYearBudget Project PersonalInfo ContactTeachingResearch Slicing XML Documents DTD backward slicing criterion. <!ELEMENT PersonalInfo (Contact, Teaching, Research)> <!ELEMENT Contact (Status, Name, Surname)> <!ELEMENT Subject (Name, Sched, Course)> <!ATTLIST Project name CDATA #REQUIRED year CDATA #REQUIRED budget CDATA #IMPLIED > NameSchedCourse Subject Status Name Surname NameYearBudget Project PersonalInfo ContactTeaching Research <!ELEMENT PersonalInfo (Contact, Teaching, Research)> <!ELEMENT Contact (Status, Name, Surname)> <!ELEMENT Subject (Name, Sched, Course)> <!ATTLIST Project name CDATA #REQUIRED year CDATA #REQUIRED budget CDATA #IMPLIED > Web Page (Original) Web Page (Slice)

19 19 Professor Ryan Gibson Logic Mon/Wed 16-18 4-Mathematics Algebra Mon/Tur 11-13 3-Mathematics … <Project name = “SysLog’’ year = “2003-2004’’ budget = “16000€’’ />... Logic Mon/Wed 16-184-Mathematics Subject Algebra Mon/Tur 11-133-Mathematics Professor Ryan Gibson Subject Syslog2003-200416000 € Project … PersonalInfo ContactTeachingResearch … Slicing XML Documents XML forward slicing criterion. Logic Mon/Wed 16-184-Mathematics Subject Algebra Mon/Tur 11-133-Mathematics Professor Ryan Gibson Subject Syslog2003-200416000 € Project … PersonalInfo Contact Teaching Research … Professor Ryan Gibson Logic Mon/Wed 16-18 4-Mathematics Algebra Mon/Tur 11-13 3-Mathematics … <Project name = “SysLog’’ year = “2003-2004’’ budget = “16000€’’ />... Web Page (Original) Web Page (Slice)

20 20 Professor Ryan Gibson Logic Mon/Wed 16-18 4-Mathematics Algebra Mon/Tur 11-13 3-Mathematics … <Project name = “SysLog’’ year = “2003-2004’’ budget = “16000€’’ />... Logic Mon/Wed 16-184-Mathematics Subject Algebra Mon/Tur 11-133-Mathematics Professor Ryan Gibson Subject Syslog2003-200416000 € Project … PersonalInfo ContactTeachingResearch … Slicing XML Documents XML backward-forward slicing criterion. Logic Mon/Wed 16-184-Mathematics Subject Algebra Mon/Tur 11-133-Mathematics Professor Ryan Gibson Subject Syslog2003-200416000 € Project … PersonalInfo Contact Teaching Research … Professor Ryan Gibson Logic Mon/Wed 16-18 4-Mathematics Algebra Mon/Tur 11-13 3-Mathematics … <Project name = “SysLog’’ year = “2003-2004’’ budget = “16000€’’ />... Web Page (Original) Web Page (Slice)

21 21 Slicing XML Documents What happens with DTDs? Slices are well-formed, but are they valid? For each XML slice we produce a DTD slice and viceversa We guarantee that XML slices are valid with respect to DTD slices. DTD document Slicer XML document DTD Slice document XML Slice document Slicing Criterion

22 22 Slicing XML Documents A simple slicing algorithm

23 23 Slicing XML Documents In the case of a DTD criterion composed by a set of positions C = {p 1 …p n }  Pos(D), the algorithm would be the same, except that the first loop would be: For each v 1.v 2.(…).v n  C do V’ := V’  {v 1, v 1.v 2, …, v 1.v 2.(…).v n }; W’ := W’  {v 1 |i.v 2 |j.(…).v n |k} Where v 1.v 2.(…).v n  v’ and v1|i.v2|j.(…).vn|k  X Both algorithms produce valid XML and DTD slices with respect to the slicing criterion

24 24 Slicing XML Documents The following theorem states the correctness of the technique: Theorem Let D be a well-formed DTD and X a well-formed XML document valid with respect to D. Given a slice D’ of D and a slice X’ of X computed with an XML slicing criterion C, and given a slice D’’ of D and a slice X’’ of X computed with a DTD slicing criterion C’, then a) D’ is well-formed and X’ is valid with respect to D’ b) D’’ is well-formed and X’’ is valid with respect to D’’ If all the elements in C are of one of the types in C’, then c) D’ = D’’ d) X’ is a subtree of X’’

25 25 Motivation Program Slicing XML DTD XSLT Slicing XML Documents Example Implementation Conclusions & Future Work Contents Implementation

26 26 Implementation We have implemented a prototype in Haskell. Haskell provides us a formal basis with many advantages for the manipulation of XML documents. - The HaXml library. It allows us to automatically translate XML or HTML documents into a Haskell representation. In particular, we use the following data structures that can represent any XML/HTML document: data Element = Elem Name [Attribute] [Content] data Attribute = (Name, Value) data Content = CElem Element | CText String

27 27 XML XSLT WebPage (Data) (Presentation) Implementation From XML slices to Webpage slices XML XSLT WebPage (Data) (Presentation)

28 28 Implementation XSLT Implementation Guidelines XSLT documents must generate the information and the presentation elements under the same conditions (i.e., the former is generated if and only if the later is generated). Both the XML data and the presentation labels are generated together. This does not imposes any restriction on the power of XSLT, since the same webpages can be generated. On the contrary, this way of programming forces the programmer to build transformations that can be easily reused and maintained, because both the information and presentation data depending on the same condition are put together.

29 29 Implementation XSLT Implementation Guidelines

30 30 Implementation The implementation, some examples and other material is publicly available at: www.dsic.upv.es/~jsilva/xml

31 31 Motivation Program Slicing XML DTD XSLT Slicing XML Documents Example Implementation Conclusions & Future Work Contents Conclusions & Future Work

32 32 Conclusions We proposed the application of program slicing techniques to XML data structures We defined an algorithm to slice XML and DTD documents XML and DTD slices that are well-formed and valid Previous slicers can be used with a modest implementation effort Slicing Web Pages The slicer can use XSLT in order to slice webpages We proposed some guidelines to generate XSLT files Future Work Migration to XML Schema New implementation based on XQuery


Download ppt "Technical University of Valencia Computer Science Department SOFSEM’07 (22/01/2007) A Program Slicing Based Method to Filter XML/DTD documents."

Similar presentations


Ads by Google