Test #6: XSLT

The task

For this test, we are revisiting the novel The Blithedale Romance from the
unit on Regex. The input XML is available at http://dh.obdurodon.org/blithedale_xslt.xml. We have revised it for this test,
so you’ll need to use this version, and not the one you used for Regex.

Before you start

Before writing any XSLT, you should explore the XML file. You'll notice that we’ve
removed parts of the novel: the front and back matter and the table of contents. As you
continue reading, you’ll see why!

The XML tags used are fairly self-explanatory, but you don’t want to miss any of them,
and in addition to just looking through the file, you can also use the XPath browser
interface in <oXygen/> to learn about the markup. What elements are used in the
document? How are they structured, that is, which elements can occur where? To get you
started, you can get the names of all of the distinct element types with the XPath
expression distinct-values(//*/name()). This finds all elements anywhere in
the document (//*); uses the name() function to get their
names, instead of the elements themselves, and it then wraps that sequence of names in
the distinct-values() function to remove the duplicates and make the list
easier to read. Before you write any XSLT, be confident that you know how each of these
element types is used in the document.

HTML requirements

Your HTML should include a table of contents that lists the number of each chapter and
its title, and links to each chapter from this table of contents. This task is similar
to what we've been practicing with the Shakespearean Sonnets; it just has a slightly
different structure. All of your output has to be created using XSLT, without any manual
editing afterwards.

Your HTML must be valid. This means that you should save the results of
the transformation by specifying a filename in the Output dropdown in
<oXygen/>, and, after running the transformation, you should open the output HTML
in <oXygen/> and validate it. You are not required to apply CSS to the file, but
if you do (it’s an optional bonus task, about which see below), the CSS needs to be
valid, it needs to be linked to the HTML, and the link needs to be created during the
transformation, and not added manually afterwards.

Required output features

Your output must include the following:

The title and author of the novel

A table of contents, containing:

A list of chapters in the novel and their titles

Links that lead to the beginning of each chapter

Chapters that are properly linked to the table of contents, so that when you click
in the table of contents, the file scrolls to the selected chapter.

You should create this output by using XSLT in an algorithmic fashion, as described in
our Thinking in algorithms.
Specifically, let the XSLT do everything it can do, and don’t create things manually
unless it isn’t possible or practical to do it with XSLT.

Successful completion of everything above this line earns an A grade.

Bonus tasks

The following features earn extra credit:

Use CSS to improve the appearance of the output.

If you use CSS, use @class attributes in the HTML, where appropriate,
to assist with the CSS styling.

Add comments to your XSLT to document your code.

What to submit

Upload your XSLT file and, if you created CSS, your CSS stylesheet. Do not upload either
the input XML (we already have it) or the output HTML (we’ll run your XSLT
transformation to create it).