Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify which stax parser to use

Tags:

stax

woodstox

I have a woodstox and and java SE 1.6 stax parser in the classpath but woodstox seems to get selected by default. However in certain cases I'd like to use the default Java stax parser. Is there any way to specify which implementation to use?

like image 841
Fredrik L Avatar asked Feb 22 '11 22:02

Fredrik L


1 Answers

Easiest way is to just directly instantiate one you want -- there is no need to use XMLInputFactory.newInstance(); for Woodstox you would instantiate com.ctc.wstx.stax.WstxInputFactory. For Sun implementation it is something else (com.sun.sjsxp or such) -- you can see class name if you instantiate it via Stax API when Woodstox jar is not in classpath.

But if you absolutely want to use indirection, value of system property "javax.xml.stream.XMLInputFactory" is used, as per javadocs: value is the name of class to instantiate.

like image 120
StaxMan Avatar answered Sep 28 '22 04:09

StaxMan