<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="../../../_utils/schema/yaps.rnc" type="application/relax-ng-compact-syntax"?>
<?xml-model href="../../../_utils/schema/yaps.isosch" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<?xml-stylesheet type="text/css" href="../../../_utils/stylesheets/yaps-tei.css"?>
<!-- $Id: xml_newIntro.xml 51709 2026-05-28 23:29:13Z syd $ -->
<TEI xmlns="http://www.wwp.northeastern.edu/ns/yaps" version="5.0">
  <teiHeader>
    <fileDesc>
      <titleStmt>
        <title>An Introduction to XML</title>
        <author>Julia Flanders and Syd Bauman</author>
      </titleStmt>
      <editionStmt>
        <edition>WWP Encoder Training, Fall 2024</edition>
      </editionStmt>
      <publicationStmt>
        <distributor>Women Writers Project (via website)</distributor>
        <address>
          <addrLine>url:mailto:wwp@northeastern.edu</addrLine>
        </address>
        <date when="2024-09-30"/>
        <availability status="restricted">
          <p>Copyright 2011 Syd Bauman, Julia Flanders, and WWP</p>
          <p>This TEI-encoded XML file is available under the terms of the <ref
              target="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons
              Attribution-ShareAlike 3.0 (Unported)</ref> license.</p>
        </availability>
        <pubPlace>Boston, MA  USA</pubPlace>
      </publicationStmt>
      <sourceDesc>
        <p>Basic introduction to XML, covers all the essentials.</p>
      </sourceDesc>
    </fileDesc>
    <revisionDesc>
      <change who="#sbauman.emt" when="2024-09-30">Copied over changes from <name type="file">xml_newIntro_sans_pointers.xml</name> except for the removal of the discussion of pointers.</change>
      <change who="#sbauman.emt" when="2023-07-17">Changed to use <gi>egMarkup</gi>. Sadly did not leave myself time to change Matt Damon to Art Linkletter. Sigh.</change>
      <change who="#sbauman.emt" when="2021-10-08">Changed element02.odg and attribute02.odg
      (and exported PNGs) to use Matt Damon instead of Anne Sexton.</change>
      <change who="#sbauman.emt" when="2015-11-08">Use element02.png and attribute02.png diagrams
        (Anne Sexton) instead of originals (Arthur Garfunkel).</change>
      <change who="personography.xml#sstanley.fxj" when="2015-10-12">Added some tutorials.</change>
      <change who="#sbauman.emt" when="2013-02-21"> Split last "practice validation" slide into 2,
        adding schema frag </change>
      <change who="#jflanders.lfw" when="2012-02-17"/>
      <change who="#jflanders.lfw" when="2011-09-26">Created by building on xml_minimal.xml</change>
    </revisionDesc>
  </teiHeader>
  <text>
    <presentation>
      <abstract>
        <p>This tutorial outlines the fundamental rules of XML, what XML is, and how it relates to
          the TEI. This tutorial will also explain why your project may want to use XML, as opposed
          to some other type of markup system.</p>
      </abstract>
      <section xml:id="so">
        <head>Structure?</head>
        <slide>
          <table>
            <row>
              <cell rend="css(width: 33%; padding-right: 2em;)">
                <figure>
                  <graphic url="../../../_utils/gfx/toolbox_simple.jpg" width="100%"/>
                </figure>
              </cell>
              <cell rend="css(width: 33%; padding-right: 2em;)">
                <figure>
                  <graphic url="../../../_utils/gfx/toolbox_disorganized.jpg" width="100%"/>
                </figure>
              </cell>
              <cell rend="css(width: 33%; padding-right: 0em;)">
                <figure>
                  <graphic url="../../../_utils/gfx/toolbox_complex.gif" width="100%"/>
                </figure>
              </cell>
            </row>
          </table>
        </slide>
        <lectureNote>
          <p>A good place to start in understanding XML—what it is and why it's important—is to
            think about how it as a way of structuring or organizing information. </p>
          <p>Structure is what makes digital information useful to us: it helps us find things, it
            helps us identify them and understand what they are, and it helps us communicate about
            them to other people. We can think of the difference between structured and unstructured
            information as being similar to the difference between different approaches to
            organizing your tools (or anything else you organize)</p>
          <p>In the first image, the only structure is the outer container; essentially, that
            toolbox only lets us say "it's in there somewhere..." but doesn't give us a way of
            predicting exactly where something will be, or grouping similar or related things
            together.</p>
          <p>In that middle image, there is a bit more structure: the toolbox has compartments to
            group things together. But the groupings here are not very rigorous (at least to my eye)
            and might not be very precise as a way of finding what you need. </p>
          <p>On the right we have the logical extreme: every tool has a very specific location;
            similar tools are grouped together. You can instantly see if something is missing. If
            you had a team of workers who all used this same toolbox, they could trade boxes and
            still be able to find things with their eyes closed. </p>
          <p>It's important to note that we're not claiming here that it's always useful to have as
            much structure as possible. Sometimes the first or second toolbox is exactly what you
            want: just a big container to hold things together. The question we're going to explore
            in this class is, how much structure is useful? and how do we represent it?</p>
        </lectureNote>
        <tutorial>
          <p>One way to understand what XML is and why it is important is to think about it as a way
            of structuring or organizing information.</p>
          <p>Structure is what makes digital information useful to us; it helps us find things, it
            helps us identify them and understand what they are, and it helps us communicate about
            them to other people. We can think of the difference between structured and unstructured
            information as being similar to the difference between different approaches to
            organizing your tools (or anything else you organize).</p>
          <p>In the first image, the only structure is the outer container; essentially, that
            toolbox only lets us say, "it's in there somewhere..." However, it doesn't give us a way
            of predicting exactly where something will be, or grouping similar or related things
            together.</p>
          <p>In the middle image, there is a bit more structure; the toolbox has compartments to
            group things together. But the groupings here are not very rigorous, and might not be
            the most efficient way of finding what you need.</p>
          <p>On the right we have the logical extreme. Every tool has a very specific location, and
            similar tools are grouped together. You can instantly see if something is missing. If
            you had a team of workers who all used this same toolbox, they could trade boxes and
            still be able to find things with their eyes closed.</p>
          <p>It's important to note that we're not claiming here that it's always useful to have as
            much structure as possible. Sometimes the first or second toolbox is exactly what you
            want: just a big container to hold things together. The question we're going to explore
            in this tutorial is, how much structure is useful? and how do we represent it?</p>
        </tutorial>
      </section>

      <section>
        <head>XML Structures the World</head>
        <slide>
          <figure>
            <graphic url="../../../_utils/gfx/xml_structures.png" height="100%"/>
          </figure>
        </slide>
        <lectureNote>
          <p>XML provides a very specific way of structuring information and of looking at the
            world. It asks us to identify individual pieces of information that we are interested in
            (by naming them), and it asks us to group them together. We can represent these
            groupings in various different visual ways: <list>
              <item>As a set of nested boxes, where the groupings are carried out by physical
                placement; if you've ever packed a camper, or if you're a collector of tiny objects,
                this approach will be familiar and appealing to you. The resulting structure of
                boxes represents the structure of the collection of objects, whatever they
                are.</item>
              <item>As a tree, where the groupings are represented by branchings; this is very much
                analogous to the idea of a family tree, where each individual is grouped with
                siblings under their common parents, and so forth; the tree structure represents the
                structure of an entire ancestry</item>
              <item>For purposes of actually editing the XML, we usually find it most useful to use
                the notation on the right, which represents the XML <soCalled>tree</soCalled> or
                  <soCalled>boxes</soCalled> using a system of <term>tags</term> that mark the
                boundaries of the boxes and the structural groupings that make up the informational
                system. Each <soCalled>box</soCalled> or tree node (or <term>element</term> in XML
                parlance) is represented by a pair of tags that mark its beginning and its end, and
                these elements can be nested inside one another.</item>
            </list>
          </p>
        </lectureNote>
        <tutorial>
          <p>XML provides a very specific way of structuring information and of looking at the
            world. It asks us to identify pieces of information that we are interested in, and it
            asks us to group them together. We can represent these groupings in various different
            visual ways, all of which represent the same thing—XML's structure. The first useful
            metaphor is that of a set of nested boxes, like in the example on the left. These boxes
            always nest perfectly within each other, and do not overlap. You can also think about
            the structure of XML as being like a tree, as in the middle example. Each XML document
            is a complete tree, and each XML element is like a branch of that tree. The example on
            the right shows XML as it is written, using a system of tags that mark the boundaries of
            the boxes and the structural groupings that make up the informational system. Each box
            or tree node (or element in XML parlance) is represented by a pair of tags that mark its
            beginning and its end, and these elements can be nested inside one another.</p>
        </tutorial>
      </section>

      <section>
        <head>XML and TEI</head>
        <slide>
          <figure>
            <graphic url="../../../_utils/gfx/xml_tei_html_toolbox.png" height="100%"/>
            <figDesc>Image showing two different toolboxes with labels for tools</figDesc>
          </figure>
        </slide>
        <lectureNote>
          <p>So what's the relationship between XML and TEI? This is where things get slightly
            tricky...</p>
          <p>Let's start with TEI: TEI is an encoding language: a language for describing the
            structure of documents. We can think of the TEI as being like the language we use to
            label the slots in our toolbox: TEI provides us with terms like "paragraph" and
            "heading" and defines what they mean. We can think of TEI as being analogous to a
            specific toolbox: one that groups together all of the different chisels and names them
            in a specific way, and separates the chisels from the hammers.</p>
          <p>There are lots of encoding languages: another one is HTML. HTML also gives us terms for
            labeling things, although it has a much smaller vocabulary than the TEI. We could think
            of HTML as being analogous to a simpler toolbox, one with fewer, more generic slots;
            instead of having different size slots for each different kind of chisel, it just has a
            bunch of more generic bins. </p>
          <p>So: TEI and HTML are encoding languages. What is XML? XML is the mechanism for
              <emph>defining</emph> encoding languages. In the context of our toolbox metaphor, XML
            is the stuff you make toolboxes and labels out of. It doesn't determine how many little
            slots your toolbox has, or what you call them, but it says "you have to have a box and
            any little slots inside it have to have labels". It provides a general mechanism for
            representing data structures.</p>
          <p>Another (more accurate) way of putting this is to say that XML is a metalanguage, while
            TEI and HTML are languages.</p>
          <p>A language has a vocabulary and a grammar: the vocabulary tells you what words exist in
            the language, and the grammar tells you how they may be used. In learning the TEI, we're
            going to learn a specific encoding language: we're going to learn a lot of its
            vocabulary and grammar rules: what things you can "say" in TEI, what information
            structures you can describe, what kinds of slots there are in the toolbox.</p>
          <p>A meta-language provides the mechanism for defining words and grammatical structures.
            We aren't going to talk about this mechanism directly, but if you're curious we can tell
            you more about it over lunch. At a simpler level, the XML meta-language also gives us
            the notation for writing in text encoding languages, and that is what we are going to
            look at next. </p>
          <p>[Pause and make sure everyone is clear so far...]</p>
        </lectureNote>
        <tutorial>
          <p>So what exactly is the relationship between XML and the TEI?</p>
          <p>The TEI is an encoding language, specifically a language meant to describe documents.
            The TEI provides us with terms like <q>paragraph</q> and <q>heading</q>, and defines
            what these terms mean. Taking the example from the slide, we can think of the TEI as
            being the vocabulary we use to label the different tools in our toolbox. We can think of
            TEI as being analogous to a specific toolbox: one that groups together all of the
            different chisels and names them in a specific way, and separates the chisels from the
            hammers.</p>
          <p>There are lots of encoding languages, such as HTML (hypertext markup language), MML
            (music markup language), or MathML. We'll use HTML as our example, since it is the most
            commonly-used. Like TEI, HTML also gives us terms for labeling things, although it has a
            much smaller vocabulary than the TEI. We could think of HTML as being analogous to a
            simpler toolbox, one with fewer, more generic slots; instead of having different size
            slots for each different kind of chisel, it just has a bunch of more generic bins.</p>
          <p>So if TEI and HTML are encoding languages, what, then, is XML? XML is our mechanism for
            defining encoding languages. In the context of our toolbox metaphor, XML makes up the
            materials that allow us to construct toolboxes and create labels. Think of it as the
            boxes and markers and stickers that allow you to create an organizational system. It
            doesn't determine how many little slots your toolbox has, or what you call them, but it
            says <said>you must have a box, and any little slots inside it must have labels.</said>
            It provides a general mechanism for representing data structures.</p>
          <p>Another way to describe this relationship is to say, where TEI and HTML are languages,
            XML is a metalanguage. A language has a vocabulary and grammar; the vocabulary tells you
            what words exist in the language, and the grammar tells you how they may be used. As we
            learn the TEI, we're going to learn a lot of its vocabulary and grammar rules; these are
            all specific to the encoding language. </p>
          <p>XML, as a metalanguage, provides the mechanisms for defining the grammatical structures
          of all encoding languages, including TEI. Also important for this tutorial is that XML
          provides the notation (syntax) for writing in text encoding languages. XML's notation
          allows us to distinguish between the content we encode and
          the markup itself.</p>
        </tutorial>
      </section>

      <section>
        <head>How do XML and the TEI fit in?</head>
        <slide>
          <figure>
            <graphic width="100%" url="../../../_utils/gfx/concept_syntax_language.png"/>
          </figure>
        </slide>
        <lectureNote>
          <p>So this is a workshop about modeling and representation, but it's also a seminar about
            TEI, and you've heard the term <term>XML</term> uttered as well: how do these pieces
            relate to one another?</p>
          <p>In text encoding, the concepts that underlie our modeling all come from us: from our
            minds, from culture, etc.</p>
          <p>XML specifies a syntax for text encoding: a way of distinguishing the markup from the
            content</p>
          <p>TEI provides the specifics of the actual text encoding language: the controlled
            vocabulary of terms (like <term>note</term>) that we will use in marking up the text</p>
          <p>We'll be talking about each of these things in more detail over the rest of the morning
            and over the next few days.</p>
        </lectureNote>
        <tutorial>
          <p>We've already discussed how XML is a metalanguage that allows us to define the grammar
            and vocabulary of the TEI, but now we're going to discuss in more detail how these
            pieces relate to each other.</p>
          <p>In text encoding, all of the concepts that underlie our modelling come from us: our
            disciplines, theoretical frameworks, culture, etc.</p>
          <p>XML defines a syntax for text encoding. It is a method for distinguishing our markup
            from the content that we are marking up.</p>
          <p>The TEI provides the specifics of the actual encoding language. It translates our
            concepts into XML, and provides a controlled vocabulary that we use in marking up the
            text.</p>
        </tutorial>
      </section>

      <section>
        <head>XML: More Detail</head>
        <slide>
          <p>Important things about XML: <list>
              <item>International standard, non-proprietary</item>
              <item>Expressed in plain text</item>
              <item>Hardware and software independent</item>
            </list>
          </p>
        </slide>
        <lectureNote>
          <p>Step back for a moment and look at the big picture: <list>
              <item>We're trying to structure our data, represent information structures that matter
                to us</item>
              <item>We could do this in many different ways; in a sense, using styles in MS word is
                a kind of <soCalled>information structure</soCalled></item>
              <item>What's distinctive about XML?</item>
            </list>
          </p>
          <p>A number of important things about XML: <list>
              <item>XML is an international standard, non-proprietary: this means that no one owns
                the standard</item>
              <item>XML is expressed in plain text, which means that it's intelligible to humans
                even if you don't have an XML-specific piece of software to read it with. (This
                means that the information it contains has a longer life: we can read and understand
                it even if we can't process it.)</item>
              <item>XML is hardware and software independent: XML data can be read and processed by
                a huge variety of tools on any hardware platform.</item>
            </list>
          </p>
        </lectureNote>
        <tutorial>
          <p>Let's take a minute to step back and look at the big picture.</p>
          <p>What we're trying to do is structure our data and represent information structures that
            matter to us. There are many different ways that we could do this, so what is so
            distinctive about XML?</p>
          <p>First of all, XML is an international standard, which makes it easy to share your data.
            It is also non-proprietary, which means that no one owns this standard. Another benefit
            of XML is that it is expressed in plain text, which makes it easily human-readable.
            Finally, it is hardware and software independent, so it can be processed by a variety of
            tools on any hardware platform. This means that it is not tied to one specific program
            or application. This is especially important to the longevity of your data (basically,
            it will be useful even if the specific application you use becomes outdated).</p>
        </tutorial>
      </section>

      <section>
        <head>XML Elements</head>
        <slide>
          <p>Text is divided into <term>elements</term> (the <soCalled>nouns</soCalled> of the
            encoding — <term>content objects</term>).</p>
          <list>
            <item>elements by <term>start-tags</term> and <term>end-tags</term><eg><hi
                  rend="class(current)">&lt;heading&gt;</hi><![CDATA[Wines]]><hi
                  rend="class(current)">&lt;/heading&gt;</hi></eg></item>
            <item>start-tags by <code>&lt; … &gt;</code><eg><hi rend="class(current)"
                  >&lt;</hi><![CDATA[heading]]><hi rend="class(current)">&gt;</hi></eg></item>
            <item>end-tags by <code>&lt;/ … &gt;</code><eg><hi rend="class(current)"
                  >&lt;/</hi><![CDATA[heading]]><hi rend="class(current)">&gt;</hi></eg></item>
            <item>special case: short-hand for an element with no content<eg><hi
                  rend="class(current)">&lt;</hi><![CDATA[anchor]]><hi rend="class(current)"
                  >/&gt;</hi><![CDATA[ = <anchor></anchor>]]></eg></item>
          </list>
          <figure rend="centered">
            <graphic url="../../../_utils/gfx/element02.png" width="50%"/>
          </figure>
        </slide>
        <lectureNote>
          <p>An XML element is like a slot in a toolbox, or a box in your attic, or field in your
            database: it's a thing that identifies and labels a piece of information that you want
            to know about.</p>
          <p>In the toolbox, we mark the boundaries with pieces of wood (or plastic or whatever) so
            that things stay put</p>
          <p>In XML, we mark the boundaries with things called <term>tags</term>, and these also
            serve as a label, a way of giving the name for the element.</p>
          <p>Since we've said that what we're looking at here is a language, we can also think of
            elements as being like the nouns in our language: the things we want to name and talk
            about.</p>
        </lectureNote>
        <tutorial>
          <p>An XML element is like a slot in a toolbox, or a box in your attic, or field in your
            database. It's a thing that identifies and labels a piece of information that you want
            to know about. In the toolbox, we mark the boundaries of the things we're trying to
            organize, so that everything stays in place.</p>
          <p>In XML, we mark the boundaries of elements with things called tags. These also serve as
            a label for the element. We should also note that tags in XML are not just important for
            us as readers (serving as human-readable labels for the features we choose to mark). XML
            tags are also important for the processor. The brackets and the forward-slashes serve to
            delimit the element, and allow the processor to differentiate elements from the content.
            Take a minute to look over the way that we notate start tags, end tags, and empty
            elements.</p>
          <p>Since we've said that what we're looking at here is a language, we can also think of
            elements as being like the nouns in our language: the things we want to name and talk
            about.</p>
        </tutorial>
      </section>

      <section>
        <head>Example Elements</head>
        <slide>
          <p>
            <egMarkup scheme="TEI"><name>Virginia Cole</name></egMarkup>
            <egMarkup scheme="TEI"><p>Call me Ishmael. Some years ago—never mind how
long precisely —having little or no money in my purse,
and nothing particular to interest me on shore … </p></egMarkup>
            <egMarkup scheme="TEI"><l>To be or not to be, that is the question</l>
<l>Whether 'tis nobler in the mind to suffer</l>
<l>the slings and arrows of outrageous fortune</l></egMarkup>
            <egMarkup scheme="TEI"><p>Owl lived at The Chustnuts, an old-world residence
<lb/>of great charm, which was grander than anybody
<lb/>else's, or seemed so to Bear, because it had both a
<lb/>knocker <emph>and</emph> a bell-pull … </p></egMarkup>
          </p>
        </slide>
        <tutorial>
          <p>Take a minute to look over these sample passages, and acquaint yourself with what
            elements look like, and how they are used. If it's useful for you, try to figure out:
            how many elements are in each example? how many tags? This will help to acquaint you
            with XML's syntax. Additionally, this will help you understand the difference between an
            element and a tag.</p>
        </tutorial>
      </section>

      <section>
        <head>XML Attributes</head>
        <slide>
          <figure>
            <graphic url="../../../_utils/gfx/attribute02.png" width="50%"/>
          </figure>
          <list>
            <item>any number of attributes can be specified on a given start- (or empty-) tag</item>
            <item>but <emph>only one</emph> with a given name!</item>
            <item>order does not matter</item>
            <item>whitespace can be adjusted to make it look good to humans</item>
          </list>
        </slide>
        <lectureNote>
          <p>An XML attribute is like an adjective: it modifies an element, just as an adjective
            modifies a noun, provides more information about it. Attributes are a bit more detailed
            than adjectives: they tell you what aspect of the element they're describing, like its
            type, or its size, or its color (the name of the attribute) along with the specific
            descriptor within that category of information (the attribute value). </p>
          <p>So: just to get the hang of this: give me a noun... then give me an adjective... now
            translate this into an element with an attribute</p>
        </lectureNote>
        <tutorial>
          <p>An XML attribute is like an adjective to the element's noun, in that it modifies an
            element. However, attributes are a bit more detailed than adjectives. They tell you what
            aspect of the element they're describing, like its type, or its size, or its color (the
            name of the attribute) and the specific descriptor within that category of information
            (the attribute value).</p>
          <p>Once again, the rules of XML are at play here. XML specifies that the attribute name
            must be separated by whitespace from the element name (or other attributes), and it must
            be followed by an equal sign, and the attribute value must be in quotes.</p>
          <p>It is also important to note that you can have more than one attribute on a given
            element (we often use more than one adjective for a noun!), but we cannot repeat a given
            attribute more than once (so you can't have two <att>type</att> attributes on name). The
            order of the attributes does not matter.</p>
          <p>To practice the notation of attributes, try creating a <gi>person</gi> element for
            yourself that describes things like, your occupation, your alma mater, your hairstyle,
            your gender, or your place of birth.</p>
          <p>For example, you may put
            <![CDATA[<person job="musician" alma-mater="queens college" dob="1941-10-13">Paul Simon</person>]]></p>
        </tutorial>
      </section>

      <section>
        <head>Anatomy of an Element</head>
        <slide>
          <figure>
            <graphic url="../../../_utils/gfx/anatomy-element.png" width="100%"/>
          </figure>
        </slide>
        <tutorial>
          <p>Take a minute here to look over the anatomy of an element as a whole. The vocabulary
            here is pretty important, and it's useful to get the hang of it early on. Also, feel
            free to bookmark this slide and come back to it later, if you need a refresher!</p>
        </tutorial>
      </section>

      <section>
        <head>XML in Detail</head>
        <slide>
          <egMarkup scheme="TEI">
            <div type="poem" n="18">
              <head>Sonnet 18</head>
              <lg type="sonnet" rhyme="ababcdcdefefgg">
                <l n="1">Shall I compare thee to a summer's <rhyme label="a">day</rhyme>?</l>
                <l n="2">Thou art more lovely and more tempe<rhyme label="b">rate</rhyme>.</l>
                <l n="3">Rough winds do shake the darling buds of <rhyme label="a"><name>May</name></rhyme>,</l>
                <l n="4">And summer's lease hath all too short a <rhyme label="b">date</rhyme>.</l>
                <l n="5">Sometime too hot the eye of heaven <rhyme label="c">shines</rhyme>,</l>
                <l n="6">And often is his gold complexion <rhyme label="d">dimm'd</rhyme>;</l>
                <l n="7">And every fair from fair sometime dec<rhyme label="c">lines</rhyme>,</l>
                <l n="8">By chance or nature's changing course unt<rhyme label="d">rimm'd</rhyme>;</l>
                <l n="9">But thy eternal summer shall not <rhyme label="e">fade</rhyme></l>
                <l n="10">Nor lose possession of that fair thou <rhyme label="f">ow'st</rhyme>;</l>
                <l n="11">Nor shall <name type="epithet">Death</name> brag thou wander'st in his <rhyme label="e">shade</rhyme>,</l>
                <l n="12">When in eternal lines to time thou <rhyme label="f">grow'st</rhyme>:</l>
                <l n="13">So long as men can breathe or eyes can <rhyme label="g">see</rhyme>,</l>
                <l n="14">So long lives this, and this gives life to <rhyme label="g">thee</rhyme>.</l>
              </lg>
            </div>
          </egMarkup>
        </slide>
        <lectureNote>
          <p>So let's look at an XML document in more detail. What elements do you see? What
            attributes? What do they mean? </p>
          <!-- reinforce vocabulary -->
          <p>A few more things to note as we look at a sample XML document up close: <list>
              <item>Although the earlier examples didn't reveal this explicitly, an XML
                representation has order: an XML document is an ordered sequence of elements.</item>
              <item>Also notice that elements can nest inside one another, like boxes inside
                boxes</item>
            </list>
          </p>
        </lectureNote>
        <tutorial>
          <p>Now that you're coming to understand elements and how they function, lets look at a
            more detailed example of an XML document. The previous slides didn't state this
            explicitly, but by now, you've probably figured out that XML representation has order:
            an XML document is an ordered sequence of elements. XML elements can also nest inside
            each other, as in the document here.</p>
          <p>Take a minute and write down (or just think about) the different type of information
            that the XML is telling us in this case. What are the different elements and attributes
            conveying?</p>
          <p>You'll notice that in this example, we are taking certain concepts about literature and
            making them explicit through markup. Unless we had very good natural language
            processing, our computers would probably not be able to recognize that the work above is
            a sonnet (more specifically a Shakespearean sonnet), so we need to use our markup to
            make these statements. So, as we do literary analysis, we note that the poem has 14
            lines, so we label the lines with the <att>n</att> attribute.* We further know that this
            group of lines has a rhyme scheme of ababcdcdefefgg, so we state that using the
              <att>rhyme</att> attribute. When doing literary analysis, we can come to the
            conclusion that a 14-line poem with this rhyme scheme is a sonnet. If we wanted to, we
            could also further state what the meter of the lines in the poem (iambic pentameter), or
            that the poem is broken down into 4 line groups: 3 quatrains, 1 couplet.</p>
          <p>The markup also states that there is a <gi>name</gi>, and that this name is an epithet.
            This example also shows that you can do phrase-level literary analysis using markup.</p>
          <p>*This step isn't entirely necessary, since computers can count pretty well...</p>
        </tutorial>
      </section>

      <section>
        <head>Another sample</head>
        <slide>
          <eg><![CDATA[    ]]><hi rend="class(interest)">Warp Speed, Ms Bright!</hi><![CDATA[
There was a young lady named Bright,
Who travelled much faster than light,
She departed one day,
In a relative way,
And returned on the previous night. ]]></eg>

          <egMarkup scheme="TEI">
            <lg type="limerick" rhyme="aabba" n="3">
              <head>Warp Speed, Ms Bright!</head>
              <l>There was a young lady named <rhyme label="a">Bright</rhyme>,</l>
              <l>Who travelled much faster than <rhyme label="a">light</rhyme>,</l>
              <l>She departed one <rhyme label="b">day</rhyme>,</l>
              <l>In a <term xml:id="t17">relative</term> <rhyme label="b">way</rhyme>,</l>
              <l>And returned on the previous <rhyme label="a">night</rhyme>.</l>
              <note target="#t17">See
              <ptr target="http://en.wikipedia.org/wiki/Theory_of_relativity"/>.</note>
            </lg>
          </egMarkup>
        </slide>
        <tutorial>
          <p>Here is another example that we can walk through.</p>
          <p>Here, we have another poem that is represented by the <gi>lg</gi> element (which stands
            for <q>line group</q>). We can see from its attributes that it is a limerick with the
            rhyme scheme aabba. Presumably it is the third in some sequence of poems, as we can see
            from the <att>n</att> attribute being <q>3.</q> It has a heading and five lines. The
              <gi>rhyme</gi> element is telling us which words rhyme with each other. There is also
            a note that is glossing the term <q>relative</q> and pointing us to the Wikipedia page
            on the <q>Theory of Relativity.</q></p>
        </tutorial>
      </section>

      <section>
        <head>Sample (simplified) Tree</head>
        <slide>
          <figure>
            <graphic url="../../../_utils/gfx/tree_limerick1.png" width="100%"/>
            <figDesc>Classic simplified tree diagram of the limerick <title>Warp Speed, Ms
                Bright!</title> that uses a dashed curved arrow to represent the link from the
                <gi>note</gi> to the <gi>term</gi>, and a dotted arror to indicate the link from the
                <gi>ptr</gi> to the Wikipedia article. It is <soCalled>simplified</soCalled> because
              it does not contain attribute (or text) nodes, and is missing an <gi>l</gi>.</figDesc>
          </figure>
        </slide>
        <tutorial>
          <p>This slide provides another way of representing the limerick we saw on the previous
            page: this time in a tree structure. This is a <q>simplified</q> tree because it does
            not contain the information provided by the attributes and omits the text nodes.
            However, it does show us how the XML is nested, and additionally provides us with the
            linking and pointing information between <gi>term</gi> and <gi>note</gi>, and
              <gi>ptr</gi> and the Wikipedia page.</p>
        </tutorial>
      </section>

      <section>
        <head>Rules for all XML documents</head>
        <slide>
          <p>Well-formedness means: <list>
              <item>Everything is properly delimited</item>
              <item>A single (one and only one) root element</item>
              <item rend="css(color:red;font-weight:bold)">No overlap:</item>
            </list></p>
          <eg type="ill-formed"><![CDATA[<lg type="stanza">
  ]]><hi rend="CSS( color: green; )">&lt;l&gt;</hi><hi rend="CSS( color: blue; )"
              >&lt;s&gt;</hi><![CDATA[A bird came down the walk]]><hi rend="CSS( color: green; )"
              >&lt;/l&gt;</hi><![CDATA[
  ]]><hi rend="CSS( color: green; )">&lt;l&gt;</hi><![CDATA[He did not know I saw.]]><hi
              rend="CSS( color: blue; )">&lt;/s&gt;</hi><hi rend="CSS( color: green; )"
              >&lt;/l&gt;</hi><![CDATA[
  ]]><hi rend="CSS( color: green; )">&lt;l&gt;</hi><hi rend="CSS( color: blue; )"
              >&lt;s&gt;</hi><![CDATA[He bit an angleworm in half,]]><hi rend="CSS( color: green; )"
              >&lt;/l&gt;</hi><![CDATA[
  ]]><hi rend="CSS( color: green; )">&lt;l&gt;</hi><![CDATA[And ate the fellow raw.]]><hi
              rend="CSS( color: blue; )">&lt;/s&gt;</hi><hi rend="CSS( color: green; )"
              >&lt;/l&gt;</hi><![CDATA[
</lg>]]></eg>
        </slide>
        <lectureNote>
          <p>The final things you need to know about XML documents: the rules they have to
            follow!</p>
          <p>These rules come from the W3C as part of the XML standard: all XML languages have to
            obey these rules. So when you write XHTML, for instance, you also need to obey the rules
            of well-formedness.</p>
          <p>First, they must observe the basic rules of XML, which we've seen in practice in our
            examples but need to spell out explicitly here: <list>
              <item>They must have all of their delimiters (angle brackets, quotation marks,
                etc.)</item>
              <item>There must be a single root element containing the entire XML document</item>
              <item>The elements of XML documents must all nest neatly inside one another, without
                overlapping</item>
            </list> If they obey these rules, they are said to be <term>well-formed</term>. </p>
        </lectureNote>
        <tutorial>
          <p>The last thing you need to know about XML documents is the rules that they follow!</p>
          <p>These rules come from the W3C standard for XML, so all XML documents need to follow
            these three rules. These are specifically called the rules of well-formedness, and every
            XML language—from TEI to HTML to MathML—must follow these rules.</p>
          <p>The first is that all elements must be properly delimited, i.e. they must contain all
            necessary characters (such as pointy brackets, quotation marks, forward slashes) in the
            appropriate places.</p>
          <p>The second rule is that all documents must have a single root element, or there must be
            one and only one outermost wrapper element that encloses the whole document. One way to
            think about this rule is by thinking about XML as a tree. Usually trees have one trunk
            off of which everything branches. Without the singular root element in XML you wouldn't
            have a tree; you would have a forest!</p>
          <p>Finally, XML cannot overlap. Basically this means that elements must be contained
            completely within each other. You cannot have a <gi>said</gi> element that begins in the
            middle of one <gi>p</gi> element and ends in the next. As you can imagine, this rule of
            XML may not always do the best job of describing our documents. Sometimes documents have
            overlapping structures. We will discuss how to deal with the problem of XML overlap
            later, but for now, you just need to remember that it isn't allowed.</p>
        </tutorial>
      </section>

      <section>
        <head>Thought experiments to test ourselves: Well-formedness</head>
        <slide>
          <p>Which of the following are well-formed XML?</p>
          <list rend="ordered">
            <item><eg><![CDATA[<name type="person>Pearl S. Buck</name>]]></eg></item>
            <item><eg><![CDATA[<name type="person">Toni Morrison<name>]]></eg></item>
            <item><eg><![CDATA[<name="person">Carl Sagan</name>]]></eg></item>
            <item><eg><![CDATA[<name type="person">Kurt Vonnegut</name>]]></eg></item>
            <item><eg><![CDATA[<name type=person>John Cleese</name>]]></eg></item>
            <item><eg><![CDATA[<name type="person"><forename>Frances</forename> <surname>Perkins</surname></name>]]></eg></item>
            <item><eg><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<item>No overlap!</item>
<item>One root element!</item>
<item>All delimiters!</item>]]></eg></item>
            <item><eg><![CDATA[<lg type="poem">
  <l>There was an old man with a beard</l>
  <l>Who said, <said>It is just as I feared;</l>
  <l>Two Owls and a Hen,</l>
  <l>Four Larks and a Wren,</l>
  <l>Have all made their nests in my beard!</said></l>
</lg>]]></eg></item>
          </list>
        </slide>
        <tutorial>
          <p>Take a minute to go through these examples and determine which snippets of XML are
            well-formed and which ones aren't. This will help to solidify your understanding of XML
            syntax. As a plus: it will help you with troubleshooting when you begin to encode your
            own TEI documents!</p>
          <list rend="ordered">
            <head>Answer key:</head>
            <item>Ill-formed - there is a missing quote after the attribute value.</item>
            <item>Ill-formed - end-tag is missing slash, so processor will think it's just a new
              start tag!</item>
            <item>Ill-formed - missing attribute name. The processor will only allow an equals sign
              if there is whitespace between the element name and attribute name (and, of course,
              attribute name must be present!)</item>
            <item>Well-formed! This is an exemplary element.</item>
            <item>Ill-formed - the quotes around the attribute value are missing.</item>
            <item>Well-formed! All of the necessary characters are included in the correct places.
              Additionally, there is a singular root element.</item>
            <item>Ill-formed - Although each individual element is written out correctly, there is
              no root element to tie them all together.</item>
            <item>Ill-formed - this is an example of XML overlap. As you can see, the <gi>said</gi>
              tag crosses the boundaries of an several <gi>l</gi> tags (i.e. it starts in the middle
              of an <gi>l</gi> element, and doesn't end until after the end of that element).
              Remember that elements need to nest perfectly inside each other (no overlap!).</item>
          </list>
        </tutorial>
      </section>

      <section>
        <head>Rules for specific encoding languages</head>
        <slide>
          <p>Validity means: <list>
              <item>Correct vocabulary: all elements and attributes actually exist in that
                language</item>
              <item>Correct grammar: elements are used in the right place, in the right order</item>
            </list></p>
        </slide>
        <lectureNote>
          <p>In addition, XML documents may conform to the rules established by a specific XML
            language (such as TEI or HTML)</p>
          <p>These rules are very similar to the rules for speaking a human language: are you using
            the right words? Are you using them in the right way?</p>
          <p>When we test an XML document for validity, we are checking the document to see whether
            it matches the rules for a specific language.</p>
        </lectureNote>
        <tutorial>
          <p>In addition to well-formedness (conforming to the rules of XML as a metalanguage),
            there is also validity which requires conforming to the rules of a specific language,
            such as TEI or HTML.</p>
          <p>These rules are very similar to the rules for speaking in a human language: am I using
            the right words? and am I using them in the correct manner?</p>
          <p>When we check an XML document for validity, we are making sure that the document obeys
            the rules of a specific language.</p>
        </tutorial>
      </section>

      <section>
        <head>Thought experiments to test ourselves: Validity — rules</head>
        <slide>
          <p>A simple schema for a simple language, prose: <list>
              <item>A <emph>letter</emph> must begin with a date, followed by a salutation, at least
                one paragraph, and a signature</item>
              <item>A <emph>date</emph> may contain transcribed text</item>
              <item>A <emph>paragraph</emph> may contain names and transcribed text</item>
              <item>A <emph>signature</emph> may contain names and transcribed text</item>
              <item>A <emph>salutation</emph> may contain names and transcribed text</item>
              <item>A <emph>name</emph> may contain transcribed text</item>
            </list>
          </p>
          <p>Same, formal (RELAX NG Compact): <eg xml:space="preserve"><![CDATA[start = element letter {
  date,
  salutation,
  paragraph+,
  signature
  }
date = element date { text }
paragraph = element paragraph { stuff* }
signature = element signature { stuff* }
salutation = element salutation { stuff* }
stuff = text | name
name = element name { text }]]></eg>
          </p>
        </slide>
        <tutorial>
          <p>Validity is determined by a schema, which defines the specific rules for an encoding
            language. At the bottom of this document, you can see a very simple sample schema. Above
            it, is the schema translated into more easily-readable terms. Take a minute to look over
            the rules in this schema, and then we can test our knowledge of validity (you don't need
            to memorize the rules of the schema, as they are reiterated on the next page).</p>
        </tutorial>
      </section>

      <section>
        <head>Thought experiments to test ourselves: Validity — problems</head>
        <slide>
          <list>
            <item>A <emph>letter</emph> must begin with a date, followed by a salutation, at least
              one paragraph, and a signature</item>
            <item>A <emph>date</emph> or <emph>name</emph> may contain transcribed text</item>
            <item>A <emph>paragraph</emph>, <emph>signature</emph>, or <emph>salutation</emph> may
              contain names and transcribed text</item>
          </list>
          <p>Some examples: are they valid?</p>
          <list rend="ordered">
            <item>
              <egMarkup scheme="ad-hoc"><letter>
  <date>2012-02-12</date>
  <salutation>Dear Harry,</salutation>
  <paragraph>Symmetrical dates are so elegant!</paragraph>
  <signature>Yours, Larry</signature>
</letter></egMarkup>
            </item>
            <item>
              <egMarkup scheme="ad-hoc"><letter>
  <salutation>Dear <name>Larry</name>,</salutation>
  <paragraph>Dates just reveal your enslavement to the space-time continuum.</paragraph>
  <signature>Yours, <name>Harry</name></signature>
</letter></egMarkup>
            </item>
            <item>
              <egMarkup scheme="ad-hoc"><letter>
  <salutation>Dear <name>Harry</name>,</salutation>
  <paragraph>My triskaidekaphobia is acting up.</paragraph>
  <signature>Yours, Larry</signature>
  <date>2012-02-13</date>
</letter></egMarkup>
            </item>
            <item>
              <egMarkup scheme="ad-hoc"><letter>
  <date>2012-02-14</date>
  <salutation>Dear Larry,</salutation>
  <paragraph>Happy <name>Valentine</name>'s Day!</paragraph>
  <paragraph>I was just kidding about the space-time continuum.</paragraph>
  <paragraph>You know who...</paragraph>
</letter></egMarkup>
            </item>
            <item>
              <egMarkup scheme="ad-hoc"><letter>
  <paragraph>Ack! I forgot! Is <date>Feb. 14</date> always Valentine's
   Day? I should put it on my calendar.</paragraph>
</letter></egMarkup>
            </item>
          </list>
        </slide>
        <tutorial>
          <p>Take a minute to look through these examples and determine if they are valid, according
            to the rules of our encoding schema. As you go through, you will probably realize that
            our schema is not the best at describing the data we have (many of the examples are
            invalid according to our schema, but are perfectly acceptable as letters). In addition
            to teaching you about validity, this exercise will show you the importance of having a
            schema that fits well with your data!</p>
          <list rend="ordered">
            <head>Answer key:</head>
            <item>valid - This example follows the rules of the schema perfectly, but may not
              perfectly follow the rules of your project. As you can see, the two names in
              salutation and signature are not encoded in name, which is probably against the
              project practices. However, according to the rules of our schema this is a perfectly
              valid example.</item>
            <item>invalid - this example is missing the required <gi>date</gi> element before
                <gi>salutation</gi>.</item>
            <item>invalid - this example has the required date, but it is in the wrong place. Our
              schema does not allow dates to come last—only first.</item>
            <item>invalid - this example is missing the required element <gi>signed</gi></item>
            <item>invalid - This example has the required date, but it is nested inside paragraph
              (which is illegal in our schema). Additionally, the example is missing salutation and
              signature.</item>
          </list>
          <list>
            <head>This tutorial is complete, please see links below to continue:</head>
            <item><ref target="../overview/overview_newer_tutorial_00.xhtml">Proceed to next
                tutorial in TEI Primer and Mannuscripts and the TEI Primer</ref></item>
            <item><ref target="../../../../resources/tei_prim.html">Return to TEI
              Primer</ref></item>
            <item><ref target="../../../../resources/ms_encoding.html">Return to Manuscripts and the
                TEI Primer</ref></item>
            <item><ref target="../../../../resources/tutorial_main.html">Return to main tutorial
                page</ref></item>
          </list>
        </tutorial>
      </section>

    </presentation>
  </text>
</TEI>
