SlideShare a Scribd company logo
DTD
Introduction
• Stands for Document Type Definition
• Allows to create rules for the elements within
your XML documents
• So, for an XML document to be well-formed, it
needs to use correct XML syntax, and it needs to
conform to its DTD or schema
• Is declared at the top of your XML document
• The actual contents of the DTD can be included
within your XML document or included in
another .dtd document
Example DTD
DTD <!DOCTYPE>
• DTD can either be
– internal (written into the same document that it's
being used in)
– external (located in another document).
• DTD is declared at the top of your XML
document using the !DOCTYPE declaration.
The basic syntax is:
DTD Variations
• <!DOCTYPE rootname [DTD]>
• <!DOCTYPE rootname SYSTEM URL>
• The keyword SYSTEM indicates that it's a
private DTD (not for public distribution)
• DTD is defined in a document located at the
URL
• <!DOCTYPE rootname SYSTEM URL [DTD]>
• The keyword SYSTEM indicates that it's a
private DTD (not for public distribution)
• The presence of URL and [DTD] together
indicates that this is both an external and
internal DTD (part of the DTD is defined in a
document located at the URL, the other part is
defined within the XML document)
Example
Internal DTD
• Whether we use an external or internal DTD,
the actual syntax for the DTD is the same
• Same code could just as easily be part of an
internal DTD or an external one
• The only difference between internal and
external is in the way it's declared with
DOCTYPE
Example
External DTD
• Is one that resides in a separate document
• To use the external DTD, we need to link to it
from our XML document by providing the URI
of the DTD file
• This URI is in the form of a URL
• The URL can point to a local file using a
relative reference, or a remote one (eg, using
HTTP)
Example
Combined DTD
• Can use both an internal DTD and an external
one at the same time
• This could be useful if you need to adhere to a
common DTD, but also need to define your
own definitions locally
Example
DTD Elements
• Creating a DTD is quite straight forward
• To define an element in your DTD, we use the
<!ELEMENT> declaration
• The actual contents of your <!ELEMENT>
declaration will depend on the syntax rules
you need to apply to your element
Basic Syntax
• <!ELEMENT element_name content_model>
– element_name is the name of the element
– content_model could indicate a specific rule, data
or another element
• If it specifies a rule, it will be set to either ANY or
EMPTY
• If specifies data or another element, the data
type/element name needs to be surrounded by
brackets (i.e. (tutorial) or (#PCDATA))
Plain Text
• If an element should contain plain text, you define the
element using #PCDATA.
• PCDATA stands for Parsed Character Data
• Syntax:
– <!ELEMENT element_name (#PCDATA)>
• Example:
– <!ELEMENT name (#PCDATA)>
• The above line in your DTD allows the name element to
contain non-markup data in your XML document:
– <name>XML Tutorial</name>
Unrestricted Elements
• If it doesn't matter what element contains, we
can create an element using the
content_model of ANY
• Doing this removes all syntax checking, so we
should avoid using this if possible
• Syntax:
– <!ELEMENT element_name ANY>
• Example:
– <!ELEMENT tutorials ANY>
Empty Elements
• Empty element is one without a closing tag.
• For example, in HTML, the <br /> and <img /> tags are
empty elements.
• Here's how you define an empty element:
• Syntax:
– <!ELEMENT element_name EMPTY>
• Example:
– <!ELEMENT header EMPTY>
• The above line in your DTD defines the following empty
element for your XML document:
– <header />
Child Elements
• Can specify that an element must contain
another element, by providing the name of
the element it must contain.
• Here's how you do that:
• Syntax:
– <!ELEMENT element_name
(child_element_name)>
• Example:
– <!ELEMENT tutorials (tutorial)>
• The above line in DTD allows the tutorials
element to contain one instance of the
tutorial element in XML document:
Multiple Child Elements (Sequences)
• You can also provide a comma separated list of
elements if it needs to contain more than one element.
This is referred to as a sequence. The XML document
must contain the tags in the same order that they're
specified in the sequence.
• Syntax:
<!ELEMENT element_name (child_element_name,
child_element_name,...)>
• Example:
<!ELEMENT tutorial (name, author)>
• The above line in DTD allows the tutorial
element to contain one instance of the name
element and one instance of the author
element in XML document:
DTD Element Operators
• Are used to specify the number the times the
child elements can be used inside parents
elements
Zero or More
• To allow zero or more of the same child
element, use an asterisk (*)
• Syntax:
<!ELEMENT element_name
(child_element_name*)>
• Example:
<!ELEMENT tutorials (tutorial*)>
One or More
• To allow one or more of the same child
element, use a plus sign (+):
• Syntax:
<!ELEMENT element_name
(child_element_name+)>
• Example:
<!ELEMENT tutorials (tutorial+)>
Zero or One
• To allow either zero or one of the same child
element, use a question mark (?):
• Syntax:
<!ELEMENT element_name
(child_element_name?)>
• Example:
<!ELEMENT tutorials (tutorial?)>
Choices
• Can define a choice between one or another
element by using the pipe (|) operator.
• Syntax:
<!ELEMENT element_name (choice_1 | choice_2
| choice_3)>
• For example, if the tutorial element requires a
child called either name, title, or subject (but only
one of these)
<!ELEMENT tutorial (name | title | subject)>
DTD Operators with Sequences
• Can apply any of the DTD operators to a
sequence:
• Syntax:
<!ELEMENT element_name
(child_element_name dtd_operator,
child_element_name dtd_operator,...)>
• Example:
<!ELEMENT tutorial (name+, author?)>
DTD Attributes
• Just as we need to define all elements in your
DTD, we also need to define any attributes
they use.
• Use the <!ATTLIST> declaration to define
attributes
• Single <!ATTLIST> declaration to declare all
attributes for a given element
• Syntax
• Example
DTD Attribute Default Values

More Related Content

What's hot

XSLT
XSLTXSLT
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
Bình Trọng Án
 
Xml dtd
Xml dtdXml dtd
Xml dtd
HeenaRajput1
 
Xml namespace
Xml namespaceXml namespace
Xml namespace
GayathriS578276
 
Xml schema
Xml schemaXml schema
Xml schema
Akshaya Akshaya
 
Xml ppt
Xml pptXml ppt
Xml ppt
seemadav1
 
Javascript arrays
Javascript arraysJavascript arrays
Javascript arrays
Hassan Dar
 
Xml Presentation-3
Xml Presentation-3Xml Presentation-3
Xml Presentation-3Sudharsan S
 
Simple object access protocol(soap )
Simple object access protocol(soap )Simple object access protocol(soap )
Simple object access protocol(soap )
balamurugan.k Kalibalamurugan
 
Xml presentation
Xml presentationXml presentation
Xml presentation
Miguel Angel Teheran Garcia
 
Xml schema
Xml schemaXml schema
Xml schema
Prabhakaran V M
 
SQL
SQLSQL
Xpath.ppt
Xpath.pptXpath.ppt
Xpath.ppt
Prerak10
 
It8074 soa-unit i
It8074 soa-unit iIt8074 soa-unit i
It8074 soa-unit i
RevathiAPICSE
 
Difference between dtd and xsd
Difference between dtd and xsdDifference between dtd and xsd
Difference between dtd and xsd
Umar Ali
 
XML
XMLXML
WSDL
WSDLWSDL
Html Basic Tags
Html Basic TagsHtml Basic Tags
Html Basic Tags
Richa Singh
 

What's hot (20)

XSLT
XSLTXSLT
XSLT
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
Xml dtd
Xml dtdXml dtd
Xml dtd
 
Xml namespace
Xml namespaceXml namespace
Xml namespace
 
Xml schema
Xml schemaXml schema
Xml schema
 
Xml ppt
Xml pptXml ppt
Xml ppt
 
Javascript arrays
Javascript arraysJavascript arrays
Javascript arrays
 
Xml Presentation-3
Xml Presentation-3Xml Presentation-3
Xml Presentation-3
 
Simple object access protocol(soap )
Simple object access protocol(soap )Simple object access protocol(soap )
Simple object access protocol(soap )
 
Xml presentation
Xml presentationXml presentation
Xml presentation
 
Xml schema
Xml schemaXml schema
Xml schema
 
SQL
SQLSQL
SQL
 
Xpath.ppt
Xpath.pptXpath.ppt
Xpath.ppt
 
It8074 soa-unit i
It8074 soa-unit iIt8074 soa-unit i
It8074 soa-unit i
 
Difference between dtd and xsd
Difference between dtd and xsdDifference between dtd and xsd
Difference between dtd and xsd
 
XML
XMLXML
XML
 
Javascript validating form
Javascript validating formJavascript validating form
Javascript validating form
 
WSDL
WSDLWSDL
WSDL
 
Xpath presentation
Xpath presentationXpath presentation
Xpath presentation
 
Html Basic Tags
Html Basic TagsHtml Basic Tags
Html Basic Tags
 

Similar to DTD

XML DTD DOCUMENT TYPE DEFINITION
XML DTD DOCUMENT TYPE DEFINITIONXML DTD DOCUMENT TYPE DEFINITION
XML DTD DOCUMENT TYPE DEFINITION
SaraswathiRamalingam
 
Xml dtd
Xml dtdXml dtd
Xml dtd
sana mateen
 
2-DTD.ppt
2-DTD.ppt2-DTD.ppt
2-DTD.ppt
KGSCSEPSGCT
 
Unit iv xml
Unit iv xmlUnit iv xml
Unit iv xml
smitha273566
 
01 xml document structure
01 xml document structure01 xml document structure
01 xml document structure
Baskarkncet
 
It8074 soa-unit i
It8074 soa-unit iIt8074 soa-unit i
It8074 soa-unit i
smitha273566
 
it8074-soa-uniti-.pdf
it8074-soa-uniti-.pdfit8074-soa-uniti-.pdf
it8074-soa-uniti-.pdf
FreeFire293813
 
XML's validation - DTD
XML's validation - DTDXML's validation - DTD
XML's validation - DTD
videde_group
 
II UNIT PPT NOTES.pdf this is the data structures
II UNIT PPT NOTES.pdf this is the data structuresII UNIT PPT NOTES.pdf this is the data structures
II UNIT PPT NOTES.pdf this is the data structures
PriyankaRamavath3
 
Web Technologies Unit 2 Print.pdf
Web Technologies Unit 2 Print.pdfWeb Technologies Unit 2 Print.pdf
Web Technologies Unit 2 Print.pdf
AnonymousXhmybK
 
DTD1.pptx
DTD1.pptxDTD1.pptx
DTD1.pptx
MouDhara1
 
Xml Lecture Notes
Xml Lecture NotesXml Lecture Notes
Xml Lecture Notes
Santhiya Grace
 
Introduction to XML.ppt
Introduction to XML.pptIntroduction to XML.ppt
Introduction to XML.ppt
Varsha Uchagaonkar
 
Introduction to XML.ppt
Introduction to XML.pptIntroduction to XML.ppt
Introduction to XML.ppt
Varsha Uchagaonkar
 
Web Technology Part 4
Web Technology Part 4Web Technology Part 4
Web Technology Part 4
Thapar Institute
 
Document type definition
Document type definitionDocument type definition
Document type definitionRaghu nath
 
XML Schema
XML SchemaXML Schema
XML Schema
Kumar
 

Similar to DTD (20)

XML DTD DOCUMENT TYPE DEFINITION
XML DTD DOCUMENT TYPE DEFINITIONXML DTD DOCUMENT TYPE DEFINITION
XML DTD DOCUMENT TYPE DEFINITION
 
Xml dtd
Xml dtdXml dtd
Xml dtd
 
2-DTD.ppt
2-DTD.ppt2-DTD.ppt
2-DTD.ppt
 
Unit iv xml
Unit iv xmlUnit iv xml
Unit iv xml
 
01 xml document structure
01 xml document structure01 xml document structure
01 xml document structure
 
It8074 soa-unit i
It8074 soa-unit iIt8074 soa-unit i
It8074 soa-unit i
 
it8074-soa-uniti-.pdf
it8074-soa-uniti-.pdfit8074-soa-uniti-.pdf
it8074-soa-uniti-.pdf
 
XML's validation - DTD
XML's validation - DTDXML's validation - DTD
XML's validation - DTD
 
II UNIT PPT NOTES.pdf this is the data structures
II UNIT PPT NOTES.pdf this is the data structuresII UNIT PPT NOTES.pdf this is the data structures
II UNIT PPT NOTES.pdf this is the data structures
 
Web Technologies Unit 2 Print.pdf
Web Technologies Unit 2 Print.pdfWeb Technologies Unit 2 Print.pdf
Web Technologies Unit 2 Print.pdf
 
DTD1.pptx
DTD1.pptxDTD1.pptx
DTD1.pptx
 
Xml Lecture Notes
Xml Lecture NotesXml Lecture Notes
Xml Lecture Notes
 
Introduction to XML.ppt
Introduction to XML.pptIntroduction to XML.ppt
Introduction to XML.ppt
 
Introduction to XML.ppt
Introduction to XML.pptIntroduction to XML.ppt
Introduction to XML.ppt
 
Web Technology Part 4
Web Technology Part 4Web Technology Part 4
Web Technology Part 4
 
Document type definitions part 1
Document type definitions part 1Document type definitions part 1
Document type definitions part 1
 
Xml and Co.
Xml and Co.Xml and Co.
Xml and Co.
 
Document type definition
Document type definitionDocument type definition
Document type definition
 
Dtd
DtdDtd
Dtd
 
XML Schema
XML SchemaXML Schema
XML Schema
 

More from Kamal Acharya

Programming the basic computer
Programming the basic computerProgramming the basic computer
Programming the basic computer
Kamal Acharya
 
Computer Arithmetic
Computer ArithmeticComputer Arithmetic
Computer Arithmetic
Kamal Acharya
 
Introduction to Computer Security
Introduction to Computer SecurityIntroduction to Computer Security
Introduction to Computer Security
Kamal Acharya
 
Session and Cookies
Session and CookiesSession and Cookies
Session and Cookies
Kamal Acharya
 
Functions in php
Functions in phpFunctions in php
Functions in php
Kamal Acharya
 
Web forms in php
Web forms in phpWeb forms in php
Web forms in php
Kamal Acharya
 
Making decision and repeating in PHP
Making decision and repeating  in PHPMaking decision and repeating  in PHP
Making decision and repeating in PHP
Kamal Acharya
 
Working with arrays in php
Working with arrays in phpWorking with arrays in php
Working with arrays in php
Kamal Acharya
 
Text and Numbers (Data Types)in PHP
Text and Numbers (Data Types)in PHPText and Numbers (Data Types)in PHP
Text and Numbers (Data Types)in PHP
Kamal Acharya
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
Kamal Acharya
 
Capacity Planning of Data Warehousing
Capacity Planning of Data WarehousingCapacity Planning of Data Warehousing
Capacity Planning of Data Warehousing
Kamal Acharya
 
Data Warehousing
Data WarehousingData Warehousing
Data Warehousing
Kamal Acharya
 
Search Engines
Search EnginesSearch Engines
Search Engines
Kamal Acharya
 
Web Mining
Web MiningWeb Mining
Web Mining
Kamal Acharya
 
Information Privacy and Data Mining
Information Privacy and Data MiningInformation Privacy and Data Mining
Information Privacy and Data Mining
Kamal Acharya
 
Cluster Analysis
Cluster AnalysisCluster Analysis
Cluster Analysis
Kamal Acharya
 
Association Analysis in Data Mining
Association Analysis in Data MiningAssociation Analysis in Data Mining
Association Analysis in Data Mining
Kamal Acharya
 
Classification techniques in data mining
Classification techniques in data miningClassification techniques in data mining
Classification techniques in data mining
Kamal Acharya
 
Data Preprocessing
Data PreprocessingData Preprocessing
Data Preprocessing
Kamal Acharya
 
Introduction to Data Mining and Data Warehousing
Introduction to Data Mining and Data WarehousingIntroduction to Data Mining and Data Warehousing
Introduction to Data Mining and Data Warehousing
Kamal Acharya
 

More from Kamal Acharya (20)

Programming the basic computer
Programming the basic computerProgramming the basic computer
Programming the basic computer
 
Computer Arithmetic
Computer ArithmeticComputer Arithmetic
Computer Arithmetic
 
Introduction to Computer Security
Introduction to Computer SecurityIntroduction to Computer Security
Introduction to Computer Security
 
Session and Cookies
Session and CookiesSession and Cookies
Session and Cookies
 
Functions in php
Functions in phpFunctions in php
Functions in php
 
Web forms in php
Web forms in phpWeb forms in php
Web forms in php
 
Making decision and repeating in PHP
Making decision and repeating  in PHPMaking decision and repeating  in PHP
Making decision and repeating in PHP
 
Working with arrays in php
Working with arrays in phpWorking with arrays in php
Working with arrays in php
 
Text and Numbers (Data Types)in PHP
Text and Numbers (Data Types)in PHPText and Numbers (Data Types)in PHP
Text and Numbers (Data Types)in PHP
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Capacity Planning of Data Warehousing
Capacity Planning of Data WarehousingCapacity Planning of Data Warehousing
Capacity Planning of Data Warehousing
 
Data Warehousing
Data WarehousingData Warehousing
Data Warehousing
 
Search Engines
Search EnginesSearch Engines
Search Engines
 
Web Mining
Web MiningWeb Mining
Web Mining
 
Information Privacy and Data Mining
Information Privacy and Data MiningInformation Privacy and Data Mining
Information Privacy and Data Mining
 
Cluster Analysis
Cluster AnalysisCluster Analysis
Cluster Analysis
 
Association Analysis in Data Mining
Association Analysis in Data MiningAssociation Analysis in Data Mining
Association Analysis in Data Mining
 
Classification techniques in data mining
Classification techniques in data miningClassification techniques in data mining
Classification techniques in data mining
 
Data Preprocessing
Data PreprocessingData Preprocessing
Data Preprocessing
 
Introduction to Data Mining and Data Warehousing
Introduction to Data Mining and Data WarehousingIntroduction to Data Mining and Data Warehousing
Introduction to Data Mining and Data Warehousing
 

Recently uploaded

1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 

Recently uploaded (20)

1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 

DTD

  • 1. DTD
  • 2. Introduction • Stands for Document Type Definition • Allows to create rules for the elements within your XML documents • So, for an XML document to be well-formed, it needs to use correct XML syntax, and it needs to conform to its DTD or schema • Is declared at the top of your XML document • The actual contents of the DTD can be included within your XML document or included in another .dtd document
  • 4. DTD <!DOCTYPE> • DTD can either be – internal (written into the same document that it's being used in) – external (located in another document). • DTD is declared at the top of your XML document using the !DOCTYPE declaration. The basic syntax is:
  • 6. • <!DOCTYPE rootname SYSTEM URL> • The keyword SYSTEM indicates that it's a private DTD (not for public distribution) • DTD is defined in a document located at the URL
  • 7. • <!DOCTYPE rootname SYSTEM URL [DTD]> • The keyword SYSTEM indicates that it's a private DTD (not for public distribution) • The presence of URL and [DTD] together indicates that this is both an external and internal DTD (part of the DTD is defined in a document located at the URL, the other part is defined within the XML document)
  • 9. Internal DTD • Whether we use an external or internal DTD, the actual syntax for the DTD is the same • Same code could just as easily be part of an internal DTD or an external one • The only difference between internal and external is in the way it's declared with DOCTYPE
  • 11. External DTD • Is one that resides in a separate document • To use the external DTD, we need to link to it from our XML document by providing the URI of the DTD file • This URI is in the form of a URL • The URL can point to a local file using a relative reference, or a remote one (eg, using HTTP)
  • 13.
  • 14. Combined DTD • Can use both an internal DTD and an external one at the same time • This could be useful if you need to adhere to a common DTD, but also need to define your own definitions locally
  • 16.
  • 17. DTD Elements • Creating a DTD is quite straight forward • To define an element in your DTD, we use the <!ELEMENT> declaration • The actual contents of your <!ELEMENT> declaration will depend on the syntax rules you need to apply to your element
  • 18. Basic Syntax • <!ELEMENT element_name content_model> – element_name is the name of the element – content_model could indicate a specific rule, data or another element • If it specifies a rule, it will be set to either ANY or EMPTY • If specifies data or another element, the data type/element name needs to be surrounded by brackets (i.e. (tutorial) or (#PCDATA))
  • 19. Plain Text • If an element should contain plain text, you define the element using #PCDATA. • PCDATA stands for Parsed Character Data • Syntax: – <!ELEMENT element_name (#PCDATA)> • Example: – <!ELEMENT name (#PCDATA)> • The above line in your DTD allows the name element to contain non-markup data in your XML document: – <name>XML Tutorial</name>
  • 20. Unrestricted Elements • If it doesn't matter what element contains, we can create an element using the content_model of ANY • Doing this removes all syntax checking, so we should avoid using this if possible • Syntax: – <!ELEMENT element_name ANY> • Example: – <!ELEMENT tutorials ANY>
  • 21. Empty Elements • Empty element is one without a closing tag. • For example, in HTML, the <br /> and <img /> tags are empty elements. • Here's how you define an empty element: • Syntax: – <!ELEMENT element_name EMPTY> • Example: – <!ELEMENT header EMPTY> • The above line in your DTD defines the following empty element for your XML document: – <header />
  • 22. Child Elements • Can specify that an element must contain another element, by providing the name of the element it must contain. • Here's how you do that: • Syntax: – <!ELEMENT element_name (child_element_name)> • Example: – <!ELEMENT tutorials (tutorial)>
  • 23. • The above line in DTD allows the tutorials element to contain one instance of the tutorial element in XML document:
  • 24. Multiple Child Elements (Sequences) • You can also provide a comma separated list of elements if it needs to contain more than one element. This is referred to as a sequence. The XML document must contain the tags in the same order that they're specified in the sequence. • Syntax: <!ELEMENT element_name (child_element_name, child_element_name,...)> • Example: <!ELEMENT tutorial (name, author)>
  • 25. • The above line in DTD allows the tutorial element to contain one instance of the name element and one instance of the author element in XML document:
  • 26. DTD Element Operators • Are used to specify the number the times the child elements can be used inside parents elements
  • 27. Zero or More • To allow zero or more of the same child element, use an asterisk (*) • Syntax: <!ELEMENT element_name (child_element_name*)> • Example: <!ELEMENT tutorials (tutorial*)>
  • 28. One or More • To allow one or more of the same child element, use a plus sign (+): • Syntax: <!ELEMENT element_name (child_element_name+)> • Example: <!ELEMENT tutorials (tutorial+)>
  • 29. Zero or One • To allow either zero or one of the same child element, use a question mark (?): • Syntax: <!ELEMENT element_name (child_element_name?)> • Example: <!ELEMENT tutorials (tutorial?)>
  • 30. Choices • Can define a choice between one or another element by using the pipe (|) operator. • Syntax: <!ELEMENT element_name (choice_1 | choice_2 | choice_3)> • For example, if the tutorial element requires a child called either name, title, or subject (but only one of these) <!ELEMENT tutorial (name | title | subject)>
  • 31. DTD Operators with Sequences • Can apply any of the DTD operators to a sequence: • Syntax: <!ELEMENT element_name (child_element_name dtd_operator, child_element_name dtd_operator,...)> • Example: <!ELEMENT tutorial (name+, author?)>
  • 32. DTD Attributes • Just as we need to define all elements in your DTD, we also need to define any attributes they use. • Use the <!ATTLIST> declaration to define attributes • Single <!ATTLIST> declaration to declare all attributes for a given element