Lecture 6 XML DTD Content of.xml fileContent of.dtd file.

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.
Introduction to XML: DTD
XML Study-Session: Part II Validating XML Documents.
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
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
Introduction to XLink Transparency No. 1 XML Information Set W3C Recommendation 24 October 2001 (1stEdition) 4 February 2004 (2ndEdition) Cheng-Chia Chen.
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
COS 381 Day 14. Agenda Questions?? Resources Source Code Available for examples in Text Book in Blackboard
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
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.
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.
XML eXtensible Markup Language by Darrell Payne. Experience Logicon / Sterling Federal C, C++, JavaScript/Jscript, Shell Script, Perl XML Training XML.
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.
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 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.
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.
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)
XML Documents Chao-Hsien Chu, Ph.D. School of Information Sciences and Technology The Pennsylvania State University Elements Attributes Comments PI Document.
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
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.
CSE3201 Information Retrieval Systems DTD Document Type Definition.
Sheet 1XML Technology in E-Commerce 2001Lecture 2 XML Technology in E-Commerce Lecture 2 Logical and Physical Structure, Validity, DTD, XML Schema.
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.
When we create.rtf document apart from saving the actual info the tool saves additional info like start of a paragraph, bold, size of the font.. Etc. This.
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.
XML CORE CSC1310 Fall XML DOCUMENT XML document XML document is a convenient way for parsers to archive data. In other words, it is a way to describe.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
DTDs© Aptech Limited DTDs 03. DTDs© Aptech LimitedDTDs© Aptech Limited Document Type Definition  In this first lesson, Document Type Definition, you.
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.
Unit 4 Representing Web Data: XML
Document Type Definition DTDs
Session III Chapter 6 – Creating DTDs
Chapter 7 Representing Web Data: XML
New Perspectives on XML
Session II Chapter 6 – Creating DTDs
Presentation transcript:

Lecture 6 XML DTD Content of.xml fileContent of.dtd file

What is DTD? DTD (Document Type Definition) define an XML document’s structure. DTD (Document Type Definition) define an XML document’s structure. A typical DTD defines what elements can appear in an XML document, how they can be nested and what attributes the elements have. A typical DTD defines what elements can appear in an XML document, how they can be nested and what attributes the elements have. When creating an XML document we can specify which DTD it conforms to. When creating an XML document we can specify which DTD it conforms to. DTDs are written using the Extended Backus- Naur Form. DTDs are written using the Extended Backus- Naur Form. DTDs can be locally or publicly stored. Examples of public DTDs are the XHTML’s DTDs. DTDs can be locally or publicly stored. Examples of public DTDs are the XHTML’s DTDs.

.dtd.xml.xsd DTD Schema or.xml DOM API Software System SAX API.css.xsl.fo Stylesheet DTD in the Context of an XML Project

Document Type Declaration <!DOCTYPE myMessage [ ]> Internal subset External subset <!DOCTYPE myMessage SYSTEM "myDTD.dtd" [ ]> Mixed DTD is DOCTYPE’s Internal Subset + External Subset Alternatives

Document Type Declaration (full example) Hello World! example.xml message.dtd root element

Sequences, Pipe Characters and Occurrence Indicators Pablo Honey You 3:27 Creep 3:55

Sequences, Pipe Characters and Occurrence Indicators (contd.) XML: How to Program Multimedia Peter O’Connor

Sequences, Pipe Characters and Occurrence Indicators (contd.) <!ELEMENT donutBox ( jelly?, lemon*, ( ( crème | sugar)+ | glazed ) )> grape half-sour sour chocolate semi-sweet whipped sweet

Occurrence Indicators (summary) A* A may occur zero, one or more times A* A may occur zero, one or more times A+ A may occur one or more times (but must occur at least once) A+ A may occur one or more times (but must occur at least once) A? A must either not occur or occur once A? A must either not occur or occur once

EMPTY, Mixed Content and ANY ANY is used in early stages of developing DTDs. Here is some text, some other text and even more text

Attribute Declarations Element x has an attribute y of type CDATA whose value must be provided. Attribute types: 1.CDATA – string that can contain any character text except & ' and " 2.Tokenized attribute types: ID, IDREF, ENTITY, NMTOKEN 3.Enumerated attribute types: NOTATION

Well-formed and Valid XML Documents An XML document is well-formed if it is syntactically correct, i.e. An XML document is well-formed if it is syntactically correct, i.e. 1.There is a single root element. 2.Each element has a start and an end tag. 3.Elements are nested properly. 4.Attribute values are in quotes. An XML Document is Valid if it conforms to the DTD specified with the DOCTYPE declaration An XML Document is Valid if it conforms to the DTD specified with the DOCTYPE declaration Any element, attribute and entity used in the XML document must be defined in the DTD;Any element, attribute and entity used in the XML document must be defined in the DTD; Each element’s content and attributes must correspond to the declarations in the DTDEach element’s content and attributes must correspond to the declarations in the DTD An XML document can be well-formed but NOT valid! An XML document can be well-formed but NOT valid!

XML Processor Also called XML Parser Also called XML Parser A software program required to process an XML document A software program required to process an XML document Checks syntaxChecks syntax A validating XML processors checks whether an XML document conforms to the specified DTDA validating XML processors checks whether an XML document conforms to the specified DTD Reports any errorsReports any errors Required to pass all characters in a document, including white space characters, to the application using the XML documentRequired to pass all characters in a document, including white space characters, to the application using the XML document A validating XML processor must also inform the application which characters constitute white space appearing in element contentA validating XML processor must also inform the application which characters constitute white space appearing in element content

Parameter Entities Internal (parsed) Internal (parsed) Used to declare entities existing only in the DTDUsed to declare entities existing only in the DTD Entity value can be a string of characters that contains:Entity value can be a string of characters that contains: any character that is not &, %, ", ', any character that is not &, %, ", ', parameter entity reference %Name; parameter entity reference %Name; general entity reference &Name; (to be explained shortly) general entity reference &Name; (to be explained shortly) Unicode character reference, e.g., A O Unicode character reference, e.g., A O External (parsed) External (parsed) Used to link to external DTDsUsed to link to external DTDs Can be private or publicCan be private or public URI – Uniform Resource Identifier (more generic than URL)

Parameter Entities (examples) %student;

General Entities Internal (parsed) Internal (parsed) Can be thought of text macrosCan be thought of text macros Entity value can be a string of characters;Entity value can be a string of characters; any character that is not &, %, ", ', any character that is not &, %, ", ', parameter entity reference %Name; parameter entity reference %Name; general entity reference &Name; general entity reference &Name; Unicode character reference, e.g., A O Unicode character reference, e.g., A O ? <!DOCTYPE author [ ]> &js;

General Entities (contd.) External (parsed) External (parsed) Generally reference text that an XML parser has to parse.Generally reference text that an XML parser has to parse. Useful for creating a common reference shared between multiple documents.Useful for creating a common reference shared between multiple documents. Any changes made to external entities are automatically updated in documents they are referenced.Any changes made to external entities are automatically updated in documents they are referenced. Can be private or publicCan be private or public <!ENTITY pc PUBLIC "-//W3C//TEXT copyright//EN" " &c; &pc;

General Entities (contd.) External NDATA entities (unparsed) External NDATA entities (unparsed) Generally reference to non-XML data.Generally reference to non-XML data. Refer to data that an XML processor does not have to parseRefer to data that an XML processor does not have to parse <!ENTITY plogo PUBLIC "-//W3C//GIF logo//EN" " NDATA gif> NOTATIONS are used to identify the format of unparsed entities (non-XML data), elements with a notation attribute, or specific processing instructions.

Predefined General Entities There are 5 predefined entities There are 5 predefined entities < << < > >> > & && & " "" " &apos; '&apos; ' Every character can also be represented as character entity (UNICODE value) Every character can also be represented as character entity (UNICODE value) e.g., ¶ or 꽌e.g., ¶ or 꽌

Attribute Declarations Attributes are defined for the elements they belong to or <!ATTLIST test subject CDATA #REQUIRED difficulty CDATA #IMPLIED >

Attribute Types CDATA CDATA character data, that is, text that does not form markup (no " ' & %)character data, that is, text that does not form markup (no " ' & %) Tokenized attribute types Tokenized attribute types ID, IDREF, IDREFS, ENTITY, ENTITIES, NMTOKEN, NMTOKENSID, IDREF, IDREFS, ENTITY, ENTITIES, NMTOKEN, NMTOKENS Enumerated types Enumerated types NOTATION, EnumeratedNOTATION, Enumerated

Attribute Types (contd.) Tokenized attribute types Tokenized attribute types IDID IDs of a particular value should not appear more than once in an XML document IDs of a particular value should not appear more than once in an XML document An element type may only have one ID attribute An element type may only have one ID attribute An ID attribute can only have an #IMPLIED or #REQUIRED default value An ID attribute can only have an #IMPLIED or #REQUIRED default value The first character of an ID value must be a letter, _, or : The first character of an ID value must be a letter, _, or : IDREFIDREF must refer to an ID value declared elsewhere in the document must refer to an ID value declared elsewhere in the document IDREFSIDREFS Allows multiple ID values separated by whitespace Allows multiple ID values separated by whitespace

Attribute Types (contd.) Tokenized attribute types (more…) Tokenized attribute types (more…) ENTITYENTITY Reference to a general entity Reference to a general entity ENTITIESENTITIES Allows multiple entity names separated by white space Allows multiple entity names separated by white space NMTOKENNMTOKEN Name according to the XML specification; The first character must be a letter, digit,., -, _, or : Name according to the XML specification; The first character must be a letter, digit,., -, _, or : NMTOKENSNMTOKENS Allows multiple NMTOKEN names separated by white space Allows multiple NMTOKEN names separated by white space

Attribute Types (contd.)... Example 1

Attribute Types (contd.) Example 2

Attribute Types (contd.) Enumerated attribute types Enumerated attribute types NOTATIONNOTATION useful when text needs to be interpreted in a particular way, for example, by another application. The first character must be a letter, _, or : useful when text needs to be interpreted in a particular way, for example, by another application. The first character must be a letter, _, or : EnumeratedEnumerated Enumerated attribute types allow you to make a choice between different attribute values. The first character of an Enumerated value must be a letter, digit,., -, _, or : Enumerated attribute types allow you to make a choice between different attribute values. The first character of an Enumerated value must be a letter, digit,., -, _, or :

Attribute Types (contd.) <!DOCTYPE code [ ]> Some VRML instructions Example 3

Attribute Types (contd.) <!DOCTYPE ToDoList [ ]> This is an important task that must be completed This task can wait Example 4

Attribute Default Values #REQUIRED #REQUIRED Such an attribute must be suppliedSuch an attribute must be supplied #IMPLIED #IMPLIED Such an attribute may be suppliedSuch an attribute may be supplied #FIXED #FIXED Such an attribute has a fixed value (even if it is NOT supplied)Such an attribute has a fixed value (even if it is NOT supplied)

Attribute Default Values (contd.) <!DOCTYPE ToDoList [ ]> This is an important task. This is by default a task with a normal status.

Declarations in DTD