XML Editing

A quick glance at the various forum topics shows that a lot of people are having trouble with making valid XML. They're either missing tags, putting slashes in the wrong places, missing quotes or using the wrong syntax in general.

Using a good editor will help catch some of these things, and using a DTD will catch some more things. This little guide will help you get setup with an editor and DTD both.

DTD stands for Document Type Definition, and it gives you some basic rules for the layout of the XML. Which tags are allowed to go where, what attributes, etc. It's rather basic, so it won't catch all mistakes, but it takes care of a lot of things.

Notepad++ seems popular among SpellCast users, and it does have some nice editing features, and syntax highlighting. The XMLTools plugin helps it along with syntax & DTD validation. I'll cover setting this up first.

I myself use Eclipse with the XML Tools extension, which despite having almost the same name as the Notepad++ plugin is a different beast. Eclipse is a little hefty, and meant for much more complex projects, but I really like it, so I'll cover it too.

Notepad++

Download and install Notepad++

  1. Click the Download link at the top.
  2. Find the Download Notepad++ executable files link and click that.
  3. From the list of files pick the highest version of the installer.exe.
  4. Run the installer. The default settings are fine, so you can just OK, Next & Finish through the whole thing.

Now you can run Notepad++ and open your XML files to get your first taste.

Adding XMLTools to Notepad++

  1. Close Notepad++ and go back to the Download page on http://notepad-plus.sourceforge.net/
  2. Find the XMLTools plugin on the list of plugins at the bottom of the page and click its link.
  3. From the list of files pick the highest version of the zip file that's not labeled with “source”.
  4. Then click the External Libs link and download the ext_libs.zip file.
  5. Extract the XMLTools zip file into your Notepad++\plugins directory.
  6. Extract the ext_libs.zip file into your Notepad++ directory, not in the plugins directory.
  7. Run Notepad++ and check that the Plugins > XML Tools menu is operational.
  8. Make sure all your XML files have the following as their first line:
<?xml version="1.0"?>

Now you can use the syntax checking option from the XML Tools menu, or even enable automatic syntax checking to make sure your XML is at least well formed.

Eclipse

Download and install Eclipse

  1. Click on the Eclipse IDE for Java Developers link. (This particular package comes with the XMLTools included.)
  2. Click on the link following Download from and save the file.
  3. Extract the zipfile to your Program Files or Program Files(x86) directory.
  4. Make a shortcut to eclipse.exe somewhere convenient, like in your quicklaunch bar or on your desktop.
  5. Double-click the shortcut.
    • If Eclipse runs, you can go to the next main step.
    • If it does not and complains about Java, follow the following steps:
    1. Go to http://java.sun.com/javase/downloads/index.jsp and download the latest Java Development Kit
    2. Run the installer after downloading it.
    3. Try double-clicking the shortcut again. Continue with the main steps if Eclipse runs now.
    4. If it does not, edit the shortcut and add -vm <full path to javaw.exe in your newly installed JDK> to the Target. For instance: “C:\Program Files\eclipse\eclipse.exe” -vm “C:\Program Files\Java\jdk1.6.0_05\bin\javaw.exe”
  6. When Eclipse asks for a workspace directory, the default will do. Don't forget to check the “make this my default choice” checkbox.
  7. If you want, go through the tutorials to get familiar with Eclipse.
  8. Once you get to the Workspace, go to File > New > Project…
  9. Select General > Project and hit Next.
  10. Give your project a name, like Spellcast.
  11. Uncheck Use default location and then select your spellcast directory (the one in windower\plugins\) as the Location.
  12. Hit Finish.
  13. Select Window > Show View > Navigator.
  14. Double-click the Spellcast project to open it.
  15. You can now double-click any of the XML files to start editing them.
  16. Once opened, select the Source tab at the bottom of the editor to switch to the source view.
  17. Make sure all your XML files have the following as their first line:
<?xml version="1.0"?>

Eclipse will now point out any generic errors in your XML as you edit, and you can use ctrl-space for various auto-completions. However, auto-completion doesn't start to really shine until you start using the DTD.

Using the Spellcast DTD

The easiest way to do this is just to add the following line to your XML file, right after the XML header, and before the <spellcast> element:

<!DOCTYPE spellcast PUBLIC "spellcast" "http://windower.net/plugins/spellcast.dtd">

So the top of a typical Spellcast XML file should look like this:

<?xml version="1.0"?>
<!DOCTYPE spellcast PUBLIC "spellcast" "http://windower.net/plugins/spellcast.dtd">
<spellcast>
...

The only downside to using the DTD to validate things is that XML in general is a little stricter than Spellcast is, and thus you will get errors on any element or attribute that is not in lowercase. So you will have to change things like

<Action Type="Equip" Set="Melee"/>

to

<action type="equip" set="Melee"/>

Note that names you use can be capitalized without a problem. The same goes for gear.

If you want to have a local copy of the Spellcast DTD, you can download it to your spellcast directory and replace the URL in the DOCTYPE declaration to just spellcast.dtd. At the time of writing the latest version of the Notepad++ XML Tools cannot handle this, though. However this might have changed when you read this.

plugins/spellcast/xmlediting.txt · Last modified: 2009/08/08 14:00 (external edit)
www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0