HiOA HiOA

DTDs and valid documents

Tor Arne Dahl, 23.08.2011

Overview

XML—repetition

Suggested solution to yesterday's exercise

reviews.xml

Schema

Different schema languages

XHTML—an XML application

DTD

Our example document

<?xml version="1.0" encoding="UTF-8"?>
<books>
   <book number="b1">
      <title>How to Build a Digital Library</title>
      <authors>
         <author>
            <first_name>Ian H.</first_name>
            <family_name>Witten</family_name>
         </author>
         <author>
            <first_name>David</first_name>
            <family_name>Bainbridge</family_name>
         </author>
      </authors>
      <year>2003</year>
      <publisher>Morgan Kaufmann Publishers</publisher>
      <isbn>1-55860-790-0</isbn>
   </book>
   <book number="b2">
      <title>Understanding Digital Libraries</title>
      <edition>2</edition>
      <authors>
         <author>
            <first_name>Michael</first_name>
            <family_name>Lesk</family_name>
         </author>
      </authors>
      <year>2005</year>
      <publisher>Morgan Kaufmann Publishers</publisher>
      <isbn>1-55860-924-5</isbn>
   </book>
</books>

A possible DTD for this document

<!ELEMENT books (book+)>
<!ELEMENT book (title, edition?, authors, year, publisher, isbn)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT edition (#PCDATA)>
<!ELEMENT authors (author+)>
<!ELEMENT author (first_name, family_name)>
<!ELEMENT first_name (#PCDATA)>
<!ELEMENT family_name (#PCDATA)>
<!ELEMENT year (#PCDATA)>
<!ELEMENT publisher (#PCDATA)>
<!ELEMENT isbn (#PCDATA)>

<!ATTLIST book number ID #REQUIRED>

Element declarations

Element declarations: Parsed character data

Element declarations: Child elements

Element declarations: Mixed content

Element declarations: Empty elements

Attribute declarations

Attribute declarations—some examples

General entities

Advanced topics

A generic XML document

1. <?xml version="1.0"?>
2. <!DOCTYPE book_reviews SYSTEM
      "http://www.jbi.hio.no/book_reviews.dtd"

3. [
      <!ENTITY part1 SYSTEM "part1.xml">
      <!ENTITY ouc "Oslo University College">
   ]>

4. <book_reviews>
      <!-- The actual document -->
   </book_reviews>

  1. XML declaration
  2. External subset
  3. Internal subset
  4. The root (or document) element

The document type declaration

Two topics from yesterday

Exercise

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Tor Arne Dahl
Tor-Arne.Dahl@hioa.no
Last modified: 22 August 2011