You are on page 1of 39

H XML

Web.

H
XML
Web
Web
.
H
XML

HTML
.



H XML

XML
: /

HTML

XML
.


(<...>)
y / </>
XML
<!
>.
<!- - - ->
XML .
y

.
XML
HTML
.
XML
.

XML case-sensitive,

.

.

XML

<?xml version = 1
1.0
0 standalone = yes
yes

<>
<>

<>ProductX</>
<>1</>

<> Bellaire</>

<>5</>

<>

<> 123456789</>

<>Smith </>

<> 32.5</>
</ >
</>
<>

<> 453453453</>

<>Joyce</>
<> 20.0</>

</>
<\>

<>
<>ProductY</>
<>2</>
<>Sugarland</>
<>5</>
<>
<> 123456789</>
7.5
7.5</>
/
<>
</>
<>
<> 453453453</>
<> 20.0</>
20 0</>
</>
<>
<>333445555</>
<>10.0</>
</>
<\>
</>

document

Eo

ProductX

Bellaire

123456789

Smith

32.5

453453453

Joyce

20.0

XML :


.
XML :

.
XML :
.

10

XML

XML

standalone

.

y
y

standalone = yes
standalone = no

11

XML

y
y


XML
DTD (Document Type definition) XML .

12

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.

<!DOCTYPE
!DOCTYPE [
<!ELEMENT (+)>
<!ELEMENT (, , , ?, )>
<!ELEMENT Eo (#PCDATA)>
<!ELEMENT (#PCDATA)>
<!ELEMENT (#PCDATA)>
<!ELEMENT (#PCDATA)>
<!ELEMENT (*)>
<!ELEMENT (, ?, ?, )>
<!ELEMENT (#PCDATA)>
<!ELEMENT (#PCDATA)>
<!ELEMENT (#PCDATA)>
<!ELEMENT (#PCDATA)>
]>

13

1:
2-13:

.
2: +




1
.
3: ?





0
.
8:

*
0
.

14

.
:

y
y

,
- #PCDATA (
XML) . #PCDATA


,
.
,, ,

|, .. 1|2
1 2.
.

15

XML XML
DTD
XML :
<?xml version=1.0 standalone = no?>
<DOCTYPE
SYSTEM .dtd>

XML DTD
.dtd XML .

16

DTD .
DTD


.
DTD XML
DTD
,

17

XML
XML .


XML .
.

18

1.
2.
3
3.
4.
5.
6.
7
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
8
19.
20.
21.
22
22.
23.
24.

<?xml version =1.0 encoding=utf-8?>


<xsd: schema xmlns: xsd = http://www.w3.org/2001/XMLSchema>
sd e
e e t name
a e = company>
co pa y
<xsd:
element
<xsd: annotation>
<xsd: documentation>Root Element</xsd: documentation>
</xsd: annotation>
<xsd: complexType>
<xsd: sequence>
<xsd: element name = name type =xsd: string/>
<xsd: element name = type type =xsd: string/>
d element
l
t name = address>
dd

<xsd:
<xsd: complexType>
<xsd: sequence>
<xsd: element name = street type =xsd:string/>
<xsd: element name = city type =xsd: string/>
<xsd: element name = country type =xsd:string/>
</xsd: sequence>
</xsd:
/ sd co
complexType>
p e ype
</xsd: element>
</xsd: sequence>
<xsd: attribute name =id type =xsd: integer use=required/>
</xsd: complexType>
</xsd: element>
</xsd: schema>

20



.
XML
xmlns:xsd=http://www.w3.org/2001/XMLSchema.
2 xsd
XML .
3
xsd:element name
4-6

annotation documentation

.
3 .

21

<xsd: complexType>.
p
yp

<xsd: simpleType>


XMLSchema
XMLS h
W3,
W3
Boolean, string, decimal, float, date
8
<xsd: sequence>.
9-11

<xsd:element name
xsd:>

22

11 address
.

.
17-20 .
21
required,

XML
22-24 .

23

<element
l
name=person>

0
2.
<complexType>
3
3.
<sequence>
4.
<element name=name type=string/>
5.
<element name=born type=date/>
6.
<element name=dead type=date minOccurs=0/>
7.
<element name=qualification type=string minOccurs=0/>
8.
</sequence>
/
9.
<attribute name=id type= ID use=required/>
10.
</complexType>
10
11. </element>
1.

24

1.
2.
3.
3
4.
5.
6.
7.
8.
9.
10.
11.
12.
13
13.
14.
15.
16.
17.
18.
19.
20.

<?xml version="1.0" encoding="UTF-8"?>


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Catalog"
name "Catalog" type="CatalogType"/>
type "CatalogType"/>
<xs:element name="Movie" type="MovieType"/>
<xs:complexType name="CatalogType">
q
<xs:sequence>
<xs:element ref="Movie" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="MovieType">
<xs:sequence>
<xs:element name="num" type="xs:integer"/>
<xs:element name="titleMovie" type="xs:string"/>
<xs:element name="originalLanguage" type="LangType"/>
<xs:element name="yearOfProduction" type="xs:gYear"/>
yp
<xs:element name="duration" type="xs:time"/>
<xs:element name="genre" type="GenreType" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="nationality" type="xs:string"/>
</xs:complexType>

26

21. <xs:simpleType name="LangType">


22.
<xs:restriction base="xs:string">
23.
<xs:enumeration value="english"/>
23
value "english"/>
24.
<xs:enumeration value="french"/>
25.
<xs:enumeration value="korean"/>
<xs:enumeration value="chinese"/>
26.
27.
</xs:restriction>
28. </xs:simpleType>
29.
<xs:simpleType name="GenreType">
30.
<xs:restriction base="xs:string">
31.
<xs:enumeration value="Horror"/>
32.
<xs:enumeration value="Fantasy"/>
33
33.
<xs:enumeration value="Drama"/>
34.
<xs:enumeration value="Thriller"/>
35.
<xs:enumeration value="Comedy"/>
36.
<xs:enumeration value="Romance"/>
37.
<xs:enumeration value="Adventure"/>
38.
<xs:enumeration value="Science fiction"/>
39.
<xs:enumeration value="Detective"/>
40.
<xs:enumeration value="Dramatic comedy"/>
41.
<xs:enumeration value="Action"/>
42.
</xs:restriction>
43
43.
</xs:simpleType>
44. </xs:schema>
.

27

3,4
3 4



CatalogType MovieType.
5-9 CatalogType ref
MovieType.

7
MovieType .
21 SimpleType
22 restriction
LangType string.
23 enumeration
LangType
.

28

1.
2.
3.
3
4.
5.
6.
7.
8.
9.
10.
11.
12.
13
13.
14.
15.
16.
17.
18.
19.
20.
21.

<?xml version="1.0" encoding="UTF-8"?>


<Catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="Movie.xsd">
xsi:noNamespaceSchemaLocation "Movie xsd">
<Movie nationality="Korean">
<num>0002</num>
<titleMovie>My
y sassy
y g
girl</titleMovie>
Catalog
C t l S
h

Schema
<originalLanguage>korean</originalLanguage>
instance
<yearOfProduction>2001</yearOfProduction>

<duration>02:03:00</duration>

<genre>Comedy</genre>

<genre>Drama</genre>

</Movie>
Movie.xsd
xsd
Movie
<Movie nationality="American">
<num>0010</num>
<titleMovie>The Sixth Sense</titleMovie>
<originalLanguage>english</originalLanguage>
g
g g
g
g
g g
<yearOfProduction>2000</yearOfProduction>
<duration>01:47:00</duration>
<genre>Drama</genre>

<genre>Thriller</genre>
</Movie>

30

22.
<Movie nationality="Korean">
23.
<num>0012</num>
24.
<titleMovie>A moment to remember</titleMovie>
25.
<originalLanguage>korean</originalLanguage>
26.
<yearOfProduction>2004</yearOfProduction>
27.
<duration>02:05:00</duration>
28.
<genre>Drama</genre>
29.
<genre>Romance</genre>
30.
</Movie>
31.
32. </Catalog>

31

document

Catalog
g

nationality

Movie

Korean
num

0002

TitleMovie

My sassy
girl

original
Language
korean

yearOfPr
oduction
2001

duration

02:03:00

genre

Comedy

genre

Drama

32

1.
2.
3.
4.
5.
6.
7.
8.
9
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.

<breakfast_menu>
<food>
<name>Belgian Waffles</name>
p
$
p
<price>$5.95</price>
<description> two of our famous Belgian Waffles with plenty of real maple syrup </description>
<calories>650</calories>
</food>
<food>
<name>Strawberry Belgian Waffles</name>
<price>$7.95</price>
<description> light Belgian waffles covered with strawberries and whipped cream </description>
<calories>900</calories>
</food>
<food>
f d
<name>Berry-Berry Belgian Waffles</name>
<price>$8.95</price>
<description> light Belgian waffles covered with an assortment of fresh berries and whipped cream </description>
<calories>900</calories>
</food>
<food>
<name>French Toast</name>
<price>$4.50</price>
<description> thick slices made from our homemade sourdough bread </description>
<calories>600</calories>
</food>
<food>
<name>Homestyle Breakfast</name>
<price>$6.95</price>
i
$6 95 / i
<description> two eggs, bacon or sausage, toast, and our ever-popular hash browns </description>
<calories>950</calories>
</food>
</breakfast_menu>

34

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25
25.
26.
27.
28.
29.
30.
31.

<?xml version="1.0" encoding="ISO-8859-1" ?>


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="shiporder">
<xs:complexType>
<xs:sequence>
<xs:element
xs:element name
name="orderperson"
orderperson type
type="xs:string"/>
xs:string /
<xs:element name="shipto">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name=
name="address"
address type=
type="xs:string"/>
xs:string />
<xs:element name="city" type="xs:string"/>
<xs:element name="country" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="item" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:string"/>
yp
g
<xs:element name="note" type="xs:string" minOccurs="0"/>
<xs:element name="quantity" type="xs:positiveInteger"/>
<xs:element name="price" type="xs:decimal"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="orderid" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
/
l
t
</xs:schema>
.

36

1.
2.
3.
4
4.
5.
6.
7.
8
8.
9.
10.
11.
12
12.
13.
14.
15.
16
16.
17.
18.
19.
20
20.
21.
22.
23.

<?xml version="1.0" encoding="ISO-8859-1"?>


<shiporder orderid="889923"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
i N
S h
L
ti
" hi d
d">
xsi:noNamespaceSchemaLocation="shiporder.xsd">
<orderperson>John Smith</orderperson>
<shipto>
<name>Ola Nordmann</name>
< dd
<address>Langgt
>L
t 23</address>
23</ dd
>
<city>4000 Stavanger</city>
<country>Norway</country>
</shipto>
<it >
<item>
<title>Empire Burlesque</title>
<note>Special Edition</note>
<quantity>1</quantity>
<price>10 90</price>
<price>10.90</price>
</item>
<item>
<title>Hide your heart</title>
<quantity>1</quantity>
<price>9.90</price>
</item>
</shiporder>

37

1.


XML
:

.

(RDBMS, ORDBMS, OODBMS)


XML .

2.
y

(RDBMS, ORDBMS, OODBMS)


XML
.

XML

3.
y

XML
,
,



XML .

XML
.

4.
y


XML .

38

You might also like