XML - Managing Data Exchange/Data Schemas (Answers)

XML

= Exercises =   In chapter 4, you were asked to create a schema document to define a restaurant. In the next chapter you were asked to create a schema defining a franchise restaurant. In this exercise, you need to create a new XML Schema document and use the redefine mechanism to extend your original restaurant data type by appending the necessary franchise information. Amend the XML instance document you used for your franchise restaurant to use the newly created XML schema document for validation. 

 Create a schema document that contains the type library in the table below. Now create a new schema document that will be used to describe bars in a city, use the import mechanism to import the schema and namespace that contains the USAddressType, and use the USAddressType to define the address of the bar. Create an XML instance document with at least two bars for any US city to validate against the newly created schema document.

Table 7-11: Exercise 2 – Type Library USAddress.xsd   Retrieve the XML instance document and XML schema document you created in the exercises for chapter 2. Change the elementFormDefault value to ‘qualified’ and make the necessary changes to the XML instance document so that it will validate correctly. 

 Develop a type library for the tourGuide schema in chapter 4. Use common sense to group related elements and data types. Keep in mind that some data types may be reusable or may need to be generalized to allow them to be reused (or redefined).  

Answers by Danny Popov

Question 1

chapter4.xsd

Chap4Redefined.xsd

Chap4Redefined.xml

Question 2

USAddress.xsd

Bar.xsd

Bar.xml

Question 3

Museum.xsd

Museum.xml

Question 4

TypeLibrary.xsd