Document Type Definitions Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.

Slides:



Advertisements
Similar presentations
XML I.
Advertisements

Defining XML The Document Type Definition. Document Type Definition text syntax for defining –elements of XML –attributes (and possibly default values)
17 Apr 2002 XML Syntax: DTDs Andy Clark. Validation of XML Documents XML documents must be well-formed XML documents may be valid – Validation verifies.
XML 6.3 DTD 6. XML and DTDs A DTD (Document Type Definition) describes the structure of one or more XML documents. Specifically, a DTD describes:  Elements.
XML Document Type Definitions ( DTD ). 1.Introduction to DTD An XML document may have an optional DTD, which defines the document’s grammar. Since the.
XML Study-Session: Part II Validating XML Documents.
Document Type Definition DTDs CS-328. What is a DTD Defines the structure of an XML document Only the elements defined in a DTD can be used in an XML.
Document Type Definitions
CSCI 7818 (Topics in Software Engineering) Web Infrastructure, Services, and Applications Document Type Definition (DTD) Author: Lukasz Kurgan.
A Technical Introduction to XML Transparency No. 1 XML quick References.
 2002 Prentice Hall, Inc. All rights reserved. ISQA 407 XML/WML Winter 2002 Dr. Sergio Davalos.
Full declaration When an element is declared to have element content, the children element types must also be declared Example: to which the following.
Physical and Logical Structure
XML Verification Well-formed XML document  conforms to basic XML syntax  contains only built-in character entities Validated XML document  conforms.
Document Type Definitions. XML and DTDs A DTD (Document Type Definition) describes the structure of one or more XML documents. Specifically, a DTD describes:
VALIDATING AN XML DOCUMENT
Tutorial 3: XML Creating a Valid XML Document. 2 Creating a Valid Document You validate documents to make certain necessary elements are never omitted.
XP New Perspectives on XML Tutorial 3 1 DTD Tutorial – Carey ISBN
Validating DOCUMENTS with DTDs
Chapter 4: Document Type Definitions. Chapter 4 Objectives Learn to create DTDs Validate an XML document against a DTD Use DTDs to create XML documents.
XML CPSC 315 – Programming Studio Fall 2008 Project 3, Lecture 1.
XML 1 Enterprise Applications CE00465-M XML. 2 Enterprise Applications CE00465-M XML Overview Extensible Mark-up Language (XML) is a meta-language that.
XML Syntax - Writing XML and Designing DTD's
XP 1 DECLARING A DTD A DTD can be used to: –Ensure all required elements are present in the document –Prevent undefined elements from being used –Enforce.
XML (2) DTD Sungchul Hong.
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
1 Tutorial 13 Validating Documents with DTDs Working with Document Type Definitions.
Avoid using attributes? Some of the problems using attributes: Attributes cannot contain multiple values (child elements can) Attributes are not easily.
 2002 Prentice Hall, Inc. All rights reserved. Chapter 6 – Document Type Definition (DTD) Outline 6.1Introduction 6.2Parsers, Well-formed and Valid XML.
Lecture 6 XML DTD Content of.xml fileContent of.dtd file.
1 Chapter 10: XML What is XML What is XML Basic Components of XML Basic Components of XML XPath XPath XQuery XQuery.
XML 2nd EDITION Tutorial 1 Creating An Xml Document.
XML - DTD Week 4 Anthony Borquez. What can XML do? provides an application independent way of sharing data. independent groups of people can agree to.
XML Extensible Markup Language Aleksandar Bogdanovski Programing Enviroment LABoratory
SNU OOPSLA Lab. XML Documents 1 : Structure The ubiquitous XML(2) © copyright 2001 SNU OOPSLA Lab.
IS432: Semi-Structured Data Dr. Azeddine Chikh. 4. Document Type Definitions (DTDs)
IS432 Semi-Structured Data Lecture 2: DTD Dr. Gamal Al-Shorbagy.
XML Instructor: Charles Moen CSCI/CINF XML  Extensible Markup Language  A set of rules that allow you to create your own markup language  Designed.
Lecture 16 Introduction to XML Boriana Koleva Room: C54
An Introduction to XML Sandeep Bhattaram
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Understanding How XML Works Ellen Pearlman Eileen Mullin Programming the.
XML Introduction. What is XML? XML stands for eXtensible Markup Language XML stands for eXtensible Markup Language XML is a markup language much like.
1 Dr Alexiei Dingli XML Technologies DTD. 2 Document Type Definition Defines –the legal building blocks of an XML document –the document structure –The.
1/11 ITApplications XML Module Session 3: Document Type Definition (DTD) Part 1.
XML Design Goals 1.XML must be easily usable over the Internet 2.XML must support a wide variety of applications 3.XML must be compatible with SGML 4.It.
Document Type Definitions (DTD) A Document Type Definition (DTD) defines the structure and the legal elements and attributes of an XML document. A DTD.
Beginning XML 3 rd Edition. Chapter 4: Document Type Definitions.
INFSY 547: WEB-Based Technologies Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
SNU OOPSLA Lab. Logical structure © copyright 2001 SNU OOPSLA Lab.
QUALITY CONTROL WITH SCHEMAS CSC1310 Fall BASIS CONCEPTS SchemaSchema is a pass-or-fail test for document Schema is a minimum set of requirements.
CIS 375—Web App Dev II DTD. 2 Introduction to DTD DTD stands for ______________________. The purpose of a DTD is to define the legal building blocks of.
XSD: XML Schema Language Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
XML Document Type Definitions and the Document object model.
Introduction to DTD A Document Type Definition (DTD) defines the legal building blocks of an XML document. It defines the document structure with a list.
XML DTD. XML Validation XML with correct syntax is "Well Formed" XML. XML validated against a DTD is "Valid" XML.
Document Type Definition (DTD) Eugenia Fernandez IUPUI.
DTD Document Type Definition. Agenda Introduction to DTD DTD Building Blocks DTD Elements DTD Attributes DTD Entities DTD Exercises DTD Q&A.
Introduction to XML Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Copyrighted material John Tullis 3/18/2016 page 1 04/29/00 XML Part 4 John Tullis DePaul Instructor
CH 9 Attribute Declaration 1. Objective What is an attribute Declaring attributes Declaring multiple attribute Alternatives to default attributes values.
CITA 330 Section 2 DTD. Defining XML Dialects “Well-formedness” is the minimal requirement for an XML document; all XML parsers can check it Any useful.
Extensible Markup Language (XML) Pat Morin COMP 2405.
XML Technologies DTD.
Well-formed and Valid XML Documents
Document Type Definition DTDs
Session III Chapter 6 – Creating DTDs
Web Programming Maymester 2004
New Perspectives on XML
Session II Chapter 6 – Creating DTDs
Document Type Definition (DTD)
Presentation transcript:

Document Type Definitions Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University

168493: XML and Web Services (II/2546) 2 DTD: Document Type Definition Define the structure of XML documents with a list of legal elements Why use a DTD? Different groups of people can agree to use a common set of tags for interchanging data To verify that the data received from others is valid

168493: XML and Web Services (II/2546) 3 A DTD of the Sample Document

168493: XML and Web Services (II/2546) 4 Building Blocks of XML Elements Attributes Entities: define common text PCDATA: parsed character data Text that will be parsed by a parser Tags inside the text are treated as markup CDATA: character data Text is not parsed by a parser. Text is kept as it is

168493: XML and Web Services (II/2546) 5 Element Type Declarations Each element type declaration starts with <!ELEMENT Followed by the name and a content specification Its structure Example

168493: XML and Web Services (II/2546) 6 Empty Elements Empty elements are declared with keyword EMPTY DTD example: XML example: or

168493: XML and Web Services (II/2546) 7 Elements with Only Character Data Elements with only character data are declared with #PCDATA inside parentheses DTD example: XML example: Students

168493: XML and Web Services (II/2546) 8 Elements with any contents Declared with keyword ANY Can contain any combination of parsable data DTD example: XML example: Hello there

168493: XML and Web Services (II/2546) 9 Elements with Sequence Children Defined with the name of the children inside parentheses Children are declared in a sequence separated by commas Children must appear in the same sequence in the document DTD example:

168493: XML and Web Services (II/2546) 10 Occurrence Types Element with only one occurrence No symbol after the element Ex: Element with the minimum of one occurrence Symbol + after the element Ex:

168493: XML and Web Services (II/2546) 11 Occurrence Types (Cont.) Element with zero or more occurrences Symbol * after an element Ex: Element with zero or one occurrence Symbol ? after an element

168493: XML and Web Services (II/2546) 12 Elements with Content Options Provide an alternative with symbol | DTD example: XML example: Duangporn Nok

168493: XML and Web Services (II/2546) 13 Elements with Mixed Content Mixed with children and parsed character data Declared with symbol | DTD example XML example joy is a person

168493: XML and Web Services (II/2546) 14 Attributes Declarations Attribute declarations Start with the string “<!ATTLIST” Followed with an element name A list of the information of attributes The general structure

168493: XML and Web Services (II/2546) 15 Attribute Declarations ID: Identifier DTD: XML: CDATA: “character data”: not parsed DTD: XML:

168493: XML and Web Services (II/2546) 16 Attribute Defaults Attributes can have default values. For some attributes, the XML author does not need to specify an attribute value The processor can supply the default value if it exists But there are some attributes that the attribute values need to be specified

168493: XML and Web Services (II/2546) 17 Attribute Defaults (Cont.) Default values The DTD author specifies the default value Implied attributes The processor specifies the default value Required attributes The XML author specifies the default value Fixed attributes The attribute value is fixed and specified by the DTD author

168493: XML and Web Services (II/2546) 18 Default Values Include the default value after the type or list of allowed values in the attribute list declaration Examples: DTD: XML: red

168493: XML and Web Services (II/2546) 19 Impliable Attributes Allow the user to omit a value for a particular attribute without forcing a particular default Examples: some shirts are “one size fits all” DTD: XML: red Leave the values to be assigned by a processor or to be ignored

168493: XML and Web Services (II/2546) 20 Required Attributes The XML author is required to specify the attribute values A value for an attribute is important and cannot reliably be defaulted Examples DTD: XML:

168493: XML and Web Services (II/2546) 21 Fixed Attributes Attribute values cannot be overridden at all For the purpose of easy integration between documents

168493: XML and Web Services (II/2546) 22 Attribute Types Attribute value normalization CDATA and name token attributes Enumerated and notation attributes ID and IDREF attributes ENTITY attributes

168493: XML and Web Services (II/2546) 23 Attribute Values and Types The value of an attribute is not necessary the exact character string that you enter between the quotation marks The string first go through a process called attribute-value normalization Attribute types apply to the normalized value

168493: XML and Web Services (II/2546) 24 Attribute Value Normalization XML processors normalize values to make authors’ lives simpler If it were not for normalization, The XML authors must be very careful where and how they put white spaces in an attribute value All XML attribute values are entered as quoted strings

168493: XML and Web Services (II/2546) 25 Normalization Process 1. Strip off the surrounding quotes 2. Character and entity references are replaced 3. Newline characters are replaced by spaces Examples: |“ token “|  |token|

168493: XML and Web Services (II/2546) 26 CDATA Attributes CDATA stands for “character data” DTD: XML: …

168493: XML and Web Services (II/2546) 27 NMTOKEN Attributes NMTOKEN: Name Token attributes Similar to CDATA but restricted in the characters that name tokens allow Name tokens are composed of strings made up of letters, numbers, and a select group of special characters Period (.), Dash (-), Underscore (_), and colon (:)

168493: XML and Web Services (II/2546) 28 NMTOKEN Examples DTD: XML: …

168493: XML and Web Services (II/2546) 29 Entity Declarations Allow you to associate a name with a fragment which can be A piece of common text A reference to an external file containing either text or binary data Three kinds of entities Internal entities External entities Parameter entities

168493: XML and Web Services (II/2546) 30 Internal Entities Associate a name with a string of literal text Examples: DTD: XML: &KKU; is in Thailand

168493: XML and Web Services (II/2546) 31 External Entities Allow an XML document to refer to the contents of another file If another file contains text, Its content is inserted at the point of reference and parsed as part of the document If another file contains binary data, Its content is not parsed May only be referenced in an attribute

168493: XML and Web Services (II/2546) 32 External Entities (Cont.) Another file is a text file Another file contains binary data, such as figures

168493: XML and Web Services (II/2546) 33 Parameter Entities Can only occur in the DTD A parameter entity declaration is identified by placing % (percent- space) in front of its name in the declaration The percent sign is also used in references to parameter entities, instead of the ampersand

168493: XML and Web Services (II/2546) 34 Parameter Entities (Cont.) Examples: Without parameter entities With parameter entities

168493: XML and Web Services (II/2546) 35 Notation Declarations Provide a name for the notation Which may allow an XML processor to locate an application capable of processing data in the given notation Example:

168493: XML and Web Services (II/2546) 36 Declaring a DTD Two ways that a DTD can be declared Inline in an XML document (Internal DOCTYPE declaration) As an external reference (External DOCTYPE declaration)

168493: XML and Web Services (II/2546) 37 Internal DOCTYPE declaration <!DOCTYPE Note [ … ]> …

168493: XML and Web Services (II/2546) 38 External DOCTYPE Declaration …