Several XML editors exist. A very flexible and free one is emacs with its psgml mode, which, amongst other things, offers emacs-style completion on tags. Also, it lets you check your file (if it can read the DTD), shows which elements are possible at a given pountin the source file, etc.
The emacs editor is one of the most often used editors on Unix (and today is also popular on Microsoft Windows). It is highly customizable via Lisp code and can easily cope with the syntax of various languages. Lennart Staflin developed the basic SGML/XML support in the form of an emacs ``macro mode'' psgml. For editing DTDs Tony Graham contributed his emacs macros tdtd.
All these modes present you with menus and commands for inserting tags, thus helping you to enter only contextually valid tags and allowing you to edit attribute values in a separate window with information about types and defaults. They also identify structural errors.
Figure A.1 shows an example of a small DocBook file where together with James Clark's nsgmls SGML/XML parser and emacs's psgml mode one can verify at each point in the document which element, attritute, etc. is allowed. Moreover, colours are used to distinguish the different XML language components, making editing significantly easier.
If you type "C-c C-e" (or go into the Markup window, and choose the Insert Element entry) emacs will prompt you for an element, and offer as completions all elements valid at that point.
Once it inserts the element, it inserts it with any required following elements along with a comment saying which ones you could put later on.
As an example, if you type the following into the a DocBook emacs:
C-c C-e variab<SPACE BAR><RETURN>
a variablelist and its expansion is inserted into the text buffer, as follows:
<!-- one of (epigraph authorblurb abstract highlights
comment bridgehead anchor sidebar procedure msgset table
figure example equation informaltable informalexample
informalequation graphicco graphic blockquote address
simpara para formalpara funcsynopsis cmdsynopsis synopsis
screenshot screenco screen programlistingco programlisting
literallayout warning tip note important caution
variablelist simplelist segmentedlist orderedlist
itemizedlist glosslist calloutlist) -->
As another example, when we type:
C-c C-e i<SPACE BAR>
we get the following completions:
Click mouse-2 on a completion to select it.
In this buffer, type RET to select the completion near point.
Possible completions are:
The current element is closed by typing "C-c /".