XML Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 4.00

DOCTYPE - Document Type Declaration Statement

This section describes syntax formats of the DOCTYPE statement, which is used to declare that this XML document has been linked to DTD document type with the specified root element name.

DOCTYPE is a DTD statement included in an XML file to declare that this XML document has been linked to DTD document type and to specify the name of the root element of this XML document.

Valid syntax formats for DOCTYPE statement are:

<!DOCTYPE root_element [
   internal_DTD_statements
]>

<!DOCTYPE root_element SYSTEM "DTD_location">

<!DOCTYPE root_element SYSTEM "DTD_location" [
   internal_DTD_statements
]>

<!DOCTYPE root_element PUBLIC "DTD_name" "DTD_location">

<!DOCTYPE root_element PUBLIC "DTD_name" "DTD_location"
   internal_DTD_statements
]>

General rules about the DOCTYPE statement:

  • It must appear right after the "xml" processing instruction and before the root element.
  • "root_element" names the root element of the XML document.
  • Key word "SYSTEM" indicates that the external DTD file specified as "DTD_location" is private.
  • Key word "PUBLIC" indicates that the external DTD file specified as "DTD_location" is public.
  • "DTD_location" is a URL of the external DTD file.
  • "DTD_name" is a publicly recognized name of a specific DTD file, like "-//W3C//DTD HTML 4.0 Transitional//EN".
  • If an internal DTD statement is conflicting with an external statement, the internal statement takes precedence.

Table of Contents

 About This Book

 Introduction of XML (eXtensible Markup Language)

 XML File Syntax

 XML File Browsers

 DOM (Document Object Model) Programming Interface

 SAX (Simple API for XML) Programming Interface

 DTD (Document Type Definition) Introduction

Syntaxes of DTD Statements

DOCTYPE - Document Type Declaration Statement

 ELEMENT - Element Declaration Statement

 ATTLIST - Attribute List Declaration Statement

 ENTITY - Entity Declaration Statement

 dictionary_dtd.xml - XML DTD Document Type Example

 Validating an XML Document against the Specified DTD Document Type

 XSD (XML Schema Definition) Introduction

 Syntaxes of XSD Statements

 Validating an XML Document against the Specified XML Schema

 XSL (Extensible Stylesheet Language) Introduction

 XSLT (XSL Transformations) Introduction

 Java Implementation of XSLT

 XPath (XML Path) Language

 XSLT Elements as Programming Statements

 Control and Generate XML Element in the Result

 References

 Printable Copy - PDF Version

Dr. Herong Yang, updated in 2009
DOCTYPE - Document Type Declaration Statement