Hack 6 Explore XML Documents in Graphical Editors

figs/beginner.gif figs/hack6.gif

Text editor not enough for you? This hack looks at XML documents with graphical editors.

Along with XML has come a thundering horde of graphical XML editors that do everything short of buttering your toast. Many editors are readily available (see http://www.xmlsoftware.com/editors.html for a comprehensive though not exhaustive list), but I'll mention only a few safe bets here.

1.7.1 xmlspy

xmlspy 2004 by Altova (http://www.xmlspy.com) is a feature-rich, graphical editor for XML for the Windows environment. xmlspy has also been tested on Red Hat Linux running Wine, and Mac OS/X running Microsoft Virtual PC for Mac. The Home Edition of this popular editor is available for free, but you must pay for licensess for Professional and Enterprise editions. I'll give you a quick feature fly-over of xmlspy?though there are a number of features I won't get around to mentioning.

xmlspy can help you create documents and schemas by hand or from templates (examples), organize work into projects, and import text and database files. You can view documents as text with syntax highlighting or in a grid view, check spelling, validate against DTDs and XML Schema documents, perform XSLT transformations [Hack #33] and evaluate XPath location paths. xmlspy provides support for WSDL (http://www.w3.org/TR/wsdl) and SOAP [Hack #63] . You can also use xmlspy to generate Java, C++, or C# code [Hack #99] from DTDs or XML Schema documents.

Figure 1-10 shows the document valid.xml in xmlspy with helper panes on the right. These panes let you insert elements, attributes, and entities with a single click. The Project pane on the left gives you quick access to all kinds of templates.

Figure 1-10. valid.xml in xmlspy 2004

1.7.2 xRay2

xRay2 is a free, Windows-only graphical XML editor from Architag (http://architag.com/xray/). Figure 1-11 displays time.xml in xRay2. It's a small download (a little over 5 megabytes) and comes with only a handful of files. This editor is a great learning tool because it checks your XML as you type. It uses syntax highlighting, and the shaded pane at the bottom of the editing window shows a red, yellow, or green background color depending on what you're typing (think traffic light). The status bar also reports whether your document is well-formed. You can check your XML in real time or at measured intervals, or turn it off altogether. xRay2 also recognizes and checks against DTD and XML Schema documents and can perform XSLT transformations [Hack #33] .

Figure 1-11. time.xml in xRay2

1.7.3 <oXygen/>

<oXygen/> is supported on Windows, the Mac, and Linux and other flavors of Unix. This editor is written in Java and has lots of useful features. And the price is right: you can get a 30-day trial, and a single license costs only $74 USD. (It's cheaper in quantity.) Norm Walsh wrote a glowing little review of <oXygen/> worth reading (http://norman.walsh.name/2004/01/22/oxygen). Figure 1-12 shows time.xml in <oXygen/>.

Figure 1-12. time.xml in <oXygen/> 3.0

<oXygen/> lets you create XML documents or schemas from templates or from scratch, and then use projects to organize your work. You can view documents with syntax highlighting or with a tree editor (see Figure 1-13); check spelling; validate against DTDs, XML Schema, RELAX NG in both XML and compact syntax, even Namespace Routing Language (see http://www.thaiopensource.com/relaxng/nrl.html); perform XSLT transformations [Hack #33] ; and evaluate XPath location paths. Two features that I particularly like are the ability to use FTP (http://www.ietf.org/rfc/rfc959.txt) and WebDAV (http://www.webdav.org/) and to save a document to a URL from within <oXygen/>, and seeing the code point for the Unicode character where the cursor is flashing displayed in the status bar.

Figure 1-13. Tree Editor view of time.xml in <oXygen/> 3.0

1.7.4 See Also

  • jEdit: http://www.jedit.org

  • Armed Bear: http://armedbear-j.sourceforge.net/

  • XML Cooktop: http://www.xmlcooktop.com

  • XMLDistilled Editor: http://www.xmldistilled.com/tools/

  • SysOnyx's xmlHack: http://www.sysonyx.com

  • Bob Foster's XML Buddy and XML Buddy Pro, an Eclipse (http://www.eclipse.org/) IDE plug-in: http://www.xmlbuddy.com

  • Xopus browser-based editor for Internet Explorer: http://xopus.com/

  • XMLmind: http://www.xmlmind.com/xmleditor/

  • XMLwriter XML Editor: http://www.xmlwriter.net/

  • Blast Radius' XMetal 4: http://www.sq.com

  • Sonic Stylus Studio: http://www.stylusstudio.com/index.html

  • Tibco TurboXML: http://www.tibco.com/solutions/products/extensibility/turbo_xml.jsp

  • Topologi's Collaborative Markup Editor: http://www.topologi.com

  • Editing XML documents in Microsoft Word 2003 [Hack #14]