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:

  1. Find the title of movies with a cast of less than 20
  2. Find all stars of "A Clockwork Orange"
  3. Find the title of all movies with a related book called "Wuthering Heights"
  4. Find the 3rd related book to "Lord of the Rings"
  5. Find movies acted in by "Cate Blanchett"
Write XQuery for:
  1. Find all movies with Mark Hamil as a non-star, released after Star Wars (do not put the year of release as a constant)
  2. 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>
    
  3. 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.