Hack 33 Transform an XML Document Within a Graphical Editor

   

figs/beginner.gif figs/hack33.gif

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, 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
figs/xmlh_0301.gif


Figure 3-2. Choosing an XSL file in xmlspy
figs/xmlh_0302.gif


Figure 3-3. Result of transforming time.xml with clock.xsl
figs/xmlh_0303.gif


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 XSLT Program pull-down menu, select clock.xsl (see Figure 3-5).

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

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

Figure 3-4. time.xml in xRay2
figs/xmlh_0304.gif


Figure 3-5. clock.xsl in xRay2
figs/xmlh_0305.gif


Figure 3-6. Result of transforming time.xml with clock.xsl in xRay2
figs/xmlh_0306.gif


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/>
figs/xmlh_0307.gif


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


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


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/



XML Hacks
XML Hacks: 100 Industrial-Strength Tips and Tools
ISBN: 0596007116
EAN: 2147483647
Year: 2006
Pages: 156

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net