Hi momos,
here is an example of a DTD:
Code:
<!ELEMENT recipe (recipe_name, author, meal,
ingredients, directions)>
<!ELEMENT ingredients (item+)>
<!ELEMENT meal (#PCDATA, course?)>
<!ELEMENT item (#PCDATA)>
<!ATTLIST item
measure (cups|tsps|number|ozs) #REQUIRED
amount CDATA #REQUIRED>
<!ELEMENT recipe_name (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT directions (#PCDATA)>
<!ELEMENT course (#PCDATA)>
and here is an example of an XML file using the DTD:
Code:
<!DOCTYPE X SYSTEM "/dtd/recipe.dtd">
<recipe>
<recipe_name>Pasta Origino</recipe_name>
<author>Giuseppe Verdi</author>
<meal>Dinner<course>starter</course></meal>
<ingredients>
<item measure = "cups" amount = "3">Tagliatelle</item>
<item measure = "tsps" amount = "6">Tomato Puree</item>
<item measure = "ozs" amount = "8">Onions</item>
...
</ingredients>
<directions>Boil the pasta for ten minutes
...
</directions>
</recipe>
Another example DTD (tutorial.dtd):
Code:
<!ELEMENT X (A?, B+)>
<!ELEMENT A (C?, D*)>
<!ELEMENT B (C, D)>
<!ELEMENT C (#PCDATA)>
<!ELEMENT D EMPTY>
And an example valid document using the DTD:
Code:
<!DOCTYPE X SYSTEM "/dtd/tutorial.dtd">
<X>
<A>
<C>some information</C>
<D/>
</A>
<B>
<C/><D/>
</B>
</X>
Bookmarks