1.
a) select
Y.name
from
moviedb.movies.movie X, moviedb.stars.star Y
where
X.title = "Air Force One" and
X.actors.actor.idref = Y.id and
Y.sex = "Male"
b) select
X.sname, X.address
from
moviedb.studios.studio X, moviedb.stars.star Y
where
X.owns.movie.idref = Y.starredIn.movie.idref and
Y.name = "Harrison Ford"
c) select
X.title, Y.name
from
moviedb.movies.movie X, moviedb.stars.star Y
where
X.title = like "%War%" and
X.actors.actor.idref = Y.id
d) < !
DOCTYPE moviedb [
< ! ELEMENT moviedb ( movies,
stars, studios ) >
< ! ELEMENT movies ( movie * )
>
< ! ELEMENT movie ( title, year,
length, film, actors, ownedby ) >
< ! ATTLIST movie id ID #REQUIRED >
< ! ELEMENT title ( #PCDATA )
>
< ! ELEMENT year ( #PCDATA ) >
< ! ELEMENT length ( #PCDATA )
>
< ! ATTLIST length units CDATA
#REQUIRED >
< ! ELEMENT film ( #PCDATA ) >
< ! ELEMENT actors ( actor * )
>
< ! ATTLIST actor idref IDREF
#REQUIRED >
< ! ELEMENT ownedby EMPTY >
< ! ATTLIST ownedby idref IDREF
#REQUIRED >
< ! ELEMENT stars ( star * ) >
< ! ELEMENT star ( name, sex,
address, starredIn ) >
< ! ATTLIST star id ID #REQUIRED
>
< ! ELEMENT name ( #PCDATA ) >
< ! ELEMENT sex ( #PCDATA ) >
< ! ELEMENT address ( street, city ) >
< ! ELEMENT street ( #PCDATA )
>
< ! ELEMENT city ( #PCDATA ) >
< ! ELEMENT starredIn ( movie * )
>
< ! ELEMENT movie EMPTY >
< ! ATTLIST movie idref IDREF
#REQUIRED >
< ! ELEMENT studios ( studio * )
>
< ! ELEMENT studio ( sname,
address, owns ) >
< ! ATTLIST studio id ID
#REQUIRED >
< ! ELEMENT sname ( #PCDATA )
>
< ! ELEMENT address ( #PCDATA )
>
< ! ELEMENT owns ( movie * ) >
]
>
2.
< xsl :
template match = " / " >
< html >
< head >
<
title > State Details < /title >
< /head >
< body >
<
xsl : apply - templates />
< /body >
< /html >
< /xsl : template >
< xsl =
template match = "sname" >
< h2 > State Details < /h2
> <BR>
< h2 > < xsl : value - of /
> < /h2 >
< /xsl :
template >
< xsl =
template match = "scode" >
< tr >
< td > < b > State Code
: < /b > < /td >
< td align = "left"
> < xsl : value - of / > < /td >
< /tr >
< /xsl :
template >
< xsl =
template match = "capital" >
< tr >
< td > < b > State
Capital : < /b > < /td >
< td align = "left"
> < xsl : value - of / > < /td >
< /tr >
< /xsl :
template >
< xsl =
template match = "nickname" >
< tr >
< td > < b > Nickname :
< /b > < /td >
< td align = "left"
> < xsl : value - of / > < /td >
< /tr >
< /xsl :
template >
< xsl =
template match = "population" >
< tr >
< td > < b > Population
: < /b > < /td >
< td > < xsl : value - of /
> < /td >
< /tr >
< /xsl :
template >
< xsl =
template match = "majorcities" >
< tr >
< td > < b > Major
Cities : < /b > < /td >
< td > < xsl : apply -
templates select = "cname"/ > < /td >
< /tr >
< /xsl :
template >
< xsl =
template match = "cname" >
< xsl : value - of / > ,
 
< /xsl :
template >
< xsl = template match = "state" >
< center > < BR >
< xsl: apply - templates select =
"sname" / >
< table border = 0 >
<
xsl: apply - templates select = "scode" / >
<
xsl: apply - templates select = "capital" / >
<
xsl: apply - templates select = "population" / >
<
xsl: apply - templates select = "nickname" / >
<
xsl: apply - templates select = "majorcities" / >
< / table >
< /center >
< /xsl :
template >
3.
(Note: suppose all collection elements have at last one
subelement use +)
< ! DOCTYPE
Journals [
< ! ELEMENT Journals ( Journal +
) >
< ! ELEMENT Journal ( JournalName
+, Volumes + ) >
< ! ELEMENT JournalName ( #PCDATA
) >
< ! ELEMENT Volumes ( VolumeEntry
+ ) >
< ! ELEMENT VolumeEntry ( Volume,
Year, Numbers ) >
< ! ELEMENT Volume ( #PCDATA )
>
< ! ELEMENT Year ( #PCDATA ) >
< ! ELEMENT Numbers ( NumberEntry
+ ) >
< ! ELEMENT NumberEntry ( Number,
Date, Articles ) >
< ! ELEMENT Number ( #PCDATA )
>
< ! ELEMENT Date ( #PCDATA ) >
< ! ELEMENT Articles ( Article +
) >
< ! ELEMENT Article (
Authors,Title, StartPage, EndPage ) >
< ! ELEMENT Authors ( Author + )
>
< ! ELEMENT Author ( name ) >
< ! ELEMENT name ( #PCDATA ) >
< ! ELEMENT Title ( #PCDATA )
>
< ! ELEMENT StartPage ( #PCDATA )
>
< ! ELEMENT EndPage ( #PCDATA )
>
]
>