Document Type Definition (DTD) : Author: Lukasz Kurgan
Document Type Definition (DTD) : Author: Lukasz Kurgan
What is DTD?
• DTD defines:
– a structure of the XML document
– a list of legal elements of the XML document
DTD by Lukasz Kurgan
Attributes provide extra information about <img src="computer.gif" /> <note att=“abc.xml" />
elements
Entities variables used to define common & " '
text
PCDATA PCDATA means parsed character data. PCDATA is text that will be parsed by a
parser. Tags inside the text will be treated as markup and entities will be expanded.
CDATA 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 by Lukasz Kurgan
– Elements name cannot include <> characters and must start with
letter or underscore
– Elements name can include namespace declaration:
Namespace:element-name
DTD by Lukasz Kurgan
value explanation
attribute-type CDATA character data
(eval|eval|..) enumerated value
ID unique id
NMTOKEN valid XML name
default-value #DEFAULT value default value
#REQUIRED must be included in the element
#IMPLIED does not have to be included
#FIXED value value is fixed
DTD by Lukasz Kurgan
XML example:
<square width="100"></square>
DTD by Lukasz Kurgan
Entities in DTD
Example:
In DTD:
<!ENTITY writer “Robert Eckstein">
<!ENTITY copyright “©”>
In XML:
<author>©right; &writer;</author>
DTD by Lukasz Kurgan
Example:
In DTD:
<!ENTITY article SYSTEM “http://www.articles.com/DTD.xml">
In XML:
<articles_xml>
<heading>Article from www.articles.com</heading>
&article;
</articles_xml>
DTD by Lukasz Kurgan
HTML=XML+DTD+XSL
BROWSER
HTML page
returned
DTD by Lukasz Kurgan
“Bigger” Example
<?xml version="1.0" standalone="no"?>
<!DOCTYPE MLBibliographies SYSTEM "default.dtd">
<MLBibliographies>
<PageTitle>Machine Learning Bibliographies</PageTitle>
<PageSubTitle>Maintained by Lukasz Kurgan</PageSubTitle>
<Category href="FeatureSelection.xml"> 1. Feature Selection</Category>
<Category href="RuleInduction.xml"> 2. Rule Induction</Category>
<Category href=""> 3. Discretization</Category>
<Category href=""> 4. Learning Ensemble of Classifiers</Category>
<LastUpdate> 09/11/01</LastUpdate>
</MLBibliographies>
DTD document
<!ELEMENT MLBibliographies (PageTitle, PageSubTitle, Category*, LastUpdate, Publication*)>
<!ELEMENT PageTitle (#PCDATA)>
<!ELEMENT PageSubTitle (#PCDATA)>
<!ELEMENT Category (#PCDATA)>
<!ELEMENT LastUpdate (#PCDATA)>
<!ATTLIST Category href CDATA #IMPLIED>
DTD by Lukasz Kurgan
Links
Demo:
http://isl1.cudenver.edu/default.dtd
Simple Tutorial:
http://www.xml101.com/dtd/dtd_intro.asp
My Impressions
• XML = extremely syntax sensitive
– good thing that assures unification and accessibility of the
knowledge on the net