Logo

Navigation
  • Home
  • Services
    • ERP Solutions
    • Implementation Solutions
    • Support and Maintenance Solutions
    • Custom Solutions
    • Upgrade Solutions
    • Training and Mentoring
    • Web Solutions
    • Production Support
    • Architecture Designing
    • Independent Validation and Testing Services
    • Infrastructure Management
  • Expertise
    • Microsoft Development Expertise
    • Mobile Development
    • SQL Server Database and BI
    • SAP BI, SAP Hana, SAP BO
    • Oracle and BI
    • Oracle RAC
  • Technical Training
    • Learn Data Management
      • Business Intelligence
      • Data Mining
      • Data Modeling
      • Data Warehousing
      • Disaster Recovery
    • Learn Concepts
      • Application Development
      • Client Server
      • Cloud Computing Tutorials
      • Cluster Computing
      • CRM Tutorial
      • EDI Tutorials
      • ERP Tutorials
      • NLP
      • OOPS
      • Concepts
      • SOA Tutorial
      • Supply Chain
      • Technology Trends
      • UML
      • Virtualization
      • Web 2.0
    • Learn Java
      • JavaScript Tutorial
      • JSP Tutorials
      • J2EE
    • Learn Microsoft
      • MSAS
      • ASP.NET
      • ASP.NET 2.0
      • C Sharp
      • MS Project Training
      • Silverlight
      • SQL Server 2005
      • VB.NET 2005
    • Learn Networking
      • Networking
      • Wireless
    • Learn Oracle
      • Oracle 10g
      • PL/SQL
      • Oracle 11g Tutorials
      • Oracle 9i
      • Oracle Apps
    • Learn Programming
      • Ajax Tutorial
      • C Language
      • C++ Tutorials
      • CSS Tutorial
      • CSS3 Tutorial
      • JavaScript Tutorial
      • jQuery Tutorial
      • MainFrame
      • PHP Tutorial
      • VBScript Tutorial
      • XML Tutorial
    • Learn Software Testing
      • Software Testing Types
      • SQA
      • Testing
  • Career Training
    • Career Improvement
      • Career Articles
      • Certification Articles
      • Conflict Management
      • Core Skills
      • Decision Making
      • Entrepreneurship
      • Goal Setting
      • Life Skills
      • Performance Development
      • Personal Excellence
      • Personality Development
      • Problem Solving
      • Relationship Management
      • Self Confidence
      • Self Supervision
      • Social Networking
      • Strategic Planning
      • Time Management
    • Education Help
      • Career Tracks
      • Essay Writing
      • Internship Tips
      • Online Education
      • Scholarships
      • Student Loans
    • Managerial Skills
      • Business Communication
      • Business Networking
      • Facilitator Skills
      • Managing Change
      • Marketing Management
      • Meeting Management
      • Process Management
      • Project Management
      • Project Management Life Cycle
      • Project Management Process
      • Project Risk Management
      • Relationship Management
      • Task Management
      • Team Building
      • Virtual Team Management
    • Essential Life Skills
      • Anger Management
      • Anxiety Management
      • Attitude Development
      • Coaching and Mentoring
      • Emotional Intelligence
      • Stress Management
      • Positive Thinking
    • Communication Skills
      • Conversation Skills
      • Cross Culture Competence
      • English Vocabulary
      • Listening Skills
      • Public Speaking Skills
      • Questioning Skills
    • Soft Skills
      • Assertive Skills
      • Influence Skills
      • Leadership Skills
      • Memory Skills
      • People Skills
      • Presentation Skills
    • Finding a Job
      • Etiquette Tips
      • Group Discussions
      • HR Interviews
      • Interview Notes
      • Job Search Tips
      • Resume Tips
      • Sample Resumes
 

XML – Document Type Definitions (DTD)

By Exforsys | on June 14, 2006 |
XML Tutorial

XML – Document Type Definitions (DTD)

In this totuorial you will learn about XML – Document Type Definitions (DTD) – Need, DTD, Types Of DTD’s , Internal DTD , External DTD.

 

NEED

XML documents can contain many different types of markups including elements, attributes and entity references. Whatever maybe the application it is desirable that the XML document conforms to a certain set of rules governing the data structure it contains. DTD and Schema’s are used for this purpose.

For Example,

< name >12233< /name >

If a DTD defines that data in name tags should contain only characters and if it contains numbers , as shown above, the document is invalidated by the XML parser using the Document Type Definition (DTD) as reference.

DTD

DTD stands for Document Type Definitions. It describes syntax that explains which elements may appear in the XML document and what are the element contents and attributes.

A valid XML document must include the reference to DTD which validates it. When a DTD is absent the validating parser can’t verify the data format but can attempt to interpret the data.

TYPES OF DTD

• Internal DTD: DTD can be embedded into XML document
• External DTD: DTD can be in a separate file

INTERNAL DTD

Internal DTD are embedded in the XML document itself. They are convenient when constraints are applied to a single document. They are also used while designing a complex DTD for testing a sample document. Also, modifications becomes relatively simpler since the DTD and markup are in the same document.

Syntax : < ! DOCTYPE root_name[assignments] >

It begins with the DOCTYPE keyword (after < less than and ! exclamation mark) followed by the name of the root element. The root is followed by a square bracket which signifies beginning of declaration assignments. The last entry is a less than symbol ( >).

In the assignments section elements are declared as follows –

< !ELEMENT child_name(child_name or data type) >

Detailed explanation on this is covered in the next tutorial.

E.g.

< ?xml version=’1.0′ encoding=’utf-8′? >
< !– DTD for a AddressBook.xml — >
< !DOCTYPE AddressBook [
< !ELEMENT AddressBook (Address+) >
< !ELEMENT Address (Name, Street, City) >
< !ELEMENT Name (#PCDATA) >
< !ELEMENT Street (#PCDATA) >
< !ELEMENT City (#PCDATA) >
] >
< AddressBook >
< Address >
< Name >Jeniffer< /Name >
< Street >Wall Street < /Street >
< City >New York< /City >
< /Address >
< /AddressBook >

Above when viewed in IE 5.0 or above

Here the order of the declarations is not important . Thus,

< ?xml version=’1.0′ encoding=’utf-8′? >
< !– DTD for a AddressBook.xml — >
< !DOCTYPE AddressBook [
< !ELEMENT AddressBook (Address+) >
< !ELEMENT Address (Name, Street, City) >
< !ELEMENT Name (#PCDATA) >
< !ELEMENT Street (#PCDATA) >
< !ELEMENT City (#PCDATA) >
] >


is same as

< ?xml version=’1.0′ encoding=’utf-8′? >
< !– DTD for a AddressBook.xml — >
< !DOCTYPE AddressBook [
< !ELEMENT AddressBook (Address+) >
< !ELEMENT City (#PCDATA) >
< !ELEMENT Name (#PCDATA) >
< !ELEMENT Address (Name, Street, City) >
< !ELEMENT Street (#PCDATA) >
] >

EXTERNAL DTD

DTD is present in separate file and a reference is placed to its location in the document. External DTD’s are easy to apply to multiple documents. In case, a modification is to be made in future , it could be done in just one file and the onerous task of doing it for all the documents is omitted.

External DTD’s are of two Types

1) Public

These are standardized DTD’s and give publicly available set of rules for writing XML Documen

2) NonPublic

These are created by private organizations.

Adding Public DTD To Documents

We consider an example to understand the process of adding public DTD to documents

< !DOCTYPE spec PUBLIC “-//W3C//DTD Specification V2.0//EN” “/XML/2005/01/xml v20.dtd ” >

  • Here keyword PUBLIC specifies it’s a publicly available DTD.
    .
  • -/+(Minus/Plus) sign implies that DTD isn’t / is a recognized standard.
    .
  • // used for separating category of information.
    .
  • W3C – Owner Of DTD
    .
  • DTD Specification V2.0 – States the label for DTD
    .
  • EN – Abbreviation for ISO 639-1 encoding
    .
  • “/XML/2005/01/xml v20.dtd” – URL where DTD is stored.

ADDING NON- PUBLIC DTD TO DOCUMENTS

The syntax for adding non- public DTD to documents is as follows

< !DOCTYPE root_name SYSTEM “file path” >

In the DOCTYPE declaration after the root_name specify SYSTEM to indicate that it’s a non-public DTD followed by file path where the DTD is stored which could be a URL or a file path.



Example

The DTD for AddressBook.xml is contained in a file AddressBook.dtd
AddressBook.xml contains only XML Data with a reference to the DTD file

< ?xml version="1.0" encoding="UTF-8"? >
< !DOCTYPE AddressBook SYSTEM "file:/// c:/XML/AddressBook.dtd dtd" > " >
< AddressBook >
< Address >
< Name >Jeniffer< /Name >
< Street >Wall Street< /Street >
< City >New York< /City >
< /Address >
< /AddressBook >

« « Introduction to Ajax
XML – Elements in Document Type Definitions (DTD) » »

Author Description

Avatar

Editorial Team at Exforsys is a team of IT Consulting and Training team led by Chandra Vennapoosa.

Free Training

RSSSubscribe 394 Followers
  • Popular
  • Recent
  • XML Web Services

    July 11, 2007 - 0 Comment
  • XML Parsing

    July 14, 2007 - 0 Comment
  • XML Introduction

    May 14, 2006 - 0 Comment
  • XML Processing

    July 16, 2007 - 0 Comment
  • XML – Elements, Attributes, Entities

    May 14, 2006 - 0 Comment
  • XML Remote Calling Procedure

    July 19, 2007 - 0 Comment
  • XML – Elements in Document Type Definitions (DTD)

    June 14, 2006 - 0 Comment
  • XML Security

    July 21, 2007 - 0 Comment
  • Working with XML in Flash

    August 30, 2007 - 0 Comment
  • XML SQL Server

    July 23, 2007 - 0 Comment
  • Working with XML in C

    September 7, 2007 - 0 Comment
  • Working with XML in Perl

    September 6, 2007 - 0 Comment
  • Working with XML in Python

    September 2, 2007 - 0 Comment
  • Working with XML in Flash

    August 30, 2007 - 0 Comment
  • Working with XML in Oracle

    August 30, 2007 - 0 Comment
  • Working with XML in Visual Basic

    August 28, 2007 - 0 Comment
  • Using XML with Microsoft Excel

    August 24, 2007 - 0 Comment
  • XML Spy

    August 24, 2007 - 0 Comment
  • XML and Service Oriented Architecture

    July 25, 2007 - 0 Comment
  • XML SQL Server

    July 23, 2007 - 0 Comment

Exforsys e-Newsletter

ebook
 

Related Articles

  • Working with XML in C
  • Working with XML in Perl
  • Working with XML in Python
  • Working with XML in Flash
  • Working with XML in Oracle

Latest Articles

  • Project Management Techniques
  • Product Development Best Practices
  • Importance of Quality Data Management
  • How to Maximize Quality Assurance
  • Utilizing Effective Quality Assurance Strategies
  • Sitemap
  • Privacy Policy
  • DMCA
  • Trademark Information
  • Contact Us
© 2023. All Rights Reserved.IT Training and Consulting
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.AcceptReject Read More
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT