Text only | Skip links
Skip links||IT Services, University of Oxford

1. First steps with Oxygen

In this first exercise you will learn how to use Oxygen to
  • create a new XML document
  • add markup to a document
  • keep your document well-formed
  • display and edit your document without seeing tags

2. Creating a new document

Start up Oxygen, and click the New Document icon at top left (or select New Document from the File menu, or type CTRL-N.) to display the New dialog.

Select the default XML option, and press OK.

In the "Create an XML Document" dialog, uncheck the tick box Use a DTD or a schema, since we don't yet have a schema.

Press OK to continue.

Oxygen opens a blank document, containing just the XML declaration at the start. As you start typing in XML as instructed below, notice how hard Oxygen tries to make your document well-formed.

  • move to the second line
  • type in <div type=" and pause
  • notice that Oxygen supplies the closing quote for you
  • continue typing verse and move the cursor after the closing quote (use an arrow key)
  • Type the closing > and note that Oxygen immediately supplies the closing </div> for you. Press the RETURN key

3. Adding text to a document

Your document should now look like this:

  • From the Document menu select File (Note: Not the File Menu on the menu bar, but that one found under the Document Menu!)
  • Select Insert File from the submenu that opens.
  • Navigate to the file progress.txt in your 'documents/text/' directory (or download it) and insert it into your document.

This is a plain text version of the poem at the start of our sample Punch issue. In the rest of this exercise we will add some minimal tagging. Depending on your experience this may go faster or slower, but please bear with the exercise as we need to ensure that everyone understands the basics first!

4. Tagging bits of a document

  • With the mouse, select the word ‘PROGRESS’ at the start of the text.
  • Press CTRL-E (or select XML Refactoring/Surround with Tag from the Document menu).
  • Type the name of the tag you want to use into the popup: this is a heading, so type head and press OK

Repeat the process for the whole of the following paragraph including square brackets: this time, tag it as a <p>.

5. Tagging the poem

We will tag the poem proper using <lg> to enclose each stanza, and <l> to enclose each <l>.

  • Try typing the sequence <lg><l> at the start of the first line. Delete the unwanted </l> and possibly </lg> tags inserted by Oxygen.
  • Put the cursor at the end of the first stanza (after the word ‘sticks’) and type <
  • A small menu opens, showing that you can enter a closing-tag (to close the <l> element) here. Select it.
  • Type another < and the same menu appears: but note that this time the closing-tag to be inserted is a </lg>. Select this, and the document becomes valid -- no red lines visible.
  • What will happen if you repeat the process, do you think? Try it and see!

6. Tagging the poem properly

Although well-formed our tagging is not very honest. We have a single <l> element containing several lines, and lots of stanzas which are not tagged as anything at all. If we were validating this document against a schema we'd be in trouble.

  • put the cursor at the end of the first line (after ‘die!’)
  • select XML Refactoring/Split Element from the Document menu. (Note the shortcut key!)

This closes the current <l> and immediately opens a new one, so that our document remains valid. We just need to repeat this process for each line. We could do that by repeating what we just did. Or, more simply perhaps, we could add the XML Document Refactoring toolbar, which would provide a single button to do the job. Or we could use the shortcut key for this operation when in the XML Document Refactoring menu, and use that!

Another way would be to copy and paste it: use the mouse to select the sequence of characters you just inserted (</l><l>); copy it with CTRL-C; move the cursor to the end of the next line; paste it with CTRL-V. Repeat this for each line, except the last one of course.

Finally, tag the name of the author of the poem (‘Evoe’) using the <signed> element.

If you have time left at the end of the exercise, explore some of the other functions of the oXygen editor, using the Help it provides if necessary.

7. Save your file!

Make sure you save your file, we'll want to use it in the next exercise! You may wish to save the file as 'exercise1.xml'



James Cummings. Date: July 2009
Copyright University of Oxford