Transform an XML Document Within a Graphical Editor

Transform XML documents with XSLT in a graphical environment.

Graphical XML editors almost universally offer built-in XSLT transformations now. This hack will show you how to transform XML documents with XSLT in xmlspy, xRay2, and <oXygen/>.

xmlspy

Altova’s xmlspy 2004 is a Windows-only graphical XML editor, which you can download from http://www.xmlspy.com. As you install xmlspy, you can get a free license for the Home Edition. Assuming that you have downloaded and installed xmlspy, follow these steps to transform time.xml with clock.xsl (you saw a brief example of this in the hack that discussed creating an XML Document from a text file [Hack #18] ):

  1. Launch xmlspy.

  2. Open the file time.xml with File Open from the working directory (the directory where you extracted the file archive for the book).

  3. Choose View Text view.

  4. Open the file clock.xsl with File Open, also in the same working directory as time.xml.

  5. Choose View Text view again. At this point, xmlspy should appear as it does in Figure 3-1.

  6. Click on the time.xml window to give it focus.

  7. Press F10 or choose XSL XSL Transformation, and the “Please choose XSL file” dialog box appears, as shown in Figure 3-2.

  8. Click the Browse button, select clock.xsl, and click OK.

  9. Another window appears showing you the result of the transformation. Choose View View text. The result appears in Figure 3-3.

Figure 3-1. time.xml in xmlspy

Figure 3-2. Choosing an XSL file in xmlspy

Figure 3-3. Result ...

Get XML Hacks now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.