Configuring Woodstox XML parser: Stax2 properties - @cowtowncoder - Medium (original) (raw)

@cowtowncoder

As part 2 of the overview of Woodstox (java, stax) XML parser, let’s have a look at another set of configuration options: that of Stax2 extension API.

Another way to configure: profiles

As mentioned earlier, the standard Stax way of configuring anything is through factories, using setProperty(name, value) method. This applies to Stax2 as well.

But there is also another mechanism for applying “profiles”: group of settings aimed at setting configuration defaults meant to optimize specific aspect. These methods are named as configureFor[Goal], for example “configureForSpeed”.

XMLInputFactory2 has following profile-configuration methods:

XMLOutputFactory2 has following profile-configuration methods:

Stax2 configuration properties

Use of profiles sets values for multiple properties (sometimes both plain Stax and Stax2 properties). But it is always possible to also set individual properties directly. Let’s have a look at what Stax2-extension properties exist and are supported by Woodstox. Note: most are Boolean valued: I only mention type if it is something other than Boolean.

XMLInputFactory2 specifies following Stax2 properties (along with default values Woodstox uses):

XMLOutputFactory2 specifies following Stax2 properties:

And last but not least, Woodstox-specific properties

Now that we have covered 2 out of 3 properties sets, we are almost ready to have a look at the largest set of properties: ones specific (for now) to Woodstox itself. But that’s worth its separate entry. Stay tuned!