SlideShare una empresa de Scribd logo
1 de 13
XML DTD
BY
SANA MATEEN
XML DTD
• An XML document may have an optional DTD, which defines the
document’s grammar.
Since the DTD defines the XML document’s grammar, we can use an
XML parser to check that if an XML document conforms to the grammar
defined by the DTD.
• The purpose of a DTD is to define the legal building blocks of an XML
document.
• Terminology for XML:
-- well-formed: if tags are correctly closed.
-- valid: if it has a DTD and conforms to it.
Validation is useful in data exchange.
• A DTD can be declared inside the XML document, or as an external
reference.
• 1) Internal DTD
This is a example of a simple XML document with an internal DTD:
The DTD a is interpreted like this:
!DOCTYPE tutorials defines that the root
element of this document is tutorials
!ELEMENT tutorials defines that the tutorials
element contains minimum one occurrence of
child element.
!ELEMENT tutorial defines that the tutorials
element must contain two element name,url.
!ELEMENT name defines the to element to be
of type "#PCDATA"
!ELEMENT url defines the from element to
be of type "#PCDATA”
EXTERNAL DTD
• If the DTD is declared in an external file, the <!DOCTYPE> definition
must contain a reference to the DTD file:
• The keyword SYSTEM indicates that it's a private DTD
DTD - XML Building Blocks
• The main building blocks of both XML and HTML documents are elements.
• Seen from a DTD point of view, all XML documents are made up by the
following building blocks:
• Elements
• Attributes
• Entities
• PCDATA
• CDATA
• Entities
• Some characters have a special meaning in XML, like the less than sign (<) that
defines the start of an XML tag.
• Most of you know the HTML entity: "&nbsp;". This "no-breaking-space" entity
is used in HTML to insert an extra space in a document. Entities are expanded
when a document is parsed by an XML parser.
• The following entities are predefined in XML:
PCDATA and CDATA
• PCDATA
• PCDATA means parsed character data.
• Think of character data as the text found between the start tag and the end
tag of an XML element.
• PCDATA is text that WILL be parsed by a parser. The text will be
examined by the parser for entities and markup.
• However, parsed character data should not contain any &, <, or >
characters; these need to be represented by the &amp; &lt; and &gt;
entities, respectively.
• CDATA means character data.
• CDATA is text that will NOT be parsed by a parser. Tags inside the text
will NOT be treated as markup and entities will not be expanded.
DTD ELEMENTS
• In a DTD, elements are declared with an ELEMENT declaration.
• Declaring Elements
• In a DTD, XML elements are declared with the following syntax:
• Empty Elements
• Empty elements are declared with the category keyword EMPTY:
DTD - Attributes
• In a DTD, attributes are declared with an ATTLIST declaration.
• Declaring Attributes
• An attribute declaration has the following syntax:
• <!ATTLIST element-name attribute-name attribute-type attribute-value>
DTD example:
<!ATTLIST payment type CDATA "check">
XML example:
<payment type="check" />
The attribute-value can be one of the following:
DTD - Entities
1. Entities are used to define shortcuts to special characters.
2. Entities can be declared internal or external.
3. An Internal Entity Declaration
1. <!ENTITY entity-name "entity-value">
Xml dtd

Más contenido relacionado

La actualidad más candente

Querying XML: XPath and XQuery
Querying XML: XPath and XQueryQuerying XML: XPath and XQuery
Querying XML: XPath and XQuery
Katrien Verbert
 
Displaying XML Documents Using CSS and XSL
Displaying XML Documents Using CSS and XSLDisplaying XML Documents Using CSS and XSL
Displaying XML Documents Using CSS and XSL
Bình Trọng Án
 

La actualidad más candente (20)

Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
Xml ppt
Xml pptXml ppt
Xml ppt
 
DOM and SAX
DOM and SAXDOM and SAX
DOM and SAX
 
Xml dtd
Xml dtdXml dtd
Xml dtd
 
Querying XML: XPath and XQuery
Querying XML: XPath and XQueryQuerying XML: XPath and XQuery
Querying XML: XPath and XQuery
 
XML-Extensible Markup Language
XML-Extensible Markup Language XML-Extensible Markup Language
XML-Extensible Markup Language
 
XML, DTD & XSD Overview
XML, DTD & XSD OverviewXML, DTD & XSD Overview
XML, DTD & XSD Overview
 
Xml
XmlXml
Xml
 
Xml schema
Xml schemaXml schema
Xml schema
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
Html
HtmlHtml
Html
 
Multimedia Database
Multimedia Database Multimedia Database
Multimedia Database
 
XML and DTD
XML and DTDXML and DTD
XML and DTD
 
Xml dtd- Document Type Definition- Web Technology
Xml dtd- Document Type Definition- Web TechnologyXml dtd- Document Type Definition- Web Technology
Xml dtd- Document Type Definition- Web Technology
 
XML
XMLXML
XML
 
Dbms relational model
Dbms relational modelDbms relational model
Dbms relational model
 
Dynamic HTML (DHTML)
Dynamic HTML (DHTML)Dynamic HTML (DHTML)
Dynamic HTML (DHTML)
 
Displaying XML Documents Using CSS and XSL
Displaying XML Documents Using CSS and XSLDisplaying XML Documents Using CSS and XSL
Displaying XML Documents Using CSS and XSL
 
Encapsulation of operations, methods & persistence
Encapsulation of operations, methods & persistenceEncapsulation of operations, methods & persistence
Encapsulation of operations, methods & persistence
 
Xml processors
Xml processorsXml processors
Xml processors
 

Destacado

Destacado (13)

Jsp elements
Jsp elementsJsp elements
Jsp elements
 
Reading init param
Reading init paramReading init param
Reading init param
 
Intro xml
Intro xmlIntro xml
Intro xml
 
Events1
Events1Events1
Events1
 
Xhtml
XhtmlXhtml
Xhtml
 
Using cookies and sessions
Using cookies and sessionsUsing cookies and sessions
Using cookies and sessions
 
Understanding layout managers
Understanding layout managersUnderstanding layout managers
Understanding layout managers
 
Jdbc in servlets
Jdbc in servletsJdbc in servlets
Jdbc in servlets
 
Xml dom
Xml domXml dom
Xml dom
 
Dom parser
Dom parserDom parser
Dom parser
 
Http request and http response
Http request and http responseHttp request and http response
Http request and http response
 
Xml schema
Xml schemaXml schema
Xml schema
 
Quiz app(j tabbed pane,jdialog,container,actionevent,jradiobutton,buttongroup...
Quiz app(j tabbed pane,jdialog,container,actionevent,jradiobutton,buttongroup...Quiz app(j tabbed pane,jdialog,container,actionevent,jradiobutton,buttongroup...
Quiz app(j tabbed pane,jdialog,container,actionevent,jradiobutton,buttongroup...
 

Similar a Xml dtd

Document type definition
Document type definitionDocument type definition
Document type definition
Raghu nath
 
Test for an issue
Test for an issueTest for an issue
Test for an issue
techweb08
 
Chen's first test slides
Chen's first test slidesChen's first test slides
Chen's first test slides
Hima Challa
 
Chen test paper20abcdeftfdfd
Chen test paper20abcdeftfdfdChen test paper20abcdeftfdfd
Chen test paper20abcdeftfdfd
techweb08
 

Similar a Xml dtd (20)

XML DTD DOCUMENT TYPE DEFINITION
XML DTD DOCUMENT TYPE DEFINITIONXML DTD DOCUMENT TYPE DEFINITION
XML DTD DOCUMENT TYPE DEFINITION
 
Xml2
Xml2Xml2
Xml2
 
2-DTD.ppt
2-DTD.ppt2-DTD.ppt
2-DTD.ppt
 
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
 
01 xml document structure
01 xml document structure01 xml document structure
01 xml document structure
 
Document type definition
Document type definitionDocument type definition
Document type definition
 
It8074 soa-unit i
It8074 soa-unit iIt8074 soa-unit i
It8074 soa-unit i
 
DTD1.pptx
DTD1.pptxDTD1.pptx
DTD1.pptx
 
Unit iv xml
Unit iv xmlUnit iv xml
Unit iv xml
 
Web Technology Part 4
Web Technology Part 4Web Technology Part 4
Web Technology Part 4
 
Web Technologies Unit 2 Print.pdf
Web Technologies Unit 2 Print.pdfWeb Technologies Unit 2 Print.pdf
Web Technologies Unit 2 Print.pdf
 
Xml by Luqman
Xml by LuqmanXml by Luqman
Xml by Luqman
 
Dtd
DtdDtd
Dtd
 
Session 2
Session 2Session 2
Session 2
 
XML's validation - DTD
XML's validation - DTDXML's validation - DTD
XML's validation - DTD
 
CIS-189 Final Review
CIS-189 Final ReviewCIS-189 Final Review
CIS-189 Final Review
 
Test for an issue
Test for an issueTest for an issue
Test for an issue
 
Chen's first test slides
Chen's first test slidesChen's first test slides
Chen's first test slides
 
Chen test paper20abcdeftfdfd
Chen test paper20abcdeftfdfdChen test paper20abcdeftfdfd
Chen test paper20abcdeftfdfd
 

Más de sana mateen

Más de sana mateen (20)

Files
FilesFiles
Files
 
PHP Variables and scopes
PHP Variables and scopesPHP Variables and scopes
PHP Variables and scopes
 
Php intro
Php introPhp intro
Php intro
 
Php and web forms
Php and web formsPhp and web forms
Php and web forms
 
Mail
MailMail
Mail
 
Files in php
Files in phpFiles in php
Files in php
 
File upload php
File upload phpFile upload php
File upload php
 
Regex posix
Regex posixRegex posix
Regex posix
 
Encryption in php
Encryption in phpEncryption in php
Encryption in php
 
Authentication methods
Authentication methodsAuthentication methods
Authentication methods
 
Unit 1-subroutines in perl
Unit 1-subroutines in perlUnit 1-subroutines in perl
Unit 1-subroutines in perl
 
Unit 1-uses for scripting languages,web scripting
Unit 1-uses for scripting languages,web scriptingUnit 1-uses for scripting languages,web scripting
Unit 1-uses for scripting languages,web scripting
 
Unit 1-strings,patterns and regular expressions
Unit 1-strings,patterns and regular expressionsUnit 1-strings,patterns and regular expressions
Unit 1-strings,patterns and regular expressions
 
Unit 1-scalar expressions and control structures
Unit 1-scalar expressions and control structuresUnit 1-scalar expressions and control structures
Unit 1-scalar expressions and control structures
 
Unit 1-perl names values and variables
Unit 1-perl names values and variablesUnit 1-perl names values and variables
Unit 1-perl names values and variables
 
Unit 1-introduction to scripts
Unit 1-introduction to scriptsUnit 1-introduction to scripts
Unit 1-introduction to scripts
 
Unit 1-introduction to perl
Unit 1-introduction to perlUnit 1-introduction to perl
Unit 1-introduction to perl
 
Unit 1-array,lists and hashes
Unit 1-array,lists and hashesUnit 1-array,lists and hashes
Unit 1-array,lists and hashes
 
Uses for scripting languages,web scripting in perl
Uses for scripting languages,web scripting in perlUses for scripting languages,web scripting in perl
Uses for scripting languages,web scripting in perl
 
Scalar expressions and control structures in perl
Scalar expressions and control structures in perlScalar expressions and control structures in perl
Scalar expressions and control structures in perl
 

Último

DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
MayuraD1
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
mphochane1998
 

Último (20)

DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Bridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxBridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptx
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 

Xml dtd

  • 2. XML DTD • An XML document may have an optional DTD, which defines the document’s grammar. Since the DTD defines the XML document’s grammar, we can use an XML parser to check that if an XML document conforms to the grammar defined by the DTD. • The purpose of a DTD is to define the legal building blocks of an XML document. • Terminology for XML: -- well-formed: if tags are correctly closed. -- valid: if it has a DTD and conforms to it. Validation is useful in data exchange.
  • 3. • A DTD can be declared inside the XML document, or as an external reference. • 1) Internal DTD This is a example of a simple XML document with an internal DTD: The DTD a is interpreted like this: !DOCTYPE tutorials defines that the root element of this document is tutorials !ELEMENT tutorials defines that the tutorials element contains minimum one occurrence of child element. !ELEMENT tutorial defines that the tutorials element must contain two element name,url. !ELEMENT name defines the to element to be of type "#PCDATA" !ELEMENT url defines the from element to be of type "#PCDATA”
  • 4.
  • 5. EXTERNAL DTD • If the DTD is declared in an external file, the <!DOCTYPE> definition must contain a reference to the DTD file: • The keyword SYSTEM indicates that it's a private DTD
  • 6.
  • 7. DTD - XML Building Blocks • The main building blocks of both XML and HTML documents are elements. • Seen from a DTD point of view, all XML documents are made up by the following building blocks: • Elements • Attributes • Entities • PCDATA • CDATA • Entities • Some characters have a special meaning in XML, like the less than sign (<) that defines the start of an XML tag. • Most of you know the HTML entity: "&nbsp;". This "no-breaking-space" entity is used in HTML to insert an extra space in a document. Entities are expanded when a document is parsed by an XML parser. • The following entities are predefined in XML:
  • 8. PCDATA and CDATA • PCDATA • PCDATA means parsed character data. • Think of character data as the text found between the start tag and the end tag of an XML element. • PCDATA is text that WILL be parsed by a parser. The text will be examined by the parser for entities and markup. • However, parsed character data should not contain any &, <, or > characters; these need to be represented by the &amp; &lt; and &gt; entities, respectively. • CDATA means character data. • CDATA is text that will NOT be parsed by a parser. Tags inside the text will NOT be treated as markup and entities will not be expanded.
  • 9. DTD ELEMENTS • In a DTD, elements are declared with an ELEMENT declaration. • Declaring Elements • In a DTD, XML elements are declared with the following syntax: • Empty Elements • Empty elements are declared with the category keyword EMPTY:
  • 10.
  • 11. DTD - Attributes • In a DTD, attributes are declared with an ATTLIST declaration. • Declaring Attributes • An attribute declaration has the following syntax: • <!ATTLIST element-name attribute-name attribute-type attribute-value> DTD example: <!ATTLIST payment type CDATA "check"> XML example: <payment type="check" />
  • 12. The attribute-value can be one of the following: DTD - Entities 1. Entities are used to define shortcuts to special characters. 2. Entities can be declared internal or external. 3. An Internal Entity Declaration 1. <!ENTITY entity-name "entity-value">