Learning More About XML

The examples in this document go along with our XML: The Least You Need to Know tutorial, the slides of which are on the Web at http://www.ifindkarma.com/attic/papers/xml/tutorial/

Books worth reading are:

  1. Presenting XML by Richard Light, Sams.Net, August 1997. (it has plenty more examples like the one here; you can order it from Amazon)
  2. XML: Principles, Tools, and Techniques, http://www.w3j.com/xml/, edited by Dan Connolly and Rohit Khare, O'Reilly and Associates, Autumn 1997. (you can order it from Amazon)

Papers worth reading are:

  1. X Marks the Spot: Using XML to Automate the Web by Rohit Khare and Adam Rifkin (IEEE Internet Computing, July/August 1997, Volume 1, Number 4, Pages 78-87), http://www.ifindkarma.com/attic/papers/xml/x-marks-the-spot.html
  2. Beyond HTML: XML and Automated Web Processing by Tim Bray, http://developer.netscape.com/news/viewsource/bray_xml.html
  3. The Evolution of Web Documents: The Ascent of XML by Dan Connolly, Rohit Khare and Adam Rifkin (XML special issue of the World Wide Web Journal, Autumn 1997, Volume 2, Number 4, Pages 119-128), http://www.ifindkarma.com/attic/papers/xml/ascent-of-xml.html
  4. Capturing the State of Distributed Systems with XML by Rohit Khare and Adam Rifkin (XML special issue of the World Wide Web Journal, Autumn 1997, Volume 2, Number 4, Pages 207-218), http://www.ifindkarma.com/attic/papers/xml/xml-for-archiving.html
  5. The Origin of (Document) Species by Rohit Khare and Adam Rifkin (To be presented at the WWW7 Conference in Brisbane, Australia, April 14-18, 1998), http://www.ifindkarma.com/attic/papers/www/origin-of-species.html

Also, stop by our XML Links on the Web page at http://www.ifindkarma.com/attic/local/xml.html


Memo DTD

This is the Memo DTD from chapter 13 of Richard Light's Presenting XML, Sams.Net, August 1997. You can order this book from Amazon.

<!-- Memo DTD. First declare the parameter entities: -->
<!ENTITY % common-elements "list | image | quote | anchor">
<!ENTITY % a.global "
    ID ID #IMPLIED">

<!-- The top-level memo element: -->
<!ELEMENT memo (header, links, text)>

<!-- Header information: -->
<!ELEMENT header (sender | recipient | date | main-heading | subject)*>
<!ATTLIST header %a.global;>
<!ELEMENT sender (#PCDATA)>
<!ELEMENT recipient (#PCDATA)>
<!ATTLIST recipient %a.global;>
<!ELEMENT date (#PCDATA)>
<!ATTLIST date
    %a.global;
    SORTFORM CDATA #IMPLIED>
<!ELEMENT main-heading (#PCDATA)>
<!ELEMENT subject (#PCDATA)>

<!-- Fixed GROUP and DOCUMENT elements to reference 'link farm': -->
<!ELEMENT links (memolinks)>
<!ATTLIST links
    %a.global;
    XML-LINK CDATA #FIXED "group">
<!ELEMENT memolinks EMPTY>
<!ATTLIST memolinks
    XML-LINK CDATA #FIXED "document"
    HREF CDATA #FIXED "memo-links.xml">

<!-- Elements within the text of the memo: -->
<!ELEMENT text (section | p | %common-elements;)+>
<!ATTLIST text %a.global;>
<!ELEMENT section (head?, (section | p | %common-elements;)+)>
<!ATTLIST section %a.global;>
<!ELEMENT p (#PCDATA | %common-elements;)*>
<!ATTLIST p %a.global;>
<!ELEMENT list (item)+>
<!ATTLIST list
    %a.global;
    TYPE (bullet|number|plain) "bullet">
<!ELEMENT item (#PCDATA)>
<!ATTLIST item %a.global;>
<!ELEMENT image EMPTY>
<!ATTLIST image
    %a.global;
    SRC ENTITY #REQUIRED
    DESC CDATA #IMPLIED
    ALIGN (TOP|MIDDLE|BOTTOM) "middle">
<!ELEMENT anchor (#PCDATA)>
<!ATTLIST anchor %a.global;>

<!-- Notation declarations: -->
<!NOTATION GIF SYSTEM "http://www.viewers.org/gview.exe">
<!NOTATION JPEG SYSTEM "http://www.viewers.org/jview.exe">

Link Farm

This is the Link Farm example from chapter 13 of Richard Light's Presenting XML, Sams.Net, August 1997. You can order this book from Amazon.

<!ELEMENT quotation (citation, source+)>
<!ATTLIST quotation
    XML-LINK CDATA #FIXED "extended"
    ROLE CDATA #IMPLIED
    TITLE CDATA #IMPLIED
    SHOW (EMBED|REPLACE|NEW) "REPLACE"
    ACTUATE (AUTO|USER) "USER"
    BEHAVIOR CDATA #IMPLIED>

<!ELEMENT citation EMPTY>
<!ATTLIST citation
    XML-LINK CDATA #FIXED "LOCATOR"
    ROLE CDATA #FIXED "citation"
    HREF CDATA #REQUIRED
    TITLE CDATA #IMPLIED
    SHOW (EMBED|REPLACE|NEW) "EMBED"
    ACTUATE (AUTO|USER) "AUTO"
    BEHAVIOR CDATA #IMPLIED>

<!ELEMENT source EMPTY>
<!ATTLIST source
    XML-LINK CDATA #FIXED "LOCATOR"
    ROLE CDATA #FIXED "source"
    HREF CDATA #REQUIRED
    TITLE CDATA #IMPLIED
    SHOW (EMBED|REPLACE|NEW) "REPLACE"
    ACTUATE (AUTO|USER) "USER"
    BEHAVIOR CDATA #IMPLIED>

Sample Memo Marked Up as an XML Document

This is just a simple example of a document conforming to the Memo DTD.

<?XML version="1.0"?>
<!DOCTYPE memo SYSTEM "memo.dtd">
<memo>
<header>
<sender>Adam Rifkin</sender>
<recipient>Rohit Khare</recipient>
<date sortform="19980114">January 14, 1998</date>
<main-heading>XML: The Least You Need to Know</main-heading>
</header>
<links><memolinks/></links>
<text>
<p id="p1"><anchor id="a1"></anchor>I?m almost finished with the slides.</p>
<p id="p2"><anchor id="a2"></anchor>Call me at (626) 449-4123 in an hour.</p>
</text></memo>

A Memo Style Sheet

This is the style sheet example from chapter 13 of Richard Light's Presenting XML, Sams.Net, August 1997. You can order this book from Amazon. This style sheet does not actually handle all of the parts of the Memo DTD; it simply serves as an illustration of what style sheets can do.

<!doctype style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN">

(define memo-style
  (style
    font-family-name: "Arial"))

(define para-style
  (style
    line-spacing: 13pt
    font-size: 12pt))

(define header-line-style
  (style
    line-spacing: 17pt
    font-size: 16pt))

(define heading-style
  (style
    font-size: 24pt
    line-spacing: 26pt
    quadding: 'center
    font-weight: 'bold))

(define (para-with-prefix prefix)
  (make paragraph
    use: header-line-style
    (make line-field
      field-width: 50pt
      (literal prefix))
    (process-children-trim)))

(default (process-children-trim))

(element MEMO
  (make sequence
    use: memo-style
    (process-children-trim)))

(element P
  (make paragraph
    use: para-style
    space-before: 10pt))

(element main-heading
  (make paragraph
    use: heading-style
    space-before: 20pt))

(element sender
  (para-with-prefix "From:"))

(element recipient
  (para-with-prefix "To:"))

(element date
  (para-with-prefix "Date:"))

(element sender
  (para-with-prefix "From:"))

(element recipient
  (para-with-prefix "To:"))

(element date
  (para-with-prefix "Date:"))

(element links (empty-sosofo))

(element anchor
  (make paragraph
    (literal "[fragment of original message was here]")))

Rohit Khare and Adam Rifkin.

Last modified: Thu Jan 15 17:40:35 PST 1998