King's College London · FACULTY OF ARTS & HUMANITIES

7AAVIN01 Chap.5 Writing Well-Formed XML in Oxygen

- one subject, every graph, every model, every mark
8 Chapters3-page Bible
Our own words - no uploaded lecturer files
Updated for this semester
Chapter 5 of 11 · 7AAVIN01

Writing Well-Formed XML in Oxygen

Writing Well-Formed XML in Oxygen turns the Week 2 practical into a method. It sets out the rules every XML file must follow: a single root element, start and end tags, nesting without overlap, element names without spaces in one consistent case, and attributes placed only in the start tag.

It walks through the recipe exercise in Oxygen, from analysis to skeleton to content, shows how to read the green and red indicators, and closes with working habits: the three editor views, XPath searching, saving and the difference between a well-formed file and a validated one.

The method matters because the report's Option 2 may include an initial prototype, and a clean, well-formed file is the minimum evidence that the prototype works. The chapter therefore stresses habits as much as rules: analyse before typing, build the skeleton before adding content, paste fragment by fragment, save often under names without spaces, and fix each red mark as it appears.

It also explains why the Text view is the one to use, what XPath searching offers, and why a schema or DTD would let a project check its files against agreed rules rather than accept any well-formed document. A worked example diagnoses two errors that turn Oxygen's indicator red, overlapping elements and a space in a name, and the closing checklist summarises the rules to verify before you save a final copy.

In this chapter

What this chapter covers

  • 01

    Elements, start tags and end tags

  • 02

    One root element

  • 03

    Nesting without overlap

  • 04

    Naming rules and case

  • 05

    Attributes in the start tag

  • 06

    The recipe exercise in Oxygen

  • 07

    Finding errors from the red box

  • 08

    Schemas and validation

Worked example · free

Repair a broken XML fragment

Q [3 marks]. AskSia-authored practice. Fix this fragment so it is well-formed: <Book><title>Harbour Songs</book></title>. The marks shown are an AskSia practice allocation, not an official University marking scheme.
A single element is labelled from left to right: the start tag holds the element name and an attribute whose name and quoted value add detail, then come the conA single element is labelled from left to right: the start tag holds the element name and an attribute whose name and quoted value add detail, then come the content and the end tag, which never repeats the attribute.<person role="captain">Ana Ruiz</person>Attribute nameAttribute valueStart tagContentEnd tagAttributes: start tag only
A single element is labelled from left to right: the start tag holds the element name and an attribute whose name and quoted value add detail, then come the content and the end tag, which never repeats the attribute.
  • 1The names Book and book differ in case, so the start and end tags do not match; use lower case for both.
  • 1The title element closes after book, so the elements overlap; close title first.
  • 1Corrected: <book><title>Harbour Songs</title></book>.
Two errors: inconsistent case and overlapping elements. The repaired fragment nests title fully inside book.
Sia tip — Read tags as matched pairs from the inside out; the first pair that does not close cleanly is the error.
Glossary

Key terms

Well-formed XML
An XML document that follows the basic syntax rules of the language, which Oxygen shows with a green indicator.
Root element
The single element that contains all other content in an XML document.
Attribute
A name and quoted value placed in an element's start tag to add information about that element.
Processing instruction
The first line of an XML file that tells programs to treat it as XML.
XPath
A query notation for finding elements in an XML file, such as //place for every place element.
FAQ

Writing Well-Formed XML in Oxygen FAQ

What does well-formed mean in XML?

A well-formed file follows the basic syntax: one root element, every element closed, no overlapping elements and legal names. Oxygen shows a green box when this holds and a red one when it does not.

Where do attributes go in an XML element?

They go only in the start tag, after a space: the attribute name, an equals sign and the value in quotation marks. Several attributes can be added, each separated by a space.

Do I need to buy Oxygen for the module?

No. The module recommends the 30-day trial licence, which can be obtained only once. For later work you can use another XML editor or a general code editor that understands syntax, for example Visual Studio Code.

Which Oxygen view should I use for markup?

Use the Text view, which shows every tag. The Grid view lays the structure out in blocks like a database, and the Author view resembles a word processor, but both hide details you need to see while learning to write correct markup.

What is the difference between well-formed and valid XML?

A well-formed file obeys the basic syntax of XML. A valid file also matches a schema or DTD that defines which elements may appear and where, so validation checks the agreed structure of a project, not just the grammar.

What should I do when I cannot find an XML error?

Look at the red marks on the right of the Oxygen window and the message at the bottom. If that fails, copy the code elsewhere and paste it back a line at a time until the error reappears; the last line pasted contains it.

Study strategy

Assessment move

Rebuild the recipe file from a blank document without looking at the instructions, then deliberately break it in three ways and practise finding each error from Oxygen's messages. Finally, mark up a second short text of your own choice and write down every naming decision you made. Time yourself building a skeleton for a new text type, such as a letter or a playbill, until the structure comes quickly.

Keep a log of every error message you meet and its fix; by the end of the week it becomes a personal troubleshooting guide for the prototype.

A+Everything unlocked
Unlocks this Bible + all 18 of your subjects at King's College London, plus 1,000+ more Bibles across the AskSia library.
Sia - your 7AAVIN01 tutor, unlimited, worked the way the exam marks it
The full 3-page Bible + practice bank with worked solutions
Chrome extension - sync your LMS so Sia knows your deadlines
Bilingual EN / Chinese on every Bible and every Sia answer
$0.99 Trial
30-day money-back · cancel in one tap · how it works