<!-- /* Font Definitions */ @font-face {font-family:Courier; panose-1:2 7 4 9 2 2 5 2 4 4; mso-font-alt:"Courier New"; mso-font-charset:0; mso-generic-font-family:modern; mso-font-format:other; mso-font-pitch:fixed; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体;} @page Section1 {size:595.3pt 841.9pt; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} -->
Section 3. Validating a document
Xml document will be parsed as a DOM document or a SAX stream. (What is DOM and SAX stream? We will tell it later)
The parse will also check the structure of document against DTD or schema if it has been configured to do so. It also will create error handler.
--Error Handler will look for it later.
Section 4. DTD(Document Type Definition)
External DTDs
<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
--<!DOCTYPE : tell the processor it is DOCTYPE declaration.
--html: indicates that the name of the root element for the document. If the document started anything but <html>, it would immediately be deemed invalid.
--PUBLIC : designate a publicly recognized DTD, potentially saving the processor a trip to the server to retrieve it. (What’s meaning?) Other option is SYSTEM.
-- -//W3C//DTD HTML 4.01 Transitional//EN: The actual public identifier for the Transitional XHTML DTD.
For custom DTDs, developers typically use a SYSTEM identifier, such as:
<!DOCTYPE memories SYSTEM "http://www.nicholaschase.com/memories.dtd">
Structure of an internal DTD
Variable element content
With a pipe character (|), meaning the data structure contains an element named location that may contain either a place element or a description element. With a pipe character(|) for choicing.
<!ELEMENT location (place | description) >
Modifiers (*, +, and ?)
--*: means an element can appear 0 or more times
--+: means an element can appear 1 or more times.
--?: means an element can appear 0 or 1 time.
For example:
<!DOCTYPE memories[
<!ELEMENT memories (memory*)> --memories can have 0 or more memory
<!ELEMENT memory (media,
subdate,
donor?, --0 or 1 donor
subject+, --1 or more subject
location)>
<!ELEMENT subdate (#PCDATA)>
<!ELEMENT donor (#PCDATA)>
<!ELEMENT subject (#PCDATA)>
<!ELEMENT location (place |
description)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT place (#PCDATA)>
<!ELEMENT media EMPTY>
]>
“?” means 0 or 1. But cannot insert donor element in memory parent. (WHY?)