An XML Primer

A very simple XML file (which also happens to be an edit mode) looks like so:

<?xml version="1.0"?>

<!DOCTYPE MODE SYSTEM "xmode.dtd">

        <PROPERTY NAME="commentStart" VALUE="/*" />
        <PROPERTY NAME="commentEnd" VALUE="*/" />

        <SPAN TYPE="COMMENT1">

Note that each opening tag must have a corresponding closing tag. If there is nothing between the opening and closing tags, for example <TAG></TAG>, the shorthand notation <TAG /> may be used. An example of this shorthand can be seen in the <PROPERTY> tags above.

Validation and Errors

Most XML file formats have a formal grammar specified in either DTD, XSD or RNG. In the example above, we can see that the DOCTYPE, or formal grammar for jEdit mode files is described in xmode.dtd, which happens to come from jEdit's source code. If you install the XML plugin, and while editing a mode file in jEdit, go to Plugins - XML - Parse as XML, you should see a structure tree in Sidekick, and you will also see errors (if there are any) in ErrorList, if the document does not conform to the proper XML syntax or the document's formal grammar. In addition, the XML plugin provides completion tips for elements and attributes. All of these things can help immensely especially when learning XML.

It is highly recommended that you check your XML files for validation errors before submitting them to the community.

XML is case sensitive. Span or span is not the same as SPAN.

To insert a special character such as < or > literally in XML (for example, inside an attribute value), you must write it as an entity. An entity consists of the character's symbolic name enclosed within & and ;. The most frequently used entities are:

For example, the following will cause a syntax error:


Instead, you must write:


Now that the basics of XML have been covered, the rest of this section will cover each construct in detail.