An XML Primer
Prev | Chapter 10. Mode Definition Syntax | Next

## 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">

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

        <RULES>
            <SPAN TYPE="COMMENT1">
                <BEGIN>/*</BEGIN>
                <END>*/</END>
            </SPAN>
        </RULES>
    </MODE>

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.

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:

- `&lt;` - The less-than (<) character

- `&gt;` - The greater-than (>) character

- `&amp;` - The ampersand (&) character

For example, the following will cause a syntax error:

    <SEQ TYPE="OPERATOR">&</SEQ>

Instead, you must write:

    <SEQ TYPE="OPERATOR">&amp;</SEQ>

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

Prev | Up | Next
Chapter 10. Mode Definition Syntax | Home | The Preamble and MODE tag