Presentation is loading. Please wait.

Presentation is loading. Please wait.

Advance Database S2-2011 Week-7 Dr.Kwanchai Eurviriyanukul

Similar presentations


Presentation on theme: "Advance Database S2-2011 Week-7 Dr.Kwanchai Eurviriyanukul"— Presentation transcript:

1 Advance Database S2-2011 Week-7 Dr.Kwanchai Eurviriyanukul Kwanchai@rmutl.ac.th

2 Contents Week-7 XML Basics 5: 7 ธค. – DOM – XML DTD – XML Schema : 14 ธค XML Query – XPath 6: 21 ธค – Xquery7: 24 ธค – XSL 8: 24 ธค WebService 9: 4 มค – TH-E-GIF DataIntegration 10: 11 มค – Schema matching and mapping Parallel Database 11:18 มค GIS 12:

3 Homework Week-7 1.For the given questions, please hand-write the corresponding XPath queries. 2.Implement a PHP program to execute the queries in 1. to return correct results 3.Note we have class on this Saturday Dec 24 th, 2011. 4. เวลา 10.00 - 12.00 น. ( ภาคทฤษฎี ) ห้อง C1 311 เวลา 13.00 - 15.00 น. ( ภาคปฎิับัติ ) ห้้อง S1 201

4 Exercise 1.Find the price of each product of any kind. 2.Find the amount of hard disk on each PC. 3.Find the model numbers of PC’s with a hard disk of at least 200 gigabytes. 4.Find all the laptop elements 5.Find the makers of color printers. 6.Find the makers of PC’s and/or laptops. 7.Find the makers of at least two printers.

5 Contents Week-7 Reviews XML Schema XML Namespaces Quiz 10 mins Query Languages for XML – XPath

6

7 XML Schema 1.? 2.? 3.?

8 XML Schema 2.? 3.?

9 XML Schema 3.?

10 XML Schema

11 1.? 2.? 3.?

12 XML Schema 2.? 3.?

13 XML Schema 3.?

14 XML Schema

15 1.? 2.? 3. ? 4.? 5.? 6.?

16 2.? 3. ? 4.? 5.? 6.?

17 3. ? 4.? 5.? 6.?

18 4.? 5.? 6.?

19 5.? 6.?

20

21

22

23 1.? 2.? 3.? 5.? 4.? 6.? 7.? 6.? 8.?

24 2.? 3.? 5.? 4.? 6.? 7.? 6.? 8.?

25 3.? 5.? 4.? 6.? 7.? 6.? 8.?

26 5.? 4.? 6.? 7.? 6.? 8.?

27 5.? 6.? 7.? 6.? 8.?

28 6.? 7.? 6.? 8.?

29 7.? 8.?

30

31

32 Contents Week-7 Reviews XML Schema XML Namespaces Quiz 10 mins Query Languages for XML – XPath

33 XML Namespaces XML Namespaces provide a method to avoid element name conflicts http://www.w3schools.com/xml/xml_namespaces.asp

34 XML Namespaces Solving the Name Conflict Using a Prefix http://www.w3schools.com/xml/xml_namespaces.asp

35 XML Namespaces XML Namespaces - The xmlns Attribute http://www.w3schools.com/xml/xml_namespaces.asp

36 XML Namespaces XML Namespaces - The xmlns Attribute http://www.w3schools.com/xml/xml_namespaces.asp

37 XML Namespaces Default Namespaces: xmlns="namespaceURI http://www.w3schools.com/xml/xml_namespaces.asp

38 XML Namespaces Default Namespaces: xmlns="namespaceURI http://www.w3schools.com/xml/xml_namespaces.asp Benefit?????

39 XML Namespaces Default Namespaces: xmlns="namespaceURI http://www.w3schools.com/xml/xml_namespaces.asp saves us from using prefixes in all the child elements

40 1.?

41

42 2.? 1.?

43 2.?

44

45 Name space quizs http://zvon.org/comp/r/tut-Namespace.html#Pages~Introduction

46 Name space quizs http://zvon.org/comp/r/tut-Namespace.html#Pages~Introduction 1.? 2.?

47 Name space quizs http://zvon.org/comp/r/tut-Namespace.html#Pages~Introduction 2.?

48 Name space quizs http://zvon.org/comp/r/tut-Namespace.html#Pages~Introduction

49 Name space quizs http://zvon.org/comp/r/tut-Namespace.html#Pages~Introduction Default namespace used for the element where it occures and for its children and descendants.

50 http://files.schlitt.info/slides/ipc_2009_se_xml_and_xpath_with_php_schlitt.pdf

51 Contents Week-7 Reviews XML Schema XML Namespaces Quiz 10 mins Query Languages for XML – XPath

52 XPath Quiz

53 Contents Week-7 Reviews XML Schema Quiz 10 mins Query Languages for XML – XPath

54

55 Go to W3School Webpage

56

57 1.?

58

59

60

61

62

63

64

65 2.? 3.? 4.? 5.? 6.?

66 2.? 3.? 4.? 5.? 6.?

67 3.? 4.? 5.? 6.?

68 4.? 5.? 6.?

69 5.? 6.?

70

71

72 1.?

73

74

75

76

77

78

79

80

81

82 2.? 1.?

83 2.?

84

85 XPath Syntax

86 Stanford Examples

87 87 Example: /BARS 2.50 3.00 … <BEER name = ”Bud” soldBy = ”JoesBar SuesBar … ”/> … One item, the BARS element

88 88 Example: /BARS/BAR 2.50 3.00 … <BEER name = ”Bud” soldBy = ”JoesBar SuesBar …”/> … This BAR element followed by all the other BAR elements

89 89 Example: /BARS/BAR/PRICE 2.50 3.00 … <BEER name = ”Bud” soldBy = ”JoesBar SuesBar …”/> … These PRICE elements followed by the PRICE elements of all the other bars.

90 90 Attributes in Paths Instead of going to subelements with a given tag, you can go to an attribute of the elements you already have. An attribute is indicated by putting @ in front of its name.

91 91 Example: /BARS/BAR/PRICE/@theBeer 2.50 3.00 … <BEER name = ”Bud” soldBy = ”JoesBar SuesBar …”/> … These attributes contribute ”Bud” ”Miller” to the result, followed by other theBeer values.

92 92 Remember: Item Sequences Until now, all item sequences have been sequences of elements. When a path expression ends in an attribute, the result is typically a sequence of values of primitive type, such as strings in the previous example.

93 93 Paths that Begin Anywhere If the path starts from the document node and begins with //X, then the first step can begin at the root or any subelement of the root, as long as the tag is X.

94 94 Example: //PRICE 2.50 3.00 … <BEER name = ”Bud” soldBy = ”JoesBar SuesBar …”/> … These PRICE elements and any other PRICE elements in the entire document

95 95 Wild-Card * A star (*) in place of a tag represents any one tag. Example: /*/*/PRICE represents all price objects at the third level of nesting.

96 96 Example: /BARS/* 2.50 3.00 … <BEER name = ”Bud” soldBy = ”JoesBar SuesBar … ”/> … This BAR element, all other BAR elements, the BEER element, all other BEER elements

97 97 Selection Conditions A condition inside […] may follow a tag. If so, then only paths that have that tag and also satisfy the condition are included in the result of a path expression.

98 98 Example: Selection Condition /BARS/BAR/PRICE[. < 2.75] 2.50 3.00 … The condition that the PRICE be < $2.75 makes this price but not the Miller price part of the result. The current element.

99 99 Example: Attribute in Selection /BARS/BAR/PRICE[@theBeer = ”Miller”] 2.50 3.00 … Now, this PRICE element is selected, along with any other prices for Miller.

100 Node Type Property

101 Live Demo

102

103 Excercise 1.Find the price of each product of any kind. 2.Find the amount of hard disk on each PC. 3.Find the model numbers of PC’s with a hard disk of at least 200 gigabytes. 4.Find all the laptop elements 5.Find the makers of color printers. 6.Find the makers of PC’s and/or laptops. 7.Find the makers of at least two printers.

104 Excercise 1.Find the price of each product of any kind.

105 Excercise 1.Find the price of each product of any kind. //@price

106 Excercise 2.Find the amount of hard disk on each PC.

107 Excercise 2.Find the amount of hard disk on each PC. //PC/Hardisk

108 Excercise 3.Find the model numbers of PC’s with a hard disk of at least 200 gigabytes.

109 Excercise 3.Find the model numbers of PC’s with a hard disk of at least 200 gigabytes.

110 Excercise 3.Find the model numbers of PC’s with a hard disk of at least 200 gigabytes.

111 Excercise 4.Find all the laptop elements

112 Excercise 5.Find the makers of color printers.

113 Excercise 1.Find the price of each product of any kind. 2.Find the amount of hard disk on each PC. 3.Find the model numbers of PC’s with a hard disk of at least 200 gigabytes. 4.Find all the laptop elements 5.Find the makers of color printers. 6.Find the makers of PC’s and/or laptops. 7.Find the makers of at least two printers.

114 End of Week-7


Download ppt "Advance Database S2-2011 Week-7 Dr.Kwanchai Eurviriyanukul"

Similar presentations


Ads by Google