Download presentation
Presentation is loading. Please wait.
Published byEmerald Cummings Modified over 9 years ago
1
Beginning XML 3 rd Edition
2
Chapter 4: Document Type Definitions
3
Chapter 4 Objectives Learn to create DTDs Validate an XML document against a DTD Use DTDs to create XML documents from multiple files
4
Preparing the Ground Download the Codeplot editor
5
Preparing the Ground
6
What’s in a Name? <!DOCTYPE name [ ]> John Fitzgerald Johansen Doe
7
Try It Out What’s in a Name?
8
The Document Type Declaration System Identifiers Public Identifiers
9
Try It Out The External DTD
10
Sharing Vocabularies Use your favorite search engine Cover Pages http://xml.coverpages.org Dublin Core Metadata Initiative http://www.dublincore.org
11
Anatomy of a DTD
12
Element Declarations Element declarations consist of three basic parts: The ELEMENT declaration The element name The element content model
13
Element Content Or
14
Sequences John Fitzgerald Johansen Doe
15
Choices
16
Combining Sequences and Choice Using Groups
17
Mixed Content
18
Cardinality IndicatorDescription [none]As we have seen in all of our content models thus far, when no cardinality indicator is used, it indicates that the element must appear once and only once. This is the default behavior for elements used in content models. ?Indicates that the element may appear either once or not at all. +Indicates that the element may appear one or more times. *Indicates that the element may appear zero or more times.
19
Try It Out “Making Contact” Part 1 “Making Contact” Part 2
20
Attribute Declarations An ATTLIST declaration consists of three basic parts: *The ATTLIST keyword *The associated element’s name *The list of declared attributes *The attribute name *The attribute type *The attribute value declaration source CDATA #IMPLIED
21
Attribute Types TypeDescription CDATAIndicates that the attribute value is character data IDIndicates that the attribute value uniquely identifies the containing element IDREFIndicates that the attribute value is a reference, by ID, to a uniquely identifiable element IDREFSIndicates that the attribute value is a whitespace-separated list of IDREF values ENTITYIndicates that the attribute value is a reference to an external unparsed entity (we will learn more about entities later). The unparsed entity might be an image file or some other external resource such as an MP3 or some other binary file ENTITIESIndicates that the attribute value is a whitespace-separated list of ENTITY values NMTOKENIndicates that the attribute value is a name token. An NMTOKEN is a string of character data consisting of standard name characters NMTOKENSIndicates that the attribute value is a whitespace-separated list of NMTOKEN values Enumerated List Apart from using the default types, you can also declare an enumerated list of possible values for the attribute
22
Attribute Value Declarations Has a default value Has a fixed value Is required Is implied
23
Specifying Multiple Attributes <!ATTLIST contacts version CDATA #FIXED “1.0” source CDATA #IMPLIED>
24
Try It Out “Making Contact” Part 3
25
Entities Jeff is a developer & author for Beginning XML 4th edition © 2006 Wiley Publishing. Jeff loves XML! *Built-in entities *Character entities *General entities *Parameter entities
26
Built-in Entities &—the & character <—the < character >—the > character '—the ‘ character "—the “ character Jeff is a developer & author for Beginning XML 4th edition © 2006 Wiley Publishing. Jeff loves XML!
27
Character Entities ©the © character
28
General Entities Internal External or <!ENTITY jeff-description PUBLIC "-//Beginning XML//Jeff Description//EN" "jeff.txt"> Referencing &jeff-description;
29
Try It Out “Making Contact” Part 4
30
Parameter Entities Internal External: SYSTEM or PUBLIC or <!ENTITY % NameDeclarations PUBLIC "-//Beginning XML 4E//DTD External module//EN" "name4.dtd"> Referencing Examples %NameDeclarations;
31
Try It Out “Making Contact” Part 3 “Making Contact” Part 4 “Making Contact” Part 5
32
Developing DTDs For example, the following is valid: The following is not valid: <!ATTLIST contacts source CDATA #IMPLIED>
33
DTD Limitations Some limitations of DTDs include: Differences between DTD syntax and XML syntax Poor support for XML namespaces Poor data typing Limited content model descriptions
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.