Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Read the whole "Jato: The New Kid on the Open Source Block" series:
In Part 3, we turn our attention to XML-to-Java transformations and the conditional tags
<Jato:else>, as well as Jato expressions, recursive XML traversal, constructors invocation, JavaBeans property settings, conditional
parameter lists, and a little Swing.
Note: You may find the Jato Syntax Reference Guide useful for obtaining more detailed information on all the tags presented in this article.
Sounds exciting, so let's get started.
In Part 2 we transformed the hierarchical file-structure information contained in a
File object into an XML document called
site.xml. A partial listing of
site.xml is shown is Listing 1:
Listing 1. Partial listing of site.xml
<?xml version="1.0" encoding="UTF-8"?> <root path="E:\jato\examples"> <dir name="examples" modified="1/15/01 10:11 PM" permissions="rw"> <dir name="simple" modified="1/16/01 9:44 PM" permissions="rw"> <file size="2745" modified="3/16/01 4:49 PM" permissions="rw"> SimpleXmlToJava.java </file> <file size="2745" modified="3/16/01 4:49 PM" permissions="rw"> SimpleXmlToJava.java </file> </dir> </dir> <file size="0" modified="3/17/01 10:38 AM" permissions="rw"> file </file> </root>
In our new assignment, we must create a Jato script that transforms
site.xml into a Swing user interface. The finished application is shown in Figure 1.
Figure 1. JatoTree finished appearance
The user interface makes heavy use of the
JTreeTable class source code provided in "Creating TreeTables: Part 2," Scott Violet and Kathy Walrath (java.sun.com).
Before jumping into the Jato script that transforms
site.xml, let's lightly explore Jato expressions, a feature required to get an A on our assignment.
Jato introduced expressions with the release of Beta 2 in March 2001. Expressions provide a compact syntax for obtaining current
interpreter state information and evaluating logic that would require a large amount of Jato script. Jato uses expressions
to perform conditional checks for
<Jato:elseif> tags, generate debug statements, set the current object, manipulate the current input and output XML elements, construct
variable names, and cause surly programmers to perform random acts of kindness. In this aritcle, I'll quickly introduce expressions,
while a future article will deal with this subject in detail.