How to Get Code Completion and Assist for Mach-II XML Config files in ColdFusion Builder 2

When we were putting together the MachBuilder extension for ColdFusion Builder 2, Kurt Wiersma and I ran into a major roadblock: we couldn't add any features to the extension that operated on Mach-II configuration files because ColdFusion Builder 2 extensions only work on CFC and CFM files. If you want to see ColdFusion Builder extensions work on XML files in future releases of ColdFusion Builder, please vote for this feature. However, if you install the Eclipse Web Tools Project (WTP) XML editor and correctly point to the DTD for the Mach-II XML configuration file, you'll get code completion and assist in your configuration files.

While simply pointing to the correct DTD should work in pretty much any XML editor that you add to Eclipse, the standalone version of ColdFusion Builder 2 (and ColdFusion Builder 1) incudes Aptana Studio's XML editor, which doesn't provide code completion or assist. If you installed ColdFusion Builder 1 or 2 into an existing Eclipse install, you may already have an XML editor which you can use. Even so, a lot of people speak highly of the features of the WTP XML editor.

Note that this works for ColdFusion Builder 1, ColdFusion Builder 2, and CFEclipse.

ColdFusion Builder 2 is built upon the Helios release of Eclipse. You'll first need to add the generic Helios update site to your install in order to get the correct files. (If you're using the Galileo release of Eclipse (which is what ColdFusion Builder 1 was built upon), you'll need to add the Galileo update site instead.)

Here's how you get it all working:

  1. From the "Help" menu, select "Install New Software..."
  2. Add the top of the "Available Software" window that appears, click "Add" next to "Work with:"
  3. In the "Add" window, enter "Helios Update Site" for the name and http://download.eclipse.org/releases/helios/ as the URL.
  4. Click OK
  5. Eclipse will now make a remote call to the Helios Update Site and present you with a list of software that's available.
  6. Open the disclosure triangle next to "Web, XML, and Java EE Development"
  7. Select "Eclipse XML Editors and Tools"
  8. Click "Next" at the bottom of the "Available Software" window, "Next" again to get past the details page, and finally "Finish" once you accept the license agreement.

One the install has finished and you've restarted ColdFusion Builder/Eclipse, you need to open your Mach-II XML configuration file and make sure you're pointing to the correct DTD to actually get code completion and assist working. There are details on how to do this on the Mach-II Trac.

Essentially you just need to put the correct DTD at the top of your Mach-II XML configuration file, right after the opening XML tag. If you're using Mach-II 1.8.1 (the latest stable release), that declaration would be:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mach-ii PUBLIC
"-//Mach-II//DTD Mach-II Configuration 1.8.1//EN" "http://www.mach-ii.com/dtds/mach-ii_1_8_1.dtd">

One final and very important step: you have to open the Mach-II config XML file with the WST XML editor, not the default ColdFusion Builder XML editor. If you double-click the XML file, it opens in the default ColdFusion Builder XML editor. To do this, right-click on the file and select "Open With..." and then "XML Editor" (which is the Eclipse WST XML Editor).

The WST XML Editor has two modes: design and source. When you open an XML file, it defaults in to the design view. You more than likely want to click the tab at the bottom of the XML code editor window that switches to the source view. Once in that view, you can get code assist by hovering over items in the XML file and code completion by simply typing.

Thanks to Peter J. Farrell and Kurt Wiersma for pointing me in the right direction to get this working.

Comments
Jean Ducrot's Gravatar Very useful post thank. I do want to point out to help some other readers that I was unable to open the mach-ii.xml.cfm file using the standard xml editor (WST XML Editor). I had to select the APPLICATION XML editor and I was given source (and badge?!?!) tabs at the bottom of the screen. From there on it was smooth sailing.
# Posted By Jean Ducrot | 6/17/11 8:57 AM
BlogCFC was created by Raymond Camden.

Creative Commons License
The content on http://www.iterateme.com/ is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.