![]() ![]() (Required) Sets and gets the implementation of the XMLEventAllocator interface. (Required) Sets and gets the implementation of the XMLResolver interface. (Required) Sets and gets the implementation of the XMLReporter interface. (Required) Requires the processor to resolve external parsed entities. (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. Support for non-namespace-aware documents is optional. All implementations must support namespaces. (Required) Requires the processor to coalesce adjacent character data. Turns on implementation-specific validation. See the StAX specification for a more detailed listing. The following table lists the properties supported by XMLInputFactory. Use the platform default XMLInputFactory instance.Īfter getting a reference to an appropriate XMLInputFactory, an application can use the factory to configure and create stream instances. 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. Use the lib/ file in the Java SE platform's Java Runtime Environment (JRE) directory. The static method XMLInputFactory.newInstance is then used to create a new factory instance.ĭeriving from JAXP, the XMLInputFactory.newInstance method determines the specific XMLInputFactory implementation class to load by using the following lookup procedure: New instances of the abstract class XMLInputFactory are created by calling the newInstance method on the class. ![]() The XMLInputFactory class lets you configure implementation instances of XML stream reader processors created by the factory. XMLInputFactory, XMLOutputFactory, and XMLEventFactory, let you define and configure implementation instances of XML stream reader, stream writer, and event classes. ![]() The XMLInputFactory, XMLOutputFactory, and XMLEventFactory classes are described below, followed by discussions of resource allocation, namespace and attribute management, error handling, and then finally reading and writing streams using the cursor and iterator APIs. Similarly, implementation-specific settings can be queried using the getProperty factory method. Configuration is done by setting properties on the factories, whereby implementation-specific settings can be passed to the underlying implementation using the setProperty method on the factories. While (2) is sort of optional in the sense that caller could as well as handle instantiation it is not a lot of code to add and might make it easier for users to realize potential issues and (in case they hit issues first) find solution(s).In general, StAX programmers create XML stream readers, writers, and events by using the XMLInputFactory, XMLOutputFactory, and XMLEventFactory classes. Allow passing ClassLoader through XmlFactoryBuilder, to let caller change it as it sees fit.Default behavior will be to use ClassLoader of XmlInputFactory (or whichever local class calls Stax factory method).I think what I'll do for 2.13 is along these lines so that If class that does loading does it on behalf of someone else, it should take in ClassLoaderĪll of which is to say that yeah #480 makes sense.Usually class loading another class should use ClassLoader that loaded it, and.It does appear there is somewhat of a consensus on: This can lead to sub-optimal selection process, and it seems better to instead explicit pass the ClassLoader to use, and specifically pass (by default) ClassLoader that was used to load XML module class XmlFactory.īefore making the change it would be great to have some supporting documentation/articles explaining common reason for doing this, and/or something explaining potential trade-offs.Īnother thing to consider would be whether to allow configuring this aspect (maybe simple on/off to toggle between) or not: since user may simply opt to instantiate and pass factories on its own, configurability may not make much sense (if caller has to do something they might as well just pass instances to avoid all fragility of SPI approach). When creating XMLInputFactory / XMLOutputFactory instances - in cases where user does not provide explicit instances - current code uses no-argument static factory methods, which ultimately end up using context ClassLoader to locate implementation via SPI.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |