Going from DOM to something else in com.jme.util.export.xml


I’m proposing a switch from Document Object Model (DOM) to another way of parsing XML files in jME’s XML utility.  Simple API for XML (SAX) would have been the obvious choice a few years ago, but that technology has since been put down by Sun.


Sparked by a quick queston here, I’ve taken a look into what jME is utilizing as opposed to what is available for parsing XML’s.  The DOM method currently implemented requires the entire XML file to be in memory, which can quickly bog down or halt the JVM.  I’ve had apps crash with XML’s as small as 6mb!!

By contrast, SAX allowed you to deal with larger files while having a smaller memory footprint… too bad the technology is deprecated.


The question now is, what is out there to fit the demands of scalability?  XMLPull, while interesting, hasn’t been updated in almost 3 years…  I, as a general practice, try to stay away from abandonware unless its really the only thing available, and would encourage jME to do the same.

Looking around, I’ve found a few of interest:

  • VTD-XML looks like an interesting option and is under active development.

  • StAX is interesting, but ultimately based on the retired SAX, as well as un-updated in 3 years.

  • XML PULL hasn't been worked on in almost 3 years... this is almost reason enough not to touch it.

VTD-XML looks to be a good choice, but i'd have to do more playing with it and see what it is capable of.  Any suggestions/input would be appreciated as well as any qualms with getting away from DOM.  This is likely a fairly involved move, but could pay off dividends when talking about handling large OGRE meshes

A while ago I was using XStream with success. The cool thing about it is that it generally doesn’t require you to write custom export/import methods for each class, it’s fast, and it’s also customizable so you can make the output more user-readable.

I am also happily using Xstream in several of my enterprise applications.

SAX isn’t exactly depricated. There is just a new version (SAX2) and they depricated the old one.