Package org.apache.solr.util
Class SystemIdResolver
- java.lang.Object
-
- org.apache.solr.util.SystemIdResolver
-
- All Implemented Interfaces:
EntityResolver
,EntityResolver2
public final class SystemIdResolver extends Object implements EntityResolver, EntityResolver2
This is a helper class to support resolving of XIncludes or other hrefs inside XML files on top of aResourceLoader
. Just plug this class on top of aResourceLoader
and pass it asEntityResolver
to SAX parsers or via wrapper methods asURIResolver
to XSL transformers orXMLResolver
to STAX parsers. The resolver handles special SystemIds with an URI scheme ofsolrres:
that point to resources. To produce such systemIds when you initially call the parser, usecreateSystemIdFromResourceName(java.lang.String)
which produces a SystemId that can be included along the InputStream coming fromResourceLoader.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);
-
-
Field Summary
Fields Modifier and Type Field Description static String
RESOURCE_LOADER_AUTHORITY_ABSOLUTE
static String
RESOURCE_LOADER_URI_SCHEME
-
Constructor Summary
Constructors Constructor Description SystemIdResolver(org.apache.lucene.util.ResourceLoader loader)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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)
-
-
-
Field Detail
-
RESOURCE_LOADER_URI_SCHEME
public static final String RESOURCE_LOADER_URI_SCHEME
- See Also:
- Constant Field Values
-
RESOURCE_LOADER_AUTHORITY_ABSOLUTE
public static final String RESOURCE_LOADER_AUTHORITY_ABSOLUTE
- See Also:
- Constant Field Values
-
-
Method Detail
-
asEntityResolver
public EntityResolver asEntityResolver()
-
asURIResolver
public URIResolver asURIResolver()
-
asXMLResolver
public XMLResolver asXMLResolver()
-
getExternalSubset
public InputSource getExternalSubset(String name, String baseURI)
- Specified by:
getExternalSubset
in interfaceEntityResolver2
-
resolveEntity
public InputSource resolveEntity(String name, String publicId, String baseURI, String systemId) throws IOException
- Specified by:
resolveEntity
in interfaceEntityResolver2
- Throws:
IOException
-
resolveEntity
public InputSource resolveEntity(String publicId, String systemId) throws IOException
- Specified by:
resolveEntity
in interfaceEntityResolver
- Throws:
IOException
-
-