Home > bxml2Java

bxml2Java

Bxml2Java is a project mainly written in Java, it's free.

this is new version of BXML to Java translator with declarative style code generation

bxml2java(new version of BXML-to-Java-converter with declarative style code generation)

This is released with Apache 2 licence.


Apache Pivot uses a XML file called BXML. This tool converts a BXML file to equivalent Java source code.

There are some limitations: 1) javascript is not supported. 2) Listner is not mapped to Java.


The Design:

This tool generate Java code from BXML file with declarative style Java codes. Compared to the previous approach, it is more consise, and does not use any variables(almost). (see the sample generated code)


Installation:

This is designed as an extension of the current Apache Pivot source code line. The current project has minimal files. In order to build this tool, copy the folder into the latest pivot folder created by checking out by svn. (this will override BXMLSerializer.java, so you may need to copy the original before this)


Bugs: This is not completed version. But the framework would be sound. Some of the problem is related to final classes in the Pivot class. It fails because this generaes anonymous class for the final classes. So it is necessary to modify the original Pivot code to avoid this problem(change final to none final). (TreeVire.Columns, a few more classes)

The main test program I used is the StackTrader. This sample generated code is now working.(I fixed a few issues) the new sample code is attached in this file.


How to run/test:

Use eclipse to build and run this tool.

You can run BXML2JavaConverterTest.java. this will convert all bxml files under tutorial folder, and generate java source files in the same folder. The generated Java file name starts with "_". so it is easy to distinguish generated file from others.


Examples: stock_tracker_window.bxml

<?xml version="1.0" encoding="UTF-8"?> <stocktracker:StockTrackerWindow title="%stockTracker" maximized="true" xmlns:bxml="http://pivot.apache.org/bxml" xmlns:content="org.apache.pivot.wtk.content" xmlns:stocktracker="org.apache.pivot.tutorials.stocktracker" xmlns="org.apache.pivot.wtk">

</stocktracker:StockTrackerWindow>


detail_pane.bxml

<?xml version="1.0" encoding="UTF-8"?> <BoxPane orientation="vertical" styles="{fill:true}" xmlns:bxml="http://pivot.apache.org/bxml" xmlns:stocktracker="org.apache.pivot.tutorials.stocktracker" xmlns="org.apache.pivot.wtk">

Previous:jquery-kan