Download presentation
Presentation is loading. Please wait.
Published byAsher Mosley Modified over 9 years ago
1
Document Type Definition (DTD) Eugenia Fernandez IUPUI
2
Why DTDs? DTDs define the allowable structure for an XML document. A DTD defines a vocabulary for a particular type of XML document. DTDs are not required, but recommended to ensure document conformity. They are especially useful in business-to- business exchange. Various industries have agreed upon a common vocabulary.
3
Creating a DTD A DTD describes every object (e.g. element, attribute) that can appear in an XML document. It is a text file with a.dtd extension and can be created with any text editor: Notepad Visual Interdev FrontPage
4
Linking a DTD To attach a DTD to an XML document, add one of the following processing instructions:
5
What Can Be Validated: Structure Elements What elements are recognized? optional/required? What are the relationships between elements? How many child elements are allowed? What is their sequence? What is the data type of each element? Attributes What attributes are recognized? optional/required? What is the data type of each attribute? Is there a restricted set of values for an attribute?
6
Declaring Elements Syntax Content Specification list of elements #PCDATA EMPTY ANY content specification
7
Child Element List When separated by commas Elements must appear in the order given Example Valid XML Eugenia Fernandez Invalid XML Fernandez Eugenia
8
Child Element List When separated by vertical bar (or pipe |) Elements are mutually exclusive, only one must appear in the document Example Valid XML Eugenia Invalid XML Fernandez Eugenia
9
Occurrence Indicator: + plus, + appears one or more times, i.e. element can repeat Example Valid XML Eugenia Maria Alicia Fernandez Invalid XML Fernandez Eugenia
10
Occurrence Indicator: * asterisk, * appears zero or more times, i.e. element is optional and can repeat Example Valid XML Eugenia Fernandez Eugenia Maria Alicia Fernandez
11
Occurrence Indicator: ? question mark, ? appears zero or one times, i.e. element is optional and cannot repeat Example Valid XML Eugenia Fernandez Invalid XML Eugenia Maria Alicia Fernandez
12
Declaring Attributes Syntax Can appear anywhere in DTD Generally placed after the element declaration
13
Attribute Types strings (CDATA) enumerated e.g. (false | true) tokenized ID IDREF ENTITY NMTOKEN
14
Tokenized Attribute Types Restricts the values used for attributes ID unique identifier for each element IDREF/IDREFS value of an ID elsewhere in document, used to create links within a document ENTITY/ENTITIES name of external entity, like & for & NMTOKEN/NMTOKENS a word without spaces, used in enumerated values
15
Default Values for Attributes #REQUIRED attribute value must be supplied #IMPLIED if no value is supplied, application uses its own default #FIXED value attribute value must match the one specified a literal attribute takes on this value if none supplied
16
Entity Declarations general or parameter general entities act as shorthand or substitution macros like > parameter entities internal or external internal entities stored in the document external entities point to system or public identifier parsed or unparsed parsed entities contain XML text and markup unparsed entities used for non-XML content
17
The End
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.