JEdit

From Apertium
Revision as of 13:17, 23 August 2012 by Unhammer (talk | contribs) (→‎Set up validation)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

jEdit is a FOSS programmer's editor with a good XML plugin that does validation. It's written in Java, and runs on Windows, Mac OS X and Linux.

Set up validation[edit]

To set up full validation of Apertium .dix dictionary files:

  1. install jEdit (sudo apt-get install jedit on Ubuntu)
  2. start jedit and click Plugins→Plugin Manager, click the Install tab, wait for the list to fill up, and tick XML and click Install
  3. click Plugins→XML→Translate Schema using Trang
  4. for Input path, choose the file "dix.dtd" in the folder trunk/apertium/apertium/ (it might also be in /usr/local/share/apertium/ if you installed apertium to the standard path, or you could get it from http://apertium.svn.sourceforge.net/viewvc/apertium/trunk/apertium/apertium/dix.dtd)
  5. for Input type, select DTD
  6. for Output type, select RNG
  7. for Output path, select some folder in your home directory and type "dix.rng"; click OK

To automatically use dix.rng on opening a .dix file, open ~/.jedit/plugins/xml.XmlPlugin/schemas.xml and paste something like this into it

<?xml version="1.0" ?>
<locatingRules xmlns="http://thaiopensource.com/ns/locating-rules/1.0">
  <typeId id="dix" uri="/path/to/where/you/stored/dix.rng"/>
  <documentElement localName="dictionary" typeId="dix"/>
  <uri pattern="*.dix" typeId="dix"/>
  <!-- Included by jEdit by default: -->
  <include rules="jeditresource:/XML.jar!/xml/dtds/schemas.xml" />
</locatingRules>

Validate and error check a dix file[edit]

Opening a .dix file should now automatically associate it with dix.rng, giving error-checking and validation.

If you see that obvious errors not detected after opening a dix file, click Plugins→XML→Set Schema, and open the "dix.rng" file you created in the previous step. This might happen if the path is wrong in the schema.xml file shown above.

Clicking Plugins→Sidekick→Sidekick and the Parse button will give you an updated "tree view" of your XML file.

Clicking Plugins→ErrorList→Error List will show you a list of XML validation errors.

Automatically re-parse[edit]

Under Plugins→Sidekick you can tick off "Parse on Keystroke" to automatically re-parse the XML (and find errors) for every keystroke. Since parsing can slow down your computer a bit, you might want to make it so it waits a couple of seconds after the last keystroke before parsing. Open Plugins→Plugin Options and double-click Sidekick→Generate. Where it says "After last keystroke, wait (seconds)", increase the slider to 3.0.