Ex 01 DTD
Ex 01 DTD
Ex 01 DTD
DTD
Basi
di
da/
2
Disheng
Qiu
disheng.qiu@gmail.com
Luca
Rossi
luca.rossi.917@gmail.com
Hints:
• Use
a
validator:
– Eclipse
has
an
embedded
XML/DTD
validator
– W3C
Validator:
hIp://validator.w3.org/
• Common
mistakes:
– Whitespaces
• Tabs
are
allowed
• Whitespaces
are
considered
CDATA
– Quotes
• “…”
!=
"…"
– Non-‐determinis<c
sequences
• Ex.:
(this
|
this,
that
|
other)
• For
each
game,
we
want
to
be
able
to
represent
the
two
teams
involved,
which
one
was
playing
at
home,
which
players
scored
goals
(some
of
which
may
have
been
penal/es)
and
the
/me
when
each
was
scored,
and
which
players
were
shown
yellow
or
red
cards.
<player>Klose</player>
</score>
<score
/me=
"85"
type="penalty">
<player>Tox</player>
</score>
</scores>
<yellows>
<player>Tox</player>
<player>Hernanes</player>
</yellows>
<reds>
<player>Kjaer</player>
</reds>
</game>
</games>
Ex.5
-‐
From
specs
to
instance
to
DTD:
Solu/on
<?xml
version="1.0"?>
<!DOCTYPE
games[
<!ELEMENT
games
(game)*>
<!ELEMENT
game
(home-‐team,
ex-‐team,
scores,
yellows,
reds)>
<!ELEMENT
home-‐team
(#PCDATA)>
<!ELEMENT
ex-‐team
(#PCDATA)>
<!ELEMENT
scores
(score)*>
<!ELEMENT
yellows
(player)*>
<!ELEMENT
reds
(player)*>
<!ELEMENT
score
(player)*>
<!ELEMENT
player
(#PCDATA)>
<!ATTLIST
game
score
CDATA
#REQUIRED>
<!ATTLIST
score
/me
CDATA
#REQUIRED>
<!ATTLIST
score
type
(field|penalty)
#IMPLIED>
]>