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.

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.
1 DTD (Document Type Definition) Imposing Structure on XML Documents (W3Schools on DTDs)W3Schools on DTDs.
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.
1 XML DTD & XML Schema Monica Farrow G30
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
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.
Extensible Markup Language XML MIS 520 – Database Theory Fall 2001 (Day) Lecture 14.
 2002 Prentice Hall, Inc. All rights reserved. ISQA 407 XML/WML Winter 2002 Dr. Sergio Davalos.
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:
Unit 4 – XML Schema XML - Level I Basic.
XML Validation I DTDs Robin Burke ECT 360 Winter 2004.
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
XML Anisha K J Jerrin Thomas. Outline  Introduction  Structure of an XML Page  Well-formed & Valid XML Documents  DTD – Elements, Attributes, Entities.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation XML Schema 1 Lecturer.
XML CPSC 315 – Programming Studio Fall 2008 Project 3, Lecture 1.
Document Type Definitions Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
MIS 315 Bsharah An Introduction to XML 1MIS Bsharah.
XML 1 Enterprise Applications CE00465-M XML. 2 Enterprise Applications CE00465-M XML Overview Extensible Mark-up Language (XML) is a meta-language that.
August Chapter 2 - Markup and Core Concepts Learning XML by Erik T. Ray Slides were developed by Jack Davis College of Information Science and Technology.
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.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation eXist Update Lecturer.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation XML Schema 2 Lecturer.
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.
Of 33 lecture 3: xml and xml schema. of 33 XML, RDF, RDF Schema overview XML – simple introduction and XML Schema RDF – basics, language RDF Schema –
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.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Query Data Model Lecturer.
SNU OOPSLA Lab. XML Documents 1 : Structure The ubiquitous XML(2) © copyright 2001 SNU OOPSLA Lab.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Identity Constraints.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation An Introduction to XML.
IS432: Semi-Structured Data Dr. Azeddine Chikh. 4. Document Type Definitions (DTDs)
IS432 Semi-Structured Data Lecture 2: DTD Dr. Gamal Al-Shorbagy.
XML Validation I DTDs Robin Burke ECT 360 Winter 2004.
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
Jeff Ullman: Introduction to XML 1 XML Semistructured Data Extensible Markup Language Document Type Definitions.
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.
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.
Tutorial 13 Validating Documents with Schemas
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Mapping RDB Schema to.
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.
Document Type Definition (DTD) Eugenia Fernandez IUPUI.
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.
Session III Chapter 6 – Creating DTDs
New Perspectives on XML
DTD (Document Type Definition)
Session II Chapter 6 – Creating DTDs
Document Type Definition (DTD)
Presentation transcript:

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 Lecturer : Dr. Pavle Mogin

SWEN 432 Advanced Database Design and Implementation 2015 DTD 1 Plan for the DTD Topic General remarks about the Document Type Definition (DTD) The structure of a DTD Components of a DTD: –Elements, –Attributes, Reading: –Extensible Markup Language (XML) 1.0 W3C Recommendation 04 February –Any book on XML

SWEN 432 Advanced Database Design and Implementation 2015 DTD 2 Motives If we create an XML document that is well formed and send it to a communicating party, she/he will understand it, since XML is self explaining But the communicating party will never be sure whether the information received is complete, whether there is anything missing or incorrect So, if we want to exchange documents with a common: –Structure, –Meaning, and –Constraints we need a language to define languages – a meta language Using a meta language, we develop a new language and share its definition with all communicating parties

SWEN 432 Advanced Database Design and Implementation 2015 DTD 3 Document Type Definition (DTD) Document Type Definition (DTD) is a set of declarations used to define a language (meta language) DTD is an overloaded term –DTD is a meta language –DTD is a particular language (set of rules that language sentences have to obey) A particular DTD is a grammar of a language that indicates: –What elements are allowed, –Constraints on elements allowed, –In what order elements can appear –How the elements can be nested, –What attributes an element may contain, and –Constraints on element and attribute values All not mentioned in a DTD is not allowed in documents that are made according to that DTD

SWEN 432 Advanced Database Design and Implementation 2015 DTD 4 A Valid XML Document A DTD can be included in a file that contains the document it describes, or can be linked from an external file An XML document can also exist without any DTD An XML document is said to be valid if: –A DTD is associated with it, and –It is structured according to the rules set by the DTD A document may be not valid according to a DTD, but still well formed

SWEN 432 Advanced Database Design and Implementation 2015 DTD 5 Document Type Declaration A document type declaration specifies the DTD a document uses The document type declaration appears in a document’s prolog, after the XML declaration but before the root element It contains either a DTD, or the URL of a DTD A document type declaration contains or refers to a DTD An XML declaration and a document type declaration form the prolog of a document

SWEN 432 Advanced Database Design and Implementation 2015 DTD 6 An XML Document with Prolog <!DOCTYPE GREETING[ ]> Hello SWEN 432 people! Components of the prolog are shaded The DTD is:

SWEN 432 Advanced Database Design and Implementation 2015 DTD 7 Syntax of a DT Declaration A DT Declaration The name of a document type declaration has to be the name of the root element –GREETING in our example DTD is a text containing rules of a DTD that is enclosed in [ ] Any document valid with regard to our example DTD must have the root element GREEETING, and this element must be declared in the DTD

SWEN 432 Advanced Database Design and Implementation 2015 DTD 8 Sharing Common DTDs A DTD can be shared among many documents Then: –The DTD is linked into the document from an external source –The document is not standalone any more The syntax of a DT Declaration with an external DTD is: Example: <!DOCTYPE GREETING SYSTEM “ SWEN432/grt.dtd”> SYSTEM is a key word

SWEN 432 Advanced Database Design and Implementation 2015 DTD 9 General Content of a DTD A DTD contains declarations of: –Elements, –Comments –Entities, and –Attributes

SWEN 432 Advanced Database Design and Implementation 2015 DTD 10 Basic Element Types Elements have two basic types in XML: –Simple (also terminal) elements that contain only text, which is also known as parsed character data ( #PCDATA ) and –Compound or complex (also non terminal) elements that contain as their content any of the following: Other elements, Attributes, Other elements and free text, Attributes and free text, Other elements, attributes, and free text

SWEN 432 Advanced Database Design and Implementation 2015 DTD 11 Element Declaration Each tag used in a valid XML document must be declared with an element declaration in a DTD (Content Model )> An element declaration specifies: –A name, –Allowed components of the element’s content, and –Structural constraints of the components (cardinality and participation constraint) A declaration of components and their structural constraints is also called content specification, or content model, or type

SWEN 432 Advanced Database Design and Implementation 2015 DTD 12 Element Content Types Five possible content types: 1.An element (child element), 2.#PCDATA (parsed character data), 3.The special symbol ANY (any content permitted), 4.The special symbol EMPTY (element with no content), and 5.A regular expression constructed from above choices Regular expressions: –exp1, exp2, exp3 : A sequence of regular expressions, –exp* : An expression with zero or more occurrences (Kleene closure), –exp? : An expression with at most one occurrence, –exp+ : An expression with at least one occurrence, –exp1 | exp2 : The element will contain either expression 1 or expression 2 (exclusive or operator, choice)

SWEN 432 Advanced Database Design and Implementation 2015 DTD 13 A Simple XML Document COMP 442 Pavle Ahmed 10 Bad Student

SWEN 432 Advanced Database Design and Implementation 2015 DTD 14 A DTD for The Simple XML Document The preceding XML document is valid with regard to: <!ELEMENT CLASS (TITLE, LECTURER+, AUDITOR?, STUDENT*)> Discuss: –Content models –Child sequences Note, the order of element declarations is immaterial

SWEN 432 Advanced Database Design and Implementation 2015 DTD 15 Choices It is sometimes needed to control the appearance of children with exclusive or like constraints To achieve this the “ | “ operator (union) is used The vertical bar “ | “ operator allows only one of the multiple choices to appear in a valid XML document Example: A regular expression containing choices needs to be deterministic

SWEN 432 Advanced Database Design and Implementation 2015 DTD 16 Non Deterministic Reg_Exp XML processors do not accept non deterministic regular expression –A non deterministic regular expression needs to be transformed into a deterministic one, –SWEN224 (Formal Methods) stuff Loosely speaking, a regular expression is non deterministic if the operands of a union expression start with the same element names Example: –Non deterministic: a | (a, b) –Transformation: a | (a, b) ≡ (a, ε) | (a, b) ≡ a, (ε | b) ≡ a, b? ε is the empty string

SWEN 432 Advanced Database Design and Implementation 2015 DTD 17 Children with Parentheses Grouping children elements within parentheses allows achieving some special constraints All elements in a pair of parenthesis behave as a single element (with the regard to suffix) You to explain: –Example 1: –Example 2: <!ELEMENT DOCUMENT (TITLE, (PARAGRAPH | IMAGE)*, SIGNATURE?)

SWEN 432 Advanced Database Design and Implementation 2015 DTD 18 Mixed Content Content of an XML element can be mixed with child elements and parsed character data One way to achieve this is to use key word ANY The other way is the following construct This is the only construct of mixed element and # PCDATA a DTD can support The best way is: You to comment advantages and disadvantages!

SWEN 432 Advanced Database Design and Implementation 2015 DTD 19 Empty Elements In an XML DTD empty elements are identified by empty element declarations: –EMPTY is the declaration of the element’s type In an XML document, an empty element has only the start tag: –With a compulsory name, –A set of attributes (may be empty), and –A compulsory “/” at the end Example: –DTD: –XML document:

SWEN 432 Advanced Database Design and Implementation 2015 DTD 20 What Is and What Can Contain an Attribute An attribute is a (name, value) pair, where the name component is separated from the value component by an “=“ sign The name should be an XML valid name The following XML concepts may contain an attribute: –A document declaration –A processing instruction –A start tag of an element –An empty element

SWEN 432 Advanced Database Design and Implementation 2015 DTD 21 Declaring Attributes in a DTD The syntax of an attribute declaration in a DTD: Each attribute declaration belongs to exactly one element If two elements have an attribute with the same name, type, and default, this attribute has to be declared twice (each time with a different owner name)

SWEN 432 Advanced Database Design and Implementation 2015 DTD 22 An XML Document with Attributes <!DOCTYPE GREETING[ ]> Hello SWEN 432 people!

SWEN 432 Advanced Database Design and Implementation 2015 DTD 23 Attribute Types TypeMeaning CDATA Character data – text that is not markup Enumerated A list of possible values from which exactly one will be chosen ID Unique values not shared by any other ID type attribute in the document IDREF The value of an ID type attribute of an element in the document IDREFS Multiple element IDs separated by whitespace There are also other attribute types, but we do not consider them

SWEN 432 Advanced Database Design and Implementation 2015 DTD 24 Default Values An attribute default value can be either: –A specific string value, or –One of the key words: #REQUIRED, #IMPLIED (default), or #FIXED (constant value) #REQUIRED means that an attribute value is mandatory #IMPLIED means that an attribute (and it’s value) is optional #FIXED means that the attribute has a fixed (constant) value –If a #FIXED attribute is not included in a document, an XML processor will do it by including the attribute and its default value

SWEN 432 Advanced Database Design and Implementation 2015 DTD 25 Enumerated Attribute Type A list of possible values separated by vertical bars Each value must be a valid XML name The default value must be one of the enumerated values An example:

SWEN 432 Advanced Database Design and Implementation 2015 DTD 26 ID Attribute Type An ID type attribute value uniquely identifies an element within a document An element can have at most one attribute of the type ID Attributes of the type ID are usually used in conjunction with attributes of the IDREF type

SWEN 432 Advanced Database Design and Implementation 2015 DTD 27 IDREF and IDREFS Attribute Types An attribute value of the type IDREF is the ID value of an element in the same document ID and IDREF attribute types are used to connect elements that can not be connected through the tree structure of the document For example, when a child element has more parent elements An attribute of the IDREFS type serves practically the same purpose as an attribute of the IDREF type, except IDREFS means that the attribute is multivalued

SWEN 432 Advanced Database Design and Implementation 2015 DTD 28 Example of Using ID and IDREF <!DOCTYPE FAMILY [ ]> (to be continued)

SWEN 432 Advanced Database Design and Implementation 2015 DTD 29 Example of Using ID and IDREF (cont) Susan Jack Annie Kirk

SWEN 432 Advanced Database Design and Implementation 2015 DTD 30 Recursions A recursion on an element E is expressed by placing: –An element E* into element’s E content model, or –In the content model of its descendant and using attributes of the ID and IDREF types (if needed) By placing E* into content model of E (directly, or via one of its descendants) we enable the element E to appear a large number of times in a document The attributes of the ID and IDREF types are needed only if there is a N:N relationship between E elements having different roles

SWEN 432 Advanced Database Design and Implementation 2015 DTD 31 Summary An XML document structure may be defined using: –Document Type Definition, or –XML Schema definition language By defining a DTD schema a new language is introduced The most important components of a DTD are: –Element declarations, and –Attribute declarations The declaration of an element consist of: –An element name, and –An element content model (type), enclosed in parenthesis The declaration of an attribute consists of: –The owner’s name, and –A triple (att_name, att_type, att_default)