How to specify which stax parser to use
Asked Answered
L

2

7

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?

Lophobranch answered 22/2, 2011 at 22:8 Comment(0)
S
10

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.

Spinneret answered 23/2, 2011 at 7:12 Comment(0)
I
0

I had a similar problem, my local jboss has woodstox in the path but the remote server don't (or something is not properly configured). So I chose to instantiate the reference implementation:

        // Use BEA streaming parser to avoid runtime exceptions
        XMLOutputFactory xmlof = new XMLOutputFactoryBase();
Incunabulum answered 16/8, 2012 at 14:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.