Showing posts with label DTD. Show all posts
Showing posts with label DTD. Show all posts

Friday, October 27, 2006

DTD

The purpose of a DTD is to describe the building blocks of an XML document, you can declare a DTD inline in your XML document or you can create an external file and reference to that from your XML document.

The DTD should be located just after the XML declaration, if you use an external DTD the reference is likewise after the XML declaration.

Example of an external DTD reference
<!DOCTYPE book SYSTEM "book.dtd">

Example of an internal DTD
<!DOCTYPE book [
<!ELEMENT book (title, author)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
]>
<book>
<title>James goes to hollywood</title>
<author>Sam Jones</author>
</book>

Saturday, October 21, 2006

Valid

A XML document is valid when it
  • conforms to a DTD or a XML Schema
  • is well-formed