Sunday, July 10, 2011

Hyperjaxb3 0.5.6 is released

I am very glad to announce the 0.5.6 release of Hyperjaxb3.
This release features two major highlights:

It also fixes a great number of issues, please see release notes here and here.


Thursday, April 28, 2011

Jsonix 1.0 is released

I am glad to announce the first release of, Jsonix.

Jsonix (JSON interfaces for XML) is a JavaScript library which allows you to convert between XML and JSON structures. Jsonix is essentially a JavaScript analog of JAXB.

With Jsonix you can parse XML into JSON (this process is called unmarshalling) or serialize JSON in XML form (this is called marshalling).

These conversions are based on simple XML/JSON mappings which can be written manually or generated from an XML Schema.

Project website:


Download features:

  • Scripts
  • Schema compiler
  • Sample projects (batch/command line, Ant, Maven)
  • Demo projects

User guide:

Mailing lists:

Wednesday, October 27, 2010

Jsonix - JAXB for JavaScript

Folowing up on the ideas from my previous posts, I've started the project called Jsonix (JSON interfaces for XML):

Jsonix is basically a JAXB analog for JavaScript. With Jsonix you can:
  • parse XML into JSON;
  • serialize JSON into XML;
  • define XML/JSON mappings declaratively;
  • generate Jsonix mappings from XML Schemas.

Here's a small example of how a JSON purchase order could be marshalled in XML:

var context = Jsonix.Context.newInstance([ PO ]);
// Marshal JSON as XML (DOM node)
var unmarshaller = context.createUnmarshaller();

var node = marshaller.marshal({
name: {localPart: "purchaseOrder"},
value: {
shipTo: {
name: "Alice Smith",
street: "123 Maple Street",
city: "Mill Valley",
state: "CA",
zip: 90952

This will produce an XML like:
<purchaseOrder orderDate="1999-10-20">
<shipTo country="US">
<name>Alice Smith</name>
<street>123 Maple Street</street>
<city>Mill Valley</city>
<!-- ... -->

And here's how you'd unmarshal:

// Unmarshal JSON from XML (retrieved from an URL)
var unmarshaller = context.createUnmarshaller();
url : "po.xml",
success : function(po) {
assertEquals("Alice Smith",;

The project is in development, I'll be working on it next weeks.

Saturday, October 16, 2010

Generating JavaScript Code with JavaScript Code Model

JavaScript Code Model (JSCM for short) is a Java library which precisely models JavaScript grammar as defined in ECMAScript specification. JSCM allows you to programmatically create, analyze and manipulate JavaScript code.

This post demonstrates usage of JSCM to generate JavaScript code from a Java program.

Here's a code snippet which creates a factorial function:

// Instantiate the code model
JSCodeModel codeModel = new CodeModelImpl();
// Create the program
JSProgram program = codeModel.program();
// Add a function declaration
JSFunctionDeclaration factorial = program
// Add a function parameter
JSVariable x = factorial.parameter("x");
// Create an integer literal
JSDecimalIntegerLiteral one = codeModel.integer(1);
// Add a return statement to the function body

// Write the program code to the System.out
new CodeWriter(System.out).program(program);

This produces the following JavaScript code:

function factorial(x) {
return x <= 1 ? 1 : x * factorial(x - 1); }

In this example we first produce the code model by creating expressions, statements, function declarations and so on and then use code writer to serialize the created program into the System.out. This process almost guarantees that the resulting code is syntactically and grammatically correct - and well-formatted as well. And I hope the API is very convenient - especially if you compare it to the "good old" string concatenation.

In the future I'll also provide a parser which parses JavaScript code and builds its model. It will then be possible to analyze existing JavaScript code and manipulate it - for instance add profiling statements, reformat, restructure, refactor, optimize or obfuscate.

JavaScript Code Model 1.0 released

Last few weeks I've been working on the JavaScript code model, the idea I describe in my previous post.

Now it is ready and released. Here's the project page in my Confluence and a generated Maven Site.

Now I can go on with my idea of JAXB analog for JavaScript. My plans are:
  • Write a JAXB plugin which would generate XML bindings for JavaScript objects in form of JSON. This is analogous to JAXB annotations.
  • Write JavaScript runtime to parse (unmarshal) JSON objects from XML or serialize (marshal) these objects back to XML. This is analogous to JAXBContext.
In the next post I'll give an example of how JSCM can be used to generate JavaScript code.

Wednesday, September 29, 2010

JavaScript Code Model

I was recently looking for a JAXB-like API for JavaScript which would allow converting between XML and JavaScript objects on the client. Such tool would be extremely useful when working with schema-based XML documents in JavaScript clients.

Apparently, there's no such thing. So I've started thinking about writing one. To put it frankly, the idea fascinated me so much that I simply could not help starting experimenting.

Today I've started with a code model for JavaScript. I'm writing an API which would allow generating syntactically correct JavaScript from Java. This will be somewhat similar to the code model library used in JAXB/XJC, only implemented for JavaScript. I took the ECMAScript specification and a couple of grammars and wrote over 50 interfaces which model the grammar of the JavaScript code. Here's a couple of examples of what I got so far:

JSProgram program = codeModel.program();

JSNumericLiteral one = codeModel.lit(1);
JSFunctionDeclaration factorial =
JSVariable x = factorial.parameter("x");

This should produce the code of the factorial function like:

function factorial(x)
{ return x <= 1 ? 1 : x * factorial(x - 1); }

The conditional could be rolled out into an if statement:

JSIfStatement _if = factorial.body()._if(x.le(one));

I need this to be able to generate XML-JSON mappings in correct JavaScript syntax. String concatenation just does not feel right.

But what's probably the most important is that it's great fun to work on this. :)


Sunday, September 26, 2010

Juneloop - tool for programmatic manipulation of JNLP files

We recently needed to create a JNLP file for Java Web Start programmatically from a template. Basically we needed to add a property element to an existing JNLP file. There were also similar requirements from a project partner, so all in all it goes into a direction of programmatic manipulation of JNLP files.

Since JNLP is defined in DTDs (1.5, 6.0) I though this would be a good JAXB project (and a good demo case for Maven JAXB2 Plugin). All I needed to do is compile JNLP DTDs with XJC, add a couple of tests and here you go:

Juneloop, a tool for programmatic manipulation of JNLP files.

With Juneloop you can:
  • unmarshal JNLP resources;
  • create or modify JNLP object structures programmatically;
  • marshal JNLP object structures.
See Juneloop documentation here:

Labels: , , , , , ,

Long Time No See

It was quite a while that I posted last time to this blog. In this time I did a huge amount of work on my open-source projects (visit and see for yourself).

Now I've decided to come back to this blog and to use it to post announcements and updates about my OSS activities. New projects, new releases, new initiatives.

I'm certainly not hoping for a huge audience (I'm bad in marketing anyway), I just need an instrument which would help me to keep track of my developments. An maybe this will help you to find one or another useful tool.


Monday, July 28, 2008

Hyperjaxb3 0.4 to be released pretty soon

Hi everyone,

I'm writing now just to inform you guys on the process.

Last few month I was intensively working on Hyperjaxb3 version 0.4 and now it's ready. This version has gone through a large refactoring. I'll post the details in the release description but here's a couple of hightlights:

  • Previously HJ3 could only generate JPA annotations. The 0.4 version can also generate ORM mappings as XML resources (in this schema).

  • New version introduced global customizations. Now you can customize generated mappings globally. For instance, you can instruct Hyperjaxb3 to map complex collections as many-to-many (instead of default one-to-many), choose between join-column or join-table association strategies per default and many other things.
  • I've added more tests, more sample and template projects to help people start with HJ3 more easily.

As I said, HJ3 version 0.4 is ready and you can get it from the Maven2 repository. Next days I'll be working on documentation and release description, so it's not an "official" release yet. Stay tuned.

ps. Along with HJ3 version 0.4 there's also new versions of Annox and Jaxb2-commons available.