Table of Contents
Edit modes are defined using XML, the eXtensible Markup
Language; mode files have the extension
.xml
. XML is a very simple language, and as a result
edit modes are easy to create and modify. This section will start with a
short XML primer, followed by detailed information about each supported tag
and highlighting rule.
Editing a mode or a mode catalog file within jEdit will cause the changes to take effect immediately. If you edit modes using another application, the changes will take effect after the
> > command is invoked.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.
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
,
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:
<
- The less-than (<)
character
>
- The greater-than (>)
character
&
- The ampersand (&)
character
For example, the following will cause a syntax error:
<SEQ TYPE="OPERATOR">&</SEQ>
Instead, you must write:
<SEQ TYPE="OPERATOR">&</SEQ>
Now that the basics of XML have been covered, the rest of this section will cover each construct in detail.