Chapter 3. Working With XML Documents

In this chapter we will cover some of the basics of creating XML documents with Xerlin including

The Xerlin user interface is shown in Figure 3.1 It has the typical application menus such as File and Edit, and a shortcut Toolbar. Multiple document windows can be open at one time, and managed with the Windows menu and the actions available in the titlebar of each window.

Figure 3.1. User Interface

At the left is the Element Tree which shows the structure of the xml document. If you've worked with the DOM interface for XML, this tree is just a graphical representation of the DOM document. To the right is the attribute edit panel where you set the attributes for an element and where plugins can add specialized element editors.

Creating a new document

Xerlin can create new documents, or work with existing ones. In both cases, you must have a valid DTD describing the possible structure of your document as dicussed in the section called “DTDs and Schemas” To start a new document, select New File from the File menu, or click the New File button on the toolbar.

When you create a new document, Xerlin must first setup the DOCTYPE for the XML file. First, you must select a DTD file. Xerlin brings up the DTD Chooser panel shown in Figure 3.2 for you to select a DTD from a plugin or from your local filesystem.

Figure 3.2. DTD Chooser Panel

Select a DTD, or Browse your filesystem for one, then click OK

The DTD's shown initially are from DTD plugins installed in the Xerlin plugins directory (see Chapter 5). The labels given are the DTD's PUBLIC identifier given by the plugin config. When you've opened documents or selected other DTD's on your filesystem, those new DTD's will also show up on your DTD Chooser until you quit Xerlin. If a DTD doesn't have a PUBLIC id, the SYSTEM id is shown on the DTD Chooser instead. Select the DTD you want to use, and click the OK button.

If there are errors in the DTD file, an error message will be given such as in Figure 3.3 You will need to correct these errors in the DTD before you can edit a document using that DTD.

Figure 3.3. Error in a DTD

If you're using a DTD from your filesystem Xerlin will ask for a Public id. If you don't want to set a public id for the DTD, you can just click the None button. Next Xerlin will ask for the root element as in Figure 3.4 You can select one from the list, or type one if you know which root element you want. Once you've created the document, you cannot change the DOCTYPE, including the root element, from within Xerlin. Note that DTD plugins can setup the DOCTYPE without involving the end user.

Figure 3.4. Root Element Chooser

Once you have a new document (Figure 3.5) you are ready to start adding new elements to it.

Figure 3.5. New Example Document