XML Practice
Consider the following XML fragment:
<movies>
<movie id="100">
<title>Star Wars</title>
<release>1977</release>
<cast size="73">
<role real="Mark Hamil" star="true">Luke Skywalker</role>
<role.../>
...
</cast>
<relatedbooks>
<title>Clone Wars</title>
<title>...</title>
</relatedbooks>
</movie>
...
<movies>
For an XML database of this form:
Write XPaths for:
- Find the title of movies with a cast of less than 20
- Find all stars of "A Clockwork Orange"
- Find the title of all movies with a related book called "Wuthering Heights"
- Find the 3rd related book to "Lord of the Rings"
- Find movies acted in by "Cate Blanchett"
Write XQuery for:
- Find all movies with Mark Hamil as a non-star, released after Star Wars (do not put the year of release as a constant)
- Produce a file about years, in which there is an element for each year, and within it an element for each movie containing only the title.
<years>
<year id="1977">
<movie>Star Wars</movie>
<movie>...</movie>
</year>
</years>
- Make a file with elements like
<pair>
<actor></actor>
<movie></movie>
</pair>
where there are two movie elements with different movie titles, and two actor elements with the names of actors that both appeared in both movies.