1/19 ITApplications XML Module Session 4: Document Type Definition (DTD) Part 2.

Slides:



Advertisements
Similar presentations
Validation checking and testing that your web pages function as intended.
Advertisements

XML-XSL Introduction SHIJU RAJAN SHIJU RAJAN Outline Brief Overview Brief Overview What is XML? What is XML? Well Formed XML Well Formed XML Tag Name.
BeKnown How-to: Company Profiles & Jobs App for Timeline.
1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 2 Getting Started.
Copyright © 2003 Pearson Education, Inc. Slide 1-1 The Web Wizards Guide to PHP by David A. Lash.
Copyright © 2003 Pearson Education, Inc. Slide 7-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide.
Copyright © 2003 Pearson Education, Inc. Slide 8-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide.
Copyright © 2003 Pearson Education, Inc. Slide 6-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide.
1 Advanced with GMail A CYC Electives Module
Publishing Process An attempt -- GWB.
Web Page Concept and Design :
© Telcordia Technologies 2004 – All Rights Reserved AETG Web Service Tutorial AETG is a service mark of Telcordia Technologies. Telcordia Technologies.
1 WSDL: Web Service Description Language Gary Sharp Mike Breakiron.
XML Schema Heewon Lee. Contents 1. Introduction 2. Concepts 3. Example 4. Conclusion.
Using XML for Legends and Map Surround DIGITAL MAPPING TECHNIQUES 2005 By Vic Dohar Natural Resources Canada.
University of Sheffield NLP Exercise I Objective: Implement a ML component based on SVM to identify the following concepts in company profiles: company.
Blackboard Vista / CE Faculty Instructions How to protect an assessment with Identify-X Pre-requisites: - Knowledge of how to create Assessments in Blackboard.
Getting Familiar with Web Pages 1 2 The Internet Worldwide collection of interconnected computer networks that enables businesses, organizations, governments,
XML Craig Stewart Dr. Alexandra I. Cristea
1 Web Services Based partially on Sun Java Tutorial at Also, XML, Java and the Future of The Web, Jon Bosak. And WSDL.
Plagiarism Awareness Online Content, Quiz & Declaration Briefing slides for lecturers on launching Plagiarism Package in their modules Credits: Workflow.
ISO DSDL ISO – Document Schema Definition Languages (DSDL) Martin Bryan Convenor, JTC1/SC18 WG1.
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.
1 XML DTD & XML Schema Monica Farrow G30
3 November 2008CIS 340 # 1 Topics To define XML as a technology To place XML in the context of system architectures.
CS 898N – Advanced World Wide Web Technologies Lecture 21: XML Chin-Chih Chang
XML e X tensible M arkup L anguage 1/23.
XML Introduction What is XML –XML is the eXtensible Markup Language –Became a W3C Recommendation in 1998 –Tag-based syntax, like HTML –You get to make.
Document Type Definitions. XML and DTDs A DTD (Document Type Definition) describes the structure of one or more XML documents. Specifically, a DTD describes:
Jennifer Widom XML Data XML Schema. Jennifer Widom XML Schema “Valid” XML Adheres to basic structural requirements  Also adheres to content-specific.
Jennifer Widom XML Data DTDs, IDs & IDREFs. Jennifer Widom DTDs, IDs & IDREFs “Well-Formed” XML Adheres to basic structural requirements Single root element.
Introduction to XML This material is based heavily on the tutorial by the same name at
Introduction to XML: Part I By Sandeep Jangity CS 157B, Section 2 Dr. Lee.
Chapter 12 Creating and Using XML Documents HTML5 AND CSS Seventh Edition.
WORKING WITH NAMESPACES
XP New Perspectives on XML Tutorial 3 1 DTD Tutorial – Carey ISBN
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.
Neminath Simmachandran
Introducing Dreamweaver MX 2004
Tutorial 1 Getting Started with Adobe Dreamweaver CS3
1/14 ITApplications XML Module Session 2: Using and Creating XML Documents.
Introduction to XML. XML - Connectivity is Key Need for customized page layout – e.g. filter to display only recent data Downloadable product comparisons.
CP2022 Multimedia Internet Communication1 HTML and Hypertext The workings of the web Lecture 7.
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.
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.
Tutorial 1: XML Creating an XML Document. 2 Introducing XML XML stands for Extensible Markup Language. A markup language specifies the structure and content.
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.
How to use Microsoft Word. Where can I find Microsoft Word? How to select, copy and paste information Go to the document from which you wish to copy the.
Copyrighted material John Tullis 10/17/2015 page 1 04/15/00 XML Part 3 John Tullis DePaul Instructor
XML 2nd EDITION Tutorial 1 Creating An Xml Document.
CIS 451: XML DTDs Dr. Ralph D. Westfall February, 2009.
XP 1 New Perspectives on XML Binding XML Data with Internet Explorer.
XP New Perspectives on XML, 2nd Edition Tutorial 2 1 TUTORIAL 2 WORKING WITH NAMESPACES.
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.
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.
1 Tutorial 11 Creating an XML Document Developing a Document for a Cooking Web Site.
1 Tutorial 12 Working with Namespaces Combining XML Vocabularies in a Compound Document.
HTML BTEC National in Computing Section5. Create Information “HTML: defining HTML, discussing HTML uses and demonstrating HTML basics, HTML structure…..
XML A Language Presentation. Outline 1. Introduction 2. XML 2.1 Background 2.2 Structure 2.3 Advantages 3. Related Technologies 3.1 DTD 3.2 Schemas and.
XML Validation. a simple element containing text attribute; attributes provide additional information about an element and consist of a name value pair;
Week-9 (Lecture-1) XML DTD (Data Type Document): An XML document with correct syntax is called "Well Formed". An XML document validated against a DTD is.
4 Copyright © 2004, Oracle. All rights reserved. Validating XML by Using XML Schema.
Tutorial 1 Getting Started with Adobe Dreamweaver CS5.
Chapter 9 Web Services: JAX-RPC, WSDL, XML Schema, and SOAP
XML Data DTDs, IDs & IDREFs.
Presentation transcript:

1/19 ITApplications XML Module Session 4: Document Type Definition (DTD) Part 2

2/19 Entities General Entities General Entities Can specify abbreviations, short-cuts or aliases Can specify abbreviations, short-cuts or aliases &defaultTitle; &defaultTitle; &currency;34,000,000 Example DTD &currency;34,000,000 Example DTD Example XML Example XML The Company Name is: &companyname; The Company Name is: &companyname;

3/19 Example of the output using Microsoft Internet Explorer Try it !

4/19 Parameter Entities Parameter Entities Short cut for repeating syntax within a DTD Short cut for repeating syntax within a DTD Example of an Employee DTD: Filename: Employee.dtd Filename: Employee.dtd Let’s now create an in-line DTD that uses the above DTD as a parameter entity.

5/19 <!DOCTYPE payroll [ %employeedtd; ]><payroll><employee><firstname>Mark</firstname><surname>Collins</surname></employee><salary>£35,000.00</salary><mailingaddress><employee><firstname>Mark</firstname><surname>Collins</surname></employee> 34, Narrow Lane, SE3 6DY, London 34, Narrow Lane, SE3 6DY, London </mailingaddress></payroll> Filename: Payroll.xml Filename: Payroll.xml

6/19 To link an XML document to a DTD To link an XML document to a DTD It can be embedded (as in the previous slide). It can be embedded (as in the previous slide). Or the XML document can specify the DTD location as in the example below: Or the XML document can specify the DTD location as in the example below: The location is usually a URL, local or another domain, such as the following example: The location is usually a URL, local or another domain, such as the following example: Note: You will remember using this declaration in the Internet Communications module when writing your html pages!

7/19 Validating a DTD A DTD is used to validate an XML document but DTDs themselves can be validated. A DTD is used to validate an XML document but DTDs themselves can be validated. You can validate a DTD by using third-party validation tools such XMLSpy. XMLSpy is an XML editor that has built-in features for validating DTDs and is widely used in the industry. You can download a free copy of XMLSpy Home Edition from the following links: You can validate a DTD by using third-party validation tools such XMLSpy. XMLSpy is an XML editor that has built-in features for validating DTDs and is widely used in the industry. You can download a free copy of XMLSpy Home Edition from the following links:

8/19 Validating a DTD example Let’s open the following DTD in XMLSpy: Let’s open the following DTD in XMLSpy: Filename: DTDErrorEmployeeExample.dtd Filename: DTDErrorEmployeeExample.dtd Can you spot the error?

9/19 Open the DTD in the previous example with XMLSpy as illustrated below: Open the DTD in the previous example with XMLSpy as illustrated below:

10/19 Click on the green tick button in order to validate the DTD and the following screen should appear: Click on the green tick button in order to validate the DTD and the following screen should appear: Note that XMLSpy first checks that the file is well-formed and then performs the validation check. Note that XMLSpy first checks that the file is well-formed and then performs the validation check.

11/19 Rectify the error in the DTD and click on the Recheck tick button and you should see the following screen: Rectify the error in the DTD and click on the Recheck tick button and you should see the following screen: You can now use your DTD in order to validate your XML file.

12/19 Limitations of DTD’s: Limitations of DTD’s: Weakly-typed data. Weakly-typed data. The values of the data contained in elements can be anything. Hence, the application has to validate the data. The values of the data contained in elements can be anything. Hence, the application has to validate the data. A DTD does not make clear what is the root element of the associated XML. The root element is only specified in XML document A DTD does not make clear what is the root element of the associated XML. The root element is only specified in XML document DTD’s are written in a different syntax than XML and thus can not be parsed with an XML parser. DTD’s are written in a different syntax than XML and thus can not be parsed with an XML parser. All declarations in a DTD are global which means that two elements with the same name can not be defined in different contexts. This presents integration problems when using several different third-party DTDs. All declarations in a DTD are global which means that two elements with the same name can not be defined in different contexts. This presents integration problems when using several different third-party DTDs.

13/19 XML Schemas an XML based alternative to DTDs Brief overview of xml schemas: XML Schemas was developed by the W3C and attempts to address the limitations of DTDs. Brief overview of xml schemas: XML Schemas was developed by the W3C and attempts to address the limitations of DTDs. XML Schemas are written in XML. XML Schemas are written in XML. You can define global and local elements. You can define global and local elements. XML Schemas have data types such as: string, integer, decimal (with precision), boolean, date, etc… XML Schemas have data types such as: string, integer, decimal (with precision), boolean, date, etc…

14/19 Let’s illustrate schemas by using an example that compares a DTD and an XML Schema Definition (XSD): Let’s illustrate schemas by using an example that compares a DTD and an XML Schema Definition (XSD): Sample DTD: Filename: Employee.dtd Filename: Employee.dtd Equivalent XML schema sample: <xs:schema xmlns:xs=" Filename: Employee.xsd

15/19 XML Namespaces Reasons for using namespaces: Reasons for using namespaces: Distinguish between elements and attributes from different applications with the same name. Distinguish between elements and attributes from different applications with the same name. Group all related elements and attributes from one application to recognise them easier. Group all related elements and attributes from one application to recognise them easier. Distinguish between elements and attributes from different applications with the same name. Distinguish between elements and attributes from different applications with the same name. Group all related elements and attributes from one application to recognise them easier. Group all related elements and attributes from one application to recognise them easier. One of the main feature of XML is to combine markup from various XML applications. Hence, XML Namespaces make it easier for software to understand the nature of the markup been used. One of the main feature of XML is to combine markup from various XML applications. Hence, XML Namespaces make it easier for software to understand the nature of the markup been used.

16/19 XML Namespace Example: XML Namespace Example: <p><html:p> This is content and so is this. </html:p></p></body></root> Filename: NamespaceExample.xml Filename: NamespaceExample.xml In the above example, the default namespace is declared in the root element and applies to the whole XML document. However, the body declares another namespace with a prefix (html) which can be used throughout the document to indicate that individual elements belong to the html namespace. Notice the presence of two paragraph elements: and.

17/19 Points to consider when creating a namespace: Points to consider when creating a namespace: Namespaces do not refer to an exact location. Namespaces do not refer to an exact location. Designate a unique URI that determines the scope of the markup. Designate a unique URI that determines the scope of the markup. Example: Specify a namespace reference in the parent node of the markup or root node of the XML document. Specify a namespace reference in the parent node of the markup or root node of the XML document.

18/19 Declare a prefix to use for relevant markup elements. Declare a prefix to use for relevant markup elements. Add the prefix to element names to ensure the distinction between elements used in different contexts. Add the prefix to element names to ensure the distinction between elements used in different contexts. Be aware that a prefix can not start with x, m, and l (xml) in that order, in upper or lowercase. Be aware that a prefix can not start with x, m, and l (xml) in that order, in upper or lowercase. The XML processor considers elements without a prefix to belong to the default namespace if there is one. The XML processor considers elements without a prefix to belong to the default namespace if there is one. You can add version information to your namespace. Example: You can add version information to your namespace. Example:

19/19 Some namespace URI’s are standard, and may be recognised by some browsers Example: Some namespace URI’s are standard, and may be recognised by some browsers Example: Some prefixes are used by convention Example: Some prefixes are used by convention Example: xmlns:html= " " xmlns:svg= " " xmlns:xsl= " " xmlns:xsd= " " However, prefixes can be user-defined. Hence, you can change it but make sure it is meaningful to both a human reader and an XML parser.