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 – Elements in Document Type Definitions (DTD)

By Exforsys | on June 14, 2006 |
XML Tutorial

XML – Elements in Document Type Definitions (DTD)

In this tutorial you will learn about Elements in DTD, Elements, child elements (nested elements), declaring elements with character data only, declaring elements with mixed content, declaring elements with any content, declaring elements with no content and element order indicators and qualifiers.

Elements in DTD.

ELEMENTS

Every element used in the valid XML document must be declared in the Document’s DTD.

SYNTAX : < !ELEMENT element_name content_specification >

element_name: Specifies name of the XML tag
Content_specification: Specifies the contents of the element which could of the following five types

I) Standard Content
II) Only Character Data
III) Mixed Content
IV) AnyType of Content
V) No Content

CHILD ELEMENTS (NESTED ELEMENTS)

Most Element declarations define one or more child elements.

For Example, < !ELEMENT customer (customer_name) >

Here , Element customer contains one and only one nested element i.e. customer_name

< !ELEMENT Address (Name, Street, City) >

Here, element Address contains three nested elements Name, Street and City respectively

SYNTAX: < !ELEMENT parent (child) >

OR

< !ELEMENT parent (child1,child2, . . . , childN) >

DECLARING ELEMENTS WITH CHARACTER DATA ONLY

Top level elements generally contain other elements but low-level elements may contain parsed character data. In XML, #PCDATA is the keyword to declare elements with parsed character data. An element declared as #PCDATA
Can contain character data
Can contain Entities such as <, >
Cannot contain other elements

SYNTAX < !ELEMENT element_name (#PCDATA) >

Example:

– < !ELEMENT Street (#PCDATA) >

• Element Street contains the parsed character data

#CDATA is another keyword to declare character data. But unlike #PCDATA, whitespaces are retained as it is in #CDATA.


SYNTAX < !ELEMENT element_name (#CDATA) >

Example: < !ELEMENT City (#CDATA) >

Here, DTD declares the City element to contain character data.
In XML, document < City > London < /City >
The XML, parse will take take the data as “ London ” and not as “London”
as in the case of #PCDATA

.

.


DECLARING ELEMENTS WITH MIXED CONTENT

At times it is required to declare elements with mixed content i.e. both data and other elements. In such situations the pipe symbol (|) is used.

SYNTAX < !ELEMENT parent (#CDATA or #PCDATA,child1,child2, . . . , childN) >

Example:

< bank >
This account is Active
< account >123456< /account >
This account is Closed
< account >423578< /account >
< /bank >

DECLARING ELEMENTS WITH ANY CONTENT

In Real world scenarios, the developer is many a times not sure about the exact document structure while creating the DTD. At such times, ANY keyword comes handy. An element declared as ANY can

  • Contain child elements
  • Contain character data
  • Contain mixed content

SYNTAX: < !ELEMENT element_name ANY >

DECLARING ELEMENTS WITH NO CONTENT

Sometimes it is required that an elements has only attributes but no data. In such scenarios the EMPTY keyword is used.

SYNTAX : < !ELEMENT element_name EMPTY >

ELEMENT ORDER INDICATORS AND QUALIFIERS

The various order and qualification governing symbols are listed in the table append below

TYPE

VALUE

CONTEXT

DESCRIPTION

ORDER

|

Choice

Either one child element or another can occur

()

Group

Groups related elements together

,

Sequence

Element must follow another element

QUALIFIER

?

Optional

Elements appear once or not at all

*

Optional and Repeatable

Elements appear zero or more times

+

Required and Repeatable

Elements appear one or more times

EXAMPLES:

The pipe symbol (|) specifies choice. So occurrence of either of the chiold element is considered valid by the parser.

Following declaration specifies that name must contain either first_name or last_name

< !ELEMENT name (fist_name | last_name) >


Thus,
< name >
< first_name >Nick< /first_name >
< /name >

as well as

< name >
< last_name >Price< /last_name >
< /name >

are valid.

.

.

.


The sequence operator (,) is used to provide sequence of child elements.
The following declaration requires first_name followed by middle_name followed by last_name

< ! ELEMENT name (fist_name, middle_name, last_name ) >

< name >
< first_name >Nick< /first_name >
< middle_name >John< /middle_name >
< last_name >Price< /last_name >
< /name >

is valid while

< name >
< last_name >Price< /last_name >
< first_name >Nick< /first_name >
< middle_name >John< /middle_name >
< /name >

or

< name >
< middle_name >John< /middle_name >
< first_name >Nick< /first_name >
< last_name >Price< /last_name >
< /name >


or any other such combinations are invalid.

The Optional operator (?) is used to declare zero or once appearance of the element

Thus for the declaration

< !ELEMENT EVENT (LOCATION,SPONSOR?) >

< EVENT >
< LOCATION >West Bay Ballpark< /LOCATION >
< /EVENT >

OR

< EVENT >
< LOCATION >West Bay Ballpark< /LOCATION >
< SPONSOR >Flying Toys< /SPONSOR >
< /EVENT >


are valid.

while

< EVENT >
< LOCATION >West Bay Ballpark< /LOCATION >
< SPONSOR >Flying Toys< /SPONSOR >
< SPONSOR >Plastic Toys< /SPONSOR >
< /EVENT >

is invalid.

The plus sign (+) is used to indicate one or more instances of the element.

Thus for the declaration

< !ELEMENT EVENTLIST (EVENT+) >

< EVENTLIST >
< EVENT >Balsa Wood Flyer Days< /EVENT >
< EVENT >Sundays in the Park< /EVENT >
< EVENT >Teach Your Child to Fly< /EVENT >
< /EVENTLIST >

or

< EVENTLIST >
< EVENT >Balsa Wood Flyer Days< /EVENT >
< /EVENTLIST >

are valid

while

< EVENTLIST >
< /EVENTLIST >

is not valid.

The asterisk (*) signifies zero or more appearances of the elements.

Thus for the declaration

< !ELEMENT EVENT (LOCATION*, EVENT-NAME) >

< EVENT >
< LOCATION >West Bay Ballpark< /LOCATION >
< LOCATION >North Side Park< /LOCATION >
< EVENT-NAME >Sundays in the Park< /EVENT-NAME >
< /EVENT >


OR

< EVENT >
< EVENT-NAME >Sundays in the Park< /EVENT-NAME >
< /EVENT >

are valid.

« « XML – Document Type Definitions (DTD)
Common Mistakes Made By Online College Students » »

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 – Elements, Attributes, Entities

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

    July 19, 2007 - 0 Comment
  • XML – 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 Python

    September 2, 2007 - 0 Comment
  • XML and Service Oriented Architecture

    July 25, 2007 - 0 Comment
  • Working with XML in Perl

    September 6, 2007 - 0 Comment
  • XML Spy

    August 24, 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