Introductory Markup and XML:
Exercises, Further Reading & Tools
John Walsh, Indiana University

Markup Exercises

Encoding a well-formed XML document

In this assignment, you are to familiarize yourself with basic XML syntax by marking up a business card—your own or the card of a friend or family member or one you find through a Web search. You should create a well-formed XML document that uses both elements and attributes to describe the content, structure, and other features of the business card. You XML document could be relatively simple, with a few obvious elements and attributes for things like name, address, etc. and may in many ways resemble and address book entry. You may choose to encode at a very fine level of detail. In addition to basic contact information, a business card may have logos and graphics, quotations and slogans, different types of addresses: postal, email, web, twitter, etc.

Try to make your markup “readable”—someone unfamiliar with your data should be able to read element and attribute names and make sense of the data. In naming things, use complete words and avoid arcane abbreviations.

Create your document in a plain text editor or development tool or XML editor of your choice. You may upload or copy and paste your document into the XML validator at http://www.xmlvalidation.com/, as discussed in the video presentation. To check your document:

Following the steps above, you should get a report that “No errors were found ” or a list of one or more errors.

If the document has errors, attempt to make sense of the error messages, fix the errors, and check the document again, following the steps above, until the document is well-formed.

Now try your hand at encoding another type of document, or data, of your choosing.

Finding and fixing errors

The XML code below is not well-formed. It includes a number of errors. Copy the code and paste it into the XML validator at http://www.xmlvalidation.com/. Use the error messages to identify and correct the errors in the document until it is well-formed.

<?xml version="1.0" encoding="UTF-8">
<div type="dedication">
    <pb n="84"/>
    <head rendition="#center'>
        <title>TO WALTER THEODORE WATTS</title>
    </head>
    <epigraph>
        <cit>
            <quote>
                <lg>
                    <l>“We are what suns and winds and waters make us.”</l>
                </quote>
            </lg>
            <bibl rendition="#sc"> — Landor.</Bibl>
        </cit>
    </epigraph>
    <lg type="sonnet" rendition="#i">
        <lg type="octet" rendition='#sublg'>
            <l n="1"><hi rendition="#sc">Sea</hi>, wind, & sun, & light & sound &
                breath</l>
            <l n="2" rendition="#ti-1">The spirit of man fulfilling — these create</l>
            <l n="3" rendition="#ti-1">That joy wherewith man's life grown passionate</l>
            <l n="4">Gains heart to hear and sense to read and faith</l>
            <l n="5">To know the secret word our Mother saith</l>
            <l n="6" rendition='#ti-1'>In silence, and to see, though doubt wax great,</l>
            <l n="7" rendition="#ti-1">Death as the shadow cast by life on fate,</l>
            <l n="8">Passing, whose shade we call the shadow of death.</l>
        </lg>
        <lg type="sextet" rendition="#sublg">
            <l n="9">Brother, to whom our Mother as to me</l>
            <l n="10" rendition="#ti-1">Is dearer than all dreams of days undone,</l>
            <l n="11">This song I give you of the sovereign three</l>
            <l n="12" rendition=#ti-1>That are as life and sleep and death are, one:</l>
            <l n="13">A song the sea-wind gave me from the sea,</l>
            <l n="14" rendition="#ti-1">Where nought of man's endures before the sun.</l>
        </lg>
    </lg>
</div>    

Further reading

Tools

Online validation services

XML Editors

Command-line tools

These tools can be used for many things, including XML parsing and validation and XSLT processing.