XML Technologies 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

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.
History Leading to XHTML
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.
Introduction to XML: DTD
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
Review Writing XML  Style  Common errors 1XML Technologies David Raponi.
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.
Structured Documents KA1 Document Type definition DTD.
 2002 Prentice Hall, Inc. All rights reserved. ISQA 407 XML/WML Winter 2002 Dr. Sergio Davalos.
Week 4 Document Type Definition (DTD)
Full declaration When an element is declared to have element content, the children element types must also be declared Example: to which the following.
Sistemi basati su conoscenza XML Prof. M.T. PAZIENZA a.a
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:
Introduction to XML This material is based heavily on the tutorial by the same name at
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
XML Anisha K J Jerrin Thomas. Outline  Introduction  Structure of an XML Page  Well-formed & Valid XML Documents  DTD – Elements, Attributes, Entities.
Copyright © 2003 Pearson Education, Inc. Slide 3-1 Created by Cheryl M. Hughes, Harvard University Extension School — Cambridge, MA The Web Wizard’s Guide.
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.
Document Type Definitions Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
XML - DTD. The building blocks of XML documents Elements, Tags, Attributes, Entities, PCDATA, and CDATA.
1 herbert van de sompel CS 502 Computing Methods for Digital Libraries Cornell University – Computer Science Herbert Van de Sompel
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.
XML (2) DTD Sungchul Hong.
1 Tutorial 13 Validating Documents with DTDs Working with Document Type Definitions.
 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 - DTD Week 4 Anthony Borquez. What can XML do? provides an application independent way of sharing data. independent groups of people can agree to.
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
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.
The eXtensible Markup Language (XML). Presentation Outline Part 1: The basics of creating an XML document Part 2: Developing constraints for a well formed.
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.
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.
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.
1 Internal DTD External DTD. 2 Internal DTD ]> Tove Jani Reminder Don't forget me this weekend.
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.
Copyrighted material John Tullis 3/18/2016 page 1 04/29/00 XML Part 4 John Tullis DePaul Instructor
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.
Document Type Definition DTDs
The XML Language.
Session III Chapter 6 – Creating DTDs
CSCE 315 – Programming Studio Spring 2013
XML Data DTDs, IDs & IDREFs.
New Perspectives on XML
Session II Chapter 6 – Creating DTDs
Document Type Definition (DTD)
XML IST 421.
Presentation transcript:

XML Technologies DTD

What’s in a DTD? Document Type Definition Defines the legal building blocks of an XML document the document structure The legal elements and attributes A DTD can be defined inside an xml document or outside

Why do we need a DTD? An XML file can carry a description of its own format Independent groups of people can agree to use a standard DTD for interchanging data Applications can use a standard DTD to verify that the data received from the outside world is valid A DTD can be used to verify the data

<!DOCTYPE root-element [element-declarations]> An inside DTD (1) <!DOCTYPE root-element [element-declarations]>

An inside DTD (2)

An inside DTD (3) !DOCTYPE note defines that the root element of this document is note. !ELEMENT note defines that the note element contains four elements: "to,from,heading,body". !ELEMENT to defines the to element  to be of the type "#PCDATA". !ELEMENT from defines the from element to be of the type "#PCDATA". !ELEMENT heading defines the heading element to be of the type "#PCDATA". !ELEMENT body defines the body element to be of the type "#PCDATA".

External DTD <!DOCTYPE root-element SYSTEM "filename"> <!DOCTYPE note SYSTEM "note.dtd">

The building blocks Elements Attributes Entities PCDATA CDATA

Elements Main building block Can contain text, other elements or be empty The elements b, title and br can be used as follows: <b>Hello world</b> <title>Hello <b>Tom</b></title> <br />

<img src="computer.gif" /> Attributes Provide extra information about elements Always placed inside the opening tag Always have a name/value pair Which is the element, attribute and value? <img src="computer.gif" />

Entities Entity References Character < > & & " " &apos; '

CDATA Text that will NOT be parsed by a parser Tags inside the text will NOT be treated as markup and entities will not be expanded

PCDATA Parsed character data Character data is the text found between the start tag and the end tag of an XML element Text that WILL be parsed by a parser The text will be examined by the parser for entities and markup Tags inside the text will be treated as markup and entities will be expanded However, parsed character data should not contain any &, <, or > characters; these need to be represented by the & < and > entities, respectively

<!ELEMENT element-name category> Different Elements <!ELEMENT element-name category>

The Empty Element <!ELEMENT br EMPTY> <br />

Element with PCDATA <!ELEMENT element-name (#PCDATA)> <!ELEMENT from (#PCDATA)>

Element with Any <!ELEMENT element-name ANY> <!ELEMENT note ANY>

Elements with Children <!ELEMENT element-name (child1,child2,...)> <!ELEMENT note (to,from,heading,body)> *Sequence must be respected

Element with one child <!ELEMENT element-name (child-name)> <!ELEMENT note (message)>

Occurrences One or more <!ELEMENT element-name (child-name+)> <!ELEMENT note (message+)> Zero or more <!ELEMENT element-name (child-name*)> <!ELEMENT note (message*)> Zero or One <!ELEMENT element-name (child-name?)> <!ELEMENT note (message?)>

Mixing ... Either or <!ELEMENT note (to,from,header,(message|body))> Mixed content <!ELEMENT note (#PCDATA|to|from|header|message)*>

Declaring Attributes <!ATTLIST element-name attribute-name attribute-type default-value> <!ATTLIST payment type CDATA "check"> <payment type="check" />

Atribute Type Type Description CDATA The value is character data (en1|en2|..) The value must be one from an enumerated list ID The value is a unique id IDREF The value is the id of another element IDREFS The value is a list of other ids NMTOKEN The value is a valid XML name NMTOKENS The value is a list of valid XML names ENTITY The value is an entity ENTITIES The value is a list of entities NOTATION The value is a name of a notation xml: The value is a predefined xml value

Attribute Value Value Explanation value The default value of the attribute #REQUIRED The attribute is required #IMPLIED The attribute is not required #FIXED value The attribute value is fixed

CDATA example <!ATTLIST mountain country CDATA "New Zealand"> <mountains> <mountain country="New Zealand"> <name>Mount Cook</name> </mountain>

Enumerated Example <!ATTLIST tutorial published (yes | no) "no"> <tutorial published="yes"> <name>XML Tutorial</name> </tutorial>

ID example <!ATTLIST mountain mountain_id ID #REQUIRED> <mountain mountain_id="m10001"> <name>Mount Cook</name> </mountain>

ID Ref example <!ATTLIST employee employee_id ID #REQUIRED manager_id IDREF #IMPLIED> <employees> <employee employee_id="e10001" manager_id="e10002"> <first_name>Homer</first_name> <last_name>Flinstone</last_name> </employee> <employee employee_id="e10002"> <first_name>Fred</first_name> <last_name>Burns</last_name> </employees>

ID Refs example <!ATTLIST individual individual_id ID #REQUIRED parent_id IDREFS #IMPLIED> <individual individual_id="e10001" parent_id="e10002 e10003"> <first_name>Bart</first_name> <last_name>Simpson</last_name> </individual>

NMTOKEN example <!ATTLIST tutorial published NMTOKEN #REQUIRED> <mountain country="NZ"> <name>Mount Cook</name> </mountain>

Notation example <!NOTATION name SYSTEM "external_id"> <!NOTATION GIF SYSTEM "image/gif"> <!NOTATION JPG SYSTEM "image/jpeg"> <!NOTATION PNG SYSTEM "image/png"> <!ATTLIST mountain photo ENTITY #IMPLIED photo_type NOTATION (GIF | JPG | PNG) #IMPLIED>

Entity example <!ATTLIST mountain photo ENTITY #IMPLIED> <!ENTITY mt_cook_1 SYSTEM "mt_cook1.jpg"> <mountain photo="mt_cook_1"> <name>Mount Cook</name> </mountain>

More about Entities Entities are variables used to define shortcuts to standard text or special characters Entity references are references to entities Entities can be declared internal or external

Internal Entities <!ENTITY writer “Alexiei Dingli"> <!ENTITY copyright "Copyright Dingli@UOM"> <author>&writer;&copyright;</author>

External Entities <!ENTITY writer SYSTEM "http://www.um.edu.mt/entities.dtd"> <!ENTITY copyright SYSTEM "http://www.um.edu.mt/entities.dtd"> <author>&writer;&copyright;</author>

Example

Exercise Define an XML Vocabulary for a Toaster Markup Language (TML) It must support features such as: Print message on toast Display on LCD Time stamp

Questions?