Teapot: Crossbreeding XML Parsers and Text Editors

Status
Current version1.0 beta 8 (teapot-v1b8.exe)
Release dateNovember 14th, 1999 (1999-11-12)
Download pagehttp://www.tigue.com/teapot/download.html
AuthorJohn Tigue
Parsers testedExPat 1.0.2
Editors testedWinEdit2000, Codewright 5.1
Feedback<teapot@tigue.com>

Abstract

Teapot is software for getting text editors and XML parsers to work together. The result is as if Microsoft's Notepad had an XML parser built in which is used much like a spell checker. Additionally, files can be loaded from and saved to the Internet via HTTP and FTP. Teapot addresses the question: "How can I easily edit XML documents over the Web?" Teapot is a minimalist's Web editor.

Teapot was cobbled together out of freeware and shareware components which can be readily downloaded over the Web. The installation requires neither reboots nor registration. Teapot only works on Windows.

Table of Contents

Introduction

At the time of this writing there are many XML editors on the market. Yet there is still a need for a cheap and elegant way to edit XML documents on the Web. Teapot attempts to address this need. Teapot is a collection of utilities which can be used to turn a text editor into a Web-conscious XML editor. Teapot currently runs only on Windows.

Teapot is not a WYSIWYG solution. Teapot is more like Microsoft's venerable notepad.exe crossbred with an XML parser. There are also FileSave and FileOpen dialogs which work with documents on the Web.

Teapot is a very low level tool. There are no frills such as a treeview of the document's element tree, styled display, nor other graphical goodies. Below is a screen shot of a text editor (WinEdit2000) working with Teapot to edit an XML document.

The name 'Teapot' is an acronym for 'Transfer, Editor, And Parser Of Tigue.'

In this document, WinEdit2000 is used as the example text editor but you can use other editors if you like, for example, CodeWright. WinEdit2000 is the default editor for Teapot because it is quality shareware and because of its logo:

"It's a big, complicated world, but it still runs on text."

Backgrounder on Programmers' Editors

Teapot is designed to work with programmer's editors. This section describes what they are and how they work. You can skip this section if you are familiar with the concepts behind programmer's editors.

Programmer's editors are text editors much like Microsoft's notepad.exe. Additionally, these programmer's editors are designed with extensibility hooks which enable the editor to be configured to work with tools external to the editor. The editor and the external tools work together to get the job done. For a programmer, the most important external tool is a compiler. The programmers' editor specializes in editing text; and the compiler specializes in compiling the source code. This way the editor can be set up to work with different compilers for different programming languages.

In Teapot, these hooks are used to configure the programmer's editor to work with external tools which help with editing XML on the Web. The main trick in Teapot is that an XML processor is used as the "compiler" for XML documents. For the Windows version of Teapot, the parser program is teapot.exe which uses James Clark's ExPat, the parser used in Netscape 5. Teapot can be used with other XML parsers as well. Other Teapot tools are utilities for getting and saving files over HTTP and FTP.

There are more details but that covers the basics. Here are the names of some popular programmer's editors:

Installation

Teapot is not distributed with a text editor so you need to get one seperately. Consider trying out WinEdit2000; it's a mature shareware product for Windows which is easy to install and configure for teapot. WinEdit2000 is available at http://www.winedit.com/. Teapot has been tested to work with WinEdit2000 and Codewright 5.1. Other programmer's editor should work but have not been tested.

After you install a text editor install teapot.

Using Teapot with WinEdit2000

After installation of WinEdit2000 and teapot, you basically use WinEdit in ths same way you use Microsoft's notepad.exe You open files, you look at them as plain text, you edit, then you save to file. The only extra part with teapot is checking the edited file for XML well-formedness. This is what the teapot.exe program does: it reads a file and reports any well-formedness problems to the text editor. You could say well-formedness checking is the XML equivalent of spell checking.

In WinEdit2000 there is a Project menu. Its first menu item is Compile.... That's what you use to have teapot.exe parse an XML file. That's not very intuitive but then we are bending the rules here. After 'compiling' WinEdit can show us where the errors occured. Pull down the Search menu and select the Next Error item to be taken to the line where the well-formedness error occured. Next Error takes you to the first (and in our cases only) error. There is at most one error message for each run of the parser.

Read the error message in order to figure out what went wrong. The error message are not always very helpful. Error messages like 'mis-matched end tag' can sometimes point to one line but the error may actually have occured on some distant line. Eventually, you figure out what caused the well-formedness problem. Patch up the error and try to parse again. Keep repeating till the document passes the well-formedness test. That's all there is to it.

Limitations: teapot currently only does well-formedness checking. Validation could be done but has not been.

If you like toolbar buttons, you can make the Debug toolbar visible by pulling down the Edit menu, selecting Toolbars, and checking the box next to Debug. Doing so will also allow you to use the following two buttons to do the same thing as with the menus above.

      

The first one is Compile the second one is Next Error.

The fastest way to key this boring 'edit, parse, repeat' task is to memorize the following keyboard sequence:

Alt-P then Enter and then F4

Pressing Alt-P then Enter is the same as pulling down the Project menu and selecting Compile. And F4 is the hotkey shortcut to the Edit menu's 'Next Error' item. Later, you can further reduce the above to just two keys of your choice by customizing WinEdit2000.

Note that as far as XML is concerned 'compiling' is the same as 'parsing'. Essentially, WinEdit2000 uses a different word for the same thing. When you installed teapot, WinEdit2000 was configured to use teapot to 'compile' XML files. Now, WinEdit thinks that files which end in '.xml' are XML type files which should be compiled with the teapot.exe compiler.

In WinEdit2000, the line at which the XML parse error was detected is indicated by a small yellow rectangle on the left margin of WinEdit's window. The error message is shown near the bottom of WinEdit's window. Thee "Output" window will contain the raw output from the XML parser. Sadly, sometimes the parser detects the error but is not able to be very helpful in determining which line in the file needs to be edited in order to fix the well-formedness problem. For example, for the message 'mis-matched end tag' the reported error line can actually by OK and the error really occured on some other line, possibly somewhere very far away in the file.

Troubleshooting

Check the growing Teapot FAQ for help troubleshooting any setup problems.

Legal

Teapot is freeware which works with shareware. John Tigue makes no money off of Teapot. You are free to modify the Teapot code. NO WARENTEES. You can find the source in the Teapot distribution.

The XML parser teapot.exe (which ships with Teapot) is simply a trivial modification of the code for wfxml.exe which ships with ExPat. ExPat is under the The Mozilla Public License Version 1.1 So Teapot is under MPL.

The WebCommander HTTP FileSave and FileOpen dialog utility is freeware from the W3C's libwww library. See their licence.

Future Work

Potential improvements include:


This document was last modified on: 1999-11-13       Contact John Tigue <john.tigue@tigue.com>