7AAVIN01 Chap.5 Writing Well-Formed XML in Oxygen
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.
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
<Book><title>Harbour Songs</book></title>. The marks shown are an AskSia practice allocation, not an official University marking scheme.- 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>.
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.
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.
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.