Download presentation
Presentation is loading. Please wait.
Published byMagnus Gregory Modified over 9 years ago
1
XML (2) DTD Sungchul Hong
2
<!DOCTYPE simple [ <!ATTLIST DOCUMENT trackNum CDATA #REQUIRED secLevel (unclassified|classified) "unclassified"> <!ENTITY Description "This is a very simple sample document."> ]> This is an entity inside an element:&Description;
3
Document Type Definition A DTD is used to validate an XML document. Only one DTD per document Document type declaration – XML documents –Well formed documents Document must comply with the XML specification. –Valid documents A valid document is a document that has a DTD and follows the rule laid out in that DTD.
4
Document Type Declarations
5
Internal DTD Subset A DTD can be declared internal to the XML document Internal subsets are parsed before external subsets Internal declarations that match external declarations will override the corresponding declarations.
6
<!DOCTYPE simple [ <!ATTLIST DOCUMENT trackNum CDATA #REQUIRED secLevel (unclassified|classified) "unclassified"> ]> Sample Document Simon St.Laurent This is an entity inside an element:&Description;
7
External DTD Subset The Document Type Declaration will now provide a URL and either a system or public identifier Provides more flexibility than internal DTD subsets
8
Sample Document Simon St.Laurent XML Mania This is an entity inside an element:&Description;
9
Elements Declares what elements are legal, what order they should appear in and the number of elements Data can be one of five types: Empty, Elements-only, Characters-only, any and mixed.
10
Elements Empty: the corresponding element cannot contain either text or other elements – Element-only: the corresponding element can only contain other elements, no text. – Characters-only: The corresponding element can contain only text – Any: the corresponding element can include any of previous three types – Mixed: the corresponding element must have both elements and text –
11
Elements Syntax Content model –( ): substructure –, : strict ordering –| : choice –?: optional –*: zero or more of a particular item can appear. –+: The plus-sign (+) denotes that one or more of a particular item can appear.
12
Example
13
Attributes Syntax A DTD defines attributes with the declaration. –#REQUIRED-the attribute must appear with this element. –#IMLIED- the attribute may appear with this element. –#FIXED default value – the attribute must always have the default value. If it does not appear explicitly, it is assumed. –Default value – the attribute may appear with the default or can have another value.
14
Attribute Types CDATA – Character data. Used if an attribute value is only plain text. …
15
Attribute Types ID – unique name within a document used to uniquely identify an element... …
16
Attribute Types IDREF- A reference to an element with an ID, allowing for links to b created within documents. …
17
Attribute Types IDREFS – Series of references to elements with corresponding Ids …
18
Enumerated Values Enumerated values are defined with not type definition. A parenthetical sequence of legal values is given instead Do not use quotation marks and remember the values are case sensitive Cheescake
19
NOTATION NOTATION- Identify the format of external data items that we wish to use with our XML document
20
Entities Entities allow you t declare content and reference it anytime you need it within a document Entities are like an alias to some content Predefined entities <, >, &, &apos, "e
21
<!DOCTYPE simple [ <!ATTLIST DOCUMENT trackNum CDATA #REQUIRED secLevel (unclassified|classified) "unclassified"> <!ENTITY Description "This is a very simple sample document."> ]> This is an entity inside an element:&Description;
22
Problems With DTD DTD use a non-XML syntax. There is no way to type information like numbers DTDs do not allow merging of documents XML Schema
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.