Lukas Eder
Lukas Eder

Reputation: 221106

XML library with a low footprint

Because of increasing configuration complexity, I want to introduce XML for my library's configuration files, and replace the existing properties files.

I would like to

If the footprint wasn't an issue, I'd choose JAXB right away. Are there similar libraries with a lower footprint?

EDIT: By footprint, I don't mean consumed memory but the "size" of the library in KB/number of classes. I'd expect my rather simple use-case to be coverable by a library with about 5-6 classes. I don't need the full power of JAXB.

Upvotes: 2

Views: 402

Answers (3)

Ciaran McHale
Ciaran McHale

Reputation: 2244

If you are willing to consider using non XML-technologies, then you might want to look at my Config4J library (www.config4star.org). Comparing it to your wish list...

  • It provides an easy-to-use schema language.

  • The jar file is small (102KB) and it has no external dependencies.

  • The one capability missing from your wish list is a tool to automatically generate Java classes from a schema definition. However, the API of Config4J is simple enough that I'm not sure you would need such a code generator. Part III (The Config4JMS Case Study) of the Practical Usage Guide manual describes a technique for building a Spring-like library to create Java objects from configuration information.

Upvotes: 1

bdoughan
bdoughan

Reputation: 149037

JAXB is Low Footprint

A JAXB (JSR-222) implementation is also included as part of Java SE 6. The classes produced are just POJOs with the necessary annotations. In the question below the poster observes that the XMLBeans classes are four times bigger than the JAXB classes.

Reducing the Number of Classes

If you start with Java classes (instead of generating them from an XML schema) you can normally keep the model smaller. The use of @XmlWrapperElement can help eliminate classes.

Reducing the Number of Classes Further

You can leverage the @XmlPath annotation in EclipseLink JAXB (MOXy), note I'm the tech lead. It leverages XPath to extend the JAXB mappings:

Upvotes: 3

Konstantin Komissarchik
Konstantin Komissarchik

Reputation: 29139

For a zero-dependency solution use the DOM or the SAX parser that is part of every Java VM.

If you want Java type binding, stick with JAXB. Even if you find a smaller size library, you will loose out by using a non-standard solution that hasn't been as extensively tested or has as many developers who know how to use it.

Upvotes: 2

Related Questions