XML, the Perl Way

Home XML::Twig Modules Talks Articles Tutorials Reports Tools PGC mirod Le Blog print
Processing XML with Perl Michel Rodriguez

What can you do with XML

More on the XML recommendation (cont'd)

More on the XML recommendation

Document Type Definitions

A Document Type Definition (DTD) is a way to constraint XML documents of a specific class.

XML is really a meta-language: through the use of DTD's it allows designers to define syntax rules. Documents (a.k.a. instances) can be checked for its conformance to a DTD.

A DTD-less XML instance is said to be well-formed, an XML document that is conformant to a DTD is said to be valid.

The DTD for the wine document:

<!ELEMENT catalog    (class+)>
<!ELEMENT class      (category+)>
<!ATTLIST class      name (red | white | rose) #IMPLIED>
<!ELEMENT category   (item+)>
<!ATTLIST category   name CDATA #REQUIRED>
<!ELEMENT item (winery, type, year, rating, stock, price)>
<!ELEMENT winery     (#PCDATA)>
<!ELEMENT type       (#PCDATA)>
<!ELEMENT year       (#PCDATA)>
<!ELEMENT rating     (#PCDATA)>
<!ELEMENT stock      (#PCDATA)>
<!ELEMENT price      (#PCDATA)>
<!ATTLIST price      currency CDATA #REQUIRED>


What can you do with XML

More on the XML recommendation (cont'd)