Document Type
Definition
DTD
Document Tvpe Definitions
(DTDs) define an XML document's structure (e.g., what elements,attributes, etc. are permitted
in the document). An XML document is not required to have a corresponding DTD. However,
DTDs are often recommended to ensure document conformity, especially in business-to-
business (B2B) transactions, where XML documents are exchanged. DTDs specify an XML
document's structure and are themselves defined using EBNF (Extended Backus-Naur Form)
grammar-not the XML syntax.
Observation:
A transition is underway in the XML community from DTDs to Schema, which improve upon
DTDs. Schema use XML syntax, not EBNF grammar.
Parsers, Well-formed and Valid XML Documents:
Parsers are generally classified as validating or nonvalidating. A validating parser is able to read
the DTD and determine whether or not the XML document conforms to it. If the document
conforms to the DTD, it is referred to as valid. If the document fails to conform to the DTD but
is syntactically correct, it is well formed but not valid. By definition, a valid document is well
formed. A nonvalidating parser is able to read the DTD, but cannot check the document against
the DTD for conformity. If the document is syntactically correct, it is well formed.
Document Type Declaration
DTDs are introduced into XML documents using the document type declaration (i.e .DOCTYPE).
A document type declaration is placed in the XML document's prolog and begins with
<!DOCTYPE and ends with >. The document type declaration can point to declarations
that are outside the XML document (called the external subset) or can contain the declaration
inside the document (called internal subset).
For example, an internal subset mightlook like
<!DOCTYPE myMessage [
<!ELEMENT myMessage ( #PCDATA )>
]
The first myMessage
is the name of the document type declaration. Anything inside the square brackets ( [ ] )
constitutes the internal subset. As we will see momentarily,
ELEMENT and
#PCDATA are used in "element declarations.“
External subsets physically exist in a different file that typically ends with the .
Dtd extension,although this file extension is not required. External subsets are specified using
either keyword SYSTEM or PUBLIC.
For example. the
DOCTYPE
external subset might look like
<!DOCTYPE myMessage SYSTEM "myDTD.dtd">
which points to the myDTD.dtd document. Using the PUBLIC
keyword indicates that the DTD is widely used (e.g., the DTD for HTML documents). The DTD
may be made available in well-known locations for more efficient downloading. The
DOCTYPE
<!DOCTYPE HTML PUBLIC "-//w3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
uses the PUBLIC
keyword to reference the well-known DTD for HTML version 4.01. XML parsers that do not have
a local copy of the DTD may use the URL provided to download the DTD to perform validation
Both the internal and external subset may be specified at the same time. For example, the
DOCTYPE
<!DOCTYPE myMessage SYSTEM "myDTD.dtd“ <!ELEMENT myElement ( #PCDATA )>
contains declarations from the myDTD.dtd document as well as an internal declaration
Observation:
The document type declaration internal subset plus its external subset form the DTD.
The internal subset is visible only within the document in which it resides. Other external
documents cannot be validated against it. DTDs that are used by many documents should be
placed in the external subset.
Element Type Declarations
Elements are the primary building block used in XML documents and are declared in a DTD
with element type declarations (ELEMENTs). For example, to declare element myMessage,
we might write
The element name (e.g., MyElement) that follows ELEMENT is often called a generic identifier.
The set of parentheses that follow the element name specify the element's allowed content and
is called the content specification.
Keyword
PCDATA
specifies that the element must contain parsable character data. This data will be parsed by the
XML parser, therefore any markup text (i.e., <, >, &, etc.) will be treated as markup.
Error:
Attempting to use the same element name in multiple element type declarations is an error.
Example 1 lists an XML document that contains a reference to an external DTD in the
I)DOCTYPE.
Microsoft's XML Validator will be used to check the document's conformity
against its DTD. To use XML Validator, Internet Explorer 5 is required. Parsers XML4J and
Xerces can be used to check a document's validity against a DTD programmatically. Using Java
and one of these parsers provides a platform-independent way to validate XML documents.
<?xml version = "1.0"?>
<!DOCTYPE myMessage SYSTEM "intro.dtd">
<myMessage>
<message>Welcome to XML!</message>
</myMessage>
Example 1. XML document declaring associated DTD.
The document type declaration is named myMessage-the name of the root element. The
element myMessage contains a single child element named message .
<!ELEMENT myMessage ( message )> <!ELEMENT message ( #PCDATA )> Example 2. Validation
with using an external DTD The DTD declares element myMessage.
Notice that the content specification contains the name message. This indicates that element
myMessage contains exactly one child element named message. Because myMessage can only
have an element as its content, it is said to have element content. Element message whose
content is of type PCDATA. The XML Validator is capable of validating an XML document against
both DTDs and Schemas
Error:
Having a root element name other than the name specified in the document type declaration is
an error.
Document Type Definitions (DTDs) define an XML document's structure (e.g., what
elements, attributes, etc. are permitted in the XML document). An XML document is not
required to have a corresponding DTD. DTDs use EBNF (Extended Backus-Naur Form)
grammar
Parsers are generally classified as validating or nonvalidating. A validating parser is able to
read the DTD and determine whether or not the XML document conforms to it. If the
document conforms to the DTD, it is referred to as valid. If the document fails to conform to
the DTD but is syntactically correct, it is well formed but not valid. By definition, a valid
document is well formed.
A nonvalidating parser is able to read a DTD, but cannot check the document against the
DTD for conformity. If the document is syntactically correct, it is well formed.
DTDs are introduced into XML documents by using the document type declaration (i.e.,
DOCTYPE). The document type declaration can point to declarations that are outside the
XML document (called the external subset) or can contain the declaration inside the
document (called internal subset).
External subsets physically exist in a different file that typically ends with the .dtd
extension, although this file extension is not required. External Subsets are specified using
keyword SYSTEM. Both the internal and external subset may be specified at the same
time
Elements are the primary building block used in XML documents and are declared in a
DTD with element type declarations (ELEMENTs).
The element name that follows ELEMENT is often called a generic identifier. The set of
parentheses that follow the element name specify the element's allowed content and is
called the content specification.
Keyword PCDATA
specifies that the element must contain parsable character data-that is,any text except the
characters less-than ( < ), greater-than ( > ), ampersand ( & ), quote ( ' ) and double quote ( " ).
An XML document is a standalone XML document if it does not reference an external DTD.
An XML element that can only have another element for content, it is said to have element
content.
DTDs allow the document author to define the order and frequency of child elements. The
comma ( , ) - called a sequence - specifies the order in which the elements must occur.
Choices are specified using the pipe ( | ) character. The content specification may contain
any number of pipe character separated choises.
An element's frequency (i.e., number of occurrences) is specified by using either the plus
sign (+), asterisk (*) or question mark (?) occurrence indicator
The frequency of an element group (i.e., two or more elements that occur in some
combinaition) is specified by enclosing the element names inside the content specification
followed by an occurrence indicator
Elements can be further refined by describing the content types they may contain. Content
specification types (e.g., EMPTY, mixed content, ANY, etc.) describe nonelement content.
An element can be declared as having mixed content (i.e., a combination of elements and
PCDATA). The comma ( , ), plus sign ( + ) and question mark ( ? ) occurrence indicators
cannot be used with mixed content elements

More Related Content

PPT
Document Type Definition
PPT
PPT
2 dtd - validating xml documents
PPTX
Xml dtd
PPTX
XML's validation - DTD
PPTX
Xml dtd
Document Type Definition
2 dtd - validating xml documents
Xml dtd
XML's validation - DTD
Xml dtd

What's hot (20)

PPT
Introduction to XML
PDF
Introduction to DTD
PPTX
Xml dtd- Document Type Definition- Web Technology
PPTX
DTD
PPTX
Document type definitions part 1
PDF
Difference between dtd and xsd
PPT
XML and DTD
PPTX
PPT
Xml Java
PDF
SQL Server - Querying and Managing XML Data
PPTX
XML Introduction
PPT
4 xml namespaces and xml schema
PPT
01 xml document structure
PPT
3 xml namespaces and xml schema
PPT
XML Schema
PPTX
Xml For Dummies Chapter 8 Understanding And Using Dt Ds it-slideshares.blog...
PPTX
XML, DTD & XSD Overview
PPTX
Basic XML
Introduction to XML
Introduction to DTD
Xml dtd- Document Type Definition- Web Technology
DTD
Document type definitions part 1
Difference between dtd and xsd
XML and DTD
Xml Java
SQL Server - Querying and Managing XML Data
XML Introduction
4 xml namespaces and xml schema
01 xml document structure
3 xml namespaces and xml schema
XML Schema
Xml For Dummies Chapter 8 Understanding And Using Dt Ds it-slideshares.blog...
XML, DTD & XSD Overview
Basic XML
Ad

Viewers also liked (20)

PPTX
Different document types
PPS
Documentation Types
PPTX
Tablas html
PPTX
HTML Link - Image - Comments
PPT
Hyperlinks in HTML
PPTX
XML Document Object Model (DOM)
PPSX
CSS-Cascading Style Sheets - Introduction
PDF
Html table tags
PPT
How Cascading Style Sheets (CSS) Works
PPTX
Images and Lists in HTML
PDF
SharePoint Document Types
PPT
Css Ppt
PPT
Introduction to Cascading Style Sheets (CSS)
PPT
Introduction to CSS
PPT
cascading style sheet ppt
PPT
Introduction to html
PDF
International Trade Documents: 10 Top Documents
PPT
Html Ppt
PPT
Introduction to HTML
PPTX
Types of contract
Different document types
Documentation Types
Tablas html
HTML Link - Image - Comments
Hyperlinks in HTML
XML Document Object Model (DOM)
CSS-Cascading Style Sheets - Introduction
Html table tags
How Cascading Style Sheets (CSS) Works
Images and Lists in HTML
SharePoint Document Types
Css Ppt
Introduction to Cascading Style Sheets (CSS)
Introduction to CSS
cascading style sheet ppt
Introduction to html
International Trade Documents: 10 Top Documents
Html Ppt
Introduction to HTML
Types of contract
Ad

Similar to Document type definition (20)

PPTX
XML DTD DOCUMENT TYPE DEFINITION
PPTX
Unit iv xml
PPT
2-DTD.ppt
PPTX
It8074 soa-unit i
PDF
it8074-soa-uniti-.pdf
PPTX
It8074 soa-unit i
PPT
uptu web technology unit 2 Xml2
PPTX
DTD1.pptx
PPT
Ch2 neworder
PPTX
IPT Chapter 3 Data Mapping and Exchange - Dr. J. VijiPriya
PPTX
distributed system concerned lab sessions
PPTX
XML DTD and Schema
PPTX
web design technology- mark up languages
PPT
Xml and webdata
PPT
Xml and webdata
PPT
Xml and webdata
PPT
Xml and webdata
XML DTD DOCUMENT TYPE DEFINITION
Unit iv xml
2-DTD.ppt
It8074 soa-unit i
it8074-soa-uniti-.pdf
It8074 soa-unit i
uptu web technology unit 2 Xml2
DTD1.pptx
Ch2 neworder
IPT Chapter 3 Data Mapping and Exchange - Dr. J. VijiPriya
distributed system concerned lab sessions
XML DTD and Schema
web design technology- mark up languages
Xml and webdata
Xml and webdata
Xml and webdata
Xml and webdata

More from Raghu nath (20)

PPTX
Mongo db
PDF
Ftp (file transfer protocol)
PDF
MS WORD 2013
PDF
Msword
PDF
Ms word
PDF
Javascript part1
PDF
Regular expressions
PDF
Selection sort
PPTX
Binary search
PPTX
JSON(JavaScript Object Notation)
PDF
Stemming algorithms
PPTX
Step by step guide to install dhcp role
PPTX
Network essentials chapter 4
PPTX
Network essentials chapter 3
PPTX
Network essentials chapter 2
PPTX
Network essentials - chapter 1
PPTX
Python chapter 2
PPTX
python chapter 1
PPTX
Linux Shell Scripting
PPTX
Mongo db
Ftp (file transfer protocol)
MS WORD 2013
Msword
Ms word
Javascript part1
Regular expressions
Selection sort
Binary search
JSON(JavaScript Object Notation)
Stemming algorithms
Step by step guide to install dhcp role
Network essentials chapter 4
Network essentials chapter 3
Network essentials chapter 2
Network essentials - chapter 1
Python chapter 2
python chapter 1
Linux Shell Scripting

Recently uploaded (20)

PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
DOCX
Cambridge-Practice-Tests-for-IELTS-12.docx
PPTX
What’s under the hood: Parsing standardized learning content for AI
PDF
AI-driven educational solutions for real-life interventions in the Philippine...
PPTX
Introduction to pro and eukaryotes and differences.pptx
PDF
Race Reva University – Shaping Future Leaders in Artificial Intelligence
PPTX
Computer Architecture Input Output Memory.pptx
PDF
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 1).pdf
PDF
Skin Care and Cosmetic Ingredients Dictionary ( PDFDrive ).pdf
PPTX
Module on health assessment of CHN. pptx
PDF
My India Quiz Book_20210205121199924.pdf
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
PDF
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
PDF
MICROENCAPSULATION_NDDS_BPHARMACY__SEM VII_PCI .pdf
PDF
advance database management system book.pdf
PDF
English Textual Question & Ans (12th Class).pdf
PDF
semiconductor packaging in vlsi design fab
PDF
LIFE & LIVING TRILOGY - PART (3) REALITY & MYSTERY.pdf
PDF
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
FORM 1 BIOLOGY MIND MAPS and their schemes
Paper A Mock Exam 9_ Attempt review.pdf.
Cambridge-Practice-Tests-for-IELTS-12.docx
What’s under the hood: Parsing standardized learning content for AI
AI-driven educational solutions for real-life interventions in the Philippine...
Introduction to pro and eukaryotes and differences.pptx
Race Reva University – Shaping Future Leaders in Artificial Intelligence
Computer Architecture Input Output Memory.pptx
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 1).pdf
Skin Care and Cosmetic Ingredients Dictionary ( PDFDrive ).pdf
Module on health assessment of CHN. pptx
My India Quiz Book_20210205121199924.pdf
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
MICROENCAPSULATION_NDDS_BPHARMACY__SEM VII_PCI .pdf
advance database management system book.pdf
English Textual Question & Ans (12th Class).pdf
semiconductor packaging in vlsi design fab
LIFE & LIVING TRILOGY - PART (3) REALITY & MYSTERY.pdf
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...

Document type definition

  • 2. Document Tvpe Definitions (DTDs) define an XML document's structure (e.g., what elements,attributes, etc. are permitted in the document). An XML document is not required to have a corresponding DTD. However, DTDs are often recommended to ensure document conformity, especially in business-to- business (B2B) transactions, where XML documents are exchanged. DTDs specify an XML document's structure and are themselves defined using EBNF (Extended Backus-Naur Form) grammar-not the XML syntax.
  • 3. Observation: A transition is underway in the XML community from DTDs to Schema, which improve upon DTDs. Schema use XML syntax, not EBNF grammar. Parsers, Well-formed and Valid XML Documents: Parsers are generally classified as validating or nonvalidating. A validating parser is able to read the DTD and determine whether or not the XML document conforms to it. If the document conforms to the DTD, it is referred to as valid. If the document fails to conform to the DTD but is syntactically correct, it is well formed but not valid. By definition, a valid document is well formed. A nonvalidating parser is able to read the DTD, but cannot check the document against the DTD for conformity. If the document is syntactically correct, it is well formed.
  • 4. Document Type Declaration DTDs are introduced into XML documents using the document type declaration (i.e .DOCTYPE). A document type declaration is placed in the XML document's prolog and begins with <!DOCTYPE and ends with >. The document type declaration can point to declarations that are outside the XML document (called the external subset) or can contain the declaration inside the document (called internal subset). For example, an internal subset mightlook like
  • 5. <!DOCTYPE myMessage [ <!ELEMENT myMessage ( #PCDATA )> ]
  • 6. The first myMessage is the name of the document type declaration. Anything inside the square brackets ( [ ] ) constitutes the internal subset. As we will see momentarily, ELEMENT and #PCDATA are used in "element declarations.“
  • 7. External subsets physically exist in a different file that typically ends with the . Dtd extension,although this file extension is not required. External subsets are specified using either keyword SYSTEM or PUBLIC. For example. the DOCTYPE external subset might look like
  • 8. <!DOCTYPE myMessage SYSTEM "myDTD.dtd"> which points to the myDTD.dtd document. Using the PUBLIC keyword indicates that the DTD is widely used (e.g., the DTD for HTML documents). The DTD may be made available in well-known locations for more efficient downloading. The DOCTYPE
  • 9. <!DOCTYPE HTML PUBLIC "-//w3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> uses the PUBLIC keyword to reference the well-known DTD for HTML version 4.01. XML parsers that do not have a local copy of the DTD may use the URL provided to download the DTD to perform validation Both the internal and external subset may be specified at the same time. For example, the DOCTYPE
  • 10. <!DOCTYPE myMessage SYSTEM "myDTD.dtd“ <!ELEMENT myElement ( #PCDATA )> contains declarations from the myDTD.dtd document as well as an internal declaration
  • 11. Observation: The document type declaration internal subset plus its external subset form the DTD. The internal subset is visible only within the document in which it resides. Other external documents cannot be validated against it. DTDs that are used by many documents should be placed in the external subset.
  • 12. Element Type Declarations Elements are the primary building block used in XML documents and are declared in a DTD with element type declarations (ELEMENTs). For example, to declare element myMessage, we might write
  • 13. The element name (e.g., MyElement) that follows ELEMENT is often called a generic identifier. The set of parentheses that follow the element name specify the element's allowed content and is called the content specification. Keyword PCDATA specifies that the element must contain parsable character data. This data will be parsed by the XML parser, therefore any markup text (i.e., <, >, &, etc.) will be treated as markup.
  • 14. Error: Attempting to use the same element name in multiple element type declarations is an error. Example 1 lists an XML document that contains a reference to an external DTD in the I)DOCTYPE. Microsoft's XML Validator will be used to check the document's conformity against its DTD. To use XML Validator, Internet Explorer 5 is required. Parsers XML4J and
  • 15. Xerces can be used to check a document's validity against a DTD programmatically. Using Java and one of these parsers provides a platform-independent way to validate XML documents. <?xml version = "1.0"?> <!DOCTYPE myMessage SYSTEM "intro.dtd"> <myMessage> <message>Welcome to XML!</message> </myMessage> Example 1. XML document declaring associated DTD.
  • 16. The document type declaration is named myMessage-the name of the root element. The element myMessage contains a single child element named message . <!ELEMENT myMessage ( message )> <!ELEMENT message ( #PCDATA )> Example 2. Validation with using an external DTD The DTD declares element myMessage. Notice that the content specification contains the name message. This indicates that element myMessage contains exactly one child element named message. Because myMessage can only have an element as its content, it is said to have element content. Element message whose content is of type PCDATA. The XML Validator is capable of validating an XML document against both DTDs and Schemas
  • 17. Error: Having a root element name other than the name specified in the document type declaration is an error.
  • 18. Document Type Definitions (DTDs) define an XML document's structure (e.g., what elements, attributes, etc. are permitted in the XML document). An XML document is not required to have a corresponding DTD. DTDs use EBNF (Extended Backus-Naur Form) grammar
  • 19. Parsers are generally classified as validating or nonvalidating. A validating parser is able to read the DTD and determine whether or not the XML document conforms to it. If the document conforms to the DTD, it is referred to as valid. If the document fails to conform to the DTD but is syntactically correct, it is well formed but not valid. By definition, a valid document is well formed.
  • 20. A nonvalidating parser is able to read a DTD, but cannot check the document against the DTD for conformity. If the document is syntactically correct, it is well formed.
  • 21. DTDs are introduced into XML documents by using the document type declaration (i.e., DOCTYPE). The document type declaration can point to declarations that are outside the XML document (called the external subset) or can contain the declaration inside the document (called internal subset).
  • 22. External subsets physically exist in a different file that typically ends with the .dtd extension, although this file extension is not required. External Subsets are specified using keyword SYSTEM. Both the internal and external subset may be specified at the same time
  • 23. Elements are the primary building block used in XML documents and are declared in a DTD with element type declarations (ELEMENTs). The element name that follows ELEMENT is often called a generic identifier. The set of parentheses that follow the element name specify the element's allowed content and is called the content specification.
  • 24. Keyword PCDATA specifies that the element must contain parsable character data-that is,any text except the characters less-than ( < ), greater-than ( > ), ampersand ( & ), quote ( ' ) and double quote ( " ). An XML document is a standalone XML document if it does not reference an external DTD. An XML element that can only have another element for content, it is said to have element content.
  • 25. DTDs allow the document author to define the order and frequency of child elements. The comma ( , ) - called a sequence - specifies the order in which the elements must occur. Choices are specified using the pipe ( | ) character. The content specification may contain any number of pipe character separated choises.
  • 26. An element's frequency (i.e., number of occurrences) is specified by using either the plus sign (+), asterisk (*) or question mark (?) occurrence indicator
  • 27. The frequency of an element group (i.e., two or more elements that occur in some combinaition) is specified by enclosing the element names inside the content specification followed by an occurrence indicator Elements can be further refined by describing the content types they may contain. Content specification types (e.g., EMPTY, mixed content, ANY, etc.) describe nonelement content.
  • 28. An element can be declared as having mixed content (i.e., a combination of elements and PCDATA). The comma ( , ), plus sign ( + ) and question mark ( ? ) occurrence indicators cannot be used with mixed content elements