XML Hacks: 100 Industrial-Strength Tips and Tools

   

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/>.

3.4.1 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 of transforming time.xml with clock.xsl

3.4.2 xRay2

Architag's xRay2 is a free, graphical XML editor that runs only on the Windows platform. Like xmlspy, it has XSLT processing capability. You can download it from http://www.architag.com/xray.

After you have successfully downloaded and installed it, follow these steps to perform a transformation with xRay2.

  1. Launch xRay2.

  2. Open time.xml with File Open from the working directory.

  3. Open clock.xsl with File Open in the same location.

  4. Choose File New XSLT Transform.

  5. In the XML Document pull-down menu, select time.xml (see Figure 3-4).

  6. In the XSLT Program pull-down menu, select clock.xsl (see Figure 3-5).

  7. If it's not checked, check Auto-update.

  8. The result appears in the transform window as shown in Figure 3-6.

Figure 3-4. time.xml in xRay2

Figure 3-5. clock.xsl in xRay2

Figure 3-6. Result of transforming time.xml with clock.xsl in xRay2

3.4.3 <oXygen/>

SyncRO Soft's <oXygen/> is a graphical XML editor that runs on the Windows, Mac, and Linux platforms. Like both xmlspy and xRay2, <oXygen/> can process documents with XSLT. You can download a trial copy from http://www.oxygenxml.com/download.html/.

After you have downloaded and installed <oXygen/>, follow these steps:

  1. Launch <oXygen/>.

  2. Open time.xml with File Open from the working directory (see Figure 3-7).

  3. Choose Xml Configure transformation scenario, then click New. The Edit scenario dialog box appears.

  4. Name the scenario "Time," click the browse button, and open clock.xsl (see Figure 3-8). Click OK.

  5. In the Configure transformation scenario dialog box, click Transform now. The result appears in a tabbed pane at the bottom of the <oXygen/> window (see Figure 3-9).

Figure 3-7. time.xml in <oXygen/>

Figure 3-8. Edit scenario dialog box in <oXygen/>

Figure 3-9. Result of transforming time.xml with clock.xsl in <oXygen/>

3.4.4 See Also

  • Marrowsoft's <Xselerator> is an XSLT editor and debugger: http://www.marrowsoft.com/Products.htm

  • Sonic Software's Stylus Studio includes an XSLT editor, debugger, and mapper: http://www.stylusstudio.com/

Категории

© amp.flylib.com,