XML DTD Basics for Developers
XML DTD Basics for Developers
Your computer may not hav e enough memory to open the image, or the image may hav e been corrupted. Restart y our computer, and then open the file again. If the red x still appears, y ou may hav e to delete the image and then insert it again.
What is DTD?
• DTD defines:
– a structure of the XML document
– a list of legal elements of the XML document
The image cannot be display ed. Your computer may not hav e enough memory to open the image, or the image may hav e been corrupted. Restart y our computer, and then open the file again. If the red x still appears, y ou may hav e to delete the image and then insert it again.
Attributes provide extra information about <img src="computer.gif" /> <note att=“abc.xml" />
elements
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.
The image cannot be display ed. Your computer may not hav e enough memory to open the image, or the image may hav e been corrupted. Restart y our computer, and then open the file again. If the red x still appears, y ou may hav e to delete the image and then insert it again.
– Elements name cannot include <> characters and must start with
letter or underscore
– Elements name can include namespace declaration:
Namespace:element-name
The image cannot be display ed. Your computer may not hav e enough memory to open the image, or the image may hav e been corrupted. Restart y our computer, and then open the file again. If the red x still appears, y ou may hav e to delete the image and then insert it again.
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
XML example:
<square width="100"></square>
The image cannot be display ed. Your computer may not hav e enough memory to open the image, or the image may hav e been corrupted. Restart y our computer, and then open the file again. If the red x still appears, y ou may hav e to delete the image and then insert it again.
Entities in DTD
Example:
In DTD:
<!ENTITY writer “Robert Eckstein">
<!ENTITY copyright “©”>
In XML:
<author>©right; &writer;</author>
The image cannot be display ed. Your computer may not hav e enough memory to open the image, or the image may hav e been corrupted. Restart y our computer, and then open the file again. If the red x still appears, y ou may hav e to delete the image and then insert it again.
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>
The image cannot be display ed. Your computer may not hav e enough memory to open the image, or the image may hav e been corrupted. Restart y our computer, and then open the file again. If the red x still appears, y ou may hav e to delete the image and then insert it again.
HTML=XML+DTD+XSL
BROWSER
HTML page
returned
The image cannot be display ed. Your computer may not hav e enough memory to open the image, or the image may hav e been corrupted. Restart y our computer, and then open the file again. If the red x still appears, y ou may hav e to delete the image and then insert it again.
“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>
The image cannot be display ed. Your computer may not hav e enough memory to open the image, or the image may hav e been corrupted. Restart y our computer, and then open the file again. If the red x still appears, y ou may hav e to delete the image and then insert it again.