Validating KML As You Go
To use some of KML's more advanced features (such as, Region, TimeSpan/TimeStamp, and ScreenOverlay), you must author the KML directly in a text editor. Whereas
you can use a basic text editor, such as Notepad (Windows) or TextEdit (Mac OS X), they
don't provide any error-checking. This means that you won't discover mistakes until you
try to open the file in Google Earth, and recieve a parse error.
jEdit is an open-source, Java-based text editor
that works on Windows, Mac OS X, and Linux. Using a few additional plug-ins, jEdit
provides as-you-type error checking to ensure that your KML is well-formed
and validates against the official KML
schema. You can also use the Super Abbreviations plugin to quickly insert snippets
of KML. This tutorial will show you how to set-up jEdit for editing KML, demonstrate
some of its error-checking abilities, and show you how to use the KML abbreviations.
Before You Start
-
Install the Java Runtime Environment.
Go to http://www.java.com and click
Free Java Download.
-
Install the latest development version of jEdit.
Go to http://www.jedit.org and
click Download link at the upper right. Be sure to install
the latest version which is 4.3pre16 as of this writing. Do not download the
stable version (4.2) which is fairly old.
Recommendation:
During the installation process you should uncheck the "Start jEdit Server
automatically on system startup" option. This feature isn't required, and
unseleting it will prevent unnecessary programs from starting up on your
computer.
-
Download abbreviations file.
kml_superabbrevs.txt: jEdit Super Abbreviations for KML
The following videos show you how to set up jEdit plug-ins to work with XML files and
how to properly reference the OGC KML 2.2 schema, so that your
documents are validated as you type.
Setting up jEdit Plugins to Validate KML (video)
Install jEdit:
- In jEdit, click on the Plugins menu > Plugins
Manager
- Click on the Install tab of the Plugins Manager window
- Select the following plugins:
- XML (Note: jEdit will automatically select these other associated plugins:
XercesPlugin, SideKick, and ErrorList and Beauty)
- SuperAbbrevs
- Click the Install button, and when complete, click the
Close button
Note: If the plugin download is slow or does not progress follow
these steps: 1) Stop the download; 2) Click the Download Options
button; 3) Click on Update Mirror List; 4) Choose a geographic
location close to you; 5) Click OK; 5) Repeat the steps above to
select and install the plugins.
Configure plugins:
- Click the Plugins menu > Plugins Options
- Click and expand the SideKick plugin folder in the list on the
left
- Select General underneath SideKick
- Under Auto parse Settings, check Parse on buffer
save
- Check Parse on keystroke
- Adjust the slider After last keystroke, wait (seconds) to 1
second. Adjust this later to change the amount of time jEdit waits after you finish
typing to check the KML file for errors.
- Click and expand the ErrorList plugin folder in the list on the
left
- Check Automatically display on error
- Check Auto-close on no errors
- Check Auto-refocus on Text Area
- Check Show error icons in the gutter
- Click and expand the SuperAbbrevs plugin folder in the list on the
left
- Select Abbreviations under SuperAbbrevs
- Using the Select Mode pull-down menu, select
XML.
- Click the Import normal abbrevs button at the lower right
- Click on the import abbrevs button, which is the fourth button, near the plus
(+), minus (-) and settings (wrench icon) buttons.
Note: In jEdit 4.3pre16, the import abbrevs button may be invisible, but
isstill clickalbe. If you don't see a fourth button to the right of the others,
place the mouse over the center of the Edit Abbreviation button (looks like a
wrench on a piece of paper, and may be ghosted out). Move the mouse of
horizontally the right until a small gray square appears under the mouse, and
then click. This is shown in the video.
- In the Open dialog window, navigate to where you saved the kml_superabbrex.txt
file. Select it and open.
- Click OK on the Plugin Options window.
Dock plugins to side and bottom on jEdit:
- Click the Plugins menu > ErrorList > Error
List
- Click on the small, black, downward pointing arrow at the upper left of the
Error List window that appears.
- Choose Dock at Bottom
- The docked Error List window pane can be expanded or collapsed by click the
Error List button at the button.
- Click the Plugins menu > SideKick >
SideKick
- Chose the small black arrow, and choose Dock at Left.
- The docked SideKick window pane can also be toggled by clicking the
SideKick button at the left.
Create a keyboard shortcut for SupperAbbrevs:
- Click the Utilities menu > Global Options
- Click on the Shortcuts option in the list on the left, underneath
the jEdit folder.
- Select Plugins: SupperAbbrevs from the Edit
Shortcuts pull-down menu at the top.
- Double-click the "Primary Shortcut" cell next to the
"Show expansion dialog" command in the list.
- Create a key shortcut. I use Control-Enter (Command-Enter on Macs)
Note: Control-Enter may already be used by the Action
Bar command. You can override this shortcut asssignment.
- Click OK.
Error checking KML with jEdit and using Super Abbreviations (video)
Discussion / Feedback
Have questions about this tutorial? Want to give us some feedback? Visit the Google Earth
Outreach Discussion Group to discuss it with others.
What's Next?
Want to test out your new skills? Check out these other tutorials that require some
hand-editing of KML: