1 XML: Document Type Definitions 2 Road Map  Introduction to DTDs  What’s a DTD?  Why are they important?  What will we cover?  Our First DTD 

Slides:



Advertisements
Similar presentations
Defining XML The Document Type Definition. Document Type Definition text syntax for defining –elements of XML –attributes (and possibly default values)
Advertisements

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.
1 XML DTD & XML Schema Monica Farrow G30
Tutorial 9 Working with XHTML
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.
CS 898N – Advanced World Wide Web Technologies Lecture 21: XML Chin-Chih Chang
CSCI 7818 (Topics in Software Engineering) Web Infrastructure, Services, and Applications Document Type Definition (DTD) Author: Lukasz Kurgan.
 2002 Prentice Hall, Inc. All rights reserved. ISQA 407 XML/WML Winter 2002 Dr. Sergio Davalos.
Valid XML documents (contd.) For example, if we wanted to turn the example well- formed XML document we have just seen into a valid document, we would.
Tutorial 9 Working with XHTML. XP Objectives Describe the history and theory of XHTML Understand the rules for creating valid XHTML documents Apply a.
Creating a Well-Formed Valid Document. 2 Objectives Introducing XHTML Creating a Well-Formed Document Creating a Valid Document Creating an XHTML Document.
Full declaration When an element is declared to have element content, the children element types must also be declared Example: to which the following.
XML Verification Well-formed XML document  conforms to basic XML syntax  contains only built-in character entities Validated XML document  conforms.
Introduction to XML This material is based heavily on the tutorial by the same name at
XP New Perspectives on XML Tutorial 3 1 DTD Tutorial – Carey ISBN
Validating DOCUMENTS with DTDs
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Document Type Definition.
XP Tutorial 9New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with XHTML Creating a Well-Formed Valid Document Tutorial 9.
XP The University of Akron Summit College Business Technology Department Computer Information Systems 2440: 140 Internet Tools Instructor: Enoch E. Damson.
Copyright © 2003 Pearson Education, Inc. Slide 3-1 Created by Cheryl M. Hughes, Harvard University Extension School — Cambridge, MA The Web Wizard’s Guide.
Introduction to XML cs3505. References –I got most of this presentation from this site –O’reilly tutorials.
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.
Document Type Definitions Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
MIS 315 Bsharah An Introduction to XML 1MIS Bsharah.
1 herbert van de sompel CS 502 Computing Methods for Digital Libraries Cornell University – Computer Science Herbert Van de Sompel
Introduction. Document Structure Overview  XML declaration (prolog)  Document type declaration  Root element (namespace)  Document header  Document.
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 Extensible Markup Language. What is XML? ● meta-markup language ● a language for defining a family of languages ● semantic/structured mark-up language.
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.
What is XML?  XML stands for EXtensible Markup Language  XML is a markup language much like HTML  XML was designed to carry data, not to display data.
XML (2) DTD Sungchul Hong.
Introduction to XML Extensible Markup Language. What is XML XML stands for eXtensible Markup Language. A markup language is used to provide information.
FIGIS’ML Hands-on training - © FAO/FIGIS An introduction to XML Objectives : –what is XML? –XML and HTML –XML documents structure well-formedness.
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.
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 - DTD Week 4 Anthony Borquez. What can XML do? provides an application independent way of sharing data. independent groups of people can agree to.
CIS 451: XML DTDs Dr. Ralph D. Westfall February, 2009.
Introduction to XML This presentation covers introductory features of XML. What XML is and what it is not? What does it do? Put different related technologies.
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
XML Introduction. What is XML? XML stands for eXtensible Markup Language XML stands for eXtensible Markup Language XML is a markup language much like.
The eXtensible Markup Language (XML). Presentation Outline Part 1: The basics of creating an XML document Part 2: Developing constraints for a well formed.
CSE3201 Information Retrieval Systems DTD Document Type Definition.
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.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2.
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.
XP Tutorial 9New Perspectives on HTML and XHTML, Comprehensive 1 Working with XHTML Creating a Well-Formed Valid Document Tutorial 9.
XML Technology. Emerging Importance of XML –HTML-tagging is display oriented. –XML-based content tagging has important uses: data mining role-oriented.
DTD Document Type Definition. Agenda Introduction to DTD DTD Building Blocks DTD Elements DTD Attributes DTD Entities DTD Exercises DTD Q&A.
Tutorial 9 Working with XHTML. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Describe the history and theory of XHTML.
Tutorial 9 Working with XHTML. XP Objectives Describe the history and theory of XHTML Understand the rules for creating valid XHTML documents Apply a.
XML Introduction to XML Extensible Markup Language.
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 BASICS and more…. What is XML? In common:  XML is a standard, simple, self-describing way of encoding both text and data so that content can be processed.
Tutorial 9 Working with XHTML
Document Type Definition DTDs
Session III Chapter 6 – Creating DTDs
Web Programming Maymester 2004
Tutorial 9 Working with XHTML
New Perspectives on XML
CSE591: Data Mining by H. Liu
Session II Chapter 6 – Creating DTDs
Document Type Definition (DTD)
Presentation transcript:

1 XML: Document Type Definitions

2 Road Map  Introduction to DTDs  What’s a DTD?  Why are they important?  What will we cover?  Our First DTD  Adding Attributes  Multiple Elements  Creating external DTDs

3 Introduction to DTDs

4 Definitions  Document Type Definition: A set of rules for constructing an XML document.  Valid: Documents that conform to a DTD are said to be valid.

5 Why are DTDs Important?  In order to communicate, computers need to agree to specific rules.  By agreeing to standards, lots of people/computers can share data.  Once we can share data, we can create more powerful applications.

6 Case Study 1: Meerkat  What is Meerkat?  “Open Wire Service” that collects news from multiple web sites.  Created by OReilly.com  URL:  Uses an XML Document Type Definition, called RSS (Rich Site Summary) or ((Really Simple Syndication)  For Meerkat to work, all participating sites must adhere to the RSS DTD.  Yahoo news offer similar service: 

7

8 Case Study: Meerkat  RSS DTD was developed by Netscape for my.netscape.com  Encapsulates specific article information, such as: Article Title, Article Description, Date, etc.  By agreeing to follow the RSS DTD, hundreds of web sites can easily share data.

9 Example DTDs  ICE (Information and Content Exchange): enables automatic transfer of data between two or more sites.  XMLNews: standard for formatting news articles.  cXML: Commerce XML; standard for E- Commerce transactions.  BSML: Bioinformatics Sequence Markup Language.

10 Example DTDs (Cont)  Chemical Markup Language: used to represent chemical molecules.  VoiceXML: used to encode text for voice recognition and synthesis.  For a more complete list, go to:

11 Challenge in Creating DTDs  In order to be useful, DTDs need to be widely used.  Requires that companies/organizations collaborate on the creation of DTDs.  Results can be slow and fractured.  May result in competing standards.  Nonetheless, many more XML DTDs are likely to emerge within the very near future.

12 What will we cover?  DTDs can become quite complicated.  Our goal is to learn the basics so that you can read basic DTD rules.  We will focus on Element structure, attributes, and internal v. external DTDs.

13 Our First DTD

14 Example 1: Internal DTD <!DOCTYPE DOCUMENT [ ]> This is element text and an entity follows:&Description; 1. Prolog 2. Document Type Declaration 4. XML Document Data 3. DTD Rules

15 1. Prolog   XML documents start with an XML prolog.  Includes two major elements:  version: XML is currently in version 1.0  encoding: specifies the character encoding.

16 Character Encodings  XML Parsers are required to support three types of encodings:  UTF-8: Unicode Transformation - 8 bit  UCS-2: Canonical Unicode Character site  UTF-16: Unicode format  Why is this important?  Enables internationalization of software applications.

17 2. Document Type Declaration <!DOCTYPE DOCUMENT [  Indicates the start of the DTD.  Specifies the name of the DTD. This name should match the name of the root element. Name of DTD

18 3. DTD Rules  ELEMENT: declares a specific element. Here, we declare a root element, called DOCUMENT.  #PCDATA: text data that does not contain any &, characters.  ENTITY: declares an abbreviation or a shortcut.  Whenever the parser sees &Description, it will replace it with "This is entity content."

19 4. XML Document Data This is element text and an entity follows:&Description;  Note that this document contains only one element: DOCUMENT, and it therefore adheres the the DTD.  The document is therefore valid.  When parsed by an XML Parser, the parser will replace &Description with, "This is entity content."

20 Validating your Document  You can run your document through an XML parser to determine if the document is valid.  Simple web based validator:   Let’s try it with our first example…

21 Adding Attributes

22 Adding Attributes <!DOCTYPE DOCUMENT [ <!ATTLIST DOCUMENT trackNum CDATA #REQUIRED secLevel (unclassified|classified) "unclassified"> ]> This is element text and an entity follows:&Description; Here, we have added two attributes to the Document element.

23 Attributes <!ATTLIST ElementName AttributeName Type Default>  When you create an attribute, you specify the associated element, the attribute name, the attribute type, and any attribute defaults.  Attribute Types:  CDATA: attribute may contain any text data.  (this one | that one): The value of the attribute must match one of the values listed.  Other options (but, we won’t cover these...)

24 Attribute Defaults  Attribute Defaults:  #REQUIRED: The attribute must be specified.  #IMPLIED: The attribute is optional.  #FIXED value: Attribute is preset to a specific value.  Defaultvalue: Provides a default value for the attribute.

25 Attributes <!ATTLIST DOCUMENT trackNum CDATA #REQUIRED secLevel (unclassified|classified) "unclassified"> ]>  Here, we specify that the trackNum attribute can contain any text and is required.  We also specify that secLevel can be set to one of two options: unclassified of classified. The default is unclassified.  Let’s run it through our validator and see what happens...

26 Multiple Elements

27 <!DOCTYPE DOCUMENT [ <!ATTLIST DOCUMENT trackNum CDATA #REQUIRED secLevel (unclassified|classified) "unclassified"> ]> Sample Document Simon St.Laurent This is element text and an entity follows:&Description;

28 Multiple Elements  When you declare an element, you specify:  the list of elements;  rules for which elements are required;  the sequence in which they appear;  how many times they may appear

29 Symbols for Element Structure |Any element may appear,Requires appearance in specified sequence ?Zero or One Occurrences *Zero or more Occurrences +One or more Occurrences Required

30 Element Structure Here, we have:  Rigid sequence: TITLE, AUTHOR, SUMMARY, NOTE  TITLE (exactly one is required)  AUTHOR (at least one must appear)  SUMMARY (zero or more)  NOTE (zero or one)  Let’s try it on our validator…

31 <!DOCTYPE DOCUMENT [ <!ATTLIST DOCUMENT trackNum CDATA #REQUIRED secLevel (unclassified|classified) "unclassified"> ]> Sample Document Simon St.Laurent XML Mania This is element text and an entity follows: &Description;

32 Creating External DTDs

33 Internal v. External DTDs  Internal DTDs are really just for experimenting.  You really want to separate your DTD into an external file.  This enables multiple developers/ companies to all use the same DTD.

34 The External DTD: simple.dtd <!ATTLIST DOCUMENT trackNum CDATA #REQUIRED secLevel (unclassified|classified) "unclassified">

35 XML Document Sample Document Simon St.Laurent XML Mania This is element text and an entity follows:&Description; Here, we reference an external DTD: simple.dtd

36 More on External DTDs  To reference a company wide DTD, use the keyword SYSTEM  To reference a Public DTD, use the keyword PUBLIC, and specify the URL of the DTD