Exercises

7.3 Write a Microsoft XML Schema document for the XML document in Fig. 7.2 that would allow element note to be a child element of element myMessage. Element note can contain only text. Validate your document using Microsoft XML Validator.

Chapter 7

7.4 Write a schema to validate the XML document shown in Fig. 7.22. This XML document contains information about products in a grocery store. Each product is represented by a product element that contains the name, manufacturer, quantity and price of the product. Each product has a unique ID and is categorized as either perishable or nonperishable. If the product is perishable, it contains a food element. Element food contains the expiration date and nutrition facts. Nutrition facts describe the amount of proteins, fats and calcium in the food. If the product is nonperishable, it contains details of the stock available in one or more warehouses. A warehouse element has a unique ID and contains a description of the warehouse, along with product stock available at the warehouse.

5 <products xmlns = "x-schema:exer07_4-schema.xml">

7 <product id = "p12" perishable = "yes">

9 <manufacturer>xsz Co.</manufacturer>

10 <quantity>25</quantity>

14 <nutrition>

15 <calcium>10.30</calcium>

16 <proteins>35.5</proteins>

18 </nutrition>

20 <expirationDate>2 00 0-09-12</expirationDate>

24 <product id = "p13" perishable = "no">

25 <name>AA Battries</name>

26 <manufacturer>DCells</manufacturer>

27 <quantity>100</quantity>

32 xsz warehouse

33 <stock>25000</stock>

34 </warehouse>

37 rza warehouse

38 <stock>5000</stock>

39 </warehouse>

43 </products>

+1 0

Post a comment