Class ResourceEntityResolver
java.lang.Object
org.springframework.beans.factory.xml.DelegatingEntityResolver
org.springframework.beans.factory.xml.ResourceEntityResolver
- All Implemented Interfaces:
EntityResolver
EntityResolver
implementation that tries to resolve entity references
through a ResourceLoader
(usually,
relative to the resource base of an ApplicationContext
), if applicable.
Extends DelegatingEntityResolver
to also provide DTD and XSD lookup.
Allows to use standard XML entities to include XML snippets into an application context definition, for example to split a large XML file into various modules. The include paths can be relative to the application context's resource base as usual, instead of relative to the JVM working directory (the XML parser's default).
Note: In addition to relative paths, every URL that specifies a file in the current system root, i.e. the JVM working directory, will be interpreted relative to the application context too.
- Since:
- 31.07.2003
- Author:
- Juergen Hoeller
- See Also:
-
Field Summary
Fields inherited from class org.springframework.beans.factory.xml.DelegatingEntityResolver
DTD_SUFFIX, XSD_SUFFIX
-
Constructor Summary
ConstructorDescriptionResourceEntityResolver
(ResourceLoader resourceLoader) Create a ResourceEntityResolver for the specified ResourceLoader (usually, an ApplicationContext). -
Method Summary
Modifier and TypeMethodDescriptionresolveEntity
(String publicId, String systemId) protected InputSource
resolveSchemaEntity
(String publicId, String systemId) A fallback method forresolveEntity(String, String)
that is used when a "schema" entity (DTD or XSD) cannot be resolved as a local resource.Methods inherited from class org.springframework.beans.factory.xml.DelegatingEntityResolver
toString
-
Constructor Details
-
ResourceEntityResolver
Create a ResourceEntityResolver for the specified ResourceLoader (usually, an ApplicationContext).- Parameters:
resourceLoader
- the ResourceLoader (or ApplicationContext) to load XML entity includes with
-
-
Method Details
-
resolveEntity
@Nullable public InputSource resolveEntity(@Nullable String publicId, @Nullable String systemId) throws SAXException, IOException - Specified by:
resolveEntity
in interfaceEntityResolver
- Overrides:
resolveEntity
in classDelegatingEntityResolver
- Throws:
SAXException
IOException
-
resolveSchemaEntity
A fallback method forresolveEntity(String, String)
that is used when a "schema" entity (DTD or XSD) cannot be resolved as a local resource. The default behavior is to perform remote resolution over HTTPS.Subclasses can override this method to change the default behavior.
- Return
null
to fall back to the parser's default behavior. - Throw an exception to prevent remote resolution of the DTD or XSD.
- Parameters:
publicId
- the public identifier of the external entity being referenced, or null if none was suppliedsystemId
- the system identifier of the external entity being referenced, representing the URL of the DTD or XSD- Returns:
- an InputSource object describing the new input source, or null to request that the parser open a regular URI connection to the system identifier
- Since:
- 6.0.4
- Return
-