Java Gui Builder
You are here: Home   >   Documentation   >   Source Generation

Source Generation

Java Gui Builder comes bundled with an XML Stylesheet to transform the XML source into pure Java code. Below, you will find instructions on how to use this feature.

Generating Java Code using the Command Line

To generate the Java source from the XML source, you will need an XSL processing engine. You may use Xalan-J from Apache as your engine of choice. The examples below assume you are using Xalan. If you are using another engine, change the examples accordingly.

Assuming your classpath is set correctly, you can transform any XML file using the following syntax:

$ java org.apache.xalan.xslt.Process -in tutorials/simplewindow.xml -xsl xsl/java.xsl

The previous line tells the Process class to read the tutorials/simplewindow.xml file and to process it using the specified XML Stylesheet. The stylesheet contains instructions that will generate a synctactically correct Java source file, including the class declaration.

Once the task is done, list the directory content, and you will find a new file which will have the name of the window ID, and .java appended.

Generating Java Code using an Ant task

Add a new target to your Ant build file which contains code like the following:

<target name="javaGen">
    <xslt in="tutorials/simplewindow.xml" style="xsl/jgb.xsl" out="/tmp/t">
        <param name="buildDir" expression="${basedir}/build/" />
    </xslt>
</target>

This target instructs Ant to process the specified XML file using the stylesheet. The stylesheet accepts a parameter which tells it where to write the generated source. In this example, the parameter will be set to the value of ${basedir}/build/.

Back to top
SourceForge Logo
Hosted on SourceForge.net
Valid XHTML 1.0!
Valid XHTML 1.0 !
Valid CSS!
Valid CSS !
Code Coverage by Clover
Code Coverage provided by Clover
 |  Home |  License |  Downloads |  Documentation |  Developers |  Mailing Lists |  Dependencies |  Links |  Privacy Policy |  SF Project Home |