1

The Xerces version that ships with Java has a bug when dealing with empty XML elements for XML version 1.1 input. This bug has long been fixed in Apache's Xerces release (since 2.6.2).

I want to create a XMLEventReader through the XMLInputFactory interface. Something like this:

XMLInputFactory.newFactory().createXMLEventReader(new FileInputStream(inputFile));

Simply placing the Xerces jars into the classpath does not seem to work here. In fact I do not see that Apaches Xerces release extends XMLInputFactory, which seems to be a prerequisite for creating an implementation-specific input factory.

Is there a way to force XMLInputFactory.newFactory to use Apaches Xerces release from the classpath?

Community
  • 1
  • 1
jhunovis
  • 698
  • 2
  • 10
  • 22

1 Answers1

-1

Try

    <dependency>
        <groupId>xerces</groupId>
        <artifactId>xercesImpl</artifactId>
        <version>2.11.0</version>
    </dependency>

this version includes StAX and it will override default StAX impl automatically, useing jar Service Provider mechanizm

Evgeniy Dorofeev
  • 133,369
  • 30
  • 199
  • 275
  • Unfortunately our project does not use Maven. All libraries are set using by setting the classpath. – jhunovis Jun 06 '13 at 08:57
  • That's OK just download xerces 2.11.0 jar from here http://xerces.apache.org/mirrors.cgi – Evgeniy Dorofeev Jun 06 '13 at 09:20
  • 1
    It does not seem to work. I tried the sample code from the question [linked in my question](http://stackoverflow.com/questions/10727288/why-does-the-stax-parser-think-this-is-valid-xml-1-0-but-not-1-1) with only your Maven dependency on Xerces 2.11 in it. – jhunovis Jun 06 '13 at 09:48