Scenario
Alberto Delgado, the manager of the Superstar Movies video store, is attempting to use XML to develop a catalog of all of the stores' information about movies and actors. Alberto has already developed a way to structure an XML document of this type, and he has given you a sample file that uses this structure. However, he is worried that he and the other employees may fail to enter catalog entries in a consistent manner. Initially, he considered using a DTD to validate catalog documents, but he has recently learned that XML Schema enables more precise validation. Therefore, he has asked you to help him develop a schema for the catalog. You will construct two XML Schema documents: one for a library of user-defined data types, and one for the catalog itself.
Tasks
1. Using your preferred text editor, open catalogtxt.xsd, libtxt.xsd, and catalogtxt.xml from where ever you've saved them. Enter your name and the date in the comment section of each file and save them as catalog.xsd, lib.xsd, and catalog.xml respectively.
2. Go to the lib.xsd file in your text editor. Within this schema you'll create a library of data types. Add the root schema element and insert the declaration for the XML Schema namespace using the xs prefix. Set the default namespace and target of the schema to the URI https://www.superstarmovies.com/library.
3. Create the following data types:
• actorID, based on the ID data type and following the pattern a####, where # is any digit (e.g., "a0101")
• actorIDREF, based on the IDREF data type and following the same pattern as the actorID type
• movieID, based on the ID data type and following the pattern m####-###, where # is any digit (e.g., "m1996-101")
• movieIDREF, based on the IDREF data type and following the same pattern as the movieID type
• rankType, based on the integer data type and with values between 1 and 50 inclusive
4. Create a list type named actorIDREFlist for lists that contain values of type actorIDREF
5. Create the following enumerated types, both of which are based on the string type:
• yes_no, which has possible values "yes" and "no"
• genreType, which has possible values "action", "comedy", "drama" and "fantasy"
6. Create a complex type named roleType for an empty element with two attributes, both of which are required:
• character, which has the string type
• movie, which has the movieIDREF type
7. Close the lib.xsd file, saving your changes and go to the catalog.xsd file in your text editor. Within this file you'll create the schema for the catalog of movie and actor data.
8. Insert the root schema element, declaring the XML Schema namespace with the xs prefix. Declare the library namespace using the URI https://www.superstarmovies.com/library and the prefix lib. Set the default namespace and the schema target to the URI https://www.superstarmovies.com/catalog.
9. Import the lib.xsd schema file using the URI of the library namespace.
10. Insert a declaration for the complex type element catalog. This element can contain an arbitrary number (possibly 0) of actor and/or movie child elements, in any order. You should use a flat catalog design, and thus the declarations of the child elements should not be included within the scope of the catalog element's declaration. Rather, you should employ references to the declarations of these elements.
11. The actor element is also a complex type element containing the following sequence of child elements: name, date, and birthplace, followed by one or more role elements. It also has the attributes id and oscarWinner. The date and birthplace elements are optional, as is the oscarWinner attribute; the id attribute is required. The oscarWinner attribute should have a default value of "no".
12. Set the data types of the elements and attributes of the actor element as follows:
• The name and birthplace elements contain string data.
• The date element contains dates of the form yyyy-mm-dd.
• The role element is of type roleType (taken from the library namespace).
• The id attribute contains actorID data (taken from the library namespace).
• The oscarWinner attribute contains yes_no data (taken from the library namespace).
13. The movie element is also a complex type element containing the following sequence of child elements: title, year, length, and topBilledActors. It also has the required attributes id and genre, and the optional attribute earningsRank.
14. Set the data types of the elements and attributes of the movie element as follows:
• The title element contains string data.
• The year element contains a year of the form yyyy.
• The length element contains a duration of the form hh:mm:ss.
• The topBilledActors element contains actorIDREFlist data (taken from the library namespace).
• The id attribute contains movieID data (taken from the library namespace).
• The genre attribute contains genreType data (taken from the library namespace).
• The earningsRank attribute contains rankType data (taken from the library namespace).
15. Close the file, saving your changes; and then go to the catalog.xml file in your text editor.
16. Within the root catalog element, declare the XML Schema instance namespace using the prefix xsi. Declare the catalog namespace using the prefix catalog. Attach the schema from the catalog.xsd file using the appropriate namespace.
17. Change the opening and closing tags of the catalog element to a qualified name using the catalog prefix.
18. Save your changes to the catalog.xml file and validate using XML Copy Editor (see Assorted Goodies, next page) or another validating parser. Correct any reported errors to make the document valid.
19. Post a zipped/compressed file containing all your Lab files to the Lab Assignment link in the Week Four Assignments folder.