views:

559

answers:

6

Can anyone recommend a good binary XML format? It's for a JavaME application, so it needs to be a) Easy to implement on the server, and b) Easy to write a low-footprint parser for on a low-end JavaME client device.

And it goes without saying that it needs to be smaller than XML, and faster to parse.

A: 

What kind of data are you planning to use? I would say, that if the server is also done in Java, easiest way for small footprint is to send/receive binary data in predefined format. Just write everything in known order into DataOutputStream.

But it would really depend, what what kind of data are you working on and can you define the format.

Actually you should evaluate, if this kind of optimization is even needed. Maybe you target devices are not so limited :)

/JaanusSiim

JaanusSiim
+4  A: 

You might want to take a look at wbxml (Wireless Binary XML) it is optimized for size, and often used on mobile phones, but it is not optimized for parsing speed.

Pat
A: 

The data would be something akin to SVG.

izb
A: 

Check out the following: SAXProject, XMLPull and kXML. kXML I have found to be pretty good. Regards philip.ie

Philip.ie
A: 

It very much depends on the target device. If you have JSR172 available, then you are done with the parsing, the runtime does it for you. And XML is mainly about making your own format. As was alredy stated if your goal is performance, than XML is probably not the best way to go and you will end up doing some binary stuff.

Honza
+1  A: 

Hessian might be an alternative worth looking at. It is a small protocol, well-suited for Java ME applications.

"Hessian is a binary web service protocol that makes web services usable without requiring a large framework, and without learning a new set of protocols. Because it is a binary protocol, it is well-suited to sending binary data without any need to extend the protocol with attachments."

More links:

http://hessian.caucho.com/

http://www.nubius.be/info-software/hessian4j.html

darius
We used that at TomTom as well. There's one gotcha though: the ME implementation of Hessian is not the same as the SE/EE implementation of Hessian. There are quite a few things missing, so don't expect binary compatibility in all cases.
Wilfred Springer