Case Study Writing a Microsoft XML Schema for the Day Planner Application

Figure 7.20 is a Microsoft XML Schema for the day planner introduced in Chapter 5.

10 11 12

20 21 22

<!-- Microsoft XML Schema for day planner -- >

<Schema xmlns = "urn:schemas-microsoft-com:xml-data"

xmlns:dt = "urn:schemas-microsoft-com:datatypes">

<ElementType name = "planner" content = "eltOnly" model = "closed">

<element type = "year" minOccurs = "0" maxOccurs = "*"/> </ElementType>

<ElementType name = "year" content = "eltOnly" model = "closed"> <AttributeType name = "value" dt:type = "int"/> <attribute type = "value"/>

<element type = "date" minOccurs = "0" maxOccurs = "*"/> </ElementType>

<ElementType name = "date" content = "eltOnly" model = "closed"> <AttributeType name = "month" dt:type = "int"/> <attribute type = "month"/>

<AttributeType name = "day" dt:type = "int"/> <attribute type = "day"/>

<element type = "note" minOccurs = "0" maxOccurs = "*"/> </ElementType>

<ElementType name = "note" content = "textOnly" model = "closed" dt:type = "string">

<AttributeType name = "time" dt:type = "int"/> <attribute type = "time"/> </ElementType>

Fig. 7.20 Microsoft XML Schema for dayplanner.xml (part 1 of 2).

186 Schemas

Fig. 7.20 Microsoft XML Schema for dayplanner.xml (part 2 of 2).

Because years, months and days are whole number values, they are defined as ints in lines 15, 21 and 24, respectively. We also define time (line 33), which stores the time as an int. We do not use the date or time data types because we use our own format (i.e., int) for dates and times.

Figure 7.21 shows an XML document that conforms to the Microsoft XML Schema of Fig. 7.20.

0 0

Post a comment