Lecture 11b: XML and Markup Languages

What You Will Learn Today

  1. Compare markup languages.
  2. Create document type definitions.
  3. Create XML DTDs and documents.
  4. Convert HTML documents to XHTML format.

Markup Languages

Document Type Definitions (DTDs)

XML

XML Example

Create your own book DTD.

<!ELEMENT book (author, title, publisher, year)>
<!ELEMENT author (lastname, firstname, middlename?)>
<!ELEMENT lastname (#PCDATA)>
<!ELEMENT firstname (#PCDATA)>
<!ELEMENT middlename (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT publisher (#PCDATA)>
<!ELEMENT year length CDATA "4">

Use your book DTD to mark up book documents.

<?xml version="1.0" encoding="UTF-8"?>

<book>
  <author><lastname>Hofstetter</lastname><firstname>Fred</firstname></author>
  <title>Internet Literacy</title>
  <publisher>McGraw Hill</publisher>
  <year>1998</year>
</book>

XHTML

Converting from HTML to XHTML

To Do After Class