Download presentation
Presentation is loading. Please wait.
1
2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 – Schemas Outline 7.1Introduction 7.2Schemas vs. DTDs 7.3Microsoft XML Schema: Describing Elements 7.4Microsoft XML Schema: Describing Attributes 7.5Microsoft XML Schema: Data types 7.6W3C XML Schema 7.7Case Study: Writing a Microsoft XML Schema for the Day Planner Application 7.8Internet and World Wide Web Resources
2
2001 Prentice Hall, Inc. All rights reserved. Outline 2 Fig. 7.1Microsoft XML Schema document. 1 2 3 4 5 6 7 8 <ElementType name = "message" content = "textOnly" 9 model = "closed"> 10 Text messages 11 12 13 <ElementType name = "greeting" model = "closed" 14 content = "mixed" order = "many"> 15 16 17 18 <ElementType name = "myMessage" model = "closed" 19 content = "eltOnly" order = "seq"> 20 21 <element type = "greeting" minOccurs = "0" 22 maxOccurs = "1"/> 23 <element type = "message" minOccurs = "1" 24 maxOccurs = "*"/> 25 26 27
3
2001 Prentice Hall, Inc. All rights reserved. Outline 3 Fig. 7.2XML document that conforms to intro- schema.xml. 1 2 3 4 5 6 7 8 Welcome to XML Schema! 9 This is the first message. 10 11 12 This is the second message. 13
4
2001 Prentice Hall, Inc. All rights reserved. 4
5
Outline 5 Fig. 7.3Well-formed, but invalid XML document. 1 2 3 4 5 6 7 8 Welcome to XML Schema! 9 10 This is a message that contains another message. 11 This is the inner message. 12 13 14
6
2001 Prentice Hall, Inc. All rights reserved. 6
7
7 Fig. 7.4ElementType element attributes.
8
2001 Prentice Hall, Inc. All rights reserved. 8 Fig. 7.4ElementType element attributes. (Part 2)
9
2001 Prentice Hall, Inc. All rights reserved. 9 Fig. 7.5Element ElementType’s child elements.
10
2001 Prentice Hall, Inc. All rights reserved. 10 Fig. 7.6Element element attributes.
11
2001 Prentice Hall, Inc. All rights reserved. 11 Fig. 7.7Element group’s attributes.
12
2001 Prentice Hall, Inc. All rights reserved. 12 Fig. 7.8Element AttributeType’s attributes.
13
2001 Prentice Hall, Inc. All rights reserved. 13 Fig. 7.9Element attribute’s attributes.
14
2001 Prentice Hall, Inc. All rights reserved. Outline 14 Fig. 7.10 Demonstrating AttributeType and attribute. 1 2 3 4 5 6 7 8 <ElementType name = "contact" content = "eltOnly" order = "seq" 9 model = "closed"> 10 11 12 13 14 15 16 17 18 19 20 21 22 23 <ElementType name = "name" content = "textOnly" 24 model = "closed"/> 25 26 <ElementType name = "address1" content = "textOnly" 27 model = "closed"/> 28
15
2001 Prentice Hall, Inc. All rights reserved. Outline 15 Fig. 7.10 Demonstrating AttributeType and attribute. (Part 2) 29 <ElementType name = "address2" content = "textOnly" 30 model = "closed"/> 31 32 <ElementType name = "city" content = "textOnly" 33 model = "closed"/> 34 35 <ElementType name = "state" content = "textOnly" 36 model = "closed"/> 37 38 39 40 41 42 43 44 45
16
2001 Prentice Hall, Inc. All rights reserved. Outline 16 Fig. 7.11Contact list that conforms to contact- schema.xml. 1 2 3 4 5 6 7 Jane Doe 8 123 Main St. 9 Sometown 10 Somestate 11 12345 12 617-555-1234 13 978-555-4321 14
17
2001 Prentice Hall, Inc. All rights reserved. 17
18
2001 Prentice Hall, Inc. All rights reserved. 18 Fig. 7.12Some Microsoft XML Schema data types.
19
2001 Prentice Hall, Inc. All rights reserved. Outline 19 Fig. 7.13Using Microsoft XML Schema data types. 1 2 3 4 5 6<Schema xmlns = "urn:schemas-microsoft-com:xml-data" 7 xmlns:dt = "urn:schemas-microsoft-com:datatypes"> 8 9 <ElementType name = "bookstore" content = "eltOnly" 10 order = "many" model = "closed"> 11 12 13 14 15 16 <ElementType name = "shipping" content = "eltOnly" order = "seq" 17 model = "closed"> 18
20
2001 Prentice Hall, Inc. All rights reserved. Outline 20 Fig. 7.13Using Microsoft XML Schema data types. (Part 2) 19 <AttributeType name = "shipID" dt:type = "id" 20 required = "yes"/> 21 22 23 24 25 26 <ElementType name = "duration" content = "textOnly" 27 model = "closed" dt:type = "date"/> 28 29 <ElementType name = "book" content = "textOnly" model = "closed" 30 dt:type = "string"> 31 32 33 34 35 36
21
2001 Prentice Hall, Inc. All rights reserved. Outline 21 Fig. 7.14XML document conforming to id-schema.xml. 1 2 3 4 5 6 7 8 2000-08-01 9 10 11 12 2000-08-20 13 14 15 16 Java How to Program 3rd edition. 17 18 19 20 C How to Program 3rd edition. 21 22 23 24 C++ How to Program 3rd edition. 25 26
22
2001 Prentice Hall, Inc. All rights reserved. 22
23
2001 Prentice Hall, Inc. All rights reserved. 23 Fig. 7.15Invalid XML document.
24
2001 Prentice Hall, Inc. All rights reserved. Outline 24 Fig. 7.16Schema for an inventory document. 1 2 3 4 5 6<Schema xmlns = "urn:schemas-microsoft-com:xml-data" 7 xmlns:dt = "urn:schemas-microsoft-com:datatypes"> 8 9 <ElementType name = "inventory" content = "eltOnly" 10 model = "closed"> 11 12 13 14 <ElementType name = "book" content = "eltOnly" order = "seq" 15 model = "closed"> 16 17 <AttributeType name = "isbn" dt:type = "string" 18 required = "yes"/> 19 20 21 <AttributeType name = "inStock" dt:type = "enumeration" 22 dt:values = "yes no" default = "no"/> 23 24
25
2001 Prentice Hall, Inc. All rights reserved. Outline 25 Fig. 7.16Schema for an inventory document. (Part 2) 25 26 27 28 29 30 31 32 33 34 <ElementType name = "name" content = "textOnly" model = "closed" 35 dt:type = "string"/> 36 37 <ElementType name = "price" content = "textOnly" model = "closed" 38 dt:type = "float"/> 39 40 <ElementType name = "quantity" content = "textOnly" 41 dt:type = "int" model = "closed"/> 42 43 <ElementType name = "available" content = "textOnly" 44 dt:type = "date" model = "closed"/> 45
26
2001 Prentice Hall, Inc. All rights reserved. Outline 26 Fig. 7.17XML document conforming to inventory- schema.xml. 1 2 3 4 5 6 7 8 Java How to Program 3/e 9 68.00 10 200 11 12 13 14 Perl How to Program 15 68.00 16 2000-12-15 17 18
27
2001 Prentice Hall, Inc. All rights reserved. Outline 27 Fig. 7.18W3C XML Schema document. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 <xsd:element ref = "greeting" minOccurs = "0" 19 maxOccurs = "1"/> 20 <xsd:element ref = "message" minOccurs = "1" 21 maxOccurs = "unbounded"/> 22 23
28
2001 Prentice Hall, Inc. All rights reserved. Outline 28 Fig. 7.19Document that conforms to xml- schema.xsd 1 2 3 4 5 6<myMessage 7 xmlns:xsd = "http://www.w3.org/2000/10/XMLSchema-instance" 8 xsd:noNamespaceSchemaLocation = "xml-schema.xsd"> 9 10 Welcome to W3C XML Schema! 11 This is a message. 12 This is another message. 13 14
29
2001 Prentice Hall, Inc. All rights reserved. 29
30
2001 Prentice Hall, Inc. All rights reserved. Outline 30 Fig. 7.20Microsoft XML Schema for dayplanner.xml. 1 2 3 4 5 6<Schema xmlns = "urn:schemas-microsoft-com:xml-data" 7 xmlns:dt = "urn:schemas-microsoft-com:datatypes"> 8 9 <ElementType name = "planner" content = "eltOnly" 10 model = "closed"> 11 12 13 14 15 16 17 18 19
31
2001 Prentice Hall, Inc. All rights reserved. Outline 31 Fig. 7.20Microsoft XML Schema for dayplanner.xml. (Part 2) 20 21 22 23 24 25 26 27 28 29 30 <ElementType name = "note" content = "textOnly" model = "closed" 31 dt:type = "string"> 32 33 34 35 36 37
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.