public final class SystemIdResolver extends Object implements EntityResolver, EntityResolver2
ResourceLoader
. Just plug this class
on top of a ResourceLoader
and pass it as EntityResolver
to SAX parsers
or via wrapper methods as URIResolver
to XSL transformers or XMLResolver
to STAX parsers.
The resolver handles special SystemIds with an URI scheme of solrres:
that point
to resources. To produce such systemIds when you initially call the parser, use
createSystemIdFromResourceName(java.lang.String)
which produces a SystemId that can
be included along the InputStream coming from ResourceLoader.openResource(java.lang.String)
.
In general create the InputSource
to be passed to the parser like:
InputSource is = new InputSource(loader.openSchema(name)); is.setSystemId(SystemIdResolver.createSystemIdFromResourceName(name)); final DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); db.setEntityResolver(new SystemIdResolver(loader)); Document doc = db.parse(is);
Modifier and Type | Field and Description |
---|---|
static String |
RESOURCE_LOADER_AUTHORITY_ABSOLUTE |
static String |
RESOURCE_LOADER_URI_SCHEME |
Constructor and Description |
---|
SystemIdResolver(ResourceLoader loader) |
Modifier and Type | Method and Description |
---|---|
EntityResolver |
asEntityResolver() |
URIResolver |
asURIResolver() |
XMLResolver |
asXMLResolver() |
static String |
createSystemIdFromResourceName(String name) |
InputSource |
getExternalSubset(String name,
String baseURI) |
InputSource |
resolveEntity(String publicId,
String systemId) |
InputSource |
resolveEntity(String name,
String publicId,
String baseURI,
String systemId) |
public static final String RESOURCE_LOADER_URI_SCHEME
public static final String RESOURCE_LOADER_AUTHORITY_ABSOLUTE
public SystemIdResolver(ResourceLoader loader)
public EntityResolver asEntityResolver()
public URIResolver asURIResolver()
public XMLResolver asXMLResolver()
public InputSource getExternalSubset(String name, String baseURI)
getExternalSubset
in interface EntityResolver2
public InputSource resolveEntity(String name, String publicId, String baseURI, String systemId) throws IOException
resolveEntity
in interface EntityResolver2
IOException
public InputSource resolveEntity(String publicId, String systemId) throws IOException
resolveEntity
in interface EntityResolver
IOException
Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.