History 696: XML
For example, a version of Frederick Jackson Turner's The Frontier in American History prepared in XML and made available for the web, might have the following pieces. First, like any XML document, it must have a Document Type Definition (DTD), in this case defining different parts of the text such as the overall title to the work, the chapter titles, and paragraphs and notes:
<!ELEMENT doc (title, chapter*)>
<!ELEMENT chapter (title, (para|note)*)>
<!ELEMENT title (#PCDATA)*>
<!ELEMENT para (#PCDATA)*>
<!ELEMENT notenumber (#PCDATA)*>
<!ELEMENT note (#PCDATA)*>
XML tags are added to the raw text of Turner's Frontier :
<!DOCTYPE doc SYSTEM "doc.dtd">
<doc>
<title>The Frontier in American History</title>
<chapter>
<title>Chapter 1: The Significance of the Frontier in American History</title>
<para> In the Significance of the "Frontier in American History," I took for my text the following announcement of the Superintendent of the Census of 1890: "Up to and including 1880 the country had a frontier of settlement but at present the unsettled areas has been so broken into by isolated bodies of settlement that there can hardly be said to be a frontier line. In the discussion of its extent, the westward movement, etc., it cannot therefore any longer have a place in the census reports." Two centuries prior to this announcement, in 1690, a committee of the General Court of Massachusetts recommended the Court to order what shall be the frontier and to maintain a committee to settle garrisons on the frontier with forty soldiers to each frontier town as a main guard.<notenumber>1 </notenumber> In the two hundred years between this official attempt to locate the Massachusetts frontier line, and the official announcement of the ending of the national frontier line, westward expansion was the most important single process in American history.</para>
...
<note>1. Massachusetts Archives, xxxvi, p. 150.</note>
</chapter>
...
</doc>
An XSL stylesheet specifies how to take each part of this XML document and, by mixing its pieces (as defined in the DTD) with HTML tags, turn them into a new document (technically, an XHTML document) that a web browser can understand:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/TR/xhtml1/strict">
<xsl:strip-space elements="doc chapter "/>
<xsl:output
method="xml"
indent="yes"
encoding="iso-8859-1"
/>
<xsl:template match="doc">
<html>
<head>
<title>
<xsl:value-of select="title"/>
</title>
</head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="doc/title">
<h1>
<xsl:apply-templates/>
</h1>
</xsl:template>
<xsl:template match="chapter/title">
<h2>
<xsl:apply-templates/>
</h2>
</xsl:template>
<xsl:template match="para">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
<xsl:template match="notenumber">
<sup>
<xsl:apply-templates/>
</sup>
</xsl:template>
<xsl:template match="note">
<p class="note">
<xsl:apply-templates/>
</p>
</xsl:template>
</xsl:stylesheet>
The resulting document looks like this:
<?xml version="1.0" encoding="iso-8859-1"?>
<html xmlns="http://www.w3.org/TR/xhtml1/strict">
<head>
<title>The Frontier in American History</title>
</head>
<body>
<h1>The Frontier in American History</h1>
<h2>Chapter 1: The Significance of the Frontier in American History</h2>
<p>In the Significance of the "Frontier in American History," I took for my text the following announcement of the Superintendent of the Census of 1890: "Up to and including 1880 the country had a frontier of settlement but at present the unsettled areas has been so broken into by isolated bodies of settlement that there can hardly be said to be a frontier line. In the discussion of its extent, the westward movement, etc., it cannot therefore any longer have a place in the census reports." Two centuries prior to this announcement, in 1690, a committee of the General Court of Massachusetts recommended the Court to order what shall be the frontier and to maintain a committee to settle garrisons on the frontier with forty soldiers to each frontier town as a main guard.<sup>1</sup> In the two hundred years between this official attempt to locate the Massachusetts frontier line, and the official announcement of the ending of the national frontier line, westward expansion was the most important single process in American history.</p>
...
<p class="note">1. Massachusetts Archives, xxxvi, p. 150.</p>
...
</body>
</html>
In a web browser, this XHTML document would render roughly like this:
The Frontier in American History
Chapter 1: The Significance of the Frontier in American History
In the Significance of the "Frontier in American History," I took for my text the following announcement of the Superintendent of the Census of 1890: "Up to and including 1880 the country had a frontier of settlement but at present the unsettled areas has been so broken into by isolated bodies of settlement that there can hardly be said to be a frontier line. In the discussion of its extent, the westward movement, etc., it cannot therefore any longer have a place in the census reports." Two centuries prior to this announcement, in 1690, a committee of the General Court of Massachusetts recommended the Court to order what shall be the frontier and to maintain a committee to settle garrisons on the frontier with forty soldiers to each frontier town as a main guard.1 In the two hundred years between this official attempt to locate the Massachusetts frontier line, and the official announcement of the ending of the national frontier line, westward expansion was the most important single process in American history.
...
1. Massachusetts Archives, xxxvi, p. 150.
