The Java EE 5 Tutorial

XMLInputFactory Class

The XMLInputFactory class lets you configure implementation instances of XML stream reader processors created by the factory. New instances of the abstract class XMLInputFactory are created by calling the newInstance method on the class. The static method XMLInputFactory.newInstance is then used to create a new factory instance.

    Deriving from JAXP, the XMLInputFactory.newInstance method determines the specific XMLInputFactory implementation class to load by using the following lookup procedure:

  1. Use the system property.

  2. Use the lib/ file in the J2SE Java Runtime Environment (JRE) directory.

  3. Use the Services API, if available, to determine the classname by looking in the META-INF/services/ files in JAR files available to the JRE.

  4. Use the platform default XMLInputFactory instance.

After getting a reference to an appropriate XMLInputFactory, an application can use the factory to configure and create stream instances. Table 18–4 lists the properties supported by XMLInputFactory. See the StAX specification for a more detailed listing.

Table 18–4 Properties




Turns on implementation-specific validation. 


(Required) Requires the processor to coalesce adjacent character data.


Turns off namespace support. All implementations must support namespaces. Support for non-namespace-aware documents is optional. 


(Required) Requires the processor to replace internal entity references with their replacement value and report them as characters or the set of events that describe the entity.


(Required) Requires the processor to resolve external parsed entities.


(Required) Sets and gets the implementation of the XMLReporter interface.


(Required) Sets and gets the implementation of the XMLResolver interface.


(Required) Sets and gets the implementation of the XMLEventAllocator interface.