Avoid using attributes? Some of the problems using attributes: Attributes cannot contain multiple values (child elements can) Attributes are not easily.

Slides:



Advertisements
Similar presentations
CSCI N241: Fundamentals of Web Design Copyright ©2004 Department of Computer & Information Science Introducing XHTML: Module B: HTML to XHTML.
Advertisements

An Introduction to XML Based on the W3C XML Recommendations.
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.
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.
3 November 2008CIS 340 # 1 Topics To define XML as a technology To place XML in the context of system architectures.
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
Document Type Definitions
 2002 Prentice Hall, Inc. All rights reserved. ISQA 407 XML/WML Winter 2002 Dr. Sergio Davalos.
Document Type Definitions. XML and DTDs A DTD (Document Type Definition) describes the structure of one or more XML documents. Specifically, a DTD describes:
Introducing XHTML: Module B: HTML to XHTML. Goals Understand how XHTML evolved as a language for Web delivery Understand the importance of DTDs Understand.
Copyright © 2003 Pearson Education, Inc. Slide 2-1 Created by Cheryl M. Hughes, Harvard University Extension School — Cambridge, MA The Web Wizard’s Guide.
XP New Perspectives on XML Tutorial 4 1 XML Schema Tutorial – Carey ISBN Working with Namespaces and Schemas.
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.
Introduction to XML cs3505. References –I got most of this presentation from this site –O’reilly tutorials.
Why XML ? Problems with HTML HTML design - HTML is intended for presentation of information as Web pages. - HTML contains a fixed set of markup tags. This.
XML CPSC 315 – Programming Studio Fall 2008 Project 3, Lecture 1.
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
1/14 ITApplications XML Module Session 2: Using and Creating XML Documents.
Document Type Definitions Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Introduction to XML 1. XML XML started out as a standard data exchange format for the Web Yet, it has quickly become the fundamental instrument in the.
1 © Netskills Quality Internet Training, University of Newcastle Introducing XML © Netskills, Quality Internet Training University.
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 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.
Example Write the DTD rules for the following XML fragment. Kim 34 South Street NY USA Vice President $175,000 1.
 XML is designed to describe data and to focus on what data is. HTML is designed to display data and to focus on how data looks.  XML is created to structure,
Session IV Chapter 9 – XML Schemas
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
1 Tutorial 13 Validating Documents with DTDs Working with Document Type Definitions.
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 –
CIS 451: XML DTDs Dr. Ralph D. Westfall February, 2009.
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.
XP 1 Creating an XML Document Developing an XML Document for the Jazz Warehouse XML Tutorial.
17 Apr 2002 XML Syntax: Documents Andy Clark. Basic Document Structure Element tags – Elements have associated attributes Text content Miscellaneous –
Lecture 16 Introduction to XML Boriana Koleva Room: C54
1 Introduction to XML XML stands for Extensible Markup Language. Because it is extensible, XML has been used to create a wide variety of different markup.
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.
An Introduction to XML Paul Donohue May 8th 2002 Hotel Senator Zürich.
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.
Tutorial 13 Validating Documents with Schemas
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.
Well Formed XML The basics. A Simple XML Document Smith Alice.
XML CSC1310 Fall HTML (TIM BERNERS-LEE) HyperText Markup Language  HTML (HyperText Markup Language): December  Markup  Markup is a symbol.
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.
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.
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.
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.
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:

Avoid using attributes? Some of the problems using attributes: Attributes cannot contain multiple values (child elements can) Attributes are not easily expandable (for future changes) Attributes cannot describe structures (child elements can) Attributes are more difficult to manipulate by program code 1

Covert the following XML code into XML code without attributes Mathew XML Guide

Comments in XML Syntax for writing comments in XML is similar to that of HTML. 3

XML File Declaration An XML document can begin with an optional XML declaration which precedes the root element. It identifies:  The document as an XML document.  Version of XML used.  Character encoding and external dependencies. Mathew XML Guide

XML Trees 5

XML Tree The elements in an XML document form a document tree. Draw the tree for the given XML document Mathew XML Guide

Its XML Tree Root Element catalog Attribute id="bk101" Element book Element title Text Attribute currency = “US$” Element author Text Matthew Text XML Guide Element price 7

Draw the tree for the following XML Document Kim 34 South Street NY USA Vice President 175,000 8

XML Validation & Well-formedness 9

Well-formed and valid XML documents There are two levels of correctness of an XML document:  Well-formed. A well-formed XML document conforms to all of XML's syntax rules.  Valid. A valid document additionally conforms to some rules relating to the structure of the XML document. These rules are user-defined through DTDs or XML schemas.. 10

Well-Formed XML Documents A well-formed XML document is a document that conforms to the XML syntax rules. The syntax rules were described in the slides:  must begin with the XML declaration  must have one unique root element  all start tags must match end-tags  XML tags are case sensitive  all elements must be closed  all elements must be properly nested  all attribute values must be quoted An XML parser (i.e., browser) will not open an XML document if it is NOT well-formed.  Browser will report the error. 11

Valid XML Documents In XML, an optional Document Type Definition (DTD) or schema can be used to define the XML document’s structure. DTD typically specify additional rules on elements and attributes of an XML document. For example, an element named ‘student' contains 2 elements: ‘name’, ‘id' and 'day‘. Each is only character data. An XML document is considered valid if  It conforms to a DTD (i.e., has the appropriate structure)  It is well-formed (it’s syntax is correct). Well-tested tools exist that parses XML documents and validates them "against" a DTD. 12

Document Type Definition (DTD) 13

Why use DTD/Schemas? XML documents can have many different structures, and for this reason an application cannot be certain whether a particular document it receives is complete, ordered properly, and not missing data. DTDs and schemas solve this problem by providing an extensible way to describe XML document structure. Applications use DTDs or schemas to confirm whether XML documents are valid. 14

DTD The main purpose of the DTD is to define the structure of XML elements A DTD defines:  The name of the elements,  The type of content of each element,  How often and in which order elements may appear,  The name of attributes and their default values, 15

DTD – Declaring Elements In a DTD, XML elements are declared with an element declaration with the following syntax: element-content field is used to specify:  Value of an element (string, any, empty)  Name of other children elements. 16

DTD – Declaring Elements Values Elements containing string values are declared with #PCDATA (Parsed Character DATA) inside parentheses. …  Elements declared with the category keyword ANY can contain any combination of data. ….  Empty elements are declared with the category keyword EMPTY.  17

DTD – Declaring Elements with Children Elements with children are declared with the name of the children elements inside parentheses Ali ISC Children are declared in a sequence separated by commas. The children must appear in the same sequence in the document. 18

DTD – Declaring Elements with Children The children must also be declared, and the children can also have children. The full declaration of the “student" element is: Ali ISC 19

DTD – Declaring Occurrence of Elements A number of operators can be used to control the occurrence of children elements: Consider the following XML element … Declaring only one occurrence of a child element If we require that each client must have only one phone number then, the rule for client is 20

DTD – Declaring Occurrence of Elements Declaring at least one occurrence of an element If we require that each client must have at least one phone number then, the rule for client is Declaring zero or more occurrences of an element If we require that each client can have zero or more phone numbers then, the rule for client is 21

DTD – Declaring Occurrence of Elements Declaring Zero or One Occurrences of an Element If we require that each client can optionally have a phone number then, the rule for client is Declaring either/or Content If we require that each client must have either a phone number or an address then, the rule for client is 22

Example Write the DTD rules for the following XML fragment. Kim 34 South Street NY USA Vice President $175,000 23

Example The rules must satisfy the following constraints: Each employee must have a single name. An employee must have at least one address. For the address, specifying the street is optional. The address must include the state and country information. The address can also include a phone number element. Each employee can specify zero or more phone numbers. Each employee must have a job title and a salary. 24

25 Root Element PARTS_LIST Attribute type=“pc" Element PART Element title Text motherboard Element PART Text Computer Parts Element |ITEM Element COMPANY Element model Element COST Element ITEM Element COMPANY Element COST Text ASUS Text P3B-F Text Text Video Card Text ATI Text