Download presentation
Presentation is loading. Please wait.
Published byRoxanne Eugenia Hampton Modified over 9 years ago
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
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.?
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.?
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.?
42
2.? 1.?
43
2.?
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
55
Go to W3School Webpage
57
1.?
65
2.? 3.? 4.? 5.? 6.?
66
2.? 3.? 4.? 5.? 6.?
67
3.? 4.? 5.? 6.?
68
4.? 5.? 6.?
69
5.? 6.?
72
1.?
82
2.? 1.?
83
2.?
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
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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.